File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed
Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change 11package main
22
33import (
4- "fmt"
54 "quill/internal/jsonapi"
65 "sync"
76 "unsafe"
@@ -18,22 +17,21 @@ var (
1817)
1918
2019//export quill_new_interpreter
21- func quill_new_interpreter (source * C.char ) * C. char {
20+ func quill_new_interpreter (source * C.char ) C. int {
2221 goSource := C .GoString (source )
23- interp , result := jsonapi .NewQuillInterpreter (goSource )
22+ interp , _ := jsonapi .NewQuillInterpreter (goSource )
2423
25- if interp != nil {
26- mu .Lock ()
27- interpreters [nextID ] = interp
28- nextID ++
29- mu .Unlock ()
24+ if interp == nil {
25+ return - 1
3026 }
3127
32- cResult := C .CString (result )
33- if cResult == nil {
34- return C .CString (`{"success":false,"error":"Failed to allocate C string"}` )
35- }
36- return C .CString ((`{"success":true,"interpreter_id":` + fmt .Sprint (nextID - 1 ) + `}` ))
28+ mu .Lock ()
29+ id := nextID
30+ interpreters [nextID ] = interp
31+ nextID ++
32+ mu .Unlock ()
33+
34+ return C .int (id )
3735}
3836
3937//export quill_step
You can’t perform that action at this time.
0 commit comments