Mercurial > pub > dyncall > bindings
annotate go/godc/README.txt @ 35:75fe1dec0eb4
- added support for signature-based calling convention switch
author | Tassilo Philipp |
---|---|
date | Mon, 13 Apr 2020 16:07:56 +0200 |
parents | 739c40f35a6a |
children | 1e3d929e43be |
rev | line source |
---|---|
0 | 1 dyncall go bindings |
9
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
2 Copyright 2014-2016 Tassilo Philipp |
0 | 3 February 23, 2014 |
4 | |
5 | |
9
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
6 BUILD/INSTALLATION |
17 | 7 ================== |
9
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
8 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
9 1) make sure dyncall is built and libraries/headers are in include paths or |
17 | 10 |
11 CGO_CFLAGS points to them, etc. | |
9
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
12 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
13 2) Build this nut with: |
17 | 14 |
15 go build | |
9
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
16 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
17 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
18 API |
17 | 19 === |
9
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
20 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
21 Since go is low level, dyncall's public functions are pretty much exposed |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
22 function by function. Referg to dyncall(3) and godc.go. |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
23 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
24 l := new(ExtLib) |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
25 err := l.Load(libpath) |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
26 defer l.Free() |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
27 err := l.SymsInit(libpath) |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
28 defer l.SymsCleanup() |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
29 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
30 l.lib // Address lib is loaded at |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
31 l.FindSymbol(symbolname) |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
32 l.SymsCount() |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
33 l.SymsNameFromValue(l.FindSymbol(synbolname)) |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
34 l.SymsName(index) |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
35 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
36 vm := new(CallVM) |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
37 err := vm.InitCallVM() |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
38 defer vm.Free() |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
39 vm.Mode(DC_CALL_C_DEFAULT) |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
40 vm.Reset() |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
41 vm.ArgFloat(36) |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
42 rf := vm.CallFloat(l.FindSymbol("sqrtf")) |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
43 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
44 vm.Arg.... |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
45 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
46 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
47 SIGNATURE FORMAT |
17 | 48 ================ |
9
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
49 |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
50 Signature string is only used by ArgF function, rest uses type info from Go. |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
51 |
0 | 52 TYPE CONVERSIONS (and reserved signature char) |
53 | |
54 SIG | FROM GO | C/C++ | TO GO | |
55 ----+---------------------+--------------------+---------------- | |
56 'v' | | void | | |
57 'B' | bool | bool | bool | |
58 'c' | int8,C.schar | char | int8 | |
59 'C' | uint8,byte,C.uchar | unsigned char | uint8,byte | |
60 's' | int16,C.sshort | short | int16 | |
61 'S' | uint16,C.ushort | unsigned short | uint16 | |
62 'i' | int32,C.sint | int | int32 | |
63 'I' | uint32,C.uint | unsigned int | uint32 | |
64 'j' | int32,rune,C.slong | long | int32,rune | |
65 'J' | uint32,C.ulong | unsigned long | uint32 | |
66 'l' | int64,C.slonglong | long long | int64 | |
67 'L' | uint64,C.ulonglong | unsigned long long | uint64 | |
68 'f' | float32,C.float | float | float32 | |
69 'd' | float64,C.double | double | float64 | |
70 'p' | *,[],unsafe.Pointer | void* | unsafe.Pointer | |
71 'Z' | string | void* | string | |
72 | |
73 | |
17 | 74 TODO |
75 ==== | |
76 | |
0 | 77 - structs |
9
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
78 - callbacks |
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
79 - callf wrap (argf already there) |
17 | 80 - update cconv modes, so they are up to date |
9
8a45a05ff64e
- go binding cleanup, not enforcing relative paths anymore, readme update
cslag
parents:
0
diff
changeset
|
81 |