Skip to content

Commit 0d25e19

Browse files
committed
generate: Further iteration on function support
1 parent bcdaa3e commit 0d25e19

File tree

4 files changed

+523
-107
lines changed

4 files changed

+523
-107
lines changed

generate/codegen/gen_function.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (f *Function) GoArgs(currentModule *modules.Module) string {
6262
if _, ok := reservedWords[p.Name]; ok {
6363
p.Name = p.Name + "_"
6464
}
65-
typ := p.Type.GoName(currentModule, false)
65+
typ := p.Type.GoName(currentModule, true)
6666
if v, ok := typeMap[typ]; ok {
6767
typ = v
6868
}
@@ -171,7 +171,7 @@ func (f *Function) WriteGoCallCode(currentModule *modules.Module, cw *CodeWriter
171171
case *typing.PrimitiveType:
172172
sb.WriteString(cw.IndentStr + fmt.Sprintf(" C.%s(%s)", tt.CName(), p.GoName()))
173173
case *typing.PointerType:
174-
sb.WriteString(cw.IndentStr + fmt.Sprintf(" (*C.%s)(unsafe.Pointer(%s))", tt.Type.CName(), p.GoName()))
174+
sb.WriteString(cw.IndentStr + fmt.Sprintf(" (*C.%s)(unsafe.Pointer(%s))", tt.Type.ObjcName(), p.GoName()))
175175
default:
176176
sb.WriteString(cw.IndentStr + p.GoName())
177177
}
@@ -184,8 +184,9 @@ func (f *Function) WriteGoCallCode(currentModule *modules.Module, cw *CodeWriter
184184
} else {
185185
var resultName = "rv"
186186
cw.WriteLine(resultName + " := " + callCode)
187+
cw.WriteLineF("// %T", f.ReturnType)
187188
switch tt := f.ReturnType.(type) {
188-
case *typing.StructType:
189+
case *typing.StructType, *typing.PointerType:
189190
cw.WriteLineF("return *(*%s)(unsafe.Pointer(&%s))", tt.GoName(currentModule, true), resultName)
190191
default:
191192
cw.WriteLineF("return %s(%s)", returnTypeStr, resultName)

generate/codegen/modulewriter.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ func shouldSkipFunction(f *Function) bool {
152152
"CGDisplayIOServicePort": true,
153153
"CGGetEventTapList": true,
154154
"CGColorConversionInfoCreateFromListWithArguments": true,
155+
"CGEventKeyboardSetUnicodeString": true,
156+
"CGEventPostToPid": true,
157+
"CGEventKeyboardGetUnicodeString": true,
155158
}[f.Name]; ok {
156159
return true
157160
}

0 commit comments

Comments
 (0)