-
Notifications
You must be signed in to change notification settings - Fork 9
/
cpp.go
28 lines (27 loc) · 907 Bytes
/
cpp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Package cpp allows methods on C++ objects to be called directly from the
// Go runtime without requiring cgo compilation.
//
// For more information on how to use this library, see the project README:
// https://github.com/lsegal/cppgo/blob/master/README.md
package cpp
// ConvertRef converts a C++ object ref into a wrapper obj that can call
// methods on the reference object. The obj interface type should be a struct
// containing function pointers matching the interface of the C++ class.
// For example, given the following class:
//
// class Math {
// public:
// int multiply(int value, int times);
// }
//
//
// You might create a struct type Math as follows:
//
// type Math struct {
// Multiply func(value, times int) int
// }
//
// You would then call ConvertRef with a pointer to this structure.
func ConvertRef(ref uintptr, obj interface{}) error {
return ptr(ref).convert(obj)
}