gdnative

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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.

View Source
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.

View Source
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.

View Source
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.

View Source
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.

View Source
var Log = &Logger{StackNum: 2}

Log is used to log messages to Godot, and makes them viewable inside the Godot debugger.

View Source
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.

View Source
var NativeScript = new(nativeScript)

NativeScript is a wrapper for the NativeScriptAPI.

View Source
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.

View Source
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 EnableDebug

func EnableDebug()

EnableDebug will enable logging of GDNative debug messages.

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 Char

type Char string

Char is a Godot C char wrapper

type Class

type Class struct {
	// contains filtered or unexported fields
}

Class is a NativeScript registrable class

type CreateFunc

type CreateFunc func(Object, string) string

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

type DestroyFunc func(Object, string, string)

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 Double

type Double float64

Double is a Godot C double wrapper

type Float

type Float float64

Float is a Godot C float wrapper

func NewFloatFromPointer

func NewFloatFromPointer(ptr Pointer) Float

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

func NewGodotSignal(className, name string, args []SignalArgument, defaults []Variant) GDSignal

NewGodotSignal creates a new ready to go Godot signal for us and return it back

type GetPropertyFunc

type GetPropertyFunc func(Object, string, string) Variant

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 Int64T

type Int64T int64

Int64T is a Godot C int64_t wrapper

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.

func (*Logger) Warning

func (l *Logger) Warning(message ...interface{})

Warning will print a warning message to the Godot debugger and console.

func (*Logger) Write

func (l *Logger) Write(data []byte) (int, error)

Write will call Logger.Println from the given bytes, to implement the io.Writer interface.

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

type MethodFunc func(Object, string, string, int, []Variant) Variant

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

func NewPointerFromFloat(obj Float) Pointer

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) GetName

func (p *Property) GetName() string

GetName returns back the property name

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

type SetPropertyFunc func(Object, string, string, Variant)

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 SignedChar

type SignedChar int8

SignedChar is a Godot C schar wrapper

type Uint

type Uint uint

Uint is a Godot C uint wrapper

type Uint32T

type Uint32T uint32

Uint32T is a Godot C uint32_t wrapper

type Uint64T

type Uint64T uint64

Uint64T is a Godot C uint64_t wrapper

type Uint8T

type Uint8T uint8

Uint8T is a Godot C uint8_t wrapper

type VariantArray

type VariantArray struct {
	// contains filtered or unexported fields
}

VariantArray is a wrapper around Godot C **godot_variant

type WcharT

type WcharT string

WcharT is a Godot C wchar_t wrapper

func (WcharT) AsString

func (w WcharT) AsString() String

AsString converts a WCharT into a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL