-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
52 lines (39 loc) · 1.06 KB
/
main.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
45
46
47
48
49
50
51
52
package main
/*
//pass on command line with CGO_CFLAGS
//#cgo CFLAGS: -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/linux"
#cgo CFLAGS: -I include
#include "client.h"
*/
import "C"
import (
"github.com/interactive-instruments/xtraplatform-cli/xtracfg/client"
"github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd"
)
var handleC C.handle_command_func
var progress_chan chan string
func main() {
cmd.Execute()
}
//export cmd_execute
func cmd_execute(handle_command C.handle_command_func) {
handleC = handle_command
progress_chan = make(chan string, 16)
client.Init(handle, progress_chan)
cmd.Execute()
}
//export progress
func progress(msg *C.char) {
progress_chan <- C.GoString(msg)
}
func handle(command string) string {
//fmt.Printf("JNI PASS: %s\n", command)
messages := make(chan string)
// has to run concurrently since we are being called from java and calling into java at the same time
go func() {
r := C.handle_command_2(handleC, C.CString(command), C.progress_func(C.progress))
messages <- C.GoString(r)
}()
msg := <-messages
return msg
}