Commit 7336dbcb authored by Oscar Campos's avatar Oscar Campos Committed by Oscar Campos
Browse files

fix: fix generation bugs introduced by sloppy linting errors refactor

parent b02a36ec
......@@ -42,7 +42,7 @@ func (v View) HasArgs(args [][]string) bool {
// Generate generates the bindings from the JSON definition
func Generate() {
// Get the API Path so we can localte the godot api JSON.
// Get the API Path so we can locate the godot api JSON.
apiPath := os.Getenv("API_PATH")
if apiPath == "" {
panic("$API_PATH is not defined.")
......
......@@ -50,10 +50,10 @@ package gdnative
*/
import "C"
{{/* Loop through and define all of the type definitions as Go structs */}}
{{/* Loop through and define all of the type definitions as Go structs -*/}}
{{ range $i, $typedef := $view.TypeDefinitions -}}
{{/* Handle struct definitions */}}
{{ if or (eq $typedef.Base "struct") (eq $typedef.Base "void") }}
{{ if or (eq $typedef.Base "struct") (eq $typedef.Base "void") -}}
// NewEmpty{{ $typedef.GoName }} will return a pointer to an empty
// initialized {{ $typedef.GoName }}. This is primarily used in
// conjunction with MethodBindPtrCall.
......@@ -91,7 +91,7 @@ import "C"
}
{{/* The String struct is a special case to be compatible with Go strings -*/}}
{{ if (eq $typedef.GoName "String") }}
{{ if (eq $typedef.GoName "String") -}}
type {{ $typedef.GoName }} string
func (s String) getBase() *C.godot_string {
......@@ -99,6 +99,7 @@ import "C"
}
{{/* Handle all other kinds of Godot structs -*/}}
{{ else }}
// {{ $typedef.GoName }} data structure wrapper
type {{ $typedef.GoName }} struct {
base *C.{{ $typedef.Name }}
{{/* Handle struct properties */}}
......@@ -115,13 +116,14 @@ import "C"
{{ end -}}
}
// returns the wrapped C base data type for this type
func (gdt {{ $typedef.GoName }}) getBase() *C.{{ $typedef.Name }} {
return gdt.base
}
{{ end }}
{{/* Handle struct methods */}}
{{ range $j, $method := ($view.MethodsList $typedef) }}
{{ range $j, $method := ($view.MethodsList $typedef) -}}
{{/* Handle constructor methods -*/}}
// {{ $view.ToGoMethodName $typedef $method }} {{ $method.Name }} {{ $method.Arguments }} {{ $method.ReturnType }}
{{ if ($view.MethodIsConstructor $method) -}}
......
......@@ -36,7 +36,7 @@ func (v View) Debug(itm string) string {
// IsValidProperty will determine if we should be generating the given property
// in our Go structure.
func (v View) IsValidProperty(prop TypeDef) bool {
return strings.Contains(prop.Name, "_touch_that")
return !strings.Contains(prop.Name, "_touch_that")
}
// IsGodotBaseType will check to see if the given simple type definition is defining
......@@ -76,7 +76,11 @@ func (v View) ToGoReturnType(str string) string {
// HasReturn returns true if the given string is void
func (v View) HasReturn(str string) bool {
return str == "void" || str == "Void" || strings.Contains(str, "void")
if str == "void" || str == "Void" || strings.Contains(str, "void") {
return false
}
return true
}
// HasPointerReturn returns true if the given string contains an indirection operator
......@@ -217,7 +221,6 @@ func (v View) MethodsList(typeDef TypeDef) []Method {
methods = append(methods, method)
break
}
}
}
......@@ -231,7 +234,11 @@ func (v View) MethodIsConstructor(method Method) bool {
// NotSelfArg return false if the given string contains any reference to self or p_self
func (v View) NotSelfArg(str string) bool {
return str == "self" || str == "p_self"
if str == "self" || str == "p_self" {
return false
}
return true
}
// StripPointer strips the indirection operator from a given string
......@@ -357,7 +364,7 @@ func Generate() {
outFileName := strings.Replace(headerPath[len(headerPath)-1], ".h", ".gen.go", 1)
outFileName = strings.Replace(outFileName, "godot_", "", 1)
log.Println(" Generating Go code for:", outFileName+"...")
log.Printf(" Generating Go code for: \x1b[32m%s\x1b[0m...\n", outFileName)
// Create a structure for our template view. This will contain all of
// the data we need to construct our Go wrappers.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment