outside

package module
v0.0.0-...-48a9c99 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2013 License: BSD-3-Clause Imports: 9 Imported by: 77

README

outside: generic API support for the Go language (PRERELEASE)

A neat way to connect to Windows DLLs

To display a simple message box using outside


		import (
			"github.com/tHinqa/outside"
			T "github.com/tHinqa/outside/types"
		)
		type (
			HWND        uint32
			MSGBOX_TYPE uint32
		)
		var MessageBox func(
			w HWND, text, caption T.VString, t MSGBOX_TYPE) int
		outside.AddDllApis("user32.dll", true,
			Apis{{"MessageBoxW", &MessageBox}})
		defer outside.DoneOutside()

		MessageBox(0, "Hello World", "Go says...", 0)

or the equivalent in barebones Go code


		import (
			"syscall"
			"unsafe"
		)
		dll := syscall.MustLoadDLL("user32.dll")
		defer dll.Release()
		messagebox := dll.MustFindProc("MessageBoxW")

		text, _ := syscall.UTF16PtrFromString("Hello World")
		utext := (uintptr)(unsafe.Pointer(text))
		caption, _ := syscall.UTF16PtrFromString("Go says...")
		ucaption := (uintptr)(unsafe.Pointer(caption))

		messagebox.Call(0, utext, ucaption, 0)
Fire off quick questions to @tHinqa on Twitter

Features

  • Maintains type-safety while adding type-flexibility
  • Uses reflect.MakeFunc to build bindings
  • Automates marshalling
  • Covered by the same licence conditions as Go is
  • API functions can be declared to include or exclude error returns

Includes DLL entry-points for

MSWindows in outside/win32; to register them include


		import _ "github.com/tHinqa/outside/win32"

or any combination of


		import _ "github.com/tHinqa/outside/win32/advapi32"
		import _ "github.com/tHinqa/outside/win32/avicap32"
		import _ "github.com/tHinqa/outside/win32/avifil32"
		import _ "github.com/tHinqa/outside/win32/comctl32"
		import _ "github.com/tHinqa/outside/win32/comdlg32"
		import _ "github.com/tHinqa/outside/win32/gdi32"
		import _ "github.com/tHinqa/outside/win32/gdiplus"
		import _ "github.com/tHinqa/outside/win32/glu32"
		import _ "github.com/tHinqa/outside/win32/kernel32"
		import _ "github.com/tHinqa/outside/win32/mapi32"
		import _ "github.com/tHinqa/outside/win32/mpr"
		import _ "github.com/tHinqa/outside/win32/netapi32"
		import _ "github.com/tHinqa/outside/win32/ole32"
		import _ "github.com/tHinqa/outside/win32/oleaut32"
		import _ "github.com/tHinqa/outside/win32/opengl32"
		import _ "github.com/tHinqa/outside/win32/pdh"
		import _ "github.com/tHinqa/outside/win32/riched20"
		import _ "github.com/tHinqa/outside/win32/shdocvw"
		import _ "github.com/tHinqa/outside/win32/shell32"
		import _ "github.com/tHinqa/outside/win32/user32"
		import _ "github.com/tHinqa/outside/win32/winmm"
		import _ "github.com/tHinqa/outside/win32/ws2_32"
		import _ "github.com/tHinqa/outside/win32/wsock32"

Includes DLL entry-points and API definitions for

SDL2 (Simple DirectMedia Layer) in outside/sdl2

Separate repository of API definitions for

MSWindows in outside-windows

Separate repository of DLL entry-points and API definitions for

GTK in outside-gtk2

libXML2 in outside-xml2

sqlite3 in outside-sqlite3 Includes database/sql/driver implementation based on the one in mattn/go-sqlite3 [2]

Bugs and missing functionality

Version go1.1.2 reflect Convert corrupts 64-bit return values (on windows 386 at least). It's fixed in go1.2rc1.

Examples

Credits

[1] SDL source is Copyright 1997-2013 Sam Lantinga

[2] mattn/go-sqlite3 is Copyright 2012-2013 Yasuhiro Matsumoto

Documentation

Overview

Package outside.

Index

Constants

This section is empty.

Variables

Total outside calls made

Functions

func AddApis

func AddApis(am Apis)

func AddDllApis

func AddDllApis(d string, unicode bool, am Apis)

func AddDllData

func AddDllData(d string, unicode bool, am Data)

func AddEP

func AddEP(d string, unicode bool, e EP)

func AddEPs

func AddEPs(d string, unicode bool, es EPs)

func CStrToString

func CStrToString(cs uintptr) (ret string)

func DoneOutside

func DoneOutside()

func GetDLL

func GetDLL(d string) *sdll

func GetData

func GetData(e EP) interface{}

func GetProc

func GetProc(s string) *sproc

func SetStructSize

func SetStructSize(i interface{})

Helper function to set the first field in a structure to the structure size. This is needed in many Win32 structures.

func UniStrToString

func UniStrToString(cs uintptr) (ret string)

Types

type Apis

type Apis []struct {
	Ep  EP
	Fnc interface{}
}

type Data

type Data []struct {
	Name EP
	Type interface{}
}

type EP

type EP string

type EPs

type EPs []EP

Directories

Path Synopsis
Package sdl2 provides the outside environment to access SDL2.dll.
Package sdl2 provides the outside environment to access SDL2.dll.
spriteminimal
spriteminimal is a direct translation of the C example in the SDL2 distribution.
spriteminimal is a direct translation of the C example in the SDL2 distribution.
Register all the entry-points listed in the sub-packages.
Register all the entry-points listed in the sub-packages.
advapi32
Register all entry-points in advapi32.dll.
Register all entry-points in advapi32.dll.
avicap32
Register all entry-points in avicap32.dll.
Register all entry-points in avicap32.dll.
avifil32
Register all entry-points in avifil32.dll.
Register all entry-points in avifil32.dll.
comctl32
Register all entry-points in comctl32.dll.
Register all entry-points in comctl32.dll.
comdlg32
Register all entry-points in comdlg32.dll.
Register all entry-points in comdlg32.dll.
gdi32
Register all entry-points in gdi32.dll.
Register all entry-points in gdi32.dll.
gdiplus
Register all entry-points in gdiplus.dll.
Register all entry-points in gdiplus.dll.
glu32
Register all entry-points in glu32.dll.
Register all entry-points in glu32.dll.
kernel32
Register all entry-points in kernel32.dll.
Register all entry-points in kernel32.dll.
mapi32
Register all entry-points in mapi32.dll.
Register all entry-points in mapi32.dll.
mpr
Register all entry-points in mpr.dll.
Register all entry-points in mpr.dll.
netapi32
Register all entry-points in netapi32.dll.
Register all entry-points in netapi32.dll.
ole32
Register all entry-points in ole32.dll.
Register all entry-points in ole32.dll.
oleaut32
Register all entry-points in oleaut32.dll.
Register all entry-points in oleaut32.dll.
opengl32
Register all entry-points in opengl32.dll.
Register all entry-points in opengl32.dll.
pdh
Register all entry-points in pdh.dll.
Register all entry-points in pdh.dll.
riched20
Register all entry-points in riched20.dll.
Register all entry-points in riched20.dll.
shdocvw
Register all entry-points in shdocvw.dll.
Register all entry-points in shdocvw.dll.
shell32
Register all entry-points in shell32.dll.
Register all entry-points in shell32.dll.
user32
Register all entry-points in user32.dll.
Register all entry-points in user32.dll.
winmm
Register all entry-points in winmm.dll.
Register all entry-points in winmm.dll.
ws2_32
Register all entry-points in ws2_32.dll.
Register all entry-points in ws2_32.dll.
wsock32
Register all entry-points in wsock32.dll.
Register all entry-points in wsock32.dll.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL