Skip to content

Commit 7896a46

Browse files
committed
generate: Generate Ref aliases for structs
1 parent 0ebc695 commit 7896a46

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

generate/codegen/modulewriter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (m *ModuleWriter) WriteStructs() {
132132

133133
// if Ref type, allias to unsafe.Pointer
134134
if strings.HasSuffix(s.Name, "Ref") {
135-
cw.WriteLineF("type %s = unsafe.Pointer", s.GoName)
135+
cw.WriteLineF("type %s unsafe.Pointer", s.GoName)
136136
continue
137137
}
138138
}
@@ -176,7 +176,7 @@ func (m *ModuleWriter) WriteFunctions() {
176176
cw.WriteLine(fmt.Sprintf("// %s [Full Topic]", fa.Description))
177177
cw.WriteLine(fmt.Sprintf("//\n// [Full Topic]: %s", fa.DocURL))
178178
}
179-
cw.WriteLineF("func %s(%s) %s {}", fa.Type.GoName(&m.Module, true), fa.GoArgs(&m.Module), fa.GoReturn(&m.Module))
179+
cw.WriteLineF("// func %s(%s) %s {}", fa.Type.GoName(&m.Module, true), fa.GoArgs(&m.Module), fa.GoReturn(&m.Module))
180180
}
181181
}
182182

generate/generator.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ func (db *Generator) Generate(platform string, version int, rootDir string, fram
144144
}
145145
mw.Functions = append(mw.Functions, fn)
146146
case "Struct":
147-
if s.Name != "CGImageRef" {
148-
continue
149-
}
150147
fn := db.ToStruct(framework, s)
151148
if fn == nil {
152149
continue

generate/struct.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"log"
55

66
"github.com/progrium/macdriver/generate/codegen"
7+
"github.com/progrium/macdriver/generate/modules"
78
"github.com/progrium/macdriver/generate/typing"
89
)
910

1011
func (db *Generator) ToStruct(fw string, sym Symbol) *codegen.Struct {
11-
// these structs have known declparse failures
1212
knownIssues := map[string]bool{}
1313
if knownIssues[sym.Name] {
1414
_, err := sym.Parse()
@@ -22,7 +22,7 @@ func (db *Generator) ToStruct(fw string, sym Symbol) *codegen.Struct {
2222
}
2323
s := &codegen.Struct{
2424
Name: sym.Name,
25-
GoName: sym.Name,
25+
GoName: modules.TrimPrefix(sym.Name),
2626
Description: sym.Description,
2727
DocURL: sym.DocURL(),
2828
Type: styp,

0 commit comments

Comments
 (0)