Skip to content

Commit d20f106

Browse files
committed
add: C bindings returns interpreter id
1 parent 8546536 commit d20f106

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cmd/c/main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package main
22

3-
// #include <stdlib.h>
4-
// #include <stdio.h>
5-
import "C"
63
import (
4+
"fmt"
75
"quill/internal/jsonapi"
86
"sync"
97
"unsafe"
108
)
119

10+
// #include <stdlib.h>
11+
// #include <stdio.h>
12+
import "C"
13+
1214
var (
1315
interpreters = make(map[int]*jsonapi.QuillInterpreter)
1416
nextID = 1
@@ -31,7 +33,7 @@ func quill_new_interpreter(source *C.char) *C.char {
3133
if cResult == nil {
3234
return C.CString(`{"success":false,"error":"Failed to allocate C string"}`)
3335
}
34-
return cResult
36+
return C.CString((`{"success":true,"interpreter_id":` + fmt.Sprint(nextID-1) + `}`))
3537
}
3638

3739
//export quill_step

0 commit comments

Comments
 (0)