diff --git a/cmd/library/const.go b/cmd/library/const.go index b0ccf10c1..66e32dfbf 100644 --- a/cmd/library/const.go +++ b/cmd/library/const.go @@ -2,15 +2,14 @@ package main const prelude = `package main // #include -import ( - "C" - mobile "github.com/status-im/status-go/mobile" -) +import "C" +import "unsafe" +import mobile "github.com/status-im/status-go/mobile" func main() {} ` const intType = "int" const stringType = "string" -const unsafePointerType = "unsafe.Pointer" +const unsafePointerType = "&{unsafe Pointer}" const boolType = "bool" diff --git a/cmd/library/main.go b/cmd/library/main.go index fe14dce68..d405f7b85 100644 --- a/cmd/library/main.go +++ b/cmd/library/main.go @@ -41,7 +41,7 @@ func handleFunction(name string, funcDecl *ast.FuncDecl) string { results := funcDecl.Type.Results // add export tag - output := fmt.Sprintf("// export %s\n", name) + output := fmt.Sprintf("//export %s\n", name) // add initial func declaration output += fmt.Sprintf("func %s (", name) @@ -56,6 +56,8 @@ func handleFunction(name string, funcDecl *ast.FuncDecl) string { output += paramIdentity.Name typeString := fmt.Sprint(paramIdentity.Obj.Decl.(*ast.Field).Type) + // We match against the stringified type, + // could not find a better way to match this switch typeString { case stringType: output += " *C.char"