Commit 8498ef8a authored by Oscar Campos's avatar Oscar Campos
Browse files

docs: added more missing comments

parent dbc2d781
......@@ -104,6 +104,7 @@ func Generate() {
}
}
// Parse parses the given package path and returns go APIs wrapping Godot C gdnative API
func Parse(packagePath string) APIs {
// Open the gdnative_api.json file that defines the GDNative API.
body, err := ioutil.ReadFile(packagePath + "/godot_headers/gdnative_api.json")
......@@ -118,6 +119,7 @@ func Parse(packagePath string) APIs {
return apis
}
// WriteTemplate writes the parsed template on the disk
func WriteTemplate(templatePath, outputPath string, view View) {
// Create a template from our template file.
t, err := template.ParseFiles(templatePath)
......
package methods
// Method represents a Go method
type Method struct {
Arguments []Argument
GoName string
......@@ -10,6 +11,7 @@ type Method struct {
ReturnsPointer bool
}
// Argument represents a Go method argument
type Argument struct {
GoName string
GoType string
......
......@@ -247,7 +247,7 @@ func (v View) MethodIsConstructor(method Method) bool {
return false
}
// NotSelfArg return false if the given string contains any refrence to self or p_self
// NotSelfArg return false if the given string contains any reference to self or p_self
func (v View) NotSelfArg(str string) bool {
if str == "self" || str == "p_self" {
return false
......
......@@ -29,8 +29,8 @@ func EnableDebug() {
debug = true
}
// Set our API to null. This will be set when 'godot_gdnative_init' is called
// by Godot when the library is loaded.
// 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 GDNative = &gdNative{}
// gdNative is a structure that wraps the GDNativeAPI.
......@@ -94,6 +94,7 @@ func godot_gdnative_terminate(options *C.godot_gdnative_terminate_options) {
NativeScript.api = nil
}
// NewEmptyVoid returns back a new C empty or void pointer
func NewEmptyVoid() Pointer {
var empty C.void
return Pointer{base: unsafe.Pointer(&empty)}
......@@ -182,12 +183,14 @@ func (p *Pointer) getBase() unsafe.Pointer {
return p.base
}
// Char is a Godot C char wrapper
type Char string
func (c Char) getBase() *C.char {
return C.CString(string(c))
}
// Double is a Godot C double wrapper
type Double float64
func (d Double) getBase() C.double {
......@@ -216,18 +219,21 @@ func NewEmptyFloat() Pointer {
return Pointer{base: unsafe.Pointer(&obj)}
}
// Float is a Godot C float wrapper
type Float float64
func (f Float) getBase() C.float {
return C.float(f)
}
// Int64T is a Godot C int64_t wrapper
type Int64T int64
func (i Int64T) getBase() C.int64_t {
return C.int64_t(i)
}
// SignedChar is a Godot C schar wrapper
type SignedChar int8
func (s SignedChar) getBase() *C.schar {
......@@ -296,6 +302,7 @@ func (w WcharT) getBase() *C.wchar_t {
return (*C.wchar_t)(wcharString.Pointer())
}
// AsString converts a WCharT into a string
func (w WcharT) AsString() String {
return NewStringWithWideString(string(w))
}
......
......@@ -26,7 +26,7 @@ type Logger struct {
StackNum int
}
// Print will print the given message to the Godot debugger and console.
// Println will print the given message to the Godot debugger and console.
func (l *Logger) Println(message ...interface{}) {
GDNative.checkInit()
......
......@@ -16,12 +16,14 @@ import (
"unsafe"
)
// PropertyUsageFlags is a Godot C godot_property_usage_flags wrapper
type PropertyUsageFlags int
func (p PropertyUsageFlags) getBase() C.godot_property_usage_flags {
return C.godot_property_usage_flags(p)
}
// Property usage flags for bit masks
const (
PropertyUsageStorage PropertyUsageFlags = 1
PropertyUsageEditor PropertyUsageFlags = 2
......@@ -46,7 +48,7 @@ const (
PropertyUsageNoEditor PropertyUsageFlags = PropertyUsageStorage | PropertyUsageNetwork
)
// PropertyUsageFlags is a string-based lookup table of constants for PropertyUsageFlags.
// PropertyUsageFlagsLookupMap is a string-based lookup table of constants for PropertyUsageFlags.
var PropertyUsageFlagsLookupMap = map[string]PropertyUsageFlags{
"PropertyUsageStorage": PropertyUsageStorage,
"PropertyUsageEditor": PropertyUsageEditor,
......@@ -175,6 +177,7 @@ func (i *InstanceMethod) getBase() C.godot_instance_method {
return i.base
}
// MethodAttributes is a Godot C godot_method_attributes wrapper
type MethodAttributes struct {
base C.godot_method_attributes
RPCType MethodRpcMode
......
......@@ -78,7 +78,7 @@ func (c *Class) register() {
}
}
// creates an InstanceCreateFunc value using the given CreateFunc and return it back
// CreateConstructor creates an InstanceCreateFunc value using the given CreateFunc and return it back
func CreateConstructor(className string, fn CreateFunc) InstanceCreateFunc {
constructor := InstanceCreateFunc{
......@@ -90,7 +90,7 @@ func CreateConstructor(className string, fn CreateFunc) InstanceCreateFunc {
return constructor
}
// creates an InstanceDestroyFunc value using the given DestroyFunc and return it back
// CreateDestructor creates an InstanceDestroyFunc value using the given DestroyFunc and return it back
func CreateDestructor(className string, fn DestroyFunc) InstanceDestroyFunc {
destructor := InstanceDestroyFunc{
......
......@@ -6,14 +6,17 @@ package gdnative
*/
import "C"
// NewStringWithWideString creates a new String with given contents
func NewStringWithWideString(str string) String {
return String(str)
}
// NewString retruns an empty String
func NewString() String {
return ""
}
// NewStringCopy returns an empty String
func NewStringCopy(src String) String {
return ""
}
......
......@@ -7,6 +7,8 @@ package gdnative
*/
import "C"
// NewStringName returns a StringName wrapper over a Godot C godot_string_name
// initialized with the contents of the given name
func NewStringName(name String) *StringName {
var dest C.godot_string_name
arg1 := name.getBase()
......@@ -14,6 +16,8 @@ func NewStringName(name String) *StringName {
return &StringName{base: &dest}
}
// NewStringNameData returns a StringName wrapper over a Godot C godot_string_name
// initialized with the given name
func NewStringNameData(name Char) *StringName {
var dest C.godot_string_name
arg1 := name.getBase()
......
......@@ -8,6 +8,7 @@ package gdnative
*/
import "C"
// NewVariantWithString creates a new Variant initialized with the given string
func NewVariantWithString(str String) Variant {
var variant C.godot_variant
C.go_godot_variant_new_string(GDNative.api, &variant, str.getBase())
......@@ -15,11 +16,13 @@ func NewVariantWithString(str String) Variant {
return Variant{base: &variant}
}
// GetType returns back the VaraintType for this Variant
func (gdt *Variant) GetType() VariantType {
variantType := C.go_godot_variant_get_type(GDNative.api, gdt.getBase())
return VariantType(variantType)
}
// VariantArray is a wrapper around Godot C **godot_variant
type VariantArray struct {
base **C.godot_variant
array []Variant
......
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