parse.go 770 B

12345678910111213141516171819202122232425262728
  1. // Package methods is a package that parses the GDNative headers for type definitions
  2. // of methods
  3. package methods
  4. import (
  5. "os"
  6. "git.alfi.li/gamelang/gdnative-go/cmd/generate/gdnative"
  7. )
  8. // Parse will parse the GDNative headers. Takes a list of headers/structs to ignore.
  9. // Definitions in the given headers and definitions
  10. // with the given name will not be added to the returned list of type definitions.
  11. // We'll need to manually create these structures.
  12. func Parse() gdnative.APIs {
  13. // Get the API Path so we can localte the godot api JSON.
  14. apiPath := os.Getenv("API_PATH")
  15. if apiPath == "" {
  16. panic("$API_PATH is not defined.")
  17. }
  18. packagePath := apiPath
  19. // Parse the GDNative JSON for method data.
  20. apis := gdnative.Parse(packagePath)
  21. return apis
  22. }