-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcgo.go
44 lines (35 loc) · 1.44 KB
/
cgo.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package sapera
/*
#cgo CXXFLAGS: -g -DPOSIX_HOSTPC -D_REENTRANT -Dx86_64 -Wall -Wno-parentheses -Wno-missing-braces -Wno-unused-but-set-variable -Wno-unknown-pragmas -Wno-cast-qual -Wno-unused-function -Wno-unused-label
#cgo CPPFLAGS: -g -I/usr/local/include/Sapera/include -I/usr/local/include/Sapera/classes/basic
#cgo LDFLAGS: -lpthread -lstdc++ -L/usr/local/lib -lSapera++ -lSaperaLT -lCorW32
#include <stdlib.h>
#include "sap.h"
extern void goxferhandler(SapXferCallbackInfoWrapper pinfo);
extern void goacqhandler(SapAcqCallbackInfoWrapper pinfo);
*/
import "C"
import "fmt"
var xferCallbackHandler []func(cb SapXferCallbackInfo)
//export goxferhandler
func goxferhandler(cb C.SapXferCallbackInfoWrapper) {
cbinfo := SapXferCallbackInfo{p: cb}
// TODO: use cbinfo context to determine which callback applies to this transfer
if len(xferCallbackHandler) > 0 && xferCallbackHandler[0] != nil {
xferCallbackHandler[0](cbinfo)
return
}
ctx := cbinfo.GetContext()
fmt.Println("no callback handler for frame transfer from ID", ctx.GetID())
}
var acqCallbackHandler []func(cb SapAcqCallbackInfo)
//export goacqhandler
func goacqhandler(cb C.SapAcqCallbackInfoWrapper) {
cbinfo := SapAcqCallbackInfo{p: cb}
// TODO: use cbinfo context to determine which callback applies to this acquisition
if len(acqCallbackHandler) > 0 && acqCallbackHandler[0] != nil {
acqCallbackHandler[0](cbinfo)
return
}
fmt.Println("no callback handler for acquisition")
}