Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macdriver: minimum to avoid panics with API Collection #116

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gen/cmd/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func main() {
loadFile("api/foundation/nsurl.objc.json"),
loadFile("api/foundation/nsurlrequest.objc.json"),
}},
{"coregraphics", []schemaLoader{
loadFile("api/coregraphics/quartz_event_services.objc.json"),
}},

{"cocoa", []schemaLoader{
loadFile("api/foundation/nsbundle.objc.json"),
Expand Down
14 changes: 13 additions & 1 deletion gen/cmd/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func filterMethods(pred func(schema.Method) bool) schemaUpdater {
return out
}
return func(s *schema.Schema) error {
if s.Class == nil {
return nil
}
s.Class.TypeMethods = filter(s.Class.TypeMethods)
s.Class.InstanceMethods = filter(s.Class.InstanceMethods)
return nil
Expand All @@ -92,6 +95,9 @@ func filterProps(pred func(schema.Property) bool) schemaUpdater {
return out
}
return func(s *schema.Schema) error {
if s.Class == nil {
return nil
}
s.Class.TypeProperties = filter(s.Class.TypeProperties)
s.Class.InstanceProperties = filter(s.Class.InstanceProperties)
return nil
Expand Down Expand Up @@ -119,7 +125,9 @@ func loadSchemas(contents []schemaLoader) ([]*schema.Schema, error) {
func definedClasses(schemas []*schema.Schema) map[string]bool {
r := map[string]bool{}
for _, input := range schemas {
r[input.Class.Name] = true
if input.Class != nil {
r[input.Class.Name] = true
}
}
return r
}
Expand Down Expand Up @@ -179,6 +187,10 @@ func generatePackage(name string, schemas []*schema.Schema, imports []gen.Packag
addFramework("AppKit")
}
for _, input := range schemas {
if input.Class == nil {
continue
}

for _, fw := range input.Class.Frameworks {
fw = strings.ReplaceAll(fw, " ", "")
// FIXME is there a better way to determine which includes and frameworks
Expand Down
3 changes: 3 additions & 0 deletions gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ func Convert(desc PackageDescription, imports []PackageContents, schemas ...*sch
{Path: "github.com/progrium/macdriver/objc"}: true,
}
for _, s := range schemas {
if s.Class == nil {
continue
}
cb := classBuilder{
Class: *s.Class,
Imports: imports,
Expand Down