Documentation ¶
Overview ¶
Package gdnative provides a wrapper around the Godot GDNative API.
Package gdnative provides a wrapper around Godot's nativescript extension. It exists to provide a way to use Go as an alternative scripting language from GDScript.
Index ¶
- Variables
- func EnableDebug()
- func LookupRegistrableTypeDeclarations(pkg *ast.Package) map[string]Registrable
- func RegisterNewGodotClass(isTool bool, name, base string, constructor *InstanceCreateFunc, ...)
- func SetNativeScriptInit(initFunc ...func())
- type Char
- type Class
- type CreateFunc
- type DestroyFunc
- type Double
- type Float
- type FreeFunc
- type GDSignal
- type GetPropertyFunc
- type InstanceCreateFunc
- type InstanceDestroyFunc
- type InstanceMethod
- type InstancePropertyGet
- type InstancePropertySet
- type Int64T
- type Logger
- type Method
- type MethodAttributes
- type MethodFunc
- type Objectable
- type Pointer
- type Property
- type PropertyUsageFlags
- type Registrable
- type SetPropertyFunc
- type SignedChar
- type Uint
- type Uint32T
- type Uint64T
- type Uint8T
- type VariantArray
- type WcharT
Constants ¶
This section is empty.
Variables ¶
var CreateFuncRegistry = map[string]CreateFunc{}
CreateFuncRegistry is a mapping of instance creation functions. This map is used whenever a CreateFunc is registered. It is also used to look up a Creation function when Godot asks Go to create a new class instance.
var DestroyFuncRegistry = map[string]DestroyFunc{}
DestroyFuncRegistry is a mapping of instance destroy functions. This map is used whenever a DestroyFunc is registered. It is also used to look up a Destroy function when Godot asks Go to destroy a class instance.
var FreeFuncRegistry = map[string]FreeFunc{}
FreeFuncRegistry is a mapping of instance free functions. This map is used whenever a FreeFunc is registered. It is also used to look up a Free function when Godot asks Go to free a class instance.
var GDNative = new(gdNative)
GDNative is our API main entry point, it is first set here to null. This will be set when 'godot_gdnative_init' is called by Godot when the library is loaded.
var GetPropertyFuncRegistry = map[string]GetPropertyFunc{}
GetPropertyFuncRegistry is a mapping of instance property getters. This map is used whenever a GetPropertyFunc is registered. It is also used to look up a property getter function when Godot asks Go to get a property on an object.
var Log = &Logger{StackNum: 2}
Log is used to log messages to Godot, and makes them viewable inside the Godot debugger.
var MethodFuncRegistry = map[string]MethodFunc{}
MethodFuncRegistry is a mapping of instance method functions. This map is used whenever a MethodFunc is registered. It is also used to look up a Method function when Godot asks Go to call a class method.
var NativeScript = new(nativeScript)
NativeScript is a wrapper for the NativeScriptAPI.
var PropertyUsageFlagsLookupMap = map[string]PropertyUsageFlags{ "PropertyUsageStorage": PropertyUsageStorage, "PropertyUsageEditor": PropertyUsageEditor, "PropertyUsageNetwork": PropertyUsageNetwork, "PropertyUsageEditorHelper": PropertyUsageEditorHelper, "PropertyUsageCheckable": PropertyUsageCheckable, "PropertyUsageChecked": PropertyUsageChecked, "PropertyUsageInternationalized": PropertyUsageInternationalized, "PropertyUsageGroup": PropertyUsageGroup, "PropertyUsageCategory": PropertyUsageCategory, "PropertyUsageStoreIfNonZero": PropertyUsageStoreIfNonZero, "PropertyUsageStoreIfNonOne": PropertyUsageStoreIfNonOne, "PropertyUsageNoInstanceState": PropertyUsageNoInstanceState, "PropertyUsageRestartIfChanged": PropertyUsageRestartIfChanged, "PropertyUsageScriptVariable": PropertyUsageScriptVariable, "PropertyUsageStoreIfNull": PropertyUsageStoreIfNull, "PropertyUsageAnimateAsTrigger": PropertyUsageAnimateAsTrigger, "PropertyUsageUpdateAllIfModified": PropertyUsageUpdateAllIfModified, "PropertyUsageDefault": PropertyUsageDefault, "PropertyUsageDefaultIntl": PropertyUsageDefaultIntl, "PropertyUsageNoEditor": PropertyUsageNoEditor, }
PropertyUsageFlagsLookupMap is a string-based lookup table of constants for PropertyUsageFlags.
var SetPropertyFuncRegistry = map[string]SetPropertyFunc{}
SetPropertyFuncRegistry is a mapping of instance property setters. This map is used whenever a SetPropertyFunc is registered. It is also used to look up a property setter function when Godot asks Go to set a property on an object.
Functions ¶
func LookupRegistrableTypeDeclarations ¶
func LookupRegistrableTypeDeclarations(pkg *ast.Package) map[string]Registrable
LookupRegistrableTypeDeclarations parses the given package AST and adds any relevant data to the registry so we can generate boilerplate registration code
func RegisterNewGodotClass ¶
func RegisterNewGodotClass(isTool bool, name, base string, constructor *InstanceCreateFunc, destructor *InstanceDestroyFunc, methods []Method, properties []Property, signals []GDSignal)
RegisterNewGodotClass creates a new ready to go Godot class for us and registers it with in Godot
func SetNativeScriptInit ¶
func SetNativeScriptInit(initFunc ...func())
SetNativeScriptInit will configure the given function to be called when `godot_nativescript_init` is called by Godot upon NativeScript initialization. This is used so you can define a function that will run to register all of the classes that you want exposed to Godot.
Types ¶
type Class ¶
type Class struct {
// contains filtered or unexported fields
}
Class is a NativeScript registrable class
type CreateFunc ¶
CreateFunc will be called when we need to create a new instance of a class. When it is called, the Godot object will passed as an argument, as well as the methodData string, which is usually the name of the class to be created.
type DestroyFunc ¶
DestroyFunc will be called when the object is destroyed. Takes the instance object, method data, user data. The method data is generally the class name, and the user data is generally the class instance id to destroy.
type Float ¶
type Float float64
Float is a Godot C float wrapper
func NewFloatFromPointer ¶
NewFloatFromPointer will return a Float from the given unsafe pointer. This is primarily used in conjunction with MethodBindPtrCall.
type FreeFunc ¶
type FreeFunc func(string)
FreeFunc will be called when we should free the instance from memory. Takes in method data. The method data is generally the class name to be freed.
type GDSignal ¶
type GDSignal struct {
// contains filtered or unexported fields
}
GDSignal is a NativeScript registrable signal
func NewGodotSignal ¶
NewGodotSignal creates a new ready to go Godot signal for us and return it back
type GetPropertyFunc ¶
GetPropertyFunc will be called when Godot requests a property on a given class instance. When it is called, Godot will pass the Godot object instance as an argument, as well as the methodData (which is usually the name of the class), and the userData (which is generally the instance ID of the object. You should return the property as a Variant.
type InstanceCreateFunc ¶
type InstanceCreateFunc struct { CreateFunc CreateFunc MethodData string FreeFunc FreeFunc // contains filtered or unexported fields }
InstanceCreateFunc is a structure that contains the instance creation function that will be called when Godot asks Go to create a new instance of a class.
func CreateConstructor ¶
func CreateConstructor(className string, fn CreateFunc) InstanceCreateFunc
CreateConstructor creates an InstanceCreateFunc value using the given CreateFunc and return it back
type InstanceDestroyFunc ¶
type InstanceDestroyFunc struct { DestroyFunc DestroyFunc MethodData string FreeFunc FreeFunc // contains filtered or unexported fields }
InstanceDestroyFunc is a structure that contains the instance destruction function that will be called when Godot asks Go to destroy a class instance.
func CreateDestructor ¶
func CreateDestructor(className string, fn DestroyFunc) InstanceDestroyFunc
CreateDestructor creates an InstanceDestroyFunc value using the given DestroyFunc and return it back
type InstanceMethod ¶
type InstanceMethod struct { Method MethodFunc MethodData string FreeFunc FreeFunc // contains filtered or unexported fields }
InstanceMethod is a structure that contains an instance method function that will be called when Godot asks Go to call a method on a class.
type InstancePropertyGet ¶
type InstancePropertyGet struct { GetFunc GetPropertyFunc MethodData string FreeFunc FreeFunc // contains filtered or unexported fields }
InstancePropertyGet is a structure that contains an instance property getter function that will be called when Godot asks Go to get a property from a class instance.
type InstancePropertySet ¶
type InstancePropertySet struct { SetFunc SetPropertyFunc MethodData string FreeFunc FreeFunc // contains filtered or unexported fields }
InstancePropertySet is a structure that contains an instance property setter function that will be called when Godot asks Go to set a property on a class.
type Logger ¶
type Logger struct { // StackNum is how far up the stack logs should show up as. StackNum int }
Logger is a native Go structure for logging in Godot.
func (*Logger) Error ¶
func (l *Logger) Error(message ...interface{})
Error will print an error message to the Godot debugger and console.
func (*Logger) Println ¶
func (l *Logger) Println(message ...interface{})
Println will print the given message to the Godot debugger and console.
type Method ¶
type Method struct {
// contains filtered or unexported fields
}
Method is a NativeScript registrable function
func NewGodotMethod ¶
func NewGodotMethod(className, name string, method MethodFunc) Method
NewGodotMethod creates a new ready to go Godot method for us and return it back
type MethodAttributes ¶
type MethodAttributes struct { RPCType MethodRpcMode // contains filtered or unexported fields }
MethodAttributes is a Godot C godot_method_attributes wrapper
type MethodFunc ¶
MethodFunc will be called when a method attached to an instance is called. When it is called, it will be passed the Godot object the method is attached to, the methodData string (which is usually the class and method name that is being called), the userData string (which is usually the class instance ID), the number of arguments being passed to the function, and a list of Variant arguments to pass to the function.
type Objectable ¶
type Objectable interface { BaseClass() string SetOwner(Object) Owner() Object }
Objectable is the interface every Godot Object has to implement
type Pointer ¶
type Pointer struct {
// contains filtered or unexported fields
}
Pointer is a pointer to arbitrary underlying data. This is primarily used in conjunction with MethodBindPtrCall.
func MethodBindPtrCall ¶
func MethodBindPtrCall(methodBind MethodBind, instance Object, args []Pointer, returns Pointer) Pointer
MethodBindPtrCall will call the given method on the given Godot Object. Its return value is given as a pointer, which can be used to convert it to a variant.
func NewEmptyFloat ¶
func NewEmptyFloat() Pointer
NewEmptyFloat will return a pointer to an empty initialized Float. This is primarily used in conjunction with MethodBindPtrCall.
func NewEmptyVoid ¶
func NewEmptyVoid() Pointer
NewEmptyVoid returns back a new C empty or void pointer
func NewPointerFromFloat ¶
NewPointerFromFloat will return an unsafe pointer to the given object. This is primarily used in conjunction with MethodBindPtrCall.
type Property ¶
type Property struct { Value Variant // contains filtered or unexported fields }
Property is a NativeScript registrable class property
func NewGodotProperty ¶
func NewGodotProperty(className, name, hint, hintString, usage, rset string, setFunc *InstancePropertySet, getFunc *InstancePropertyGet) Property
NewGodotProperty creates a new ready to go Godot property, add it to the given class and return it
func (*Property) CreateGenericGetter ¶
func (p *Property) CreateGenericGetter() *InstancePropertyGet
created a generic getter method to get property values if none is provided
func (*Property) CreateGenericSetter ¶
func (p *Property) CreateGenericSetter() *InstancePropertySet
creates a generic setter method to set property values if none is provided
func (*Property) SetGetter ¶
func (p *Property) SetGetter(getter *InstancePropertyGet)
SetGetter sets the getter on a Property value
func (*Property) SetSetter ¶
func (p *Property) SetSetter(setter *InstancePropertySet)
SetSetter sets the setter on a Property value
type PropertyUsageFlags ¶
type PropertyUsageFlags int
PropertyUsageFlags is a Godot C godot_property_usage_flags wrapper
const ( PropertyUsageStorage PropertyUsageFlags = 1 PropertyUsageEditor PropertyUsageFlags = 2 PropertyUsageNetwork PropertyUsageFlags = 4 PropertyUsageEditorHelper PropertyUsageFlags = 8 PropertyUsageCheckable PropertyUsageFlags = 16 //used for editing global variables PropertyUsageChecked PropertyUsageFlags = 32 //used for editing global variables PropertyUsageInternationalized PropertyUsageFlags = 64 //hint for internationalized strings PropertyUsageGroup PropertyUsageFlags = 128 //used for grouping props in the editor PropertyUsageCategory PropertyUsageFlags = 256 PropertyUsageStoreIfNonZero PropertyUsageFlags = 512 //only store if nonzero PropertyUsageStoreIfNonOne PropertyUsageFlags = 1024 //only store if false PropertyUsageNoInstanceState PropertyUsageFlags = 2048 PropertyUsageRestartIfChanged PropertyUsageFlags = 4096 PropertyUsageScriptVariable PropertyUsageFlags = 8192 PropertyUsageStoreIfNull PropertyUsageFlags = 16384 PropertyUsageAnimateAsTrigger PropertyUsageFlags = 32768 PropertyUsageUpdateAllIfModified PropertyUsageFlags = 65536 PropertyUsageDefault PropertyUsageFlags = PropertyUsageStorage | PropertyUsageEditor | PropertyUsageNetwork PropertyUsageDefaultIntl PropertyUsageFlags = PropertyUsageStorage | PropertyUsageEditor | PropertyUsageNetwork | PropertyUsageInternationalized PropertyUsageNoEditor PropertyUsageFlags = PropertyUsageStorage | PropertyUsageNetwork )
Property usage flags for bit masks
type Registrable ¶
type Registrable interface { GetBase() string GetConstructor() string GetDestructor() string GetMethods() []string GetProperties() []string SetConstructor(*registryConstructor) SetDestructor(*registryDestructor) Constructor() string Destructor() string AddMethod(*registryMethod) AddMethods([]*registryMethod) Methods() []*registryMethod AddSignal(*registrySignal) AddSignals([]*registrySignal) Signals() []*registrySignal AddProperties([]*registryProperty) Properties() []*registryProperty }
Registrable is the interface external code communicates with registryClass
type SetPropertyFunc ¶
SetPropertyFunc will be called when Godot requests to set a property on a given class. When it is called, the Godot object instance will be passed as an argument, as well as the methodData (which is usually the name of the class), the userData (which is generally the instance ID of the object), and the value to set.
type VariantArray ¶
type VariantArray struct {
// contains filtered or unexported fields
}
VariantArray is a wrapper around Godot C **godot_variant