From ee53768c13feed2cdb279f8b518493da7ec7cf67 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 4 Sep 2017 20:28:13 +0700 Subject: [PATCH 01/82] Export generated init --- godot.nimble | 2 +- godot/nim/godotmacros.nim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/godot.nimble b/godot.nimble index badccf4..fa351a8 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.5.7" +version = "0.5.8" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index 0fa2d9f..9ff9b66 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -466,7 +466,7 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = returnType: newEmptyNode(), isVirtual: true, isNoGodot: false, - nimNode: newProc(ident("init"), body = initBody, + nimNode: newProc(postfix(ident("init"), "*"), body = initBody, procType = nnkMethodDef) )) else: From 99934854d035d6e0a4f4fd376bcd819a6d1d2acd Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 13 Sep 2017 20:52:08 +0700 Subject: [PATCH 02/82] Fix Reference handling --- godot/nim/godotmacros.nim | 18 ++++++++++++------ godot/nim/godotnim.nim | 33 ++++++++++++++++++++++----------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index 9ff9b66..53495c6 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -313,23 +313,29 @@ proc refcountIncremented(obj: ptr GodotObject, methodData: pointer, userData: pointer, numArgs: cint, args: var array[MAX_ARG_COUNT, ptr GodotVariant]): GodotVariant {.noconv.} = - GC_ref(cast[NimGodotObject](userData)) + let nimObj = cast[NimGodotObject](userData) + if not nimObj.isFinalized: + GC_ref(nimObj) proc refcountDecremented(obj: ptr GodotObject, methodData: pointer, userData: pointer, numArgs: cint, args: var array[MAX_ARG_COUNT, ptr GodotVariant]): GodotVariant {.noconv.} = - GC_unref(cast[NimGodotObject](userData)) - initGodotVariant(result, false) # destroy when Nim decides + let nimObj = cast[NimGodotObject](userData) + if not nimObj.isFinalized: + GC_unref(nimObj) + initGodotVariant(result, nimObj.isFinalized) -template registerGodotClass(classNameIdent, classNameLit, isRef, +template registerGodotClass(classNameIdent, classNameLit; isRefClass: bool; baseNameLit, createFuncIdent; isTool: bool) = proc createFuncIdent(obj: ptr GodotObject, methData: pointer): pointer {.noconv.} = var nimObj: classNameIdent new(nimObj, nimGodotObjectFinalizer[classNameIdent]) nimObj.setGodotObject(obj) - nimObj.setNativeObject(asNimGodotObject[NimGodotObject](obj, noRef = true)) + nimObj.isRef = when isRefClass: true else: false + nimObj.setNativeObject(asNimGodotObject[NimGodotObject]( + obj, forceNativeObject = true)) GC_ref(nimObj) result = cast[pointer](nimObj) when compiles(nimObj.init()): @@ -339,7 +345,7 @@ template registerGodotClass(classNameIdent, classNameLit, isRef, createFunc: createFuncIdent ) let destroyFuncObj = GodotInstanceDestroyFunc( - destroyFunc: when isRef: nimDestroyRefFunc else: nimDestroyFunc + destroyFunc: when isRefClass: nimDestroyRefFunc else: nimDestroyFunc ) registerClass(classNameIdent, classNameLit, false) when isTool: diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index bfb59c7..b4420c0 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -38,7 +38,9 @@ type ## ``Particles`` is valid, but Nim type system is not aware of that. ## This works in both directions - for linked native object this ## reference points to Nim object. - isExternalRef: bool + isRef*: bool + isFinalized: bool + isNative: bool ConversionResult* {.pure.} = enum ## Conversion result to return from ``fromVariant`` procedure. @@ -86,6 +88,9 @@ type ## values. ## See documentation of ``GodotPropertyHint`` for description of formats. +proc isFinalized*(obj: NimGodotObject): bool {.inline.} = + obj.isFinalized + template printWarning*(warning: typed) = ## Prints ``warning`` to Godot log, adding filename and line information. let (filename, line) = instantiationInfo() @@ -128,11 +133,11 @@ proc unreference(o: ptr GodotObject): bool = unreferenceMethodBind.ptrCall(o, nil, addr(result)) var referenceMethodBind {.threadvar.}: ptr GodotMethodBind -proc reference(o: ptr GodotObject) = +proc reference(o: ptr GodotObject): bool {.discardable.} = if isNil(referenceMethodBind): referenceMethodBind = getMethod(cstring"Reference", cstring"reference") - referenceMethodBind.ptrCall(o, nil, nil) + referenceMethodBind.ptrCall(o, nil, addr result) proc deinit*(obj: NimGodotObject) = ## Destroy the object. You only need to call this for objects not inherited @@ -142,10 +147,11 @@ proc deinit*(obj: NimGodotObject) = obj.godotObject = nil proc nimGodotObjectFinalizer*[T: NimGodotObject](obj: T) = - if obj.godotObject.isNil: return - if obj.isExternalRef and obj.godotObject.unreference(): - obj.deinit() - elif not obj.linkedObject.isNil: + if obj.godotObject.isNil or obj.isNative: return + # important to set it before so that ``unreference`` is aware + obj.isFinalized = true + if obj.isRef and obj.godotObject.unreference() or + not obj.linkedObject.isNil: obj.deinit() macro baseNativeType(T: typedesc): cstring = @@ -228,25 +234,25 @@ proc newNimGodotObject[T: NimGodotObject]( else: result = T(objInfo.constructor()) result.godotObject = godotObject + result.isRef = objInfo.isRef if not noRef and objInfo.isRef: - result.isExternalRef = true result.godotObject.reference() proc asNimGodotObject*[T: NimGodotObject]( - godotObject: ptr GodotObject, noRef: bool = false): T = + godotObject: ptr GodotObject, forceNativeObject: bool = false): T = ## Wraps ``godotObject`` into Nim type ``T``. ## This is used by `godotapigen `_ and should rarely be ## used by anything else. if godotObject.isNil: return nil let userDataPtr = godotObject.getUserData() - if not userDataPtr.isNil: + if not userDataPtr.isNil and not forceNativeObject: result = cast[T](userDataPtr) if result.godotObject != godotObject: # Could be data from other bindings result = nil if result.isNil: result = newNimGodotObject[T]( - godotObject, cstring(godotObject.getClassName()), noRef) + godotObject, cstring(godotObject.getClassName()), forceNativeObject) proc newVariant*(obj: NimGodotObject): Variant {.inline.} = newVariant(obj.godotObject) @@ -367,6 +373,10 @@ proc newOwnObj[T: NimGodotObject](name: cstring): T = "but it returned: " & $ret.getType()) else: result = asNimGodotObject[T](ret.asGodotObject()) + if result.isRef: + result.isFinalized = true + result.godotObject.reference() + result.isFinalized = false ret.deinit() proc gdnew*[T: NimGodotObject](): T = @@ -417,6 +427,7 @@ proc setNativeObject*(nimObj: NimGodotObject, ## Used from Godot constructor produced by ``gdobj`` macro. Do not call. nimObj.linkedObject = nativeObj nativeObj.linkedObject = nimObj + nativeObj.isNative = true proc removeGodotObject*(nimObj: NimGodotObject) {.inline.} = ## Used from Godot destructor produced by ``gdobj`` macro. Do not call. From 77a8cf7815ea39f51a4148ede50ce597ce727178 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 14 Sep 2017 11:04:34 +0700 Subject: [PATCH 03/82] Replace ~ with of --- godot/nim/godotnim.nim | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index b4420c0..26ee4be 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -287,17 +287,12 @@ proc `as`*[T: NimGodotObject](obj: NimGodotObject, t: typedesc[T]): T = T.name & "\n" & getStackTrace()) result = nil -proc `~`*[T: NimGodotObject](obj: NimGodotObject, - t: typedesc[T]): bool {.inline.} = - ## Godot-specific inheritance check. You must use this over Nim's standard - ## ``of`` operator, because Nim does not know which object your script is - ## attached to in runtime. For example, if you create a - ## ``gdobj Bullet of Spatial`` and the ``Bullet`` is attached to a - ## ``MeshInstance``, ``myBullet of MeshInstance`` will return ``false``, but - ## ``myBullet ~ MeshInstance`` will return ``true``. - ## This is going to be changed to ``of`` in later versions, when Nim starts - ## supporting overloading ``of`` operator. - not obj.isNil and (obj of T or obj.linkedObject of T) +proc `of`*[T: NimGodotObject](obj: NimGodotObject, + t: typedesc[T]): bool {.inline.} = + ## Godot-specific inheritance check. + not obj.isNil and (system.`of`(obj, T) or system.`of`(obj.linkedObject, T)) + +{.deprecated: [`~`: `of`].} proc newRStrLit(s: string): NimNode {.compileTime.} = result = newNimNode(nnkRStrLit) From 178192651f08f26610b71caf33d2d674fb4ff67f Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 14 Sep 2017 11:04:52 +0700 Subject: [PATCH 04/82] Update docs regarding Nim version --- docs/index.rst | 11 ++++------- godot.nimble | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 4886466..320e99a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -52,16 +52,13 @@ about compiling Godot can be found in `Godot documentation `_. -Building Nim +Installing Nim ------------- -The library requires a not yet released Nim version 0.17.1, which you can -build yourself by following instructions in the -`Nim repository `_. Make sure to also run -``./koch tools -d:release`` after the steps described there to build ``nimble`` -(package manager) and ``nimsuggest`` (IDE helper tool, -used by VSCode Nim plugin) +The library requires Nim version 0.17.2 or newer, which you can get here: +https://nim-lang.org/install.html +Make sure you also have ``nimble`` (Nim's package manager) installed. Creating Project ---------------- diff --git a/godot.nimble b/godot.nimble index fa351a8..7425e63 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.5.8" +version = "0.5.9" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" From cf75723fa154c75204807256483ac24833b9fced Mon Sep 17 00:00:00 2001 From: Evgeny Zuev Date: Tue, 19 Sep 2017 17:47:28 +0700 Subject: [PATCH 05/82] Fix crash when passing nil seq to godot Up version to 0.5.10 --- godot.nimble | 2 +- godot/nim/godotnim.nim | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/godot.nimble b/godot.nimble index 7425e63..15cf592 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.5.9" +version = "0.5.10" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 26ee4be..edc6f2e 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -689,12 +689,20 @@ proc godotTypeInfo*(T: typedesc[seq]): GodotTypeInfo = proc godotTypeInfo*(T: typedesc[array]): GodotTypeInfo = arrTypeInfo(T) -proc toVariant*[T](s: openarray[T]): Variant = +template arrayToVariant(s: untyped): Variant = var arr = newArray() mixin toVariant for item in s: arr.add(toVariant(item)) - result = newVariant(arr) + newVariant(arr) + +proc toVariant*[T](s: seq[T]): Variant = + if s.isNil: + return newVariant() + result = arrayToVariant(s) + +proc toVariant*[I, T](s: array[I, T]): Variant = + result = arrayToVariant(s) proc fromVariant*[T](s: var seq[T], val: Variant): ConversionResult = if val.getType() == VariantType.Nil: From b62db02d8f95a4d481999ef6d53a149e4351f329 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 4 Oct 2017 23:41:15 +0700 Subject: [PATCH 06/82] Use GDNative API struct --- godot.nimble | 2 +- godot/core/arrays.nim | 6 +- godot/core/basis.nim | 5 +- godot/core/colors.nim | 45 +- godot/core/dictionaries.nim | 4 +- godot/core/godotbase.nim | 55 - godot/core/godotcoretypes.nim | 102 ++ godot/core/nodepaths.nim | 3 +- godot/core/planes.nim | 105 +- godot/core/poolarrays.nim | 15 +- godot/core/quats.nim | 127 +-- godot/core/rect2.nim | 73 +- godot/core/rect3.nim | 140 ++- godot/core/rids.nim | 32 +- godot/core/transform2d.nim | 117 +-- godot/core/transforms.nim | 93 +- godot/core/variants.nim | 9 +- godot/core/vector2.nim | 188 ++-- godot/core/vector3.nim | 8 +- godot/gdnativeapi.nim | 1378 +++++++++++++++++++++++++ godot/godot.nim | 7 +- godot/godotinternal.nim | 307 ++---- godot/internal/godotarrays.nim | 197 ++-- godot/internal/godotdictionaries.nim | 84 +- godot/internal/godotinternaltypes.nim | 262 +++++ godot/internal/godotnodepaths.nim | 60 +- godot/internal/godotobjects.nim | 4 - godot/internal/godotpoolarrays.nim | 495 +++------ godot/internal/godotstrings.nim | 41 +- godot/internal/godotvariants.nim | 379 +++---- godot/nim/godotmacros.nim | 28 +- godot/nim/godotnim.nim | 10 +- 32 files changed, 2846 insertions(+), 1535 deletions(-) create mode 100644 godot/core/godotcoretypes.nim create mode 100644 godot/gdnativeapi.nim create mode 100644 godot/internal/godotinternaltypes.nim delete mode 100644 godot/internal/godotobjects.nim diff --git a/godot.nimble b/godot.nimble index 15cf592..b81ad0e 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.5.10" +version = "0.6.0" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/arrays.nim b/godot/core/arrays.nim index 5157e50..414ac99 100644 --- a/godot/core/arrays.nim +++ b/godot/core/arrays.nim @@ -1,7 +1,7 @@ # Copyright 2017 Xored Software, Inc. import hashes -import internal.godotarrays +import internal.godotinternaltypes, internal.godotarrays type Array* = ref object @@ -125,8 +125,8 @@ proc delete*(self: var Array; idx: int) {.inline.} = proc setLen*(self: var Array; size: int) {.inline.} = self.godotArray.setLen(size.cint) -proc rfind*(self: Array; what: Variant; f: int): int {.inline.} = - self.godotArray.rfind(what.godotVariant[], f.cint).int +proc rfind*(self: Array; what: Variant; fromIdx: int): int {.inline.} = + self.godotArray.rfind(what.godotVariant[], fromIdx.cint).int proc len*(self: Array): int {.inline.} = self.godotArray.len.int diff --git a/godot/core/basis.nim b/godot/core/basis.nim index 75b2aab..6f7e9d9 100644 --- a/godot/core/basis.nim +++ b/godot/core/basis.nim @@ -2,10 +2,7 @@ import math import godotbase, vector3, quats - -type - Basis* {.byref.} = object - elements*: array[3, Vector3] +import godotcoretypes proc setCells*(basis: var Basis, xx, xy, xz, yx, yy, yz, zx, zy, zz: float32) = basis.elements[0].x = xx diff --git a/godot/core/colors.nim b/godot/core/colors.nim index 3d4376a..dedb1a2 100644 --- a/godot/core/colors.nim +++ b/godot/core/colors.nim @@ -1,11 +1,6 @@ # Copyright (c) 2017 Xored Software, Inc. -type - Color* {.byref.} = object - r*: float32 - g*: float32 - b*: float32 - a*: float32 +import godotcoretypes, gdnativeapi proc initColor*(r, g, b: float32; a: float32 = 1.0'f32): Color {.inline.} = Color( @@ -19,12 +14,14 @@ proc initColor*(): Color {.inline.} = ## Initializes black color with 1.0 alpha initColor(0, 0, 0) -proc h*(self: Color): float32 {. - importc: "godot_color_get_h".} -proc s*(self: Color): float32 {. - importc: "godot_color_get_s".} -proc v*(self: Color): float32 {. - importc: "godot_color_get_v".} +proc h*(self: Color): float32 {.inline.} = + getGDNativeAPI().colorGetH(self) + +proc s*(self: Color): float32 {.inline.} = + getGDNativeAPI().colorGetS(self) + +proc v*(self: Color): float32 {.inline.} = + getGDNativeAPI().colorGetV(self) proc `$`*(self: Color): string {.inline.} = result = newStringOfCap(50) @@ -58,16 +55,20 @@ proc toARGB32*(self: Color): uint32 {.inline.} = result = (result shl 8) or uint8(self.g * 255) result = (result shl 8) or uint8(self.b * 255) -proc gray*(self: Color): float32 {. - importc: "godot_color_gray".} -proc inverted*(self: Color): Color {. - importc: "godot_color_inverted".} -proc contrasted*(self: Color): Color {. - importc: "godot_color_contrasted".} -proc lerp*(self: Color; b: Color; t: float32): Color {. - importc: "godot_color_linear_interpolate".} -proc blend*(self: Color; over: Color): Color {. - importc: "godot_color_blend".} +proc gray*(self: Color): float32 {.inline.} = + getGDNativeAPI().colorGray(self) + +proc inverted*(self: Color): Color {.inline.} = + getGDNativeAPI().colorInverted(self) + +proc contrasted*(self: Color): Color {.inline.} = + getGDNativeAPI().colorContrasted(self) + +proc lerp*(self: Color; b: Color; t: float32): Color {.inline.} = + getGDNativeAPI().colorLinearInterpolate(self, b, t) + +proc blend*(self: Color; over: Color): Color {.inline.} = + getGDNativeAPI().colorBlend(self, over) proc `==`*(a, b: Color): bool {.inline.} = a.r == b.r and a.g == b.g and a.b == b.b and a.a == b.a diff --git a/godot/core/dictionaries.nim b/godot/core/dictionaries.nim index 1276c89..5445d27 100644 --- a/godot/core/dictionaries.nim +++ b/godot/core/dictionaries.nim @@ -1,8 +1,8 @@ # Copyright 2017 Xored Software, Inc. import hashes -import internal.godotstrings, internal.godotdictionaries, - internal.godotvariants +import internal.godotinternaltypes, internal.godotdictionaries, + internal.godotvariants, internal.godotstrings type Dictionary* = ref object diff --git a/godot/core/godotbase.nim b/godot/core/godotbase.nim index 0fda0cd..0f410b8 100644 --- a/godot/core/godotbase.nim +++ b/godot/core/godotbase.nim @@ -2,61 +2,6 @@ import math -type - Error* {.size: sizeof(cint), pure.} = enum - OK, - Failed, ## Generic fail error - Unavailable, ## What is requested is unsupported/unavailable - Unconfigured, ## The object being used hasnt been properly set up yet - Unauthorized, ## Missing credentials for requested resource - ParameterRangeError, ## Parameter given out of range (5) - OutOfMemory, ## Out of memory - FileNotFound, - FileBadDrive, - FileBadPath, - FileNoPermission, ## (10) - FileAlreadyInUse, - FileCantOpen, - FileCantWrite, - FileCantRead, - FileUnrecognized, ## (15) - FileCorrupt, - FileMissingDependencies, - FileEOF, - CantOpen, ## Can't open a resource/socket/file - CantCreate, ## (20) - QueryFailed, - AlreadyInUse, - Locked, ## resource is locked - Timeout, - CantConnect, ## (25) - CantResolve, - ConnectionError, - CantAquireResource, - CantFork, - InvalidData, ## Data passed is invalid (30) - InvalidParameter, ## Parameter passed is invalid - AlreadyExists, ## When adding, item already exists - DoesNotExist, ## When retrieving/erasing, it item does not exist - DatabaseCantRead, ## Database is full - DatabaseCantWrite, ## Database is full (35) - CompilationFailed, - MethodNotFound, - LinkFailed, - ScriptFailed, - CyclicLink, ## (40) - InvalidDeclaration, - DuplicateSymbol, - PauseError, - Busy, - Skip, ## (45) - Help, ## user requested help!! - Bug, - ## a bug in the software certainly happened, due to a double - ## check failing or unexpected behavior. - PrinterOnFire, ## the parallel port printer is engulfed in flames - WTF ## shit happens, has never been used, though - # math helpers const EPSILON = 0.00001'f32 diff --git a/godot/core/godotcoretypes.nim b/godot/core/godotcoretypes.nim new file mode 100644 index 0000000..8b92407 --- /dev/null +++ b/godot/core/godotcoretypes.nim @@ -0,0 +1,102 @@ +# Copyright 2017 Xored Software, Inc. + +type + Color* {.byref.} = object + r*: float32 + g*: float32 + b*: float32 + a*: float32 + + Vector3* {.byref.} = object + x*: float32 + y*: float32 + z*: float32 + + Vector2* {.byref.} = object + x*: float32 + y*: float32 + + Plane* {.byref.} = object + normal*: Vector3 + d*: float32 + + Basis* {.byref.} = object + elements*: array[3, Vector3] + + Quat* {.byref.} = object + x*: float32 + y*: float32 + z*: float32 + w*: float32 + + Rect3* {.byref.} = object + position*: Vector3 + size*: Vector3 + + Rect2* {.byref.} = object + position*: Vector2 + size*: Vector2 + + Transform2D* {.byref.} = object + elements*: array[3, Vector2] + + Transform* {.byref.} = object + basis*: Basis + origin*: Vector3 + + RID* {.byref.} = object + data: array[sizeof(int), byte] + + Error* {.size: sizeof(cint), pure.} = enum + OK, + Failed, ## Generic fail error + Unavailable, ## What is requested is unsupported/unavailable + Unconfigured, ## The object being used hasnt been properly set up yet + Unauthorized, ## Missing credentials for requested resource + ParameterRangeError, ## Parameter given out of range (5) + OutOfMemory, ## Out of memory + FileNotFound, + FileBadDrive, + FileBadPath, + FileNoPermission, ## (10) + FileAlreadyInUse, + FileCantOpen, + FileCantWrite, + FileCantRead, + FileUnrecognized, ## (15) + FileCorrupt, + FileMissingDependencies, + FileEOF, + CantOpen, ## Can't open a resource/socket/file + CantCreate, ## (20) + QueryFailed, + AlreadyInUse, + Locked, ## resource is locked + Timeout, + CantConnect, ## (25) + CantResolve, + ConnectionError, + CantAquireResource, + CantFork, + InvalidData, ## Data passed is invalid (30) + InvalidParameter, ## Parameter passed is invalid + AlreadyExists, ## When adding, item already exists + DoesNotExist, ## When retrieving/erasing, it item does not exist + DatabaseCantRead, ## Database is full + DatabaseCantWrite, ## Database is full (35) + CompilationFailed, + MethodNotFound, + LinkFailed, + ScriptFailed, + CyclicLink, ## (40) + InvalidDeclaration, + DuplicateSymbol, + PauseError, + Busy, + Skip, ## (45) + Help, ## user requested help!! + Bug, + ## a bug in the software certainly happened, due to a double + ## check failing or unexpected behavior. + PrinterOnFire, ## the parallel port printer is engulfed in flames + WTF ## shit happens, has never been used, though diff --git a/godot/core/nodepaths.nim b/godot/core/nodepaths.nim index 3bdd41d..62e30f8 100644 --- a/godot/core/nodepaths.nim +++ b/godot/core/nodepaths.nim @@ -1,6 +1,7 @@ # Copyright 2017 Xored Software, Inc. -import internal.godotnodepaths, internal.godotstrings +import internal.godotinternaltypes, internal.godotnodepaths, + internal.godotstrings type NodePath* = ref object diff --git a/godot/core/planes.nim b/godot/core/planes.nim index 4c6ead5..360953f 100644 --- a/godot/core/planes.nim +++ b/godot/core/planes.nim @@ -2,72 +2,59 @@ import vector3 -import internal.godotstrings +import internal.godotinternaltypes, godotcoretypes, gdnativeapi -type - Plane* {.byref.} = object - normal*: Vector3 - d*: float32 +proc initPlane*(a, b, c, d: float32): Plane {.inline.} = + getGDNativeAPI().planeNewWithReals(result, a, b, c, d) -proc initPlane(dest: var Plane; a, b, c, d: float32) {. - importc: "godot_plane_new_with_reals".} -proc initPlane(dest: var Plane; v1, v2, v3: Vector3) {. - importc: "godot_plane_new_with_vectors".} -proc initPlane(dest: var Plane; normal: Vector3; d: float32) {. - importc: "godot_plane_new_with_normal".} +proc initPlane*(v1, v2, v3: Vector3): Plane {.inline.} = + getGDNativeAPI().planeNewWithVectors(result, v1, v2, v3) -proc initPlane*(a, b, c, d: float32): Plane = - initPlane(result, a, b, c, d) - -proc initPlane*(v1, v2, v3: Vector3): Plane = - initPlane(result, v1, v2, v3) - -proc initPlane*(normal: Vector3; d: float32): Plane = - initPlane(result, normal, d) - -proc toGodotString(self: Plane): GodotString {. - noSideEffect, - importc: "godot_plane_as_string".} +proc initPlane*(normal: Vector3; d: float32): Plane {.inline.} = + result = Plane( + normal: normal, + d: d + ) proc `$`*(self: Plane): string {.inline.} = - $self.toGodotString() + $getGDNativeAPI().planeAsString(self) + +proc normalized*(self: Plane): Plane {.inline.} = + getGDNativeAPI().planeNormalized(self) + +proc center*(self: Plane): Vector3 {.inline.} = + getGDNativeAPI().planeCenter(self) + +proc getAnyPoint*(self: Plane): Vector3 {.inline.} = + getGDNativeAPI().planeGetAnyPoint(self) + +proc isPointOver*(self: Plane; point: Vector3): bool {.inline.} = + getGDNativeAPI().planeIsPointOver(self, point) + +proc distanceTo*(self: Plane; point: Vector3): float32 {.inline.} = + getGDNativeAPI().planeDistanceTo(self, point) -proc normalized*(self: Plane): Plane {. - noSideEffect, - importc: "godot_plane_normalized".} -proc center*(self: Plane): Vector3 {. - noSideEffect, - importc: "godot_plane_center".} -proc getAnyPoint*(self: Plane): Vector3 {. - noSideEffect, - importc: "godot_plane_get_any_point".} -proc isPointOver*(self: Plane; point: Vector3): bool {. - noSideEffect, - importc: "godot_plane_is_point_over".} -proc distanceTo*(self: Plane; point: Vector3): float32 {. - noSideEffect, - importc: "godot_plane_distance_to".} proc contains*(self: Plane; point: Vector3; - epsilon: float32): bool {. - noSideEffect, - importc: "godot_plane_has_point".} -proc project*(self: Plane; point: Vector3): Vector3 {. - noSideEffect, - importc: "godot_plane_project".} + epsilon: float32): bool {.inline.} = + getGDNativeAPI().planeHasPoint(self, point, epsilon) + +proc project*(self: Plane; point: Vector3): Vector3 {.inline.} = + getGDNativeAPI().planeProject(self, point) + proc intersect3*(self: Plane; dest: var Vector3; - b, c: Plane): bool {. - noSideEffect, - importc: "godot_plane_intersect_3".} + b, c: Plane): bool {.inline.} = + getGDNativeAPI().planeIntersect3(self, dest, b, c) + proc intersectsRay*(self: Plane; dest: var Vector3; - v, dir: Vector3): bool {. - noSideEffect, - importc: "godot_plane_intersects_ray".} + v, dir: Vector3): bool {.inline.} = + getGDNativeAPI().planeIntersectsRay(self, dest, v, dir) + proc intersectsSegment*(self: Plane; dest: var Vector3; - segmentBegin, segmentEnd: Vector3): bool {. - noSideEffect, importc: "godot_plane_intersects_segment".} -proc `-`*(self: Plane): Plane {. - noSideEffect, - importc: "godot_plane_operator_neg".} -proc `==`*(a, b: Plane): bool {. - noSideEffect, - importc: "godot_plane_operator_equal".} + segmentBegin, segmentEnd: Vector3): bool {.inline.} = + getGDNativeAPI().planeIntersectsSegment(self, dest, segmentBegin, segmentEnd) + +proc `-`*(self: Plane): Plane {.inline.} = + getGDNativeAPI().planeOperatorNeg(self) + +proc `==`*(a, b: Plane): bool {.inline.} = + getGDNativeAPI().planeOperatorEqual(a, b) diff --git a/godot/core/poolarrays.nim b/godot/core/poolarrays.nim index bb263d2..dd3f544 100644 --- a/godot/core/poolarrays.nim +++ b/godot/core/poolarrays.nim @@ -1,7 +1,8 @@ # Copyright 2017 Xored Software, Inc. -import vector2, vector3, colors -import internal.godotpoolarrays, internal.godotstrings +import godotcoretypes +import internal.godotinternaltypes, internal.godotpoolarrays, + internal.godotstrings template definePoolArrayBase(T, GodotT, DataT, fieldName, newProcName, initProcName) = @@ -51,9 +52,6 @@ template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName; proc add*(self: var T; data: DataT) {.inline.} = self.fieldName.add(data) - proc addFirst*(self: var T, data: DataT) {.inline.} = - self.fieldName.addFirst(data) - proc insert*(self: var T; idx: int; data: DataT): Error {.inline.} = self.fieldName.insert(idx.cint, data) @@ -93,7 +91,7 @@ definePoolArrayBase(PoolStringArray, GodotPoolStringArray, string, godotPoolStringArray, newPoolStringArray, initGodotPoolStringArray) -import godotbase, arrays +import arrays definePoolArray(PoolByteArray, GodotPoolByteArray, uint8, godotPoolByteArray, newPoolByteArray, @@ -122,11 +120,6 @@ proc add*(self: var PoolStringArray; data: string) = self.godotPoolStringArray.add(s) s.deinit() -proc addFirst*(self: var PoolStringArray, data: string) = - var s = data.toGodotString() - self.godotPoolStringArray.addFirst(s) - s.deinit() - proc insert*(self: var PoolStringArray; idx: int; data: string): Error = var s = data.toGodotString() result = self.godotPoolStringArray.insert(idx.cint, s) diff --git a/godot/core/quats.nim b/godot/core/quats.nim index 9e12d55..016bbd0 100644 --- a/godot/core/quats.nim +++ b/godot/core/quats.nim @@ -1,91 +1,78 @@ # Copyright (c) 2017 Xored Software, Inc. -import vector3 -import internal.godotstrings - -type - Quat* {.byref.} = object - x*: float32 - y*: float32 - z*: float32 - w*: float32 - -proc initQuat(dest: var Quat; x, y, z, w: float32) {. - importc: "godot_quat_new".} -proc initQuat(dest: var Quat; axis: Vector3; angle: float32) {. - importc: "godot_quat_new_with_axis_angle".} +import internal.godotinternaltypes, godotcoretypes, gdnativeapi proc initQuat*(x, y, z, w: float32): Quat {.inline.} = - initQuat(result, x, y, z, w) + result = Quat( + x: x, + y: y, + z: z, + w: w + ) proc initQuat*(axis: Vector3; angle: float32): Quat {.inline.} = - initQuat(result, axis, angle) - -proc toGodotString(self: Quat): GodotString {. - noSideEffect, - importc: "godot_quat_as_string".} + getGDNativeAPI().quatNewWithAxisAngle(result, axis, angle) proc `$`*(self: Quat): string {.inline.} = - $self.toGodotString() + $getGDNativeAPI().quatAsString(self) + +proc length*(self: Quat): float32 {.inline.} = + getGDNativeAPI().quatLength(self) + +proc lengthSquared*(self: Quat): float32 {.inline.} = + getGDNativeAPI().quatLengthSquared(self) + +proc normalized*(self: Quat): Quat {.inline.} = + getGDNativeAPI().quatNormalized(self) + +proc isNormalized*(self: Quat): bool {.inline.} = + getGDNativeAPI().quatIsNormalized(self) + +proc inverse*(self: Quat): Quat {.inline.} = + getGDNativeAPI().quatInverse(self) + +proc dot*(a, b: Quat): float32 {.inline.} = + getGDNativeAPI().quatDot(a, b) + +proc xform*(self: Quat; v: Vector3): Vector3 {.inline.} = + getGDNativeAPI().quatXform(self, v) + +proc slerp*(self: Quat; b: Quat; t: float32): Quat {.inline.} = + getGDNativeAPI().quatSlerp(self, b, t) + +proc slerpni*(self: Quat; b: Quat; t: float32): Quat {.inline.} = + getGDNativeAPI().quatSlerpni(self, b, t) + +proc cubicSlerp*(self, b, preA, postB: Quat; + t: float32): Quat {.inline.} = + getGDNativeAPI().quatCubicSlerp(self, b, preA, postB, t) + +proc `*`*(a: Quat, b: float32): Quat {.inline.} = + getGDNativeAPI().quatOperatorMultiply(a, b) -proc length*(self: Quat): float32 {. - noSideEffect, - importc: "godot_quat_length".} -proc lengthSquared*(self: Quat): float32 {. - noSideEffect, - importc: "godot_quat_length_squared".} -proc normalized*(self: Quat): Quat {. - noSideEffect, - importc: "godot_quat_normalized".} -proc isNormalized*(self: Quat): bool {. - noSideEffect, - importc: "godot_quat_is_normalized".} -proc inverse*(self: Quat): Quat {. - noSideEffect, - importc: "godot_quat_inverse".} -proc dot*(a, b: Quat): float32 {. - noSideEffect, - importc: "godot_quat_dot".} -proc xform*(self: Quat; v: Vector3): Vector3 {. - noSideEffect, - importc: "godot_quat_xform".} -proc slerp*(self: Quat; b: Quat; t: float32): Quat {. - noSideEffect, - importc: "godot_quat_slerp".} -proc slerpni*(self: Quat; b: Quat; t: float32): Quat {. - noSideEffect, - importc: "godot_quat_slerpni".} -proc cubicSlerp*(self, b, pre_a, post_b: Quat; - t: float32): Quat {. - noSideEffect, - importc: "godot_quat_cubic_slerp".} -proc `*`*(a: Quat, b: float32): Quat {. - noSideEffect, - importc: "godot_quat_operator_multiply".} proc `*=`*(a: var Quat, b: float32) {.inline.} = a = a * b -proc `+`*(a, b: Quat): Quat {. - noSideEffect, - importc: "godot_quat_operator_add".} +proc `+`*(a, b: Quat): Quat {.inline.} = + getGDNativeAPI().quatOperatorAdd(a, b) + proc `+=`*(a: var Quat, b: Quat) {.inline.} = a = a + b -proc `-`*(a, b: Quat): Quat {. - noSideEffect, - importc: "godot_quat_operator_substract".} +proc `-`*(a, b: Quat): Quat {.inline.} = + getGDNativeAPI().quatOperatorSubtract(a, b) + proc `-=`* (a: var Quat, b: Quat) {.inline.} = a = a - b -proc `/`*(self: Quat; b: float32): Quat {. - noSideEffect, - importc: "godot_quat_operator_divide".} +proc `/`*(self: Quat; b: float32): Quat {.inline.} = + getGDNativeAPI().quatOperatorDivide(self, b) + proc `/=`*(self: var Quat, b: float32) {.inline.} = self = self / b -proc `==`*(a, b: Quat): bool {. - noSideEffect, - importc: "godot_quat_operator_equal".} -proc `-`*(self: Quat): Quat {. - noSideEffect, - importc: "godot_quat_operator_neg".} +proc `==`*(a, b: Quat): bool {.inline.} = + getGDNativeAPI().quatOperatorEqual(a, b) + +proc `-`*(self: Quat): Quat {.inline.} = + getGDNativeAPI().quatOperatorNeg(self) diff --git a/godot/core/rect2.nim b/godot/core/rect2.nim index d2192b1..628e203 100644 --- a/godot/core/rect2.nim +++ b/godot/core/rect2.nim @@ -1,13 +1,7 @@ # Copyright (c) 2017 Xored Software, Inc. import vector2 - -import internal.godotstrings - -type - Rect2* {.byref.} = object - position*: Vector2 - size*: Vector2 +import godotcoretypes, internal.godotinternaltypes, gdnativeapi proc initRect2*(pos, size: Vector2): Rect2 {.inline.} = Rect2(position: pos, size: size) @@ -15,40 +9,35 @@ proc initRect2*(pos, size: Vector2): Rect2 {.inline.} = proc initRect2*(x, y, sizeX, sizeY: float32): Rect2 {.inline.} = Rect2(position: vec2(x, y), size: vec2(sizeX, sizeY)) -proc toGodotString(self: Rect2): GodotString {. - noSideEffect, - importc: "godot_rect2_as_string".} - proc `$`*(self: Rect2): string {.inline.} = - $self.toGodotString() + $getGDNativeAPI().rect2AsString(self) -proc area*(self: Rect2): float32 {. - noSideEffect, - importc: "godot_rect2_get_area".} -proc intersects*(a, b: Rect2): bool {. - noSideEffect, - importc: "godot_rect2_intersects".} -proc encloses*(a, b: Rect2): bool {. - noSideEffect, - importc: "godot_rect2_encloses".} -proc hasNoArea*(self: Rect2): bool {. - noSideEffect, - importc: "godot_rect2_has_no_area".} -proc clip*(a, b: Rect2): Rect2 {. - noSideEffect, - importc: "godot_rect2_clip".} -proc merge*(a, b: Rect2): Rect2 {. - noSideEffect, - importc: "godot_rect2_merge".} -proc contains*(self: Rect2; point: Vector2): bool {. - noSideEffect, - importc: "godot_rect2_has_point".} -proc grow*(self: Rect2; by: float32): Rect2 {. - noSideEffect, - importc: "godot_rect2_grow".} -proc expand*(self: Rect2; to: Vector2): Rect2 {. - noSideEffect, - importc: "godot_rect2_expand".} -proc `==`*(a, b: Rect2): bool {. - noSideEffect, - importc: "godot_rect2_operator_equal".} +proc area*(self: Rect2): float32 {.inline.} = + getGDNativeAPI().rect2GetArea(self) + +proc intersects*(a, b: Rect2): bool {.inline.} = + getGDNativeAPI().rect2Intersects(a, b) + +proc encloses*(a, b: Rect2): bool {.inline.} = + getGDNativeAPI().rect2Encloses(a, b) + +proc hasNoArea*(self: Rect2): bool {.inline.} = + getGDNativeAPI().rect2HasNoArea(self) + +proc clip*(self, b: Rect2): Rect2 {.inline.} = + getGDNativeAPI().rect2Clip(self, b) + +proc merge*(self, b: Rect2): Rect2 {.inline.} = + getGDNativeAPI().rect2Merge(self, b) + +proc contains*(self: Rect2; point: Vector2): bool {.inline.} = + getGDNativeAPI().rect2HasPoint(self, point) + +proc grow*(self: Rect2; by: float32): Rect2 {.inline.} = + getGDNativeAPI().rect2Grow(self, by) + +proc expand*(self: Rect2; to: Vector2): Rect2 {.inline.} = + getGDNativeAPI().rect2Expand(self, to) + +proc `==`*(a, b: Rect2): bool {.inline.} = + getGDNativeAPI().rect2OperatorEqual(a, b) diff --git a/godot/core/rect3.nim b/godot/core/rect3.nim index c695ce9..7a2ef72 100644 --- a/godot/core/rect3.nim +++ b/godot/core/rect3.nim @@ -1,84 +1,72 @@ # Copyright (c) 2017 Xored Software, Inc. -import planes, vector3 - -import internal.godotstrings - -type - Rect3* {.byref.} = object - position*: Vector3 - size*: Vector3 +import godotcoretypes, internal.godotinternaltypes, gdnativeapi proc initRect3*(pos, size: Vector3): Rect3 {.inline.} = Rect3(position: pos, size: size) -proc toGodotString(self: Rect3): GodotString {. - noSideEffect, - importc: "godot_rect3_as_string".} - proc `$`*(self: Rect3): string {.inline.} = - $self.toGodotString() + $getGDNativeAPI().rect3AsString(self) -proc area*(self: Rect3): float32 {. - noSideEffect, - importc: "godot_rect3_get_area".} -proc hasNoArea*(self: Rect3): bool {. - noSideEffect, - importc: "godot_rect3_has_no_area".} -proc hasNoSurface*(self: Rect3): bool {. - noSideEffect, - importc: "godot_rect3_has_no_surface".} -proc intersects*(a, b: Rect3): bool {. - noSideEffect, - importc: "godot_rect3_intersects".} -proc encloses*(self, other: Rect3): bool {. - noSideEffect, - importc: "godot_rect3_encloses".} -proc merge*(self, other: Rect3): Rect3 {. - noSideEffect, - importc: "godot_rect3_merge".} -proc intersection*(self, other: Rect3): Rect3 {. - noSideEffect, - importc: "godot_rect3_intersection".} -proc intersectsPlane*(self: Rect3; plane: Plane): bool {. - noSideEffect, - importc: "godot_rect3_intersects_plane".} -proc intersectsSegment*(self: Rect3; start, to: Vector3): bool {. - noSideEffect, - importc: "godot_rect3_intersects_segment".} -proc contains*(self: Rect3; point: Vector3): bool {. - noSideEffect, - importc: "godot_rect3_has_point".} -proc getSupport*(self: Rect3; dir: Vector3): Vector3 {. - noSideEffect, - importc: "godot_rect3_get_support".} -proc getLongestAxis*(self: Rect3): Vector3 {. - noSideEffect, - importc: "godot_rect3_get_longest_axis".} -proc getLongestAxisIndex*(self: Rect3): cint {. - noSideEffect, - importc: "godot_rect3_get_longest_axis_index".} -proc getLongestAxisSize*(self: Rect3): float32 {. - noSideEffect, - importc: "godot_rect3_get_longest_axis_size".} -proc getShortestAxis*(self: Rect3): Vector3 {. - noSideEffect, - importc: "godot_rect3_get_shortest_axis".} -proc getShortestAxisIndex*(self: Rect3): cint {. - noSideEffect, - importc: "godot_rect3_get_shortest_axis_index".} -proc getShortestAxisSize*(self: Rect3): float32 {. - noSideEffect, - importc: "godot_rect3_get_shortest_axis_size".} -proc expand*(self: Rect3; toPoint: Vector3): Rect3 {. - noSideEffect, - importc: "godot_rect3_expand".} -proc grow*(self: Rect3; by: float32): Rect3 {. - noSideEffect, - importc: "godot_rect3_grow".} -proc getEndpoint*(self: Rect3; idx: cint): Vector3 {. - noSideEffect, - importc: "godot_rect3_get_endpoint".} -proc `==`*(a, b: Rect3): bool {. - noSideEffect, - importc: "godot_rect3_operator_equal".} +proc area*(self: Rect3): float32 {.inline.} = + getGDNativeAPI().rect3GetArea(self) + +proc hasNoArea*(self: Rect3): bool {.inline.} = + getGDNativeAPI().rect3HasNoArea(self) + +proc hasNoSurface*(self: Rect3): bool {.inline.} = + getGDNativeAPI().rect3HasNoSurface(self) + +proc intersects*(self, other: Rect3): bool {.inline.} = + getGDNativeAPI().rect3Intersects(self, other) + +proc encloses*(self, other: Rect3): bool {.inline.} = + getGDNativeAPI().rect3Encloses(self, other) + +proc merge*(self, other: Rect3): Rect3 {.inline.} = + getGDNativeAPI().rect3Merge(self, other) + +proc intersection*(self, other: Rect3): Rect3 {.inline.} = + getGDNativeAPI().rect3Intersection(self, other) + +proc intersectsPlane*(self: Rect3; plane: Plane): bool {.inline.} = + getGDNativeAPI().rect3IntersectsPlane(self, plane) + +proc intersectsSegment*(self: Rect3; start, to: Vector3): bool {.inline.} = + getGDNativeAPI().rect3IntersectsSegment(self, start, to) + +proc contains*(self: Rect3; point: Vector3): bool {.inline.} = + getGDNativeAPI().rect3HasPoint(self, point) + +proc getSupport*(self: Rect3; dir: Vector3): Vector3 {.inline.} = + getGDNativeAPI().rect3GetSupport(self, dir) + +proc getLongestAxis*(self: Rect3): Vector3 {.inline.} = + getGDNativeAPI().rect3GetLongestAxis(self) + +proc getLongestAxisIndex*(self: Rect3): cint {.inline.} = + getGDNativeAPI().rect3GetLongestAxisIndex(self) + +proc getLongestAxisSize*(self: Rect3): float32 {.inline.} = + getGDNativeAPI().rect3GetLongestAxisSize(self) + +proc getShortestAxis*(self: Rect3): Vector3 {.inline.} = + getGDNativeAPI().rect3GetShortestAxis(self) + +proc getShortestAxisIndex*(self: Rect3): cint {.inline.} = + getGDNativeAPI().rect3GetShortestAxisIndex(self) + +proc getShortestAxisSize*(self: Rect3): float32 {.inline.} = + getGDNativeAPI().rect3GetShortestAxisSize(self) + +proc expand*(self: Rect3; toPoint: Vector3): Rect3 {.inline.} = + getGDNativeAPI().rect3Expand(self, toPoint) + +proc grow*(self: Rect3; by: float32): Rect3 {.inline.} = + getGDNativeAPI().rect3Grow(self, by) + +proc getEndpoint*(self: Rect3; idx: cint): Vector3 {.inline.} = + getGDNativeAPI().rect3GetEndpoint(self, idx) + +proc `==`*(a, b: Rect3): bool {.inline.} = + getGDNativeAPI().rect3OperatorEqual(a, b) diff --git a/godot/core/rids.nim b/godot/core/rids.nim index 6ec5b86..a113f60 100644 --- a/godot/core/rids.nim +++ b/godot/core/rids.nim @@ -1,31 +1,21 @@ -import internal.godotobjects +# Copyright (c) 2017 Xored Software, Inc. -type - RID* {.byref.} = object - data: array[sizeof(int), byte] - -proc initRID(dest: var RID) {. - importc: "godot_rid_new".} -proc initRID(dest: var RID; obj: ptr GodotObject) {. - importc: "godot_rid_new_with_resource".} +import godotcoretypes, internal.godotinternaltypes, gdnativeapi proc initRID*(): RID {.inline.} = - initRID(result) + getGDNativeAPI().ridNew(result) proc initRID*(obj: ptr GodotObject): RID {.inline.} = - initRID(result, obj) - -proc idCInt(self: RID): cint {. - noSideEffect, - importc: "godot_rid_get_id".} + getGDNativeAPI().ridNewWithResource(result, obj) proc id*(self: RID): uint32 {.inline.} = - cast[uint32](self.idCInt()) + cast[uint32](getGDNativeAPI().ridGetId(self)) -proc `$`*(self: RID): string = +proc `$`*(self: RID): string {.inline.} = $self.id -proc `==`*(a, b: RID): bool {. - importc: "godot_rid_operator_equal".} -proc `<`*(a, b: RID): bool {. - importc: "godot_rid_operator_less".} +proc `==`*(a, b: RID): bool {.inline.} = + getGDNativeAPI().ridOperatorEqual(a, b) + +proc `<`*(a, b: RID): bool {.inline.} = + getGDNativeAPI().ridOperatorLess(a, b) diff --git a/godot/core/transform2d.nim b/godot/core/transform2d.nim index fece240..67222c6 100644 --- a/godot/core/transform2d.nim +++ b/godot/core/transform2d.nim @@ -1,76 +1,73 @@ # Copyright (c) 2017 Xored Software, Inc. -import vector2, rect2 - -import internal.godotstrings - -type - Transform2D* {.byref.} = object - elements*: array[3, Vector2] - -proc initTransform2D(dest: var Transform2D) {. - importc: "godot_transform2d_new_identity".} -proc initTransform2D(dest: var Transform2D; rot: float32; pos: Vector2) {. - importc: "godot_transform2d_new".} -proc initTransform2D(dest: var Transform2D; xAxis, yAxis, origin: Vector2) {. - importc: "godot_transform2d_new_axis_origin".} +import godotcoretypes, internal.godotinternaltypes, gdnativeapi proc initTransform2D*(): Transform2D {.inline.} = - initTransform2D(result) + getGDNativeAPI().transform2DNewIdentity(result) proc initTransform2D*(rot: float32; pos: Vector2): Transform2D {.inline.} = - initTransform2D(result, rot, pos) + getGDNativeAPI().transform2DNew(result, rot, pos) proc initTransform2D*(xAxis, yAxis, origin: Vector2): Transform2D {.inline.} = - initTransform2D(result, xAxis, yAxis, origin) - -proc toGodotString(self: Transform2D): GodotString {. - importc: "godot_transform2d_as_string".} + getGDNativeAPI().transform2DNewAxisOrigin(result, xAxis, yAxis, origin) proc `$`*(self: Transform2D): string {.inline.} = - $self.toGodotString() + $getGDNativeAPI().transform2DAsString(self) -proc inverse*(self: Transform2D): Transform2D {. - importc: "godot_transform2d_inverse".} -proc affineInverse*(self: Transform2D): Transform2D {. - importc: "godot_transform2d_affine_inverse".} -proc rotation*(self: Transform2D): float32 {. - importc: "godot_transform2d_get_rotation".} -proc origin*(self: Transform2D): Vector2 {. - importc: "godot_transform2d_get_origin".} -proc scale*(self: Transform2D): Vector2 {. - importc: "godot_transform2d_get_scale".} -proc orthonormalized*(self: Transform2D): Transform2D {. - importc: "godot_transform2d_orthonormalized".} -proc rotated*(self: Transform2D; phi: float32): Transform2D {. - importc: "godot_transform2d_rotated".} -proc scaled*(self: Transform2D; scale: Vector2): Transform2D {. - importc: "godot_transform2d_scaled".} -proc translated*(self: Transform2D; - offset: Vector2): Transform2D {. - importc: "godot_transform2d_translated".} -proc xformVector2*(self: Transform2D; v: Vector2): Vector2 {. - importc: "godot_transform2d_xform_vector2".} -proc xformInvVector2*(self: Transform2D; v: Vector2): Vector2 {. - importc: "godot_transform2d_xform_inv_vector2".} -proc basisXformVector2*(self: Transform2D; - v: Vector2): Vector2 {. - importc: "godot_transform2d_basis_xform_vector2".} -proc basisXformInvVector2*(self: Transform2D; - v: Vector2): Vector2 {. - importc: "godot_transform2d_basis_xform_inv_vector2".} -proc xformRect2*(self: Transform2D; v: Rect2): Rect2 {. - importc: "godot_transform2d_xform_rect2".} -proc xformInvRect2*(self: Transform2D; v: Rect2): Rect2 {. - importc: "godot_transform2d_xform_inv_rect2".} +proc inverse*(self: Transform2D): Transform2D {.inline.} = + getGDNativeAPI().transform2DInverse(self) + +proc affineInverse*(self: Transform2D): Transform2D {.inline.} = + getGDNativeAPI().transform2DAffineInverse(self) + +proc rotation*(self: Transform2D): float32 {.inline.} = + getGDNativeAPI().transform2DGetRotation(self) + +proc origin*(self: Transform2D): Vector2 {.inline.} = + getGDNativeAPI().transform2DGetOrigin(self) + +proc scale*(self: Transform2D): Vector2 {.inline.} = + getGDNativeAPI().transform2DGetScale(self) + +proc orthonormalized*(self: Transform2D): Transform2D {.inline.} = + getGDNativeAPI().transform2DOrthonormalized(self) + +proc rotated*(self: Transform2D; phi: float32): Transform2D {.inline.} = + getGDNativeAPI().transform2DRotated(self, phi) + +proc scaled*(self: Transform2D; scale: Vector2): Transform2D {.inline.} = + getGDNativeAPI().transform2DScaled(self, scale) + +proc translated*(self: Transform2D; offset: Vector2): Transform2D {.inline.} = + getGDNativeAPI().transform2DTranslated(self, offset) + +proc xformVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = + getGDNativeAPI().transform2DXformVector2(self, v) + +proc xformInvVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = + getGDNativeAPI().transform2DXformInvVector2(self, v) + +proc basisXformVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = + getGDNativeAPI().transform2DBasisXformVector2(self, v) + +proc basisXformInvVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = + getGDNativeAPI().transform2DBasisXformInvVector2(self, v) + +proc xformRect2*(self: Transform2D; rect: Rect2): Rect2 {.inline.} = + getGDNativeAPI().transform2DXformRect2(self, rect) + +proc xformInvRect2*(self: Transform2D; rect: Rect2): Rect2 {.inline.} = + getGDNativeAPI().transform2DXformInvRect2(self, rect) proc interpolateWith*(self, m: Transform2D; - c: float32): Transform2D {. - importc: "godot_transform2d_interpolate_with".} -proc `==`*(a, b: Transform2D): bool {. - importc: "godot_transform2d_operator_equal".} -proc `*`*(a, b: Transform2D): Transform2D {. - importc: "godot_transform2d_operator_multiply".} + c: float32): Transform2D {.inline.} = + getGDNativeAPI().transform2DInterpolateWith(self, m, c) + +proc `==`*(a, b: Transform2D): bool {.inline.} = + getGDNativeAPI().transform2DOperatorEqual(a, b) + +proc `*`*(a, b: Transform2D): Transform2D {.inline.} = + getGDNativeAPI().transform2DOperatorMultiply(a, b) proc `*=`*(a: var Transform2D, b: Transform2D) {.inline.} = a = a * b diff --git a/godot/core/transforms.nim b/godot/core/transforms.nim index 7765ab3..550136c 100644 --- a/godot/core/transforms.nim +++ b/godot/core/transforms.nim @@ -1,13 +1,7 @@ # Copyright (c) 2017 Xored Software, Inc. -import basis, vector3, planes, rect3 - -import internal.godotstrings - -type - Transform* {.byref.} = object - basis*: Basis - origin*: Vector3 +import godotcoretypes, internal.godotinternaltypes, gdnativeapi +import basis proc initTransform*(): Transform {.inline.} = result.basis = initBasis() @@ -23,45 +17,54 @@ proc initTransform*(xAxis, yAxis, zAxis, proc initTransform*(basis: Basis, origin: Vector3): Transform {.inline.} = Transform(basis: basis, origin: origin) -proc toGodotString(self: Transform): GodotString {. - importc: "godot_transform_as_string".} - proc `$`*(self: Transform): string {.inline.} = - $self.toGodotString() + $getGDNativeAPI().transformAsString(self) + +proc inverse*(self: Transform): Transform {.inline.} = + getGDNativeAPI().transformInverse(self) + +proc affineInverse*(self: Transform): Transform {.inline.} = + getGDNativeAPI().transformAffineInverse(self) + +proc orthonormalized*(self: Transform): Transform {.inline.} = + getGDNativeAPI().transformOrthonormalized(self) -proc inverse*(self: Transform): Transform {. - importc: "godot_transform_inverse".} -proc affineInverse*(self: Transform): Transform {. - importc: "godot_transform_affine_inverse".} -proc orthonormalized*(self: Transform): Transform {. - importc: "godot_transform_orthonormalized".} proc rotated*(self: Transform; axis: Vector3; - phi: float32): Transform {. - importc: "godot_transform_rotated".} -proc scaled*(self: Transform; scale: Vector3): Transform {. - importc: "godot_transform_scaled".} -proc translated*(self: Transform; offset: Vector3): Transform {. - importc: "godot_transform_translated".} -proc lookingAt*(self: Transform; - target, up: Vector3): Transform {. - importc: "godot_transform_looking_at".} + phi: float32): Transform {.inline.} = + getGDNativeAPI().transformRotated(self, axis, phi) -proc xformPlane*(self: Transform; v: Plane): Plane {. - importc: "godot_transform_xform_plane".} -proc xformInvPlane*(self: Transform; v: Plane): Plane {. - importc: "godot_transform_xform_inv_plane".} -proc xformVector3*(self: Transform; v: Vector3): Vector3 {. - importc: "godot_transform_xform_vector3".} -proc xformInvVector3*(self: Transform; v: Vector3): Vector3 {. - importc: "godot_transform_xform_inv_vector3".} -proc xformRect3*(self: Transform; v: Rect3): Rect3 {. - importc: "godot_transform_xform_rect3".} -proc xformInvRect3*(self: Transform; v: Rect3): Rect3 {. - importc: "godot_transform_xform_inv_rect3".} +proc scaled*(self: Transform; scale: Vector3): Transform {.inline.} = + getGDNativeAPI().transformScaled(self, scale) -proc `==`*(self: Transform; b: Transform): bool {. - importc: "godot_transform_operator_equal".} -proc `*`*(a, b: Transform): Transform {. - importc: "godot_transform_operator_multiply".} -proc `*=`*(a: var Transform, b: Transform) {.inline.} = - a = a * b +proc translated*(self: Transform; offset: Vector3): Transform {.inline.} = + getGDNativeAPI().transformTranslated(self, offset) + +proc lookingAt*(self: Transform; target, up: Vector3): Transform {.inline.} = + getGDNativeAPI().transformLookingAt(self, target, up) + +proc xformPlane*(self: Transform; plane: Plane): Plane {.inline.} = + getGDNativeAPI().transformXformPlane(self, plane) + +proc xformInvPlane*(self: Transform; plane: Plane): Plane {.inline.} = + getGDNativeAPI().transformXformInvPlane(self, plane) + +proc xformVector3*(self: Transform; v: Vector3): Vector3 {.inline.} = + getGDNativeAPI().transformXformVector3(self, v) + +proc xformInvVector3*(self: Transform; v: Vector3): Vector3 {.inline.} = + getGDNativeAPI().transformXformInvVector3(self, v) + +proc xformRect3*(self: Transform; rect: Rect3): Rect3 {.inline.} = + getGDNativeAPI().transformXformRect3(self, rect) + +proc xformInvRect3*(self: Transform; rect: Rect3): Rect3 {.inline.} = + getGDNativeAPI().transformXformInvRect3(self, rect) + +proc `==`*(self: Transform; b: Transform): bool {.inline.} = + getGDNativeAPI().transformOperatorEqual(self, b) + +proc `*`*(self, other: Transform): Transform {.inline.} = + getGDNativeAPI().transformOperatorMultiply(self, other) + +proc `*=`*(self: var Transform, other: Transform) {.inline.} = + self = self * other diff --git a/godot/core/variants.nim b/godot/core/variants.nim index c5e2359..2dcc8d8 100644 --- a/godot/core/variants.nim +++ b/godot/core/variants.nim @@ -1,7 +1,8 @@ import tables -import internal.godotobjects, internal.godotvariants, internal.godotpoolarrays, - internal.godotstrings, internal.godotnodepaths +import godotcoretypes +import internal.godotinternaltypes, internal.godotvariants, + internal.godotstrings type Variant* = ref object @@ -267,5 +268,5 @@ proc `<`*(self, other: Variant): bool = proc hashCompare*(self, other: Variant): bool = self.godotVariant.hashCompare(other.godotVariant) -proc booleanize*(self: Variant; isValid: var bool): bool = - self.godotVariant.booleanize(isValid) +proc booleanize*(self: Variant): bool = + self.godotVariant.booleanize() diff --git a/godot/core/vector2.nim b/godot/core/vector2.nim index 8b9f6da..94b5b40 100644 --- a/godot/core/vector2.nim +++ b/godot/core/vector2.nim @@ -1,109 +1,121 @@ # Copyright (c) 2017 Xored Software, Inc. -import internal.godotstrings - -type - Vector2* {.byref.} = object - x*: float32 - y*: float32 +import internal.godotinternaltypes, godotcoretypes, gdnativeapi proc vec2*(x, y: float32): Vector2 {.inline.} = Vector2(x: x, y: y) -proc toGodotString(self: Vector2): GodotString {. - importc: "godot_vector2_as_string".} - proc `$`*(self: Vector2): string {.inline.} = - $self.toGodotString() + $getGDNativeAPI().vector2AsString(self) -proc normalized*(self: Vector2): Vector2 {. - importc: "godot_vector2_normalized".} -proc length*(self: Vector2): float32 {. - importc: "godot_vector2_length".} -proc angle*(self: Vector2): float32 {. - importc: "godot_vector2_angle".} -proc lengthSquared*(self: Vector2): float32 {. - importc: "godot_vector2_length_squared".} -proc isNormalized*(self: Vector2): bool {. - importc: "godot_vector2_is_normalized".} -proc distanceTo*(self, to: Vector2): float32 {. - importc: "godot_vector2_distance_to".} -proc distanceSquaredTo*(self, to: Vector2): float32 {. - importc: "godot_vector2_distance_squared_to".} -proc angleTo*(self, to: Vector2): float32 {. - importc: "godot_vector2_angle_to".} -proc angleToPoint*(self, to: Vector2): float32 {. - importc: "godot_vector2_angle_to_point".} -proc lerp*(self, b: Vector2; t: float32): Vector2 {. - importc: "godot_vector2_linear_interpolate".} -proc cubicInterpolate*(self, b, pre_a, post_b: Vector2; t: float32): Vector2 {. - importc: "godot_vector2_cubic_interpolate".} -proc rotated*(self: Vector2; phi: float32): Vector2 {. - importc: "godot_vector2_rotated".} -proc tangent*(self: Vector2): Vector2 {. - importc: "godot_vector2_tangent".} -proc floor*(self: Vector2): Vector2 {. - importc: "godot_vector2_floor".} -proc snapped*(self: Vector2; by: Vector2): Vector2 {. - importc: "godot_vector2_snapped".} -proc aspect*(self: Vector2): float32 {. - importc: "godot_vector2_aspect".} -proc dot*(a, b: Vector2): float32 {. - importc: "godot_vector2_dot".} -proc slide*(self, n: Vector2): Vector2 {. - importc: "godot_vector2_slide".} -proc bounce*(self, n: Vector2): Vector2 {. - importc: "godot_vector2_bounce".} -proc reflect*(self, n: Vector2): Vector2 {. - importc: "godot_vector2_reflect".} -proc abs*(self: Vector2): Vector2 {. - importc: "godot_vector2_abs".} -proc clamped*(self: Vector2; length: float32): Vector2 {. - importc: "godot_vector2_clamped".} +proc normalized*(self: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Normalized(self) -proc `+`*(a, b: Vector2): Vector2 {. - importc: "godot_vector2_operator_add".} -proc `+=`*(a: var Vector2, b: Vector2) {.inline.} = - a += b +proc length*(self: Vector2): float32 {.inline.} = + getGDNativeAPI().vector2Length(self) -proc `-`*(a, b: Vector2): Vector2 {. - importc: "godot_vector2_operator_substract".} -proc `-=`*(a: var Vector2, b: Vector2) {.inline.} = - a = a - b +proc angle*(self: Vector2): float32 {.inline.} = + getGDNativeAPI().vector2Angle(self) -proc `*`*(a, b: Vector2): Vector2 {. - importc: "godot_vector2_operator_multiply_vector".} +proc lengthSquared*(self: Vector2): float32 {.inline.} = + getGDNativeAPI().vector2LengthSquared(self) -proc `*=`*(a: var Vector2, b: Vector2) {.inline.} = - a = a * b +proc isNormalized*(self: Vector2): bool {.inline.} = + getGDNativeAPI().vector2IsNormalized(self) + +proc distanceTo*(self, to: Vector2): float32 {.inline.} = + getGDNativeAPI().vector2DistanceTo(self, to) + +proc distanceSquaredTo*(self, to: Vector2): float32 {.inline.} = + getGDNativeAPI().vector2DistanceSquaredTo(self, to) + +proc angleTo*(self, to: Vector2): float32 {.inline.} = + getGDNativeAPI().vector2AngleTo(self, to) + +proc angleToPoint*(self, to: Vector2): float32 {.inline.} = + getGDNativeAPI().vector2AngleToPoint(self, to) + +proc lerp*(self, b: Vector2; t: float32): Vector2 {.inline.} = + getGDNativeAPI().vector2LinearInterpolate(self, b, t) + +proc cubicInterpolate*(self, b, preA, postB: Vector2; + t: float32): Vector2 {.inline.} = + getGDNativeAPI().vector2CubicInterpolate(self, b, preA, postB, t) + +proc rotated*(self: Vector2; phi: float32): Vector2 {.inline.} = + getGDNativeAPI().vector2Rotated(self, phi) + +proc tangent*(self: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Tangent(self) + +proc floor*(self: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Floor(self) + +proc snapped*(self: Vector2; by: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Snapped(self, by) + +proc aspect*(self: Vector2): float32 {.inline.} = + getGDNativeAPI().vector2Aspect(self) + +proc dot*(a, b: Vector2): float32 {.inline.} = + getGDNativeAPI().vector2Dot(a, b) + +proc slide*(self, n: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Slide(self, n) + +proc bounce*(self, n: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Bounce(self, n) + +proc reflect*(self, n: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Reflect(self, n) + +proc abs*(self: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Abs(self) + +proc clamped*(self: Vector2; length: float32): Vector2 {.inline.} = + getGDNativeAPI().vector2Clamped(self, length) + +proc `+`*(self, other: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2OperatorAdd(self, other) + +proc `+=`*(self: var Vector2, other: Vector2) {.inline.} = + self += other + +proc `-`*(self, other: Vector2): Vector2 = + getGDNativeAPI().vector2OperatorSubtract(self, other) + +proc `-=`*(self: var Vector2, other: Vector2) {.inline.} = + self = self - other + +proc `*`*(self, other: Vector2): Vector2 = + getGDNativeAPI().vector2OperatorMultiplyVector(self, other) + +proc `*=`*(self: var Vector2, other: Vector2) {.inline.} = + self = self * other + +proc `*`*(self: Vector2, scalar: float32): Vector2 = + getGDNativeAPI().vector2OperatorMultiplyScalar(self, scalar) -proc `*`*(self: Vector2, scalar: float32): Vector2 {. - importc: "godot_vector2_operator_multiply_scalar".} proc `*=`*(self: var Vector2, scalar: float32) {.inline.} = self = self * scalar -proc `/`*(a, b: Vector2): Vector2 {. - importc: "godot_vector2_operator_divide_vector".} -proc `/=`*(a: var Vector2, b: Vector2) {.inline.} = - a = a / b +proc `/`*(self, other: Vector2): Vector2 = + getGDNativeAPI().vector2OperatorDivideVector(self, other) + +proc `/=`*(self: var Vector2, other: Vector2) {.inline.} = + self = self / other + +proc `/`*(self: Vector2; scalar: float32): Vector2 = + getGDNativeAPI().vector2OperatorDivideScalar(self, scalar) -proc `/`*(self: Vector2; scalar: float32): Vector2 {. - importc: "godot_vector2_operator_divide_scalar".} proc `/=`*(self: var Vector2; scalar: float32) {.inline.} = self = self / scalar -proc `==`*(a, b: Vector2): bool {. - importc: "godot_vector2_operator_equal".} -proc `<`*(a, b: Vector2): bool {. - importc: "godot_vector2_operator_less".} -proc `-`*(self: Vector2): Vector2 {. - importc: "godot_vector2_operator_neg".} +proc `==`*(self, other: Vector2): bool {.inline.} = + getGDNativeAPI().vector2OperatorEqual(self, other) -proc `x=`*(self: var Vector2; x: float32) {. - importc: "godot_vector2_set_x".} -proc `y=`*(self: var Vector2; y: float32) {. - importc: "godot_vector2_set_y".} -proc x*(self: Vector2): float32 {. - importc: "godot_vector2_get_x".} -proc y*(self: Vector2): float32 {. - importc: "godot_vector2_get_y".} +proc `<`*(self, other: Vector2): bool {.inline.} = + getGDNativeAPI().vector2OperatorLess(self, other) + +proc `-`*(self: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2OperatorNeg(self) diff --git a/godot/core/vector3.nim b/godot/core/vector3.nim index c4c614b..ded30ce 100644 --- a/godot/core/vector3.nim +++ b/godot/core/vector3.nim @@ -1,13 +1,7 @@ # Copyright (c) 2017 Xored Software, Inc. import math -import godotbase - -type - Vector3* {.byref.} = object - x*: float32 - y*: float32 - z*: float32 +import godotbase, godotcoretypes proc vec3*(): Vector3 {.inline.} = Vector3() diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim new file mode 100644 index 0000000..c93e5fa --- /dev/null +++ b/godot/gdnativeapi.nim @@ -0,0 +1,1378 @@ +# Copyright 2017 Xored Software, Inc. + +import internal.godotinternaltypes, core.godotcoretypes + +type GDNativeAPI* = object + next: pointer + version: cstring + + # Color API + colorNewRGBA*: proc (dest: var Color, r, g, b, a: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorNewRGB*: proc (dest: var Color, r, g, b: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetR*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorSetR*: proc (self: var Color, r: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetG*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorSetG*: proc (self: var Color, g: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetB*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorSetB*: proc (self: var Color, b: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetA*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorSetA*: proc (self: var Color, a: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetH*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetS*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetV*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorAsString*: proc (self: Color): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorToRGBA32*: proc (self: Color): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorAsARGB32*: proc (self: Color): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGray*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorInverted*: proc (self: Color): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorContrasted*: proc (self: Color): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorLinearInterpolate*: proc (self, other: Color, t: float32): Color + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + colorBlend*: proc (self, other: Color): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorToHtml*: proc (self: Color, withAlpha: bool): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorOperatorEqual*: proc (self, other: Color): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorOperatorLess*: proc (self, other: Color): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Vector2 API + vector2New*: proc (dest: var Vector2, x, y: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2AsString*: proc (self: Vector2): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Normalized*: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Length*: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Angle*: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2LengthSquared*: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2IsNormalized*: proc (self: Vector2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2DistanceTo*: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2DistanceSquaredTo*: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2AngleTo*: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2AngleToPoint*: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2LinearInterpolate*: proc (self, b: Vector2, t: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2CubicInterpolate*: proc (self, b, preA, postB: Vector2, + t: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2Rotated*: proc (self: Vector2, phi: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Tangent*: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Floor*: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Snapped*: proc (self, by: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Aspect*: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Dot*: proc (self, other: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Slide*: proc (self, n: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Bounce*: proc (self, n: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Reflect*: proc (self, n: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Abs*: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Clamped*: proc (self: Vector2, length: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2OperatorAdd*: proc (self, other: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2OperatorSubtract*: proc (self, other: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorMultiplyVector*: proc (self, other: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorMultiplyScalar*: proc (self: Vector2, scalar: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorDivideVector*: proc (self, other: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorDivideScalar*: proc (self: Vector2, scalar: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorEqual*: proc (self, other: Vector2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2OperatorLess*: proc (self, other: Vector2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2OperatorNeg*: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2SetX: pointer + vector2SetY: pointer + vector2GetX: pointer + vector2GetY: pointer + + # Quat API + quatNew*: proc (dest: var Quat, x, y, z, w: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatNewWithAxisAngle*: proc (dest: Quat, axis: Vector3, + angle: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetX*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetX*: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetY*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetY*: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetZ*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetZ*: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetW*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetW*: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatAsString*: proc (self: Quat): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatLength*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatLengthSquared*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatNormalized*: proc (self: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatIsNormalized*: proc (self: Quat): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatInverse*: proc (self: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatDot*: proc (self, other: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatXform*: proc (self: Quat, v: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSlerp*: proc (self, other: Quat, t: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSlerpni*: proc (self, other: Quat, t: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatCubicSlerp*: proc (self, other, preA, postB: Quat, t: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorMultiply*: proc (self: Quat, b: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorAdd*: proc (self, other: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorSubtract*: proc (self, other: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorDivide*: proc (self: Quat, divider: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorEqual*: proc (self, other: Quat): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorNeg*: proc (self: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Basis API + basisNewWithRows: pointer + basisNewWithAxisAndAngle: pointer + basisNewWithEuler: pointer + basisAsString: pointer + basisInverse: pointer + basisTransposed: pointer + basisOrthonormalized: pointer + basisDeterminant: pointer + basisRotated: pointer + basisScaled: pointer + basisGetScale: pointer + basisGetEuler: pointer + basisTdotx: pointer + basisTdoty: pointer + basisTdotz: pointer + basisXform: pointer + basisXformInv: pointer + basisGetOrthogonalIndex: pointer + basisNew: pointer + basisNewWithEulerQuat: pointer + basisGetElements: pointer + basisGetAxis: pointer + basisSetAxis: pointer + basisGetRow: pointer + basisSetRow: pointer + basisOperatorEqual: pointer + basisOperatorAdd: pointer + basisOperatorSubstract: pointer + basisOperatorMultiplyVector: pointer + basisOperatorMultiplyScalar: pointer + + # Vector3 API + vector3New: pointer + vector3AsString: pointer + vector3MinAxis: pointer + vector3MaxAxis: pointer + vector3Length: pointer + vector3Length_squared: pointer + vector3IsNormalized: pointer + vector3Normalized: pointer + vector3Inverse: pointer + vector3Snapped: pointer + vector3Rotated: pointer + vector3LinearInterpolate: pointer + vector3CubicInterpolate: pointer + vector3Dot: pointer + vector3Cross: pointer + vector3Outer: pointer + vector3ToDiagonalMatrix: pointer + vector3Abs: pointer + vector3Floor: pointer + vector3Ceil: pointer + vector3DistanceTo: pointer + vector3DistanceSquaredTo: pointer + vector3AngleTo: pointer + vector3Slide: pointer + vector3Bounce: pointer + vector3Reflect: pointer + vector3OperatorAdd: pointer + vector3OperatorSubstract: pointer + vector3OperatorMultiplyVector: pointer + vector3OperatorMultiplyScalar: pointer + vector3OperatorDivideVector: pointer + vector3OperatorDivideScalar: pointer + vector3OperatorEqual: pointer + vector3OperatorLess: pointer + vector3OperatorNeg: pointer + vector3SetAxis: pointer + vector3GetAxis: pointer + + # PoolByteArray API + poolByteArrayNew*: proc (dest: var GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayNewCopy*: proc (dest: var GodotPoolByteArray, + src: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayNewWithArray*: proc (dest: var GodotPoolByteArray, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolByteArrayAppend*: proc (self: var GodotPoolByteArray, + val: byte) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayAppendArray*: proc (self: var GodotPoolByteArray, + arr: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolByteArrayInsert*: proc (self: var GodotPoolByteArray, + idx: cint, val: byte): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayInvert*: proc (self: var GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayPushBack*: proc (self: var GodotPoolByteArray, val: byte) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolByteArrayRemove*: proc (self: var GodotPoolByteArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayResize*: proc (self: var GodotPoolByteArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArraySet*: proc (self: var GodotPoolByteArray, idx: cint, data: byte) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayGet*: proc (self: GodotPoolByteArray, idx: cint): byte + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArraySize*: proc (self: GodotPoolByteArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayDestroy*: proc (self: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # PoolIntArray API + poolIntArrayNew*: proc (dest: var GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayNewCopy*: proc (dest: var GodotPoolIntArray, + src: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayNewWithArray*: proc (dest: var GodotPoolIntArray, src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolIntArrayAppend*: proc (self: var GodotPoolIntArray, val: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayAppendArray*: proc (self: var GodotPoolIntArray, + arr: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolIntArrayInsert*: proc (self: var GodotPoolIntArray, idx: cint, + val: cint): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayInvert*: proc (self: var GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayPushBack*: proc (self: var GodotPoolIntArray, val: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayRemove*: proc (self: var GodotPoolIntArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayResize*: proc (self: var GodotPoolIntArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArraySet*: proc (self: var GodotPoolIntArray, idx: cint, data: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayGet*: proc (self: GodotPoolIntArray, idx: cint): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArraySize*: proc (self: GodotPoolIntArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayDestroy*: proc (self: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # PoolRealArray API + poolRealArrayNew*: proc (dest: var GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayNewCopy*: proc (dest: var GodotPoolRealArray, + src: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayNewWithArray*: proc (dest: var GodotPoolRealArray, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolRealArrayAppend*: proc (self: var GodotPoolRealArray, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayAppendArray*: proc (self: var GodotPoolRealArray, + arr: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolRealArrayInsert*: proc (self: var GodotPoolRealArray, + idx: cint, val: float32): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayInvert*: proc (self: var GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayPushBack*: proc (self: var GodotPoolRealArray, val: float32) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolRealArrayRemove*: proc (self: var GodotPoolRealArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayResize*: proc (self: var GodotPoolRealArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArraySet*: proc (self: var GodotPoolRealArray, idx: cint, + data: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayGet*: proc (self: GodotPoolRealArray, idx: cint): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArraySize*: proc (self: GodotPoolRealArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayDestroy*: proc (self: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # PoolStringArray API + poolStringArrayNew*: proc (dest: var GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolStringArrayNewCopy*: proc (dest: var GodotPoolStringArray, + src: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayNewWithArray*: proc (dest: var GodotPoolStringArray, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayAppend*: proc (self: var GodotPoolStringArray, + val: GodotString) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayAppendArray*: proc (self: var GodotPoolStringArray, + arr: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayInsert*: proc (self: var GodotPoolStringArray, + idx: cint, val: GodotString): Error + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayInvert*: proc (self: var GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayPushBack*: proc (self: var GodotPoolStringArray, + val: GodotString) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayRemove*: proc (self: var GodotPoolStringArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayResize*: proc (self: var GodotPoolStringArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArraySet*: proc (self: var GodotPoolStringArray, idx: cint, + data: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolStringArrayGet*: proc (self: GodotPoolStringArray, idx: cint): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolStringArraySize*: proc (self: GodotPoolStringArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolStringArrayDestroy*: proc (self: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # PoolVector2 API + poolVector2ArrayNew*: proc (dest: var GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArrayNewCopy*: proc (dest: var GodotPoolVector2Array, + src: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayNewWithArray*: proc (dest: var GodotPoolVector2Array, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayAppend*: proc (self: var GodotPoolVector2Array, val: Vector2) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayAppendArray*: proc (self: var GodotPoolVector2Array, + arr: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayInsert*: proc (self: var GodotPoolVector2Array, idx: cint, + val: Vector2): Error + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayInvert*: proc (self: var GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayPushBack*: proc (self: var GodotPoolVector2Array, + val: Vector2) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayRemove*: proc (self: var GodotPoolVector2Array, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayResize*: proc (self: var GodotPoolVector2Array, size: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArraySet*: proc (self: var GodotPoolVector2Array, idx: cint, + data: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArrayGet*: proc (self: GodotPoolVector2Array, idx: cint): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArraySize*: proc (self: GodotPoolVector2Array): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArrayDestroy*: proc (self: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # PoolVector3 API + poolVector3ArrayNew*: proc (dest: var GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector3ArrayNewCopy*: proc (dest: var GodotPoolVector3Array, + src: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayNewWithArray*: proc (dest: var GodotPoolVector3Array, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayAppend*: proc (self: var GodotPoolVector3Array, val: Vector3) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayAppendArray*: proc (self: var GodotPoolVector3Array, + arr: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayInsert*: proc (self: var GodotPoolVector3Array, idx: cint, + val: Vector3): Error + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayInvert*: proc (self: var GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayPushBack*: proc (self: var GodotPoolVector3Array, + val: Vector3) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArrayRemove*: proc (self: var GodotPoolVector3Array, + idx: cint) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArrayResize*: proc (self: var GodotPoolVector3Array, + size: cint) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArraySet*: proc (self: var GodotPoolVector3Array, idx: cint, + data: Vector3) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArrayGet*: proc (self: GodotPoolVector3Array, idx: cint): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector3ArraySize*: proc (self: GodotPoolVector3Array): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector3ArrayDestroy*: proc (self: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # PoolColorArray API + poolColorArrayNew*: proc (dest: var GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayNewCopy*: proc (dest: var GodotPoolColorArray, + src: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolColorArrayNewWithArray*: proc (dest: var GodotPoolColorArray, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolColorArrayAppend*: proc (self: var GodotPoolColorArray, + val: Color) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayAppendArray*: proc (self: var GodotPoolColorArray, + arr: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolColorArrayInsert*: proc (self: var GodotPoolColorArray, + idx: cint, val: Color): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayInvert*: proc (self: var GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayPushBack*: proc (self: var GodotPoolColorArray, val: Color) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolColorArrayRemove*: proc (self: var GodotPoolColorArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayResize*: proc (self: var GodotPoolColorArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArraySet*: proc (self: var GodotPoolColorArray, idx: cint, + data: Color) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayGet*: proc (self: GodotPoolColorArray, idx: cint): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArraySize*: proc (self: GodotPoolColorArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayDestroy*: proc (self: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # Array API + arrayNew*: proc (dest: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayNewCopy*: proc (dest: var GodotArray, src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayNewPoolColorArray*: proc (dest: var GodotArray, src: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolVector3Array*: proc (dest: var GodotArray, + src: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolVector2Array*: proc (dest: var GodotArray, + src: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolStringArray*: proc (dest: var GodotArray, + src: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolRealArray*: proc (dest: var GodotArray, src: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolIntArray*: proc (dest: var GodotArray, src: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayNewPoolByteArray*: proc (dest: var GodotArray, src: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arraySet*: proc (self: var GodotArray, idx: cint, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayGet*: proc (self: GodotArray, idx: cint): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayOperatorIndex*: proc (self: var GodotArray, idx: cint): ptr GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayAppend*: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayClear*: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayCount*: proc (self: GodotArray, val: GodotVariant): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayEmpty*: proc (self: GodotArray): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayErase*: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayFront*: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayBack*: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayFind*: proc (self: GodotArray, what: GodotVariant, fromIdx: cint): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayFindLast*: proc (self: GodotArray, what: GodotVariant): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayHas*: proc (self: GodotArray, val: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayHash*: proc (self: GodotArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayInsert*: proc (self: var GodotArray, pos: cint, val: GodotVariant): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayInvert*: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPopFront*: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPopBack*: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPushBack*: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPushFront*: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayRemove*: proc (self: var GodotArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayResize*: proc (self: var GodotArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayRFind*: proc (self: GodotArray, what: GodotVariant, fromIdx: cint): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arraySize*: proc (self: GodotArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arraySort*: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arraySortCustom*: proc (self: var GodotArray, obj: ptr GodotObject, + f: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayDestroy*: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Dictionary API + dictionaryNew*: proc (dest: var GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryNewCopy*: proc (dest: var GodotDictionary, src: GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryDestroy*: proc (self: var GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionarySize*: proc (self: GodotDictionary): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryEmpty*: proc (self: GodotDictionary): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryClear*: proc (self: var GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryHas*: proc (self: GodotDictionary, key: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryHasAll*: proc (self: GodotDictionary, keys: GodotArray): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryErase*: proc (self: var GodotDictionary, key: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryHash*: proc (self: GodotDictionary): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryKeys*: proc (self: GodotDictionary): GodotArray + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryValues*: proc (self: GodotDictionary): GodotArray + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryGet*: proc (self: GodotDictionary, key: GodotVariant): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionarySet*: proc (self: var GodotDictionary, key, value: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryOperatorIndex*: proc (self: var GodotDictionary, + key: GodotVariant): ptr GodotVariant + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + dictionaryNext*: proc (self: GodotDictionary, + key: GodotVariant): ptr GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryOperatorEqual*: proc (self, other: GodotDictionary): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + dictionaryToJson*: proc (self: GodotDictionary): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # NodePath API + nodePathNew*: proc (dest: var GodotNodePath, src: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathNewCopy*: proc (dest: var GodotNodePath, src: GodotNodePath) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathDestroy*: proc (self: var GodotNodePath) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathAsString*: proc (self: GodotNodePath): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathIsAbsolute*: proc (self: GodotNodePath): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetNameCount*: proc (self: GodotNodePath): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetName*: proc (self: GodotNodePath, idx: cint): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetSubnameCount*: proc (self: GodotNodePath): cint + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nodePathGetSubname*: proc (self: GodotNodePath, idx: cint): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetProperty*: proc (self: GodotNodePath): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathIsEmpty*: proc (self: GodotNodePath): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathOperatorEqual*: proc (self, other: GodotNodePath): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # Plane API + planeNewWithReals*: proc (dest: var Plane, a, b, c, d: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeNewWithVectors*: proc (dest: var Plane, v1, v2, v3: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeNewWithNormal*: proc (dest: var Plane, normal: Vector3, d: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeAsString*: proc (self: Plane): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeNormalized*: proc (self: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeCenter*: proc (self: Plane): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeGetAnyPoint*: proc (self: Plane): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIsPointOver*: proc (self: Plane, point: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeDistanceTo*: proc (self: Plane, point: Vector3): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeHasPoint*: proc (self: Plane, point: Vector3, epsilon: float32): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeProject*: proc (self: Plane, point: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIntersect3*: proc (self: Plane, dest: var Vector3, b, c: Plane): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIntersectsRay*: proc (self: Plane, dest: var Vector3, + point, dir: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIntersectsSegment*: proc (self: Plane, dest: var Vector3, + segmentBegin, segmentEnd: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + planeOperatorNeg*: proc (self: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeOperatorEqual*: proc (self, other: Plane): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeSetNormal*: proc (self: var Plane, normal: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeGetNormal*: proc (self: Plane): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeGetD*: proc (self: Plane): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeSetD*: proc (self: var Plane, d: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Rect2 API + rect2NewWithPositionAndSize*: proc (dest: var Rect2, pos, size: Vector2) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect2New*: proc (dest: var Rect2, x, y, width, height: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2AsString*: proc (self: Rect2): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2GetArea*: proc (self: Rect2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Intersects*: proc (self, other: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Encloses*: proc (self, other: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2HasNoArea*: proc (self: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Clip*: proc (self, other: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Merge*: proc (self, other: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2HasPoint*: proc (self: Rect2, point: Vector2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Grow*: proc (self: Rect2, by: float32): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Expand*: proc (self: Rect2, to: Vector2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2OperatorEqual*: proc (self, other: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2GetPosition*: proc (self: Rect2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2GetSize*: proc (self: Rect2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2SetPosition*: proc (self: var Rect2, pos: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2SetSize*: proc (self: var Rect2, size: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Rect3 API + rect3New*: proc (dest: var Rect3, pos, size: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetPosition*: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3SetPosition*: proc (self: var Rect3, pos: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetSize*: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3SetSize*: proc (self: var Rect3, pos: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3AsString*: proc (self: Rect3): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetArea*: proc (self: Rect3): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3HasNoArea*: proc (self: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3HasNoSurface*: proc (self: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Intersects*: proc (self, other: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Encloses*: proc (self, other: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Merge*: proc (self, other: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Intersection*: proc (self, other: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3IntersectsPlane*: proc (self: Rect3, plane: Plane): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3IntersectsSegment*: proc (self: Rect3, vFrom, vTo: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3HasPoint*: proc (self: Rect3, point: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetSupport*: proc (self: Rect3, dir: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetLongestAxis*: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetLongestAxisIndex*: proc (self: Rect3): cint + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3GetLongestAxisSize*: proc (self: Rect3): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3GetShortestAxis*: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetShortestAxisIndex*: proc (self: Rect3): cint + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3GetShortestAxisSize*: proc (self: Rect3): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3Expand*: proc (self: Rect3, toPoint: Vector3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Grow*: proc (self: Rect3, by: float32): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetEndpoint*: proc (self: Rect3, idx: cint): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3OperatorEqual*: proc (self, other: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # RID API + ridNew*: proc (dest: var RID) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridGetID*: proc (self: RID): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridNewWithResource*: proc (dest: var RID, obj: ptr GodotObject) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridOperatorEqual*: proc (self, other: RID): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridOperatorLess*: proc (self, other: RID): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Transform API + transformNewWithAxisOrigin*: proc (dest: var Transform, + xAxis, yAxis, zAxis, origin: Vector3) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformNew*: proc (dest: var Transform, basis: Basis, origin: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformGetBasis*: proc (self: Transform): Basis + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformSetBasis*: proc (self: var Transform, basis: Basis) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformGetOrigin*: proc (self: Transform): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformSetOrigin*: proc (self: var Transform, v: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformAsString*: proc (self: Transform): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformInverse*: proc (self: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformAffineInverse*: proc (self: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformOrthonormalized*: proc (self: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformRotated*: proc (self: Transform, axis: Vector3, + phi: float32): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformScaled*: proc (self: Transform, scale: Vector3): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformTranslated*: proc (self: Transform, offset: Vector3): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformLookingAt*: proc (self: Transform, target, up: Vector3): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformXformPlane*: proc (self: Transform, plane: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformXformInvPlane*: proc (self: Transform, plane: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformNewIdentity*: proc (dest: var Transform) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformOperatorEqual*: proc (self, other: Transform): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformOperatorMultiply*: proc (self, other: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformXformVector3*: proc (self: Transform, v: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformXformInvVector3*: proc (self: Transform, v: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformXformRect3*: proc (self: Transform, v: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformXformInvRect3*: proc (self: Transform, v: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # Transform2D API + transform2DNew*: proc (dest: var Transform2D, rot: float32, pos: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DNewAxisOrigin*: proc (dest: var Transform2D, + xAxis, yAxis, origin: Vector2) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DAsString*: proc (self: Transform2D): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DInverse*: proc (self: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DAffineInverse*: proc (self: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DGetRotation*: proc (self: Transform2D): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DGetOrigin*: proc (self: Transform2D): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DGetScale*: proc (self: Transform2D): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DOrthonormalized*: proc (self: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DRotated*: proc (self: Transform2D, phi: float32): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DScaled*: proc (self: Transform2D, scale: Vector2): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DTranslated*: proc (self: Transform2D, offset: Vector2): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformVector2*: proc (self: Transform2D, v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformInvVector2*: proc (self: Transform2D, v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DBasisXformVector2*: proc (self: Transform2D, v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DBasisXformInvVector2*: proc (self: Transform2D, + v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DInterpolateWith*: proc (self, other: Transform2D, + t: float32): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DOperatorEqual*: proc (self, other: Transform2D): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DOperatorMultiply*: proc (self, other: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DNewIdentity*: proc (dest: var Transform2D) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformRect2*: proc (self: Transform2D, v: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformInvRect2*: proc (self: Transform2D, v: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # Variant API + variantGetType*: proc (v: GodotVariant): VariantType + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewCopy*: proc (dest: var GodotVariant, src: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewNil*: proc (dest: var GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewBool*: proc (dest: var GodotVariant, val: bool) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewUInt*: proc (dest: var GodotVariant, val: uint64) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewInt*: proc (dest: var GodotVariant, val: int64) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewReal*: proc (dest: var GodotVariant, val: float64) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewString*: proc (dest: var GodotVariant, val: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewVector2*: proc (dest: var GodotVariant, val: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewRect2*: proc (dest: var GodotVariant, val: Rect2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewVector3*: proc (dest: var GodotVariant, val: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewTransform2D*: proc (dest: var GodotVariant, val: Transform2D) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPlane*: proc (dest: var GodotVariant, val: Plane) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewQuat*: proc (dest: var GodotVariant, val: Quat) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewRect3*: proc (dest: var GodotVariant, val: Rect3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewBasis*: proc (dest: var GodotVariant, val: Basis) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewTransform*: proc (dest: var GodotVariant, val: Transform) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewColor*: proc (dest: var GodotVariant, val: Color) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewNodePath*: proc (dest: var GodotVariant, val: GodotNodePath) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewRID*: proc (dest: var GodotVariant, val: RID) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewObject*: proc (dest: var GodotVariant, val: ptr GodotObject) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewDictionary*: proc (dest: var GodotVariant, val: GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewArray*: proc (dest: var GodotVariant, val: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewPoolByteArray*: proc (dest: var GodotVariant, + val: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolIntArray*: proc (dest: var GodotVariant, val: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolRealArray*: proc (dest: var GodotVariant, + val: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolStringArray*: proc (dest: var GodotVariant, + val: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolVector2Array*: proc (dest: var GodotVariant, + val: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolVector3Array*: proc (dest: var GodotVariant, + val: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolColorArray*: proc (dest: var GodotVariant, + val: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsBool*: proc (self: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsUInt*: proc (self: GodotVariant): uint64 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsInt*: proc (self: GodotVariant): int64 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsReal*: proc (self: GodotVariant): float64 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsString*: proc (self: GodotVariant): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsVector2*: proc (self: GodotVariant): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsRect2*: proc (self: GodotVariant): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsVector3*: proc (self: GodotVariant): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsTransform2D*: proc (self: GodotVariant): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsPlane*: proc (self: GodotVariant): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsQuat*: proc (self: GodotVariant): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsRect3*: proc (self: GodotVariant): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsBasis*: proc (self: GodotVariant): Basis + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsTransform*: proc (self: GodotVariant): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsColor*: proc (self: GodotVariant): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsNodePath*: proc (self: GodotVariant): GodotNodePath + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsRID*: proc (self: GodotVariant): RID + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsObject*: proc (self: GodotVariant): ptr GodotObject + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsDictionary*: proc (self: GodotVariant): GodotDictionary + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsArray*: proc (self: GodotVariant): GodotArray + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsPoolByteArray*: proc (self: GodotVariant): GodotPoolByteArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolIntArray*: proc (self: GodotVariant): GodotPoolIntArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolRealArray*: proc (self: GodotVariant): GodotPoolRealArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolStringArray*: proc (self: GodotVariant): GodotPoolStringArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolVector2Array*: proc (self: GodotVariant): GodotPoolVector2Array + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolVector3Array*: proc (self: GodotVariant): GodotPoolVector3Array + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolColorArray*: proc (self: GodotVariant): GodotPoolColorArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantCall*: proc (self: var GodotVariant, meth: GodotString, + args: ptr array[MAX_ARG_COUNT, ptr GodotVariant], + argcount: cint, + callError: var VariantCallError): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantHasMethod*: proc (self: GodotVariant, meth: GodotString): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantOperatorEqual*: proc (self, other: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantOperatorLess*: proc (self, other: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantHashCompare*: proc (self, other: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantBooleanize*: proc (self: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantDestroy*: proc (self: var GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # String API + stringNew*: proc (dest: var GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringNewCopy*: proc (dest: var GodotString, src: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringNewData*: proc (dest: var GodotString, contents: cstring, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringNewUTF16Data: pointer + stringGetData*: proc (self: GodotString, dest: cstring, size: var cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringOperatorIndex: pointer + stringCStr*: proc (self: GodotString): cstring + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringUTF16Str: pointer + stringOperatorEqual*: proc (self, other: GodotString): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringOperatorLess*: proc (self, other: GodotString): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringOperatorPlus*: proc (self, other: GodotString): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringLength*: proc (self: GodotString): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringBeginsWith: pointer + stringBeginsWithCharArray: pointer + stringBigrams: pointer + stringChr: pointer + stringEndsWith: pointer + stringFind: pointer + stringFindFrom: pointer + stringFindmk: pointer + stringFindmkFrom: pointer + stringFindmkFromInPlace: pointer + stringFindn: pointer + stringFindnFrom: pointer + stringFindLast: pointer + stringFormat: pointer + stringFormatWithCustomPlaceholder: pointer + stringHexEncodeBuffer: pointer + stringHexToInt: pointer + stringHexToIntWithoutPrefix: pointer + stringInsert: pointer + stringIsNumeric: pointer + stringIsSubsequenceOf: pointer + stringIsSubsequenceOfi: pointer + stringLpad: pointer + stringLpadWithCustomCharacter: pointer + stringMatch: pointer + stringMatchn: pointer + stringMd5: pointer + stringNum: pointer + stringNumInt64: pointer + stringNumInt64Capitalized: pointer + stringNumReal: pointer + stringNumScientific: pointer + stringNumWithDecimals: pointer + stringPadDecimals: pointer + stringPadZeros: pointer + stringReplaceFirst: pointer + stringReplace: pointer + stringReplacen: pointer + stringRfind: pointer + stringRfindn: pointer + stringRfindFrom: pointer + stringRfindnFrom: pointer + stringRpad: pointer + stringRpadWithCustomCharacter: pointer + stringSimilarity: pointer + stringSprintf: pointer + stringSubstr: pointer + stringToDouble: pointer + stringToFloat: pointer + stringToInt: pointer + stringCamelcaseToUnderscore: pointer + stringCamelcaseToUnderscoreLowercased: pointer + stringCapitalize: pointer + stringCharToDouble: pointer + stringCharToInt: pointer + stringWcharToInt: pointer + stringCharToIntWithLen: pointer + stringCharToInt64WithLen: pointer + stringHexToInt64: pointer + stringHexToInt64WithPrefix: pointer + stringToInt64: pointer + stringUnicodeCharToDouble: pointer + stringGetSliceCount: pointer + stringGetSlice: pointer + stringGetSlicec: pointer + stringSplit: pointer + stringSplitAllowEmpty: pointer + stringSplitFloats: pointer + stringSplitFloatsAllowsEmpty: pointer + stringSplitFloatsMk: pointer + stringSplitFloatsMkAllowsEmpty: pointer + stringSplitInts: pointer + stringSplitIntsAllowsEmpty: pointer + stringSplitIntsMk: pointer + stringSplitIntsMkAllowsEmpty: pointer + stringSplitSpaces: pointer + stringCharLowercase: pointer + stringCharUppercase: pointer + stringToLower: pointer + stringToUpper: pointer + stringGetBasename: pointer + stringGetExtension: pointer + stringLeft: pointer + stringOrdAt: pointer + stringPlusFile: pointer + stringRight: pointer + stringStripEdges: pointer + stringStripEscapes: pointer + stringErase: pointer + stringAscii: pointer + stringAsciiExtended: pointer + stringUtf8: pointer + stringParseUtf8: pointer + stringParseUtf8WithLen: pointer + stringCharsToUtf8: pointer + stringCharsToUtf8WithLen: pointer + stringHash: pointer + stringHash64: pointer + stringHashChars: pointer + stringHashCharsWithLen: pointer + stringHashUtf8Chars: pointer + stringHashUtf8CharsWithLen: pointer + stringMd5Buffer: pointer + stringMd5Text: pointer + stringSha256Buffer: pointer + stringSha256Text: pointer + stringEmpty: pointer + stringGetBaseDir: pointer + stringGetFile: pointer + stringHumanizeSize: pointer + stringIsAbsPath: pointer + stringIsRelPath: pointer + stringIsResourceFile: pointer + stringPathTo: pointer + stringPathToFile: pointer + stringSimplifyPath: pointer + stringCEscape: pointer + stringCEscapeMultiline: pointer + stringCUnescape: pointer + stringHttpEscape: pointer + stringHttpUnescape: pointer + stringJsonEscape: pointer + stringWordWrap: pointer + stringXmlEscape: pointer + stringXmlEscapeWithQuotes: pointer + stringXmlUnescape: pointer + stringPercentDecode: pointer + stringPercentEncode: pointer + stringIsValidFloat: pointer + stringIsValidHexNumber: pointer + stringIsValidHtmlColor: pointer + stringIsValidIdentifier: pointer + stringIsValidInteger: pointer + stringIsValidIpAddress: pointer + stringDestroy*: proc (self: var GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Misc API + objectDestroy*: proc (self: ptr GodotObject) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + globalGetSingleton*: proc (name: cstring): ptr GodotObject + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + methodBindGetMethod*: proc (className, + methodName: cstring): ptr GodotMethodBind + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + methodBindPtrCall*: proc (methodBind: ptr GodotMethodBind, + obj: ptr GodotObject, + args: ptr array[MAX_ARG_COUNT, pointer], + ret: pointer) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + methodBindCall*: proc (methodBind: ptr GodotMethodBind, obj: ptr GodotObject, + args: ptr array[MAX_ARG_COUNT, ptr GodotVariant], + argCount: cint, + callError: var VariantCallError): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + getClassConstructor*: proc (className: cstring): GodotClassConstructor + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + alloc*: proc (bytes: cint): pointer + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + realloc*: proc (p: pointer, bytes: cint): pointer + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + free*: proc (p: pointer) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + printError*: proc (description, function, file: cstring, line: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + printWarning*: proc (description, function, file: cstring, line: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + print*: proc (message: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # NativeScript API + nativeScriptRegisterClass*: proc (gdnativeHandle: pointer, + name, base: cstring, + createFunc: GodotInstanceCreateFunc, + destroyFunc: GodotInstanceDestroyFunc) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptRegisterToolClass*: proc (gdnativeHandle: pointer, + name, base: cstring, + createFunc: GodotInstanceCreateFunc, + destroyFunc: GodotInstanceDestroyFunc) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptRegisterMethod*: proc (gdnativeHandle: pointer, + name, functionName: cstring, + attr: GodotMethodAttributes, + meth: GodotInstanceMethod) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptRegisterProperty*: proc (gdnativeHandle: pointer, + name, path: cstring, + attr: ptr GodotPropertyAttributes, + setFunc: GodotPropertySetFunc, + getFunc: GodotPropertyGetFunc) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptRegisterSignal*: proc (gdnativeHandle: pointer, name: cstring, + signal: GodotSignal) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptGetUserdata*: proc (obj: ptr GodotObject): pointer + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + +var gdNativeAPI: ptr GDNativeAPI + +proc getGDNativeAPI*(): ptr GDNativeAPI {.inline.} = + gdNativeAPI + +proc setGDNativeAPI*(apiStruct: pointer) {.inline.} = + gdNativeAPI = cast[ptr GDNativeAPI](apiStruct) diff --git a/godot/godot.nim b/godot/godot.nim index eb38a58..bab24f7 100644 --- a/godot/godot.nim +++ b/godot/godot.nim @@ -1,6 +1,7 @@ # Copyright 2017 Xored Software, Inc. import core.godotbase, godotinternal +import core.godotcoretypes import core.vector2, core.rect2, core.vector3, core.transform2d, core.planes, core.quats import core.rect3, core.basis, core.transforms, core.colors, core.nodepaths, @@ -9,9 +10,9 @@ import core.dictionaries, core.arrays, core.poolarrays, core.variants import nim.godotmacros, nim.godotnim -export godotbase, vector2, rect2, vector3, transform2d, planes, quats, - rect3, basis, transforms, colors, nodepaths, rids, dictionaries, arrays, - poolarrays, variants +export godotbase, godotcoretypes, vector2, rect2, vector3, transform2d, planes, + quats, rect3, basis, transforms, colors, nodepaths, rids, dictionaries, + arrays, poolarrays, variants export godotmacros, godotnim export GodotPropertyHint, GodotPropertyUsage \ No newline at end of file diff --git a/godot/godotinternal.nim b/godot/godotinternal.nim index c241d77..c89ea6c 100644 --- a/godot/godotinternal.nim +++ b/godot/godotinternal.nim @@ -1,259 +1,87 @@ # Copyright 2017 Xored Software, Inc. -import internal.godotobjects, internal.godotarrays, internal.godotnodepaths, - internal.godotpoolarrays, internal.godotstrings, internal.godotvariants, - internal.godotdictionaries +import internal.godotinternaltypes, internal.godotarrays, + internal.godotnodepaths, internal.godotpoolarrays, internal.godotstrings, + internal.godotvariants, internal.godotdictionaries -export godotobjects, godotarrays, godotnodepaths, godotpoolarrays, +import gdnativeapi +export godotinternaltypes, godotarrays, godotnodepaths, godotpoolarrays, godotstrings, godotvariants, godotdictionaries -const MAX_ARG_COUNT* = 128 +proc getMethod*(className: cstring; + methodName: cstring): ptr GodotMethodBind {.inline.} = + getGDNativeAPI().methodBindGetMethod(className, methodName) -# MethodBind API - -type GodotMethodBind* = object - -proc getMethod*(className: cstring; methodName: cstring): ptr GodotMethodBind {. - importc: "godot_method_bind_get_method".} proc ptrCall*(methodBind: ptr GodotMethodBind; instance: ptr GodotObject; args: ptr array[MAX_ARG_COUNT, pointer]; - ret: pointer) {. - importc: "godot_method_bind_ptrcall".} + ret: pointer) {.inline.} = + getGDNativeAPI().methodBindPtrCall(methodBind, instance, args, ret) + proc call*(methodBind: ptr GodotMethodBind; instance: ptr GodotObject; args: ptr array[MAX_ARG_COUNT, ptr GodotVariant]; argCount: cint; - callError: var VariantCallError): GodotVariant {. - importc: "godot_method_bind_call".} + callError: var VariantCallError): GodotVariant {.inline.} = + getGDNativeAPI().methodBindCall( + methodBind, instance, args, argCount, callError) -# Script API +proc nativeScriptRegisterClass*(libHandle: pointer; name, base: cstring; + createFunc: GodotInstanceCreateFunc; + destroyFunc: GodotInstanceDestroyFunc) + {.inline.} = + let api = getGDNativeAPI() + api.nativeScriptRegisterClass( + libHandle, name, base, createFunc, destroyFunc) -type - GodotNativeInitOptions* = object - inEditor*: bool - coreApiHash*: uint64 - editorApiHash*: uint64 - noApiHash*: uint64 - gdNativeLibrary*: ptr GodotObject +proc nativeScriptRegisterToolClass*(libHandle: pointer; name, base: cstring; + createFunc: GodotInstanceCreateFunc; + destroyFunc: GodotInstanceDestroyFunc) + {.inline.} = + getGDNativeAPI().nativeScriptRegisterToolClass( + libHandle, name, base, createFunc, destroyFunc) - GodotNativeTerminateOptions* = object - inEditor*: bool +proc nativeScriptRegisterMethod*(libHandle: pointer; + name: cstring; function_name: cstring; + attr: GodotMethodAttributes; + meth: GodotInstanceMethod) {.inline.} = + getGDNativeAPI().nativeScriptRegisterMethod( + libHandle, name, functionName, attr, meth) - GodotMethodRPCMode* {.size: sizeof(cint), pure.} = enum - Disabled, - Remote, - Sync, - Master, - Slave +proc nativeScriptRegisterProperty*(libHandle: pointer; + name, path: cstring; + attr: ptr GodotPropertyAttributes; + setFunc: GodotPropertySetFunc; + getFunc: GodotPropertyGetFunc) {.inline.} = + getGDNativeAPI().nativeScriptRegisterProperty( + libHandle, name, path, attr, setFunc, getFunc) - GodotMethodAttributes* = object - rpcMode*: GodotMethodRPCMode +proc nativeScriptRegisterSignal*(libHandle: pointer; name: cstring; + signal: GodotSignal) {.inline.} = + getGDNativeAPI().nativeScriptRegisterSignal(libHandle, name, signal) - GodotPropertyHint* {.size: sizeof(cint), pure.} = enum - None, ## no hint provided. - Range, ## hint_text = "min,max,step,slider; // slider is optional" - ExpRange, ## hint_text = "min,max,step", exponential edit - Enum, ## hint_text= "val1,val2,val3,etc" - ExpEasing, ## exponential easing funciton (Math::ease) - Length, ## hint_text= "length" (as integer) - SpriteFrame, - KeyAccel, ## hint_text= "length" (as integer) - Flags, ## hint_text= "flag1,flag2,etc" (as bit flags) - Layers2DRender, - Layers2DPhysics, - Layers3DRender, - Layers3DPhysics, - File, ## a file path must be passed, hint_text (optionally) - ## is a filter "*.png,*.wav,*.doc," - Dir, ## a directort path must be passed - GlobalFile, ## a file path must be passed, hint_text (optionally) is a - ## filter "*.png,*.wav,*.doc," - GlobalDir, ## a directort path must be passed - ResourceType, ## a resource object type - MultilineText, ## used for string properties that can contain multiple lines - ColorNoAlpha, ## used for ignoring alpha component when editing a color - ImageCompressLossy, - ImageCompressLossless, - ObjectId, - TypeString, ## a type string, the hint is the base type to choose - NodePathToEditedNode, ## so something else can provide this - ## (used in scripts) - MethodOfVariantType, ## a method of a type - MethodOfBaseType, ## a method of a base type - MethodOfInstance, ## a method of an instance - MethodOfScript, ## a method of a script & base - PropertyOfVariantType, ## a property of a type - PropertyOfBaseType, ## a property of a base type - PropertyOfInstance, ## a property of an instance - PropertyOfScript, ## a property of a script & base - PropertyHintMax +proc getUserdata*(instance: ptr GodotObject): pointer {.inline.} = + getGDNativeAPI().nativeScriptGetUserdata(instance) -const - GODOT_PROPERTY_USAGE_STORAGE_VALUE = 1.cint - GODOT_PROPERTY_USAGE_EDITOR_VALUE = 2.cint - GODOT_PROPERTY_USAGE_NETWORK_VALUE = 4.cint - GODOT_PROPERTY_USAGE_EDITOR_HELPER_VALUE = 8.cint - GODOT_PROPERTY_USAGE_CHECKABLE_VALUE = 16.cint - GODOT_PROPERTY_USAGE_CHECKED_VALUE = 32.cint - GODOT_PROPERTY_USAGE_INTERNATIONALIZED_VALUE = 64.cint - GODOT_PROPERTY_USAGE_GROUP_VALUE = 128.cint - GODOT_PROPERTY_USAGE_CATEGORY_VALUE = 256.cint - GODOT_PROPERTY_USAGE_STORE_IF_NONZERO_VALUE = 512.cint - GODOT_PROPERTY_USAGE_STORE_IF_NONONE_VALUE = 1024.cint - GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE_VALUE = 2048.cint - GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED_VALUE = 4096.cint - GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE_VALUE = 8192.cint - GODOT_PROPERTY_USAGE_STORE_IF_NULL_VALUE = 16384.cint - GODOT_PROPERTY_USAGE_ANIMATE_AS_TRIGGER_VALUE = 32768.cint - GODOT_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED_VALUE = 65536.cint +proc getClassConstructor*(className: cstring): GodotClassConstructor + {.inline.} = + getGDNativeAPI().getClassConstructor(className) - GODOT_PROPERTY_USAGE_DEFAULT_VALUE: cint = - GODOT_PROPERTY_USAGE_STORAGE_VALUE or GODOT_PROPERTY_USAGE_EDITOR_VALUE or - GODOT_PROPERTY_USAGE_NETWORK_VALUE - GODOT_PROPERTY_USAGE_DEFAULT_INTL_VALUE: cint = - GODOT_PROPERTY_USAGE_STORAGE_VALUE or - GODOT_PROPERTY_USAGE_EDITOR_VALUE or GODOT_PROPERTY_USAGE_NETWORK_VALUE or - GODOT_PROPERTY_USAGE_INTERNATIONALIZED_VALUE - GODOT_PROPERTY_USAGE_NOEDITOR_VALUE: cint = - GODOT_PROPERTY_USAGE_STORAGE_VALUE or GODOT_PROPERTY_USAGE_NETWORK_VALUE - -type - GodotPropertyUsage* {.size: sizeof(cint), pure.} = enum - Storage = GODOT_PROPERTY_USAGE_STORAGE_VALUE - Editor = GODOT_PROPERTY_USAGE_EDITOR_VALUE - Network = GODOT_PROPERTY_USAGE_NETWORK_VALUE - NoEditor = GODOT_PROPERTY_USAGE_NOEDITOR_VALUE - Default = GODOT_PROPERTY_USAGE_DEFAULT_VALUE - EditorHelper = GODOT_PROPERTY_USAGE_EDITOR_HELPER_VALUE - Checkable = GODOT_PROPERTY_USAGE_CHECKABLE_VALUE - ## used for editing global variables - Checked = GODOT_PROPERTY_USAGE_CHECKED_VALUE - ## used for editing global variables - Internationalized = GODOT_PROPERTY_USAGE_INTERNATIONALIZED_VALUE - ## hint for internationalized strings - DefaultIntl = GODOT_PROPERTY_USAGE_DEFAULT_INTL_VALUE - Group = GODOT_PROPERTY_USAGE_GROUP_VALUE - ## used for grouping props in the editor - Category = GODOT_PROPERTY_USAGE_CATEGORY_VALUE - NonZero = GODOT_PROPERTY_USAGE_STORE_IF_NONZERO_VALUE - ## only store if nonzero - NonOne = GODOT_PROPERTY_USAGE_STORE_IF_NONONE_VALUE - ## only store if false - NoInstanceState = GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE_VALUE - RestartIfChanged = GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED_VALUE - ScriptVariable = GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE_VALUE - StoreIfNull = GODOT_PROPERTY_USAGE_STORE_IF_NULL_VALUE - AnimateAsTrigger = GODOT_PROPERTY_USAGE_ANIMATE_AS_TRIGGER_VALUE - UpdateAllIfModified = GODOT_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED_VALUE - - GodotPropertyAttributes* {.bycopy.} = object - rsetType*: GodotMethodRPCMode - typ*: cint - hint*: GodotPropertyHint - hintString*: GodotString - usage*: cint - defaultValue*: GodotVariant - - GodotInstanceCreateFunc* {.bycopy.} = object - createFunc*: - proc (obj: ptr GodotObject; methodData: pointer): pointer {.noconv.} - ## returns user data - methodData*: pointer - freeFunc*: proc (a2: pointer) {.noconv.} - - GodotInstanceDestroyFunc* {.bycopy.} = object - destroyFunc*: - proc (obj: ptr GodotObject; methodData: pointer; - userData: pointer) {.noconv.} - methodData*: pointer - freeFunc*: proc (a2: pointer) {.noconv.} - -proc godotScriptRegisterClass*(libHandle: pointer; name, base: cstring; - create_func: GodotInstanceCreateFunc; - destroy_func: GodotInstanceDestroyFunc) {. - importc: "godot_nativescript_register_class".} -proc godotScriptRegisterToolClass*(libHandle: pointer; name, base: cstring; - createFunc: GodotInstanceCreateFunc; - destroyFunc: GodotInstanceDestroyFunc) {. - importc: "godot_nativescript_register_tool_class".} -type - GodotInstanceMethod* {.bycopy.} = object - meth*: - proc (obj: ptr GodotObject; methodData: pointer; - userData: pointer; numArgs: cint; - args: var array[MAX_ARG_COUNT, ptr GodotVariant]): - GodotVariant {.noconv.} - methodData*: pointer - freeFunc*: proc (a2: pointer) {.noconv.} - -proc godotScriptRegisterMethod*(libHandle: pointer; - name: cstring; function_name: cstring; - attr: GodotMethodAttributes; - meth: GodotInstanceMethod) {. - importc: "godot_nativescript_register_method".} -type - GodotPropertySetFunc* {.bycopy.} = object - setFunc*: proc (obj: ptr GodotObject; methodData: pointer; - userData: pointer; value: GodotVariant) {.noconv.} - methodData*: pointer - freeFunc*: proc (a2: pointer) {.noconv.} - - GodotPropertyGetFunc* {.bycopy.} = object - getFunc*: proc (obj: ptr GodotObject; methodData: pointer; - userData: pointer): GodotVariant {.noconv.} - methodData*: pointer - freeFunc*: proc (a2: pointer) {.noconv.} - -proc godotScriptRegisterProperty*(libHandle: pointer; - name: cstring; path: cstring; - attr: ptr GodotPropertyAttributes; - setFunc: GodotPropertySetFunc; - getFunc: GodotPropertyGetFunc) {. - importc: "godot_nativescript_register_property".} - -type - GodotSignalArgument* {.bycopy.} = object - name*: GodotString - typ*: cint - hint*: GodotPropertyHint - hintString*: GodotString - usage*: cint - defaultValue*: GodotVariant - - GodotSignal* = object - name*: GodotString - numArgs*: cint - args*: ptr GodotSignalArgument - numDefaultArgs*: cint - defaultArgs*: ptr GodotVariant - - -proc godotScriptRegisterSignal*(libHandle: pointer; name: cstring; - signal: GodotSignal) {. - importc: "godot_nativescript_register_signal".} - -proc getUserdata*(instance: ptr GodotObject): pointer {. - importc: "godot_nativescript_get_userdata".} - -type ClassConstructor = proc (): ptr GodotObject {.noconv.} -proc getClassConstructor*(className: cstring): ClassConstructor {. - importc: "godot_get_class_constructor".} - -proc deinit*(o: ptr GodotObject) {. - importc: "godot_object_destroy".} +proc deinit*(o: ptr GodotObject) {.inline.} = + getGDNativeAPI().objectDestroy(o) # print using Godot's error handler list -proc godotPrintError*(description: cstring; function: cstring; file: cstring; - line: cint) {. - importc: "godot_print_error".} +proc godotPrintError*(description, function, file: cstring; + line: cint) {.inline.} = + let api = getGDNativeAPI() + api.printError(description, function, file, line) -proc godotPrintWarning*(description: cstring; function: cstring; - file: cstring; line: cint) {. - importc: "godot_print_warning".} +proc godotPrintWarning*(description, function, file: cstring; + line: cint) {.inline.} = + getGDNativeAPI().printWarning(description, function, file, line) -proc godotPrint*(message: GodotString) {. - importc: "godot_print".} +proc godotPrint*(message: GodotString) {.inline.} = + getGDNativeAPI().print(message) var getClassMethodBind: ptr GodotMethodBind proc getClassName*(o: ptr GodotObject): string = @@ -267,22 +95,25 @@ proc getClassName*(o: ptr GodotObject): string = # There are physics type not known by ClassDB result = result[0..result.len-3] -proc getGodotSingleton*(name: cstring): ptr GodotObject {. - importc: "godot_global_get_singleton".} +proc getGodotSingleton*(name: cstring): ptr GodotObject {.inline.} = + getGDNativeAPI().globalGetSingleton(name) # System Functions -proc godotAlloc*(bytes: cint): pointer {. - importc: "godot_alloc".} +proc godotAlloc*(bytes: cint): pointer {.inline.} = ## Allocates the specified number of bytes. ## Using this instead of stdlib proc will help Godot track how much memory ## is in use in debug mode. -proc godotRealloc*(p: pointer; bytes: cint): pointer {. - importc: "godot_realloc".} + getGDNativeAPI().alloc(bytes) + +proc godotRealloc*(p: pointer; bytes: cint): pointer {.inline.} = ## Reallocates the pointer for the specified number of bytes. ## Using this instead of stdlib proc will help Godot track how much memory ## is in use in debug mode. -proc godotFree*(p: pointer) {.importc: "godot_free".} + getGDNativeAPI().realloc(p, bytes) + +proc godotFree*(p: pointer) {.inline.} = ## Frees the memory pointed to by the pointer. ## Using this instead of stdlib proc will help Godot track how much memory ## is in use in debug mode. + getGDNativeAPI().free(p) diff --git a/godot/internal/godotarrays.nim b/godot/internal/godotarrays.nim index d6ee910..676e6cd 100644 --- a/godot/internal/godotarrays.nim +++ b/godot/internal/godotarrays.nim @@ -1,107 +1,130 @@ # Copyright (c) 2017 Xored Software, Inc. -type - GodotArray* {.byref.} = object - data: array[sizeof(int), byte] +import godotinternaltypes, gdnativeapi, core.godotcoretypes -proc len*(self: GodotArray): cint {. - noSideEffect, - importc: "godot_array_size".} +proc len*(self: GodotArray): cint {.inline.} = + getGDNativeAPI().arraySize(self) import hashes -import godotobjects, godotpoolarrays, godotvariants, godotstrings -proc initGodotArray*(dest: var GodotArray) {. - importc: "godot_array_new".} -proc initGodotArray*(dest: var GodotArray; pca: GodotPoolColorArray) {. - importc: "godot_array_new_pool_coloarray".} -proc initGodotArray*(dest: var GodotArray; pv3a: GodotPoolVector3Array) {. - importc: "godot_array_new_pool_vector3_array".} -proc initGodotArray*(dest: var GodotArray; pv2a: GodotPoolVector2Array) {. - importc: "godot_array_new_pool_vector2_array".} -proc initGodotArray*(dest: var GodotArray; psa: GodotPoolStringArray) {. - importc: "godot_array_new_pool_string_array".} -proc initGodotArray*(dest: var GodotArray; pra: GodotPoolRealArray) {. - importc: "godot_array_new_pool_real_array".} -proc initGodotArray*(dest: var GodotArray; pia: GodotPoolIntArray) {. - importc: "godot_array_new_pool_int_array".} -proc initGodotArray*(dest: var GodotArray; pba: GodotPoolByteArray) {. - importc: "godot_array_new_pool_byte_array".} -proc iniGodotArray*(dest: var GodotArray; src: GodotArray) {. - importc: "godot_array_new_copy".} +proc initGodotArray*(dest: var GodotArray) {.inline.} = + getGDNativeAPI().arrayNew(dest) -proc deinit*(self: var GodotArray) {.importc: "godot_array_destroy".} +proc initGodotArray*(dest: var GodotArray; + pca: GodotPoolColorArray) {.inline.} = + getGDNativeAPI().arrayNewPoolColorArray(dest, pca) -proc `[]=`*(self: var GodotArray; idx: cint; - value: GodotVariant) {. - noSideEffect, - importc: "godot_array_set".} -proc `[]`*(self: GodotArray; idx: cint): GodotVariant {. - noSideEffect, - importc: "godot_array_get".} -proc mget*(self: var GodotArray; idx: cint): ptr GodotVariant {. - importc: "godot_array_operator_index".} +proc initGodotArray*(dest: var GodotArray; + pv3a: GodotPoolVector3Array) {.inline.} = + getGDNativeAPI().arrayNewPoolVector3Array(dest, pv3a) + +proc initGodotArray*(dest: var GodotArray; + pv2a: GodotPoolVector2Array) {.inline.} = + getGDNativeAPI().arrayNewPoolVector2Array(dest, pv2a) + +proc initGodotArray*(dest: var GodotArray; + psa: GodotPoolStringArray) {.inline.} = + getGDNativeAPI().arrayNewPoolStringArray(dest, psa) + +proc initGodotArray*(dest: var GodotArray; + pra: GodotPoolRealArray) {.inline.} = + getGDNativeAPI().arrayNewPoolRealArray(dest, pra) + +proc initGodotArray*(dest: var GodotArray; + pia: GodotPoolIntArray) {.inline.} = + getGDNativeAPI().arrayNewPoolIntArray(dest, pia) + +proc initGodotArray*(dest: var GodotArray; + pba: GodotPoolByteArray) {.inline.} = + getGDNativeAPI().arrayNewPoolByteArray(dest, pba) + +proc initGodotArray*(dest: var GodotArray; src: GodotArray) {.inline.} = + getGDNativeAPI().arrayNewCopy(dest, src) + +proc deinit*(self: var GodotArray) {.inline.} = + getGDNativeAPI().arrayDestroy(self) + +proc `[]=`*(self: var GodotArray; idx: cint; value: GodotVariant) {.inline.} = + getGDNativeAPI().arraySet(self, idx, value) + +proc `[]`*(self: GodotArray; idx: cint): GodotVariant {.inline.} = + getGDNativeAPI().arrayGet(self, idx) + +proc mget*(self: var GodotArray; idx: cint): ptr GodotVariant {.inline.} = + getGDNativeAPI().arrayOperatorIndex(self, idx) + +proc add*(self: var GodotArray; value: GodotVariant) {.inline.} = + getGDNativeAPI().arrayPushBack(self, value) + +proc clear*(self: var GodotArray) {.inline.} = + getGDNativeAPI().arrayClear(self) + +proc count*(self: GodotArray; value: GodotVariant): cint {.inline.} = + getGDNativeAPI().arrayCount(self, value) + +proc isEmpty*(self: GodotArray): bool {.inline.} = + getGDNativeAPI().arrayEmpty(self) + +proc erase*(self: var GodotArray; value: GodotVariant) {.inline.} = + getGDNativeAPI().arrayErase(self, value) + +proc first*(self: GodotArray): GodotVariant {.inline.} = + getGDNativeAPI().arrayFront(self) + +proc last*(self: GodotArray): GodotVariant {.inline.} = + getGDNativeAPI().arrayBack(self) -proc add*(self: var GodotArray; value: GodotVariant) {. - noSideEffect, - importc: "godot_array_append".} -proc clear*(self: var GodotArray) {.importc: "godot_array_clear".} -proc count*(self: GodotArray; value: GodotVariant): cint {. - noSideEffect, - importc: "godot_array_count".} -proc isEmpty*(self: GodotArray): bool {. - noSideEffect, - importc: "godot_array_empty".} -proc erase*(self: var GodotArray; value: GodotVariant) {. - importc: "godot_array_erase".} -proc first*(self: GodotArray): GodotVariant {. - noSideEffect, - importc: "godot_array_front".} -proc last*(self: GodotArray): GodotVariant {. - noSideEffect, - importc: "godot_array_back".} proc find*(self: GodotArray; what: GodotVariant; - f: cint): cint {. - noSideEffect, - importc: "godot_array_find".} -proc findLast*(self: GodotArray; what: GodotVariant): cint {. - noSideEffect, - importc: "godot_array_find_last".} -proc contains*(self: GodotArray; value: GodotVariant): bool {. - noSideEffect, - importc: "godot_array_has".} + fromIdx: cint): cint {.inline.} = + getGDNativeAPI().arrayFind(self, what, fromIdx) + +proc findLast*(self: GodotArray; what: GodotVariant): cint {.inline.} = + getGDNativeAPI().arrayFindLast(self, what) + +proc contains*(self: GodotArray; value: GodotVariant): bool {.inline.} = + getGDNativeAPI().arrayHas(self, value) + +proc godotHash*(self: GodotArray): cint {.inline.} = + getGDNativeAPI().arrayHash(self) -proc godotHash*(self: GodotArray): cint {. - noSideEffect, - importc: "godot_array_hash".} proc hash*(self: GodotArray): Hash {.inline.} = hash(godotHash(self)) proc insert*(self: var GodotArray; pos: cint; - value: GodotVariant) {. - importc: "godot_array_insert".} -proc reverse*(self: var GodotArray) {.importc: "godot_array_invert".} -proc popLast*(self: var GodotArray): GodotVariant {. - importc: "godot_array_pop_back".} -proc popFirst*(self: var GodotArray): GodotVariant {. - importc: "godot_array_pop_front".} -proc addLast*(self: var GodotArray; value: GodotVariant) {. - importc: "godot_array_push_back".} -proc addFirst*(self: var GodotArray; value: GodotVariant) {. - importc: "godot_array_push_front".} + value: GodotVariant): Error {.discardable, inline.} = + getGDNativeAPI().arrayInsert(self, pos, value) + +proc reverse*(self: var GodotArray) {.inline.} = + getGDNativeAPI().arrayInvert(self) + +proc popLast*(self: var GodotArray): GodotVariant {.inline.} = + getGDNativeAPI().arrayPopBack(self) + +proc popFirst*(self: var GodotArray): GodotVariant {.inline.} = + getGDNativeAPI().arrayPopFront(self) + +proc addLast*(self: var GodotArray; value: GodotVariant) {.inline.} = + getGDNativeAPI().arrayPushBack(self, value) + +proc addFirst*(self: var GodotArray; value: GodotVariant) {.inline.} = + getGDNativeAPI().arrayPushFront(self, value) + +proc delete*(self: var GodotArray; idx: cint) {.inline.} = + getGDNativeAPI().arrayRemove(self, idx) + +proc setLen*(self: var GodotArray; size: cint) {.inline.} = + getGDNativeAPI().arrayResize(self, size) -proc delete*(self: var GodotArray; idx: cint) {. - importc: "godot_array_remove".} -proc setLen*(self: var GodotArray; size: cint) {. - importc: "godot_array_resize".} proc rfind*(self: GodotArray; what: GodotVariant; - f: cint): cint {. - noSideEffect, - importc: "godot_array_rfind".} -proc sort*(self: var GodotArray) {.importc: "godot_array_sort".} -proc sortCustom*(self: var GodotArray; obj: var GodotObject; - funcName: GodotString) {. - importc: "godot_array_sort_custom".} + fromIdx: cint): cint {.inline.} = + getGDNativeAPI().arrayRFind(self, what, fromIdx) + +proc sort*(self: var GodotArray) {.inline.} = + getGDNativeAPI().arraySort(self) + +proc sortCustom*(self: var GodotArray; obj: ptr GodotObject; + funcName: GodotString) {.inline.} = + getGDNativeAPI().arraySortCustom(self, obj, funcName) iterator items*(self: GodotArray): GodotVariant = for i in 0.. Date: Thu, 5 Oct 2017 18:55:51 +0700 Subject: [PATCH 07/82] Fix void return type in godotapigen --- godot/godotapigen.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index f718c60..a8c9804 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -532,7 +532,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], body.add(newNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("GodotString"), ))) - else: + elif meth.returnType != "void": isObjRet = true body.add(newNode(nkVarSection).addChain(newIdentDefs( retValIdent, newNode(nkPtrTy).addChain(ident("GodotObject")), From f5abff05e6383cbbfdecd144303e05be58941561 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 9 Oct 2017 14:47:28 +0700 Subject: [PATCH 08/82] Extend GDNative API according to the latest update --- godot.nimble | 2 +- godot/gdnativeapi.nim | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index b81ad0e..4ec61f3 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.0" +version = "0.6.1" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index c93e5fa..4a84aeb 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -1301,6 +1301,16 @@ type GDNativeAPI* = object stringDestroy*: proc (self: var GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + # StringName API + stringNameNew: pointer + stringNameNewData: pointer + stringNameGetName: pointer + stringNameGetHash: pointer + stringNameGetDataUniquePointer: pointer + stringNameOperatorEqual: pointer + stringNameOperatorLess: pointer + stringNameDestroy: pointer + # Misc API objectDestroy*: proc (self: ptr GodotObject) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} From c5d7680e5368c3fb579b95683fbe189cd024bee5 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 12 Oct 2017 20:55:45 +0700 Subject: [PATCH 09/82] Change GodotClassConstructor to a safe signature --- godot/internal/godotinternaltypes.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/godot/internal/godotinternaltypes.nim b/godot/internal/godotinternaltypes.nim index 5c516f3..29b0e00 100644 --- a/godot/internal/godotinternaltypes.nim +++ b/godot/internal/godotinternaltypes.nim @@ -259,4 +259,5 @@ type numDefaultArgs*: cint defaultArgs*: ptr GodotVariant - GodotClassConstructor* = proc (): ptr GodotObject {.noconv.} + GodotClassConstructor* = proc (): ptr GodotObject {. + noconv, gcsafe, locks: 0, raises: [], tags: [].} From 7f73a89878fee97907d4dcf4852940553dd855ef Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 12 Oct 2017 21:26:36 +0700 Subject: [PATCH 10/82] Fix $ for core types --- godot/core/planes.nim | 3 ++- godot/core/quats.nim | 3 ++- godot/core/rect2.nim | 3 ++- godot/core/rect3.nim | 3 ++- godot/core/transform2d.nim | 3 ++- godot/core/transforms.nim | 3 ++- godot/core/vector2.nim | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/godot/core/planes.nim b/godot/core/planes.nim index 360953f..99dd652 100644 --- a/godot/core/planes.nim +++ b/godot/core/planes.nim @@ -2,7 +2,8 @@ import vector3 -import internal.godotinternaltypes, godotcoretypes, gdnativeapi +import internal.godotinternaltypes, internal.godotstrings +import godotcoretypes, gdnativeapi proc initPlane*(a, b, c, d: float32): Plane {.inline.} = getGDNativeAPI().planeNewWithReals(result, a, b, c, d) diff --git a/godot/core/quats.nim b/godot/core/quats.nim index 016bbd0..ea8cad4 100644 --- a/godot/core/quats.nim +++ b/godot/core/quats.nim @@ -1,6 +1,7 @@ # Copyright (c) 2017 Xored Software, Inc. -import internal.godotinternaltypes, godotcoretypes, gdnativeapi +import internal.godotinternaltypes, internal.godotstrings +import godotcoretypes, gdnativeapi proc initQuat*(x, y, z, w: float32): Quat {.inline.} = result = Quat( diff --git a/godot/core/rect2.nim b/godot/core/rect2.nim index 628e203..ad813a9 100644 --- a/godot/core/rect2.nim +++ b/godot/core/rect2.nim @@ -1,7 +1,8 @@ # Copyright (c) 2017 Xored Software, Inc. import vector2 -import godotcoretypes, internal.godotinternaltypes, gdnativeapi +import internal.godotinternaltypes, internal.godotstrings +import godotcoretypes, gdnativeapi proc initRect2*(pos, size: Vector2): Rect2 {.inline.} = Rect2(position: pos, size: size) diff --git a/godot/core/rect3.nim b/godot/core/rect3.nim index 7a2ef72..dc2f2c2 100644 --- a/godot/core/rect3.nim +++ b/godot/core/rect3.nim @@ -1,6 +1,7 @@ # Copyright (c) 2017 Xored Software, Inc. -import godotcoretypes, internal.godotinternaltypes, gdnativeapi +import internal.godotinternaltypes, internal.godotstrings +import godotcoretypes, gdnativeapi proc initRect3*(pos, size: Vector3): Rect3 {.inline.} = Rect3(position: pos, size: size) diff --git a/godot/core/transform2d.nim b/godot/core/transform2d.nim index 67222c6..922b24b 100644 --- a/godot/core/transform2d.nim +++ b/godot/core/transform2d.nim @@ -1,6 +1,7 @@ # Copyright (c) 2017 Xored Software, Inc. -import godotcoretypes, internal.godotinternaltypes, gdnativeapi +import internal.godotinternaltypes, internal.godotstrings +import godotcoretypes, gdnativeapi proc initTransform2D*(): Transform2D {.inline.} = getGDNativeAPI().transform2DNewIdentity(result) diff --git a/godot/core/transforms.nim b/godot/core/transforms.nim index 550136c..f70a1f8 100644 --- a/godot/core/transforms.nim +++ b/godot/core/transforms.nim @@ -1,6 +1,7 @@ # Copyright (c) 2017 Xored Software, Inc. -import godotcoretypes, internal.godotinternaltypes, gdnativeapi +import internal.godotinternaltypes, internal.godotstrings +import godotcoretypes, gdnativeapi import basis proc initTransform*(): Transform {.inline.} = diff --git a/godot/core/vector2.nim b/godot/core/vector2.nim index 94b5b40..9eca64d 100644 --- a/godot/core/vector2.nim +++ b/godot/core/vector2.nim @@ -1,6 +1,7 @@ # Copyright (c) 2017 Xored Software, Inc. -import internal.godotinternaltypes, godotcoretypes, gdnativeapi +import internal.godotinternaltypes, internal.godotstrings +import godotcoretypes, gdnativeapi proc vec2*(x, y: float32): Vector2 {.inline.} = Vector2(x: x, y: y) From 1b47dac4e96b75e2676e5302be34741c08caed16 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 16 Oct 2017 20:10:00 +0700 Subject: [PATCH 11/82] Fix thread_enter not to use GC --- godot.nimble | 2 +- godot/nim/godotnim.nim | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/godot.nimble b/godot.nimble index 4ec61f3..65e1ff1 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.1" +version = "0.6.2" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index b5c7d78..078e6ab 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -828,7 +828,10 @@ proc godot_nativescript_thread_enter() {.cdecl, exportc, dynlib.} = when compileOption("threads"): setupForeignThreadGc() else: - print(cstring"A foreign thread is created, but app is compiled without --threads:on. Bad things will happen if Nim code is invoked from this thread.") + const err = cstring"A foreign thread is created, but app is compiled without --threads:on. Bad things will happen if Nim code is invoked from this thread." + var s = err.toGodotString() + godotPrint(s) + s.deinit() proc godot_nativescript_thread_exit() {.cdecl, exportc, dynlib.} = when compileOption("threads"): From d2b86a2b9416419db0ae21f46f378972c116d74d Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Tue, 17 Oct 2017 16:32:07 +0700 Subject: [PATCH 12/82] Perform poll(0) in a loop Temporary workaround for https://github.com/nim-lang/Nim/issues/6523 --- godot/nim/godotnim.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 078e6ab..dbee55f 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -817,7 +817,8 @@ proc godot_nativescript_frame() {.cdecl, exportc, dynlib.} = setStackBottom((void*)(&`stackBottom`)); """.} if asyncdispatch.hasPendingOperations(): - poll(0) + for i in 1..10: + poll(0) GC_step(nimGcStepLengthUs, true, 0) when not defined(release): From 26570707aa7c79b260f70ac72dc706dc3c63d054 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 18 Oct 2017 11:47:20 +0700 Subject: [PATCH 13/82] Fix poll loop --- godot/nim/godotnim.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index dbee55f..0b0a765 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -816,8 +816,8 @@ proc godot_nativescript_frame() {.cdecl, exportc, dynlib.} = {.emit: """ setStackBottom((void*)(&`stackBottom`)); """.} - if asyncdispatch.hasPendingOperations(): - for i in 1..10: + for _ in 1..10: + if asyncdispatch.hasPendingOperations(): poll(0) GC_step(nimGcStepLengthUs, true, 0) From e494dc914afc047cc0801fc71c4cfcc96886df72 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 8 Nov 2017 11:14:48 +0700 Subject: [PATCH 14/82] Update GDNative API struct --- godot.nimble | 2 +- godot/gdnativeapi.nim | 63 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index 65e1ff1..fb8648f 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.2" +version = "0.6.3" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index 4a84aeb..8af25da 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -295,6 +295,8 @@ type GDNativeAPI* = object {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolByteArrayResize*: proc (self: var GodotPoolByteArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayRead: pointer + poolByteArrayWrite: pointer poolByteArraySet*: proc (self: var GodotPoolByteArray, idx: cint, data: byte) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolByteArrayGet*: proc (self: GodotPoolByteArray, idx: cint): byte @@ -330,6 +332,8 @@ type GDNativeAPI* = object {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolIntArrayResize*: proc (self: var GodotPoolIntArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayRead: pointer + poolIntArrayWrite: pointer poolIntArraySet*: proc (self: var GodotPoolIntArray, idx: cint, data: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolIntArrayGet*: proc (self: GodotPoolIntArray, idx: cint): cint @@ -367,6 +371,8 @@ type GDNativeAPI* = object {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolRealArrayResize*: proc (self: var GodotPoolRealArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayRead: pointer + poolRealArrayWrite: pointer poolRealArraySet*: proc (self: var GodotPoolRealArray, idx: cint, data: float32) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -413,6 +419,8 @@ type GDNativeAPI* = object poolStringArrayResize*: proc (self: var GodotPoolStringArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolStringArrayRead: pointer + poolStringArrayWrite: pointer poolStringArraySet*: proc (self: var GodotPoolStringArray, idx: cint, data: GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -459,6 +467,8 @@ type GDNativeAPI* = object poolVector2ArrayResize*: proc (self: var GodotPoolVector2Array, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArrayRead: pointer + poolVector2ArrayWrite: pointer poolVector2ArraySet*: proc (self: var GodotPoolVector2Array, idx: cint, data: Vector2) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -504,6 +514,8 @@ type GDNativeAPI* = object poolVector3ArrayResize*: proc (self: var GodotPoolVector3Array, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector3ArrayRead: pointer + poolVector3ArrayWrite: pointer poolVector3ArraySet*: proc (self: var GodotPoolVector3Array, idx: cint, data: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -545,6 +557,8 @@ type GDNativeAPI* = object {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolColorArrayResize*: proc (self: var GodotPoolColorArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayRead: pointer + poolColorArrayWrite: pointer poolColorArraySet*: proc (self: var GodotPoolColorArray, idx: cint, data: Color) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -556,6 +570,52 @@ type GDNativeAPI* = object {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + # Pool Array Read Access API + + poolByteArrayReadAccessPtr: pointer + poolByteArrayReadAccessOperatorAssign: pointer + poolByteArrayReadAccessDestroy: pointer + poolIntArrayReadAccessPtr: pointer + poolIntArrayReadAccessOperatorAssign: pointer + poolIntArrayReadAccessDestroy: pointer + poolRealArrayReadAccessPtr: pointer + poolRealArrayReadAccessOperatorAssign: pointer + poolRealArrayReadAccessDestroy: pointer + poolStringArrayReadAccessPtr: pointer + poolStringArrayReadAccessOperatorAssign: pointer + poolStringArrayReadAccessDestroy: pointer + poolVector2ArrayReadAccessPtr: pointer + poolVector2ArrayReadAccessOperatorAssign: pointer + poolVector2ArrayReadAccessDestroy: pointer + poolVector3ArrayReadAccessPtr: pointer + poolVector3ArrayReadAccessOperatorAssign: pointer + poolVector3ArrayReadAccessDestroy: pointer + poolColorArrayReadAccessPtr: pointer + poolColorArrayReadAccessOperatorAssign: pointer + poolColorArrayReadAccessDestroy: pointer + + poolByteArrayWriteAccessPtr: pointer + poolByteArrayWriteAccessOperatorAssign: pointer + poolByteArrayWriteAccessDestroy: pointer + poolIntArrayWriteAccessPtr: pointer + poolIntArrayWriteAccessOperatorAssign: pointer + poolIntArrayWriteAccessDestroy: pointer + poolRealArrayWriteAccessPtr: pointer + poolRealArrayWriteAccessOperatorAssign: pointer + poolRealArrayWriteAccessDestroy: pointer + poolStringArrayWriteAccessPtr: pointer + poolStringArrayWriteAccessOperatorAssign: pointer + poolStringArrayWriteAccessDestroy: pointer + poolVector2ArrayWriteAccessPtr: pointer + poolVector2ArrayWriteAccessOperatorAssign: pointer + poolVector2ArrayWriteAccessDestroy: pointer + poolVector3ArrayWriteAccessPtr: pointer + poolVector3ArrayWriteAccessOperatorAssign: pointer + poolVector3ArrayWriteAccessDestroy: pointer + poolColorArrayWriteAccessPtr: pointer + poolColorArrayWriteAccessOperatorAssign: pointer + poolColorArrayWriteAccessDestroy: pointer + # Array API arrayNew*: proc (dest: var GodotArray) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1155,6 +1215,7 @@ type GDNativeAPI* = object stringOperatorIndex: pointer stringCStr*: proc (self: GodotString): cstring {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringOperatorIndexConst: pointer stringUTF16Str: pointer stringOperatorEqual*: proc (self, other: GodotString): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1379,6 +1440,8 @@ type GDNativeAPI* = object {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + var gdNativeAPI: ptr GDNativeAPI proc getGDNativeAPI*(): ptr GDNativeAPI {.inline.} = From a93dcd1d4d3f957f04725e89df4d7606323dc4a5 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 8 Nov 2017 11:39:07 +0700 Subject: [PATCH 15/82] Update for latest Nim --- godot.nimble | 2 +- godot/godotapigen.nim | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/godot.nimble b/godot.nimble index fb8648f..0f2f049 100644 --- a/godot.nimble +++ b/godot.nimble @@ -4,4 +4,4 @@ description = "Godot Engine bindings" license = "MIT" srcDir = "godot" -requires "nim >= 0.17.0", "compiler >= 0.17.0" \ No newline at end of file +requires "nim >= 0.17.3", "compiler >= 0.17.3" \ No newline at end of file diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index a8c9804..526a1f8 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -794,7 +794,7 @@ proc genTypeFile(types: Table[string, GodotType], targetDir: string) = ) godotApiTypesTree.add(regNode) - renderModule(godotApiTypesTree, targetDir / "godottypes.nim") + writeFile(targetDir / "godottypes.nim", renderTree(godotApiTypesTree)) proc genSingletonWithDerived(tree: PNode, typ: GodotType, types: Table[string, GodotType]) = @@ -909,7 +909,7 @@ proc genApi*(targetDir: string, apiJsonFile: string) = makeMethod(types, tree, methodBindRegsitry, typ, meth, withImplementation = true) - renderModule(tree, targetDir / moduleName & ".nim") + writeFile(targetDir / moduleName & ".nim", renderTree(tree)) megaImport.add("import \"" & moduleName & "\"\n") From cc6bfa00458a2eee572ee25343a91d4b5a48ef38 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 13 Nov 2017 10:18:25 +0700 Subject: [PATCH 16/82] Update for latest GDNative API changes --- godot.nimble | 2 +- godot/gdnativeapi.nim | 4461 +++++++++++++++++++++++++++------------- godot/nim/godotnim.nim | 5 +- 3 files changed, 3086 insertions(+), 1382 deletions(-) diff --git a/godot.nimble b/godot.nimble index 0f2f049..1349055 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.3" +version = "0.6.4" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index 8af25da..ee7f6ad 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -1,1451 +1,3154 @@ # Copyright 2017 Xored Software, Inc. -import internal.godotinternaltypes, core.godotcoretypes +import internal.godotinternaltypes, core.godotcoretypes, macros -type GDNativeAPI* = object - next: pointer - version: cstring +type + GDNativeAPIType {.size: sizeof(cuint).} = enum + GDNativeCore, + GDNativeExtNativeScript, + GDNativeExtPluginScript, + GDNativeExtNativeARVR - # Color API - colorNewRGBA*: proc (dest: var Color, r, g, b, a: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorNewRGB*: proc (dest: var Color, r, g, b: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorGetR*: proc (self: Color): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorSetR*: proc (self: var Color, r: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorGetG*: proc (self: Color): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorSetG*: proc (self: var Color, g: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorGetB*: proc (self: Color): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorSetB*: proc (self: var Color, b: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorGetA*: proc (self: Color): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorSetA*: proc (self: var Color, a: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorGetH*: proc (self: Color): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorGetS*: proc (self: Color): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorGetV*: proc (self: Color): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorAsString*: proc (self: Color): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorToRGBA32*: proc (self: Color): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorAsARGB32*: proc (self: Color): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorGray*: proc (self: Color): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorInverted*: proc (self: Color): Color - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorContrasted*: proc (self: Color): Color - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorLinearInterpolate*: proc (self, other: Color, t: float32): Color - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - colorBlend*: proc (self, other: Color): Color - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorToHtml*: proc (self: Color, withAlpha: bool): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorOperatorEqual*: proc (self, other: Color): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorOperatorLess*: proc (self, other: Color): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + GDNativeAPIVersion = object + major: cuint + minor: cuint - # Vector2 API - vector2New*: proc (dest: var Vector2, x, y: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2AsString*: proc (self: Vector2): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Normalized*: proc (self: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Length*: proc (self: Vector2): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Angle*: proc (self: Vector2): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2LengthSquared*: proc (self: Vector2): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2IsNormalized*: proc (self: Vector2): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2DistanceTo*: proc (self, to: Vector2): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2DistanceSquaredTo*: proc (self, to: Vector2): float32 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - vector2AngleTo*: proc (self, to: Vector2): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2AngleToPoint*: proc (self, to: Vector2): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2LinearInterpolate*: proc (self, b: Vector2, t: float32): Vector2 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - vector2CubicInterpolate*: proc (self, b, preA, postB: Vector2, - t: float32): Vector2 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - vector2Rotated*: proc (self: Vector2, phi: float32): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Tangent*: proc (self: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Floor*: proc (self: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Snapped*: proc (self, by: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Aspect*: proc (self: Vector2): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Dot*: proc (self, other: Vector2): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Slide*: proc (self, n: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Bounce*: proc (self, n: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Reflect*: proc (self, n: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Abs*: proc (self: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Clamped*: proc (self: Vector2, length: float32): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorAdd*: proc (self, other: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorSubtract*: proc (self, other: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - vector2OperatorMultiplyVector*: proc (self, other: Vector2): Vector2 + GDNativeAPIHeader = object + typ: cuint + version: GDNativeAPIVersion + next: pointer + + GDNativeNativeScriptAPI1 = object + typ: cuint + version: GDNativeAPIVersion + next: pointer + nativeScriptRegisterClass: proc (gdnativeHandle: pointer, + name, base: cstring, + createFunc: GodotInstanceCreateFunc, + destroyFunc: GodotInstanceDestroyFunc) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptRegisterToolClass: proc (gdnativeHandle: pointer, + name, base: cstring, + createFunc: GodotInstanceCreateFunc, + destroyFunc: GodotInstanceDestroyFunc) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptRegisterMethod: proc (gdnativeHandle: pointer, + name, functionName: cstring, + attr: GodotMethodAttributes, + meth: GodotInstanceMethod) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptRegisterProperty: proc (gdnativeHandle: pointer, + name, path: cstring, + attr: ptr GodotPropertyAttributes, + setFunc: GodotPropertySetFunc, + getFunc: GodotPropertyGetFunc) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorMultiplyScalar*: proc (self: Vector2, scalar: float32): Vector2 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - vector2OperatorDivideVector*: proc (self, other: Vector2): Vector2 + nativeScriptRegisterSignal: proc (gdnativeHandle: pointer, name: cstring, + signal: GodotSignal) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorDivideScalar*: proc (self: Vector2, scalar: float32): Vector2 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - vector2OperatorEqual*: proc (self, other: Vector2): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorLess*: proc (self, other: Vector2): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorNeg*: proc (self: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2SetX: pointer - vector2SetY: pointer - vector2GetX: pointer - vector2GetY: pointer + nativeScriptGetUserdata: proc (obj: ptr GodotObject): pointer + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} - # Quat API - quatNew*: proc (dest: var Quat, x, y, z, w: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatNewWithAxisAngle*: proc (dest: Quat, axis: Vector3, - angle: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatGetX*: proc (self: Quat): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSetX*: proc (self: var Quat, val: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatGetY*: proc (self: Quat): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSetY*: proc (self: var Quat, val: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatGetZ*: proc (self: Quat): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSetZ*: proc (self: var Quat, val: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatGetW*: proc (self: Quat): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSetW*: proc (self: var Quat, val: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatAsString*: proc (self: Quat): GodotString + GDNativeCoreAPI1 = object + typ: cuint + version: GDNativeAPIVersion + next: pointer + numExtensions: cuint + extensions: ptr array[100_000, pointer] + + # Color API + colorNewRGBA: proc (dest: var Color, r, g, b, a: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorNewRGB: proc (dest: var Color, r, g, b: float32) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatLength*: proc (self: Quat): float32 + colorGetR: proc (self: Color): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatLengthSquared*: proc (self: Quat): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatNormalized*: proc (self: Quat): Quat + colorSetR: proc (self: var Color, r: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetG: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorSetG: proc (self: var Color, g: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetB: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorSetB: proc (self: var Color, b: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetA: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorSetA: proc (self: var Color, a: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetH: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetS: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetV: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorAsString: proc (self: Color): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatIsNormalized*: proc (self: Quat): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatInverse*: proc (self: Quat): Quat - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatDot*: proc (self, other: Quat): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatXform*: proc (self: Quat, v: Vector3): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSlerp*: proc (self, other: Quat, t: float32): Quat - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSlerpni*: proc (self, other: Quat, t: float32): Quat - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatCubicSlerp*: proc (self, other, preA, postB: Quat, t: float32): Quat + colorToRGBA32: proc (self: Color): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorMultiply*: proc (self: Quat, b: float32): Quat - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorAdd*: proc (self, other: Quat): Quat - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorSubtract*: proc (self, other: Quat): Quat - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorDivide*: proc (self: Quat, divider: float32): Quat - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorEqual*: proc (self, other: Quat): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorNeg*: proc (self: Quat): Quat - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - # Basis API - basisNewWithRows: pointer - basisNewWithAxisAndAngle: pointer - basisNewWithEuler: pointer - basisAsString: pointer - basisInverse: pointer - basisTransposed: pointer - basisOrthonormalized: pointer - basisDeterminant: pointer - basisRotated: pointer - basisScaled: pointer - basisGetScale: pointer - basisGetEuler: pointer - basisTdotx: pointer - basisTdoty: pointer - basisTdotz: pointer - basisXform: pointer - basisXformInv: pointer - basisGetOrthogonalIndex: pointer - basisNew: pointer - basisNewWithEulerQuat: pointer - basisGetElements: pointer - basisGetAxis: pointer - basisSetAxis: pointer - basisGetRow: pointer - basisSetRow: pointer - basisOperatorEqual: pointer - basisOperatorAdd: pointer - basisOperatorSubstract: pointer - basisOperatorMultiplyVector: pointer - basisOperatorMultiplyScalar: pointer - - # Vector3 API - vector3New: pointer - vector3AsString: pointer - vector3MinAxis: pointer - vector3MaxAxis: pointer - vector3Length: pointer - vector3Length_squared: pointer - vector3IsNormalized: pointer - vector3Normalized: pointer - vector3Inverse: pointer - vector3Snapped: pointer - vector3Rotated: pointer - vector3LinearInterpolate: pointer - vector3CubicInterpolate: pointer - vector3Dot: pointer - vector3Cross: pointer - vector3Outer: pointer - vector3ToDiagonalMatrix: pointer - vector3Abs: pointer - vector3Floor: pointer - vector3Ceil: pointer - vector3DistanceTo: pointer - vector3DistanceSquaredTo: pointer - vector3AngleTo: pointer - vector3Slide: pointer - vector3Bounce: pointer - vector3Reflect: pointer - vector3OperatorAdd: pointer - vector3OperatorSubstract: pointer - vector3OperatorMultiplyVector: pointer - vector3OperatorMultiplyScalar: pointer - vector3OperatorDivideVector: pointer - vector3OperatorDivideScalar: pointer - vector3OperatorEqual: pointer - vector3OperatorLess: pointer - vector3OperatorNeg: pointer - vector3SetAxis: pointer - vector3GetAxis: pointer - - # PoolByteArray API - poolByteArrayNew*: proc (dest: var GodotPoolByteArray) + colorAsARGB32: proc (self: Color): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGray: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorInverted: proc (self: Color): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorContrasted: proc (self: Color): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayNewCopy*: proc (dest: var GodotPoolByteArray, - src: GodotPoolByteArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayNewWithArray*: proc (dest: var GodotPoolByteArray, - src: GodotArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolByteArrayAppend*: proc (self: var GodotPoolByteArray, - val: byte) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayAppendArray*: proc (self: var GodotPoolByteArray, - arr: GodotPoolByteArray) + colorLinearInterpolate: proc (self, other: Color, t: float32): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayInsert*: proc (self: var GodotPoolByteArray, - idx: cint, val: byte): Error - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayInvert*: proc (self: var GodotPoolByteArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayPushBack*: proc (self: var GodotPoolByteArray, val: byte) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolByteArrayRemove*: proc (self: var GodotPoolByteArray, idx: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayResize*: proc (self: var GodotPoolByteArray, size: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayRead: pointer - poolByteArrayWrite: pointer - poolByteArraySet*: proc (self: var GodotPoolByteArray, idx: cint, data: byte) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayGet*: proc (self: GodotPoolByteArray, idx: cint): byte - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArraySize*: proc (self: GodotPoolByteArray): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayDestroy*: proc (self: GodotPoolByteArray) + colorBlend: proc (self, other: Color): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorToHtml: proc (self: Color, withAlpha: bool): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorOperatorEqual: proc (self, other: Color): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorOperatorLess: proc (self, other: Color): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - # PoolIntArray API - poolIntArrayNew*: proc (dest: var GodotPoolIntArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayNewCopy*: proc (dest: var GodotPoolIntArray, - src: GodotPoolIntArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayNewWithArray*: proc (dest: var GodotPoolIntArray, src: GodotArray) + # Vector2 API + vector2New: proc (dest: var Vector2, x, y: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2AsString: proc (self: Vector2): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Normalized: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Length: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Angle: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2LengthSquared: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2IsNormalized: proc (self: Vector2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2DistanceTo: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2DistanceSquaredTo: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2AngleTo: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2AngleToPoint: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2LinearInterpolate: proc (self, b: Vector2, t: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2CubicInterpolate: proc (self, b, preA, postB: Vector2, + t: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayAppend*: proc (self: var GodotPoolIntArray, val: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayAppendArray*: proc (self: var GodotPoolIntArray, - arr: GodotPoolIntArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolIntArrayInsert*: proc (self: var GodotPoolIntArray, idx: cint, - val: cint): Error - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayInvert*: proc (self: var GodotPoolIntArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayPushBack*: proc (self: var GodotPoolIntArray, val: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayRemove*: proc (self: var GodotPoolIntArray, idx: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayResize*: proc (self: var GodotPoolIntArray, size: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayRead: pointer - poolIntArrayWrite: pointer - poolIntArraySet*: proc (self: var GodotPoolIntArray, idx: cint, data: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayGet*: proc (self: GodotPoolIntArray, idx: cint): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArraySize*: proc (self: GodotPoolIntArray): cint + vector2Rotated: proc (self: Vector2, phi: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayDestroy*: proc (self: GodotPoolIntArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - # PoolRealArray API - poolRealArrayNew*: proc (dest: var GodotPoolRealArray) + vector2Tangent: proc (self: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayNewCopy*: proc (dest: var GodotPoolRealArray, - src: GodotPoolRealArray) + vector2Floor: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Snapped: proc (self, by: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Aspect: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Dot: proc (self, other: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Slide: proc (self, n: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Bounce: proc (self, n: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Reflect: proc (self, n: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Abs: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Clamped: proc (self: Vector2, length: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2OperatorAdd: proc (self, other: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayNewWithArray*: proc (dest: var GodotPoolRealArray, - src: GodotArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolRealArrayAppend*: proc (self: var GodotPoolRealArray, val: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayAppendArray*: proc (self: var GodotPoolRealArray, - arr: GodotPoolRealArray) + vector2OperatorSubtract: proc (self, other: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayInsert*: proc (self: var GodotPoolRealArray, - idx: cint, val: float32): Error - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayInvert*: proc (self: var GodotPoolRealArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayPushBack*: proc (self: var GodotPoolRealArray, val: float32) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolRealArrayRemove*: proc (self: var GodotPoolRealArray, idx: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayResize*: proc (self: var GodotPoolRealArray, size: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayRead: pointer - poolRealArrayWrite: pointer - poolRealArraySet*: proc (self: var GodotPoolRealArray, idx: cint, - data: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayGet*: proc (self: GodotPoolRealArray, idx: cint): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArraySize*: proc (self: GodotPoolRealArray): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayDestroy*: proc (self: GodotPoolRealArray) + vector2OperatorMultiplyVector: proc (self, other: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorMultiplyScalar: proc (self: Vector2, scalar: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorDivideVector: proc (self, other: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorDivideScalar: proc (self: Vector2, scalar: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorEqual: proc (self, other: Vector2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2OperatorLess: proc (self, other: Vector2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2OperatorNeg: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2SetX: pointer + vector2SetY: pointer + vector2GetX: pointer + vector2GetY: pointer - # PoolStringArray API - poolStringArrayNew*: proc (dest: var GodotPoolStringArray) + # Quat API + quatNew: proc (dest: var Quat, x, y, z, w: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatNewWithAxisAngle: proc (dest: Quat, axis: Vector3, + angle: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetX: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetX: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetY: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetY: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetZ: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetZ: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetW: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetW: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatAsString: proc (self: Quat): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatLength: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatLengthSquared: proc (self: Quat): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayNewCopy*: proc (dest: var GodotPoolStringArray, - src: GodotPoolStringArray) + quatNormalized: proc (self: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatIsNormalized: proc (self: Quat): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatInverse: proc (self: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatDot: proc (self, other: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatXform: proc (self: Quat, v: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSlerp: proc (self, other: Quat, t: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSlerpni: proc (self, other: Quat, t: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatCubicSlerp: proc (self, other, preA, postB: Quat, t: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorMultiply: proc (self: Quat, b: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorAdd: proc (self, other: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorSubtract: proc (self, other: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorDivide: proc (self: Quat, divider: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorEqual: proc (self, other: Quat): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorNeg: proc (self: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Basis API + basisNewWithRows: pointer + basisNewWithAxisAndAngle: pointer + basisNewWithEuler: pointer + basisAsString: pointer + basisInverse: pointer + basisTransposed: pointer + basisOrthonormalized: pointer + basisDeterminant: pointer + basisRotated: pointer + basisScaled: pointer + basisGetScale: pointer + basisGetEuler: pointer + basisTdotx: pointer + basisTdoty: pointer + basisTdotz: pointer + basisXform: pointer + basisXformInv: pointer + basisGetOrthogonalIndex: pointer + basisNew: pointer + basisNewWithEulerQuat: pointer + basisGetElements: pointer + basisGetAxis: pointer + basisSetAxis: pointer + basisGetRow: pointer + basisSetRow: pointer + basisOperatorEqual: pointer + basisOperatorAdd: pointer + basisOperatorSubstract: pointer + basisOperatorMultiplyVector: pointer + basisOperatorMultiplyScalar: pointer + + # Vector3 API + vector3New: pointer + vector3AsString: pointer + vector3MinAxis: pointer + vector3MaxAxis: pointer + vector3Length: pointer + vector3Length_squared: pointer + vector3IsNormalized: pointer + vector3Normalized: pointer + vector3Inverse: pointer + vector3Snapped: pointer + vector3Rotated: pointer + vector3LinearInterpolate: pointer + vector3CubicInterpolate: pointer + vector3Dot: pointer + vector3Cross: pointer + vector3Outer: pointer + vector3ToDiagonalMatrix: pointer + vector3Abs: pointer + vector3Floor: pointer + vector3Ceil: pointer + vector3DistanceTo: pointer + vector3DistanceSquaredTo: pointer + vector3AngleTo: pointer + vector3Slide: pointer + vector3Bounce: pointer + vector3Reflect: pointer + vector3OperatorAdd: pointer + vector3OperatorSubstract: pointer + vector3OperatorMultiplyVector: pointer + vector3OperatorMultiplyScalar: pointer + vector3OperatorDivideVector: pointer + vector3OperatorDivideScalar: pointer + vector3OperatorEqual: pointer + vector3OperatorLess: pointer + vector3OperatorNeg: pointer + vector3SetAxis: pointer + vector3GetAxis: pointer + + # PoolByteArray API + poolByteArrayNew: proc (dest: var GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayNewCopy: proc (dest: var GodotPoolByteArray, + src: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayNewWithArray: proc (dest: var GodotPoolByteArray, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolByteArrayAppend: proc (self: var GodotPoolByteArray, + val: byte) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayAppendArray: proc (self: var GodotPoolByteArray, + arr: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolByteArrayInsert: proc (self: var GodotPoolByteArray, + idx: cint, val: byte): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayInvert: proc (self: var GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayPushBack: proc (self: var GodotPoolByteArray, val: byte) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayNewWithArray*: proc (dest: var GodotPoolStringArray, + poolByteArrayRemove: proc (self: var GodotPoolByteArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayResize: proc (self: var GodotPoolByteArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayRead: pointer + poolByteArrayWrite: pointer + poolByteArraySet: proc (self: var GodotPoolByteArray, idx: cint, data: byte) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayGet: proc (self: GodotPoolByteArray, idx: cint): byte + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArraySize: proc (self: GodotPoolByteArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayDestroy: proc (self: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # PoolIntArray API + poolIntArrayNew: proc (dest: var GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayNewCopy: proc (dest: var GodotPoolIntArray, + src: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayNewWithArray: proc (dest: var GodotPoolIntArray, src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolIntArrayAppend: proc (self: var GodotPoolIntArray, val: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayAppendArray: proc (self: var GodotPoolIntArray, + arr: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolIntArrayInsert: proc (self: var GodotPoolIntArray, idx: cint, + val: cint): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayInvert: proc (self: var GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayPushBack: proc (self: var GodotPoolIntArray, val: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayRemove: proc (self: var GodotPoolIntArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayResize: proc (self: var GodotPoolIntArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayRead: pointer + poolIntArrayWrite: pointer + poolIntArraySet: proc (self: var GodotPoolIntArray, idx: cint, data: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayGet: proc (self: GodotPoolIntArray, idx: cint): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArraySize: proc (self: GodotPoolIntArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayDestroy: proc (self: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # PoolRealArray API + poolRealArrayNew: proc (dest: var GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayNewCopy: proc (dest: var GodotPoolRealArray, + src: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayNewWithArray: proc (dest: var GodotPoolRealArray, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolRealArrayAppend: proc (self: var GodotPoolRealArray, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayAppendArray: proc (self: var GodotPoolRealArray, + arr: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolRealArrayInsert: proc (self: var GodotPoolRealArray, + idx: cint, val: float32): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayInvert: proc (self: var GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayPushBack: proc (self: var GodotPoolRealArray, val: float32) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolRealArrayRemove: proc (self: var GodotPoolRealArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayResize: proc (self: var GodotPoolRealArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayRead: pointer + poolRealArrayWrite: pointer + poolRealArraySet: proc (self: var GodotPoolRealArray, idx: cint, + data: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayGet: proc (self: GodotPoolRealArray, idx: cint): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArraySize: proc (self: GodotPoolRealArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayDestroy: proc (self: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # PoolStringArray API + poolStringArrayNew: proc (dest: var GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolStringArrayNewCopy: proc (dest: var GodotPoolStringArray, + src: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayNewWithArray: proc (dest: var GodotPoolStringArray, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayAppend: proc (self: var GodotPoolStringArray, + val: GodotString) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayAppendArray: proc (self: var GodotPoolStringArray, + arr: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayInsert: proc (self: var GodotPoolStringArray, + idx: cint, val: GodotString): Error + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayInvert: proc (self: var GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayPushBack: proc (self: var GodotPoolStringArray, + val: GodotString) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayRemove: proc (self: var GodotPoolStringArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayResize: proc (self: var GodotPoolStringArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayRead: pointer + poolStringArrayWrite: pointer + poolStringArraySet: proc (self: var GodotPoolStringArray, idx: cint, + data: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolStringArrayGet: proc (self: GodotPoolStringArray, idx: cint): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolStringArraySize: proc (self: GodotPoolStringArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolStringArrayDestroy: proc (self: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # PoolVector2 API + poolVector2ArrayNew: proc (dest: var GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArrayNewCopy: proc (dest: var GodotPoolVector2Array, + src: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayNewWithArray: proc (dest: var GodotPoolVector2Array, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayAppend: proc (self: var GodotPoolVector2Array, val: Vector2) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayAppendArray: proc (self: var GodotPoolVector2Array, + arr: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayInsert: proc (self: var GodotPoolVector2Array, idx: cint, + val: Vector2): Error + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayInvert: proc (self: var GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayPushBack: proc (self: var GodotPoolVector2Array, + val: Vector2) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayRemove: proc (self: var GodotPoolVector2Array, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayResize: proc (self: var GodotPoolVector2Array, size: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayRead: pointer + poolVector2ArrayWrite: pointer + poolVector2ArraySet: proc (self: var GodotPoolVector2Array, idx: cint, + data: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArrayGet: proc (self: GodotPoolVector2Array, idx: cint): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArraySize: proc (self: GodotPoolVector2Array): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArrayDestroy: proc (self: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # PoolVector3 API + poolVector3ArrayNew: proc (dest: var GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector3ArrayNewCopy: proc (dest: var GodotPoolVector3Array, + src: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayNewWithArray: proc (dest: var GodotPoolVector3Array, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayAppend: proc (self: var GodotPoolVector3Array, val: Vector3) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayAppendArray: proc (self: var GodotPoolVector3Array, + arr: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayInsert: proc (self: var GodotPoolVector3Array, idx: cint, + val: Vector3): Error + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayInvert: proc (self: var GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayPushBack: proc (self: var GodotPoolVector3Array, + val: Vector3) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArrayRemove: proc (self: var GodotPoolVector3Array, + idx: cint) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArrayResize: proc (self: var GodotPoolVector3Array, + size: cint) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArrayRead: pointer + poolVector3ArrayWrite: pointer + poolVector3ArraySet: proc (self: var GodotPoolVector3Array, idx: cint, + data: Vector3) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArrayGet: proc (self: GodotPoolVector3Array, idx: cint): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector3ArraySize: proc (self: GodotPoolVector3Array): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector3ArrayDestroy: proc (self: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # PoolColorArray API + poolColorArrayNew: proc (dest: var GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayNewCopy: proc (dest: var GodotPoolColorArray, + src: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolColorArrayNewWithArray: proc (dest: var GodotPoolColorArray, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolColorArrayAppend: proc (self: var GodotPoolColorArray, + val: Color) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayAppendArray: proc (self: var GodotPoolColorArray, + arr: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolColorArrayInsert: proc (self: var GodotPoolColorArray, + idx: cint, val: Color): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayInvert: proc (self: var GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayPushBack: proc (self: var GodotPoolColorArray, val: Color) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolColorArrayRemove: proc (self: var GodotPoolColorArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayResize: proc (self: var GodotPoolColorArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayRead: pointer + poolColorArrayWrite: pointer + poolColorArraySet: proc (self: var GodotPoolColorArray, idx: cint, + data: Color) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayGet: proc (self: GodotPoolColorArray, idx: cint): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArraySize: proc (self: GodotPoolColorArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayDestroy: proc (self: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # Pool Array Read Access API + + poolByteArrayReadAccessPtr: pointer + poolByteArrayReadAccessOperatorAssign: pointer + poolByteArrayReadAccessDestroy: pointer + poolIntArrayReadAccessPtr: pointer + poolIntArrayReadAccessOperatorAssign: pointer + poolIntArrayReadAccessDestroy: pointer + poolRealArrayReadAccessPtr: pointer + poolRealArrayReadAccessOperatorAssign: pointer + poolRealArrayReadAccessDestroy: pointer + poolStringArrayReadAccessPtr: pointer + poolStringArrayReadAccessOperatorAssign: pointer + poolStringArrayReadAccessDestroy: pointer + poolVector2ArrayReadAccessPtr: pointer + poolVector2ArrayReadAccessOperatorAssign: pointer + poolVector2ArrayReadAccessDestroy: pointer + poolVector3ArrayReadAccessPtr: pointer + poolVector3ArrayReadAccessOperatorAssign: pointer + poolVector3ArrayReadAccessDestroy: pointer + poolColorArrayReadAccessPtr: pointer + poolColorArrayReadAccessOperatorAssign: pointer + poolColorArrayReadAccessDestroy: pointer + + poolByteArrayWriteAccessPtr: pointer + poolByteArrayWriteAccessOperatorAssign: pointer + poolByteArrayWriteAccessDestroy: pointer + poolIntArrayWriteAccessPtr: pointer + poolIntArrayWriteAccessOperatorAssign: pointer + poolIntArrayWriteAccessDestroy: pointer + poolRealArrayWriteAccessPtr: pointer + poolRealArrayWriteAccessOperatorAssign: pointer + poolRealArrayWriteAccessDestroy: pointer + poolStringArrayWriteAccessPtr: pointer + poolStringArrayWriteAccessOperatorAssign: pointer + poolStringArrayWriteAccessDestroy: pointer + poolVector2ArrayWriteAccessPtr: pointer + poolVector2ArrayWriteAccessOperatorAssign: pointer + poolVector2ArrayWriteAccessDestroy: pointer + poolVector3ArrayWriteAccessPtr: pointer + poolVector3ArrayWriteAccessOperatorAssign: pointer + poolVector3ArrayWriteAccessDestroy: pointer + poolColorArrayWriteAccessPtr: pointer + poolColorArrayWriteAccessOperatorAssign: pointer + poolColorArrayWriteAccessDestroy: pointer + + # Array API + arrayNew: proc (dest: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayNewCopy: proc (dest: var GodotArray, src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayNewPoolColorArray: proc (dest: var GodotArray, src: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolVector3Array: proc (dest: var GodotArray, + src: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolVector2Array: proc (dest: var GodotArray, + src: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolStringArray: proc (dest: var GodotArray, + src: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolRealArray: proc (dest: var GodotArray, src: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolIntArray: proc (dest: var GodotArray, src: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayNewPoolByteArray: proc (dest: var GodotArray, src: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arraySet: proc (self: var GodotArray, idx: cint, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayGet: proc (self: GodotArray, idx: cint): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayOperatorIndex: proc (self: var GodotArray, idx: cint): ptr GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayOperatorIndexConst: pointer + arrayAppend: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayClear: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayCount: proc (self: GodotArray, val: GodotVariant): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayEmpty: proc (self: GodotArray): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayErase: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayFront: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayBack: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayFind: proc (self: GodotArray, what: GodotVariant, fromIdx: cint): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayFindLast: proc (self: GodotArray, what: GodotVariant): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayHas: proc (self: GodotArray, val: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayHash: proc (self: GodotArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayInsert: proc (self: var GodotArray, pos: cint, val: GodotVariant): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayInvert: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPopBack: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPopFront: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPushBack: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPushFront: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayRemove: proc (self: var GodotArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayResize: proc (self: var GodotArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayRFind: proc (self: GodotArray, what: GodotVariant, fromIdx: cint): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arraySize: proc (self: GodotArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arraySort: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arraySortCustom: proc (self: var GodotArray, obj: ptr GodotObject, + f: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayDestroy: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Dictionary API + dictionaryNew: proc (dest: var GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryNewCopy: proc (dest: var GodotDictionary, src: GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryDestroy: proc (self: var GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionarySize: proc (self: GodotDictionary): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryEmpty: proc (self: GodotDictionary): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryClear: proc (self: var GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryHas: proc (self: GodotDictionary, key: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryHasAll: proc (self: GodotDictionary, keys: GodotArray): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryErase: proc (self: var GodotDictionary, key: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryHash: proc (self: GodotDictionary): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryKeys: proc (self: GodotDictionary): GodotArray + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryValues: proc (self: GodotDictionary): GodotArray + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryGet: proc (self: GodotDictionary, key: GodotVariant): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionarySet: proc (self: var GodotDictionary, key, value: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryOperatorIndex: proc (self: var GodotDictionary, + key: GodotVariant): ptr GodotVariant + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + dictionaryOperatorIndexConst: pointer + dictionaryNext: proc (self: GodotDictionary, + key: GodotVariant): ptr GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryOperatorEqual: proc (self, other: GodotDictionary): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + dictionaryToJson: proc (self: GodotDictionary): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # NodePath API + nodePathNew: proc (dest: var GodotNodePath, src: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathNewCopy: proc (dest: var GodotNodePath, src: GodotNodePath) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathDestroy: proc (self: var GodotNodePath) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathAsString: proc (self: GodotNodePath): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathIsAbsolute: proc (self: GodotNodePath): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetNameCount: proc (self: GodotNodePath): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetName: proc (self: GodotNodePath, idx: cint): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetSubnameCount: proc (self: GodotNodePath): cint + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nodePathGetSubname: proc (self: GodotNodePath, idx: cint): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetProperty: proc (self: GodotNodePath): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathIsEmpty: proc (self: GodotNodePath): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathOperatorEqual: proc (self, other: GodotNodePath): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # Plane API + planeNewWithReals: proc (dest: var Plane, a, b, c, d: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeNewWithVectors: proc (dest: var Plane, v1, v2, v3: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeNewWithNormal: proc (dest: var Plane, normal: Vector3, d: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeAsString: proc (self: Plane): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeNormalized: proc (self: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeCenter: proc (self: Plane): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeGetAnyPoint: proc (self: Plane): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIsPointOver: proc (self: Plane, point: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeDistanceTo: proc (self: Plane, point: Vector3): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeHasPoint: proc (self: Plane, point: Vector3, epsilon: float32): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeProject: proc (self: Plane, point: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIntersect3: proc (self: Plane, dest: var Vector3, b, c: Plane): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIntersectsRay: proc (self: Plane, dest: var Vector3, + point, dir: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIntersectsSegment: proc (self: Plane, dest: var Vector3, + segmentBegin, segmentEnd: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + planeOperatorNeg: proc (self: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeOperatorEqual: proc (self, other: Plane): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeSetNormal: proc (self: var Plane, normal: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeGetNormal: proc (self: Plane): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeGetD: proc (self: Plane): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeSetD: proc (self: var Plane, d: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Rect2 API + rect2NewWithPositionAndSize: proc (dest: var Rect2, pos, size: Vector2) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect2New: proc (dest: var Rect2, x, y, width, height: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2AsString: proc (self: Rect2): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2GetArea: proc (self: Rect2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Intersects: proc (self, other: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Encloses: proc (self, other: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2HasNoArea: proc (self: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Clip: proc (self, other: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Merge: proc (self, other: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2HasPoint: proc (self: Rect2, point: Vector2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Grow: proc (self: Rect2, by: float32): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Expand: proc (self: Rect2, to: Vector2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2OperatorEqual: proc (self, other: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2GetPosition: proc (self: Rect2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2GetSize: proc (self: Rect2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2SetPosition: proc (self: var Rect2, pos: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2SetSize: proc (self: var Rect2, size: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Rect3 API + rect3New: proc (dest: var Rect3, pos, size: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetPosition: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3SetPosition: proc (self: var Rect3, pos: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetSize: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3SetSize: proc (self: var Rect3, pos: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3AsString: proc (self: Rect3): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetArea: proc (self: Rect3): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3HasNoArea: proc (self: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3HasNoSurface: proc (self: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Intersects: proc (self, other: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Encloses: proc (self, other: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Merge: proc (self, other: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Intersection: proc (self, other: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3IntersectsPlane: proc (self: Rect3, plane: Plane): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3IntersectsSegment: proc (self: Rect3, vFrom, vTo: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3HasPoint: proc (self: Rect3, point: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetSupport: proc (self: Rect3, dir: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetLongestAxis: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetLongestAxisIndex: proc (self: Rect3): cint + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3GetLongestAxisSize: proc (self: Rect3): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3GetShortestAxis: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetShortestAxisIndex: proc (self: Rect3): cint + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3GetShortestAxisSize: proc (self: Rect3): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3Expand: proc (self: Rect3, toPoint: Vector3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Grow: proc (self: Rect3, by: float32): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetEndpoint: proc (self: Rect3, idx: cint): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3OperatorEqual: proc (self, other: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # RID API + ridNew: proc (dest: var RID) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridGetID: proc (self: RID): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridNewWithResource: proc (dest: var RID, obj: ptr GodotObject) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridOperatorEqual: proc (self, other: RID): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridOperatorLess: proc (self, other: RID): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Transform API + transformNewWithAxisOrigin: proc (dest: var Transform, + xAxis, yAxis, zAxis, origin: Vector3) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformNew: proc (dest: var Transform, basis: Basis, origin: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformGetBasis: proc (self: Transform): Basis + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformSetBasis: proc (self: var Transform, basis: Basis) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformGetOrigin: proc (self: Transform): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformSetOrigin: proc (self: var Transform, v: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformAsString: proc (self: Transform): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformInverse: proc (self: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformAffineInverse: proc (self: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformOrthonormalized: proc (self: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformRotated: proc (self: Transform, axis: Vector3, + phi: float32): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformScaled: proc (self: Transform, scale: Vector3): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformTranslated: proc (self: Transform, offset: Vector3): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformLookingAt: proc (self: Transform, target, up: Vector3): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformXformPlane: proc (self: Transform, plane: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformXformInvPlane: proc (self: Transform, plane: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformNewIdentity: proc (dest: var Transform) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformOperatorEqual: proc (self, other: Transform): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformOperatorMultiply: proc (self, other: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformXformVector3: proc (self: Transform, v: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformXformInvVector3: proc (self: Transform, v: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformXformRect3: proc (self: Transform, v: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformXformInvRect3: proc (self: Transform, v: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # Transform2D API + transform2DNew: proc (dest: var Transform2D, rot: float32, pos: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DNewAxisOrigin: proc (dest: var Transform2D, + xAxis, yAxis, origin: Vector2) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DAsString: proc (self: Transform2D): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DInverse: proc (self: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DAffineInverse: proc (self: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DGetRotation: proc (self: Transform2D): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DGetOrigin: proc (self: Transform2D): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DGetScale: proc (self: Transform2D): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DOrthonormalized: proc (self: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DRotated: proc (self: Transform2D, phi: float32): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DScaled: proc (self: Transform2D, scale: Vector2): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DTranslated: proc (self: Transform2D, offset: Vector2): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformVector2: proc (self: Transform2D, v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformInvVector2: proc (self: Transform2D, v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DBasisXformVector2: proc (self: Transform2D, v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DBasisXformInvVector2: proc (self: Transform2D, + v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DInterpolateWith: proc (self, other: Transform2D, + t: float32): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DOperatorEqual: proc (self, other: Transform2D): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DOperatorMultiply: proc (self, other: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DNewIdentity: proc (dest: var Transform2D) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformRect2: proc (self: Transform2D, v: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformInvRect2: proc (self: Transform2D, v: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # Variant API + variantGetType: proc (v: GodotVariant): VariantType + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewCopy: proc (dest: var GodotVariant, src: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewNil: proc (dest: var GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewBool: proc (dest: var GodotVariant, val: bool) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewUInt: proc (dest: var GodotVariant, val: uint64) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewInt: proc (dest: var GodotVariant, val: int64) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewReal: proc (dest: var GodotVariant, val: float64) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewString: proc (dest: var GodotVariant, val: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewVector2: proc (dest: var GodotVariant, val: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewRect2: proc (dest: var GodotVariant, val: Rect2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewVector3: proc (dest: var GodotVariant, val: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewTransform2D: proc (dest: var GodotVariant, val: Transform2D) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPlane: proc (dest: var GodotVariant, val: Plane) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewQuat: proc (dest: var GodotVariant, val: Quat) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewRect3: proc (dest: var GodotVariant, val: Rect3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewBasis: proc (dest: var GodotVariant, val: Basis) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewTransform: proc (dest: var GodotVariant, val: Transform) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewColor: proc (dest: var GodotVariant, val: Color) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewNodePath: proc (dest: var GodotVariant, val: GodotNodePath) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewRID: proc (dest: var GodotVariant, val: RID) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewObject: proc (dest: var GodotVariant, val: ptr GodotObject) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewDictionary: proc (dest: var GodotVariant, val: GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewArray: proc (dest: var GodotVariant, val: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewPoolByteArray: proc (dest: var GodotVariant, + val: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolIntArray: proc (dest: var GodotVariant, val: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolRealArray: proc (dest: var GodotVariant, + val: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolStringArray: proc (dest: var GodotVariant, + val: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolVector2Array: proc (dest: var GodotVariant, + val: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolVector3Array: proc (dest: var GodotVariant, + val: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolColorArray: proc (dest: var GodotVariant, + val: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsBool: proc (self: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsUInt: proc (self: GodotVariant): uint64 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsInt: proc (self: GodotVariant): int64 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsReal: proc (self: GodotVariant): float64 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsString: proc (self: GodotVariant): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsVector2: proc (self: GodotVariant): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsRect2: proc (self: GodotVariant): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsVector3: proc (self: GodotVariant): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsTransform2D: proc (self: GodotVariant): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsPlane: proc (self: GodotVariant): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsQuat: proc (self: GodotVariant): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsRect3: proc (self: GodotVariant): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsBasis: proc (self: GodotVariant): Basis + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsTransform: proc (self: GodotVariant): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsColor: proc (self: GodotVariant): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsNodePath: proc (self: GodotVariant): GodotNodePath + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsRID: proc (self: GodotVariant): RID + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsObject: proc (self: GodotVariant): ptr GodotObject + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsDictionary: proc (self: GodotVariant): GodotDictionary + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsArray: proc (self: GodotVariant): GodotArray + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsPoolByteArray: proc (self: GodotVariant): GodotPoolByteArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolIntArray: proc (self: GodotVariant): GodotPoolIntArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolRealArray: proc (self: GodotVariant): GodotPoolRealArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolStringArray: proc (self: GodotVariant): GodotPoolStringArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolVector2Array: proc (self: GodotVariant): GodotPoolVector2Array + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolVector3Array: proc (self: GodotVariant): GodotPoolVector3Array + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolColorArray: proc (self: GodotVariant): GodotPoolColorArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantCall: proc (self: var GodotVariant, meth: GodotString, + args: ptr array[MAX_ARG_COUNT, ptr GodotVariant], + argcount: cint, + callError: var VariantCallError): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantHasMethod: proc (self: GodotVariant, meth: GodotString): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantOperatorEqual: proc (self, other: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantOperatorLess: proc (self, other: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantHashCompare: proc (self, other: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantBooleanize: proc (self: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantDestroy: proc (self: var GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # String API + stringNew: proc (dest: var GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringNewCopy: proc (dest: var GodotString, src: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringNewData: proc (dest: var GodotString, contents: cstring, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringNewUTF16Data: pointer + stringGetData: proc (self: GodotString, dest: cstring, size: var cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringOperatorIndex: pointer + stringCStr: proc (self: GodotString): cstring + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringOperatorIndexConst: pointer + stringUTF16Str: pointer + stringOperatorEqual: proc (self, other: GodotString): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringOperatorLess: proc (self, other: GodotString): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringOperatorPlus: proc (self, other: GodotString): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringLength: proc (self: GodotString): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringBeginsWith: pointer + stringBeginsWithCharArray: pointer + stringBigrams: pointer + stringChr: pointer + stringEndsWith: pointer + stringFind: pointer + stringFindFrom: pointer + stringFindmk: pointer + stringFindmkFrom: pointer + stringFindmkFromInPlace: pointer + stringFindn: pointer + stringFindnFrom: pointer + stringFindLast: pointer + stringFormat: pointer + stringFormatWithCustomPlaceholder: pointer + stringHexEncodeBuffer: pointer + stringHexToInt: pointer + stringHexToIntWithoutPrefix: pointer + stringInsert: pointer + stringIsNumeric: pointer + stringIsSubsequenceOf: pointer + stringIsSubsequenceOfi: pointer + stringLpad: pointer + stringLpadWithCustomCharacter: pointer + stringMatch: pointer + stringMatchn: pointer + stringMd5: pointer + stringNum: pointer + stringNumInt64: pointer + stringNumInt64Capitalized: pointer + stringNumReal: pointer + stringNumScientific: pointer + stringNumWithDecimals: pointer + stringPadDecimals: pointer + stringPadZeros: pointer + stringReplaceFirst: pointer + stringReplace: pointer + stringReplacen: pointer + stringRfind: pointer + stringRfindn: pointer + stringRfindFrom: pointer + stringRfindnFrom: pointer + stringRpad: pointer + stringRpadWithCustomCharacter: pointer + stringSimilarity: pointer + stringSprintf: pointer + stringSubstr: pointer + stringToDouble: pointer + stringToFloat: pointer + stringToInt: pointer + stringCamelcaseToUnderscore: pointer + stringCamelcaseToUnderscoreLowercased: pointer + stringCapitalize: pointer + stringCharToDouble: pointer + stringCharToInt: pointer + stringWcharToInt: pointer + stringCharToIntWithLen: pointer + stringCharToInt64WithLen: pointer + stringHexToInt64: pointer + stringHexToInt64WithPrefix: pointer + stringToInt64: pointer + stringUnicodeCharToDouble: pointer + stringGetSliceCount: pointer + stringGetSlice: pointer + stringGetSlicec: pointer + stringSplit: pointer + stringSplitAllowEmpty: pointer + stringSplitFloats: pointer + stringSplitFloatsAllowsEmpty: pointer + stringSplitFloatsMk: pointer + stringSplitFloatsMkAllowsEmpty: pointer + stringSplitInts: pointer + stringSplitIntsAllowsEmpty: pointer + stringSplitIntsMk: pointer + stringSplitIntsMkAllowsEmpty: pointer + stringSplitSpaces: pointer + stringCharLowercase: pointer + stringCharUppercase: pointer + stringToLower: pointer + stringToUpper: pointer + stringGetBasename: pointer + stringGetExtension: pointer + stringLeft: pointer + stringOrdAt: pointer + stringPlusFile: pointer + stringRight: pointer + stringStripEdges: pointer + stringStripEscapes: pointer + stringErase: pointer + stringAscii: pointer + stringAsciiExtended: pointer + stringUtf8: pointer + stringParseUtf8: pointer + stringParseUtf8WithLen: pointer + stringCharsToUtf8: pointer + stringCharsToUtf8WithLen: pointer + stringHash: pointer + stringHash64: pointer + stringHashChars: pointer + stringHashCharsWithLen: pointer + stringHashUtf8Chars: pointer + stringHashUtf8CharsWithLen: pointer + stringMd5Buffer: pointer + stringMd5Text: pointer + stringSha256Buffer: pointer + stringSha256Text: pointer + stringEmpty: pointer + stringGetBaseDir: pointer + stringGetFile: pointer + stringHumanizeSize: pointer + stringIsAbsPath: pointer + stringIsRelPath: pointer + stringIsResourceFile: pointer + stringPathTo: pointer + stringPathToFile: pointer + stringSimplifyPath: pointer + stringCEscape: pointer + stringCEscapeMultiline: pointer + stringCUnescape: pointer + stringHttpEscape: pointer + stringHttpUnescape: pointer + stringJsonEscape: pointer + stringWordWrap: pointer + stringXmlEscape: pointer + stringXmlEscapeWithQuotes: pointer + stringXmlUnescape: pointer + stringPercentDecode: pointer + stringPercentEncode: pointer + stringIsValidFloat: pointer + stringIsValidHexNumber: pointer + stringIsValidHtmlColor: pointer + stringIsValidIdentifier: pointer + stringIsValidInteger: pointer + stringIsValidIpAddress: pointer + stringDestroy: proc (self: var GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # StringName API + stringNameNew: pointer + stringNameNewData: pointer + stringNameGetName: pointer + stringNameGetHash: pointer + stringNameGetDataUniquePointer: pointer + stringNameOperatorEqual: pointer + stringNameOperatorLess: pointer + stringNameDestroy: pointer + + # Misc API + objectDestroy: proc (self: ptr GodotObject) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + globalGetSingleton: proc (name: cstring): ptr GodotObject + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + methodBindGetMethod: proc (className, + methodName: cstring): ptr GodotMethodBind + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + methodBindPtrCall: proc (methodBind: ptr GodotMethodBind, + obj: ptr GodotObject, + args: ptr array[MAX_ARG_COUNT, pointer], + ret: pointer) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + methodBindCall: proc (methodBind: ptr GodotMethodBind, obj: ptr GodotObject, + args: ptr array[MAX_ARG_COUNT, ptr GodotVariant], + argCount: cint, + callError: var VariantCallError): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + getClassConstructor: proc (className: cstring): GodotClassConstructor + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + alloc: proc (bytes: cint): pointer + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + realloc: proc (p: pointer, bytes: cint): pointer + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + free: proc (p: pointer) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + printError: proc (description, function, file: cstring, line: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + printWarning: proc (description, function, file: cstring, line: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + print: proc (message: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + GDNativeAPI* = object + # Color API + colorNewRGBA*: proc (dest: var Color, r, g, b, a: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorNewRGB*: proc (dest: var Color, r, g, b: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetR*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorSetR*: proc (self: var Color, r: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetG*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorSetG*: proc (self: var Color, g: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetB*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorSetB*: proc (self: var Color, b: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetA*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorSetA*: proc (self: var Color, a: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetH*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetS*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGetV*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorAsString*: proc (self: Color): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorToRGBA32*: proc (self: Color): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorAsARGB32*: proc (self: Color): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorGray*: proc (self: Color): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorInverted*: proc (self: Color): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorContrasted*: proc (self: Color): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorLinearInterpolate*: proc (self, other: Color, t: float32): Color + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + colorBlend*: proc (self, other: Color): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorToHtml*: proc (self: Color, withAlpha: bool): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorOperatorEqual*: proc (self, other: Color): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + colorOperatorLess*: proc (self, other: Color): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Vector2 API + vector2New*: proc (dest: var Vector2, x, y: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2AsString*: proc (self: Vector2): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Normalized*: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Length*: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Angle*: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2LengthSquared*: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2IsNormalized*: proc (self: Vector2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2DistanceTo*: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2DistanceSquaredTo*: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2AngleTo*: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2AngleToPoint*: proc (self, to: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2LinearInterpolate*: proc (self, b: Vector2, t: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2CubicInterpolate*: proc (self, b, preA, postB: Vector2, + t: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2Rotated*: proc (self: Vector2, phi: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Tangent*: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Floor*: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Snapped*: proc (self, by: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Aspect*: proc (self: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Dot*: proc (self, other: Vector2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Slide*: proc (self, n: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Bounce*: proc (self, n: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Reflect*: proc (self, n: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Abs*: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2Clamped*: proc (self: Vector2, length: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2OperatorAdd*: proc (self, other: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2OperatorSubtract*: proc (self, other: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorMultiplyVector*: proc (self, other: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorMultiplyScalar*: proc (self: Vector2, scalar: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorDivideVector*: proc (self, other: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorDivideScalar*: proc (self: Vector2, scalar: float32): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + vector2OperatorEqual*: proc (self, other: Vector2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2OperatorLess*: proc (self, other: Vector2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + vector2OperatorNeg*: proc (self: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Quat API + quatNew*: proc (dest: var Quat, x, y, z, w: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatNewWithAxisAngle*: proc (dest: Quat, axis: Vector3, + angle: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetX*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetX*: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetY*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetY*: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetZ*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetZ*: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatGetW*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSetW*: proc (self: var Quat, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatAsString*: proc (self: Quat): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatLength*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatLengthSquared*: proc (self: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatNormalized*: proc (self: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatIsNormalized*: proc (self: Quat): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatInverse*: proc (self: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatDot*: proc (self, other: Quat): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatXform*: proc (self: Quat, v: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSlerp*: proc (self, other: Quat, t: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatSlerpni*: proc (self, other: Quat, t: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatCubicSlerp*: proc (self, other, preA, postB: Quat, t: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorMultiply*: proc (self: Quat, b: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorAdd*: proc (self, other: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorSubtract*: proc (self, other: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorDivide*: proc (self: Quat, divider: float32): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorEqual*: proc (self, other: Quat): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + quatOperatorNeg*: proc (self: Quat): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # PoolByteArray API + poolByteArrayNew*: proc (dest: var GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayNewCopy*: proc (dest: var GodotPoolByteArray, + src: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayNewWithArray*: proc (dest: var GodotPoolByteArray, src: GodotArray) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayAppend*: proc (self: var GodotPoolStringArray, - val: GodotString) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolStringArrayAppendArray*: proc (self: var GodotPoolStringArray, - arr: GodotPoolStringArray) + poolByteArrayAppend*: proc (self: var GodotPoolByteArray, + val: byte) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayAppendArray*: proc (self: var GodotPoolByteArray, + arr: GodotPoolByteArray) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayInsert*: proc (self: var GodotPoolStringArray, - idx: cint, val: GodotString): Error - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolStringArrayInvert*: proc (self: var GodotPoolStringArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolStringArrayPushBack*: proc (self: var GodotPoolStringArray, + poolByteArrayInsert*: proc (self: var GodotPoolByteArray, + idx: cint, val: byte): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayInvert*: proc (self: var GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayPushBack*: proc (self: var GodotPoolByteArray, val: byte) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolByteArrayRemove*: proc (self: var GodotPoolByteArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayResize*: proc (self: var GodotPoolByteArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArraySet*: proc (self: var GodotPoolByteArray, idx: cint, data: byte) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayGet*: proc (self: GodotPoolByteArray, idx: cint): byte + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArraySize*: proc (self: GodotPoolByteArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolByteArrayDestroy*: proc (self: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # PoolIntArray API + poolIntArrayNew*: proc (dest: var GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayNewCopy*: proc (dest: var GodotPoolIntArray, + src: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayNewWithArray*: proc (dest: var GodotPoolIntArray, src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolIntArrayAppend*: proc (self: var GodotPoolIntArray, val: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayAppendArray*: proc (self: var GodotPoolIntArray, + arr: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolIntArrayInsert*: proc (self: var GodotPoolIntArray, idx: cint, + val: cint): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayInvert*: proc (self: var GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayPushBack*: proc (self: var GodotPoolIntArray, val: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayRemove*: proc (self: var GodotPoolIntArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayResize*: proc (self: var GodotPoolIntArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArraySet*: proc (self: var GodotPoolIntArray, idx: cint, data: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayGet*: proc (self: GodotPoolIntArray, idx: cint): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArraySize*: proc (self: GodotPoolIntArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolIntArrayDestroy*: proc (self: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # PoolRealArray API + poolRealArrayNew*: proc (dest: var GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayNewCopy*: proc (dest: var GodotPoolRealArray, + src: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayNewWithArray*: proc (dest: var GodotPoolRealArray, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolRealArrayAppend*: proc (self: var GodotPoolRealArray, val: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayAppendArray*: proc (self: var GodotPoolRealArray, + arr: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolRealArrayInsert*: proc (self: var GodotPoolRealArray, + idx: cint, val: float32): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayInvert*: proc (self: var GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayPushBack*: proc (self: var GodotPoolRealArray, val: float32) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolRealArrayRemove*: proc (self: var GodotPoolRealArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayResize*: proc (self: var GodotPoolRealArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArraySet*: proc (self: var GodotPoolRealArray, idx: cint, + data: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayGet*: proc (self: GodotPoolRealArray, idx: cint): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArraySize*: proc (self: GodotPoolRealArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolRealArrayDestroy*: proc (self: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # PoolStringArray API + poolStringArrayNew*: proc (dest: var GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolStringArrayNewCopy*: proc (dest: var GodotPoolStringArray, + src: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayNewWithArray*: proc (dest: var GodotPoolStringArray, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayAppend*: proc (self: var GodotPoolStringArray, val: GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayRemove*: proc (self: var GodotPoolStringArray, idx: cint) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolStringArrayResize*: proc (self: var GodotPoolStringArray, size: cint) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolStringArrayRead: pointer - poolStringArrayWrite: pointer - poolStringArraySet*: proc (self: var GodotPoolStringArray, idx: cint, - data: GodotString) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayGet*: proc (self: GodotPoolStringArray, idx: cint): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArraySize*: proc (self: GodotPoolStringArray): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayDestroy*: proc (self: GodotPoolStringArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - - # PoolVector2 API - poolVector2ArrayNew*: proc (dest: var GodotPoolVector2Array) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayNewCopy*: proc (dest: var GodotPoolVector2Array, - src: GodotPoolVector2Array) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector2ArrayNewWithArray*: proc (dest: var GodotPoolVector2Array, - src: GodotArray) + poolStringArrayAppendArray*: proc (self: var GodotPoolStringArray, + arr: GodotPoolStringArray) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayAppend*: proc (self: var GodotPoolVector2Array, val: Vector2) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector2ArrayAppendArray*: proc (self: var GodotPoolVector2Array, - arr: GodotPoolVector2Array) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector2ArrayInsert*: proc (self: var GodotPoolVector2Array, idx: cint, - val: Vector2): Error - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector2ArrayInvert*: proc (self: var GodotPoolVector2Array) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector2ArrayPushBack*: proc (self: var GodotPoolVector2Array, - val: Vector2) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector2ArrayRemove*: proc (self: var GodotPoolVector2Array, idx: cint) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector2ArrayResize*: proc (self: var GodotPoolVector2Array, size: cint) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector2ArrayRead: pointer - poolVector2ArrayWrite: pointer - poolVector2ArraySet*: proc (self: var GodotPoolVector2Array, idx: cint, - data: Vector2) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayGet*: proc (self: GodotPoolVector2Array, idx: cint): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArraySize*: proc (self: GodotPoolVector2Array): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayDestroy*: proc (self: GodotPoolVector2Array) + poolStringArrayInsert*: proc (self: var GodotPoolStringArray, + idx: cint, val: GodotString): Error {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - # PoolVector3 API - poolVector3ArrayNew*: proc (dest: var GodotPoolVector3Array) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayNewCopy*: proc (dest: var GodotPoolVector3Array, - src: GodotPoolVector3Array) + poolStringArrayInvert*: proc (self: var GodotPoolStringArray) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayNewWithArray*: proc (dest: var GodotPoolVector3Array, - src: GodotArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector3ArrayAppend*: proc (self: var GodotPoolVector3Array, val: Vector3) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector3ArrayAppendArray*: proc (self: var GodotPoolVector3Array, - arr: GodotPoolVector3Array) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector3ArrayInsert*: proc (self: var GodotPoolVector3Array, idx: cint, - val: Vector3): Error - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector3ArrayInvert*: proc (self: var GodotPoolVector3Array) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolVector3ArrayPushBack*: proc (self: var GodotPoolVector3Array, - val: Vector3) {.noconv, raises: [], gcsafe, - tags: [], locks: 0.} - poolVector3ArrayRemove*: proc (self: var GodotPoolVector3Array, - idx: cint) {.noconv, raises: [], gcsafe, - tags: [], locks: 0.} - poolVector3ArrayResize*: proc (self: var GodotPoolVector3Array, - size: cint) {.noconv, raises: [], gcsafe, - tags: [], locks: 0.} - poolVector3ArrayRead: pointer - poolVector3ArrayWrite: pointer - poolVector3ArraySet*: proc (self: var GodotPoolVector3Array, idx: cint, - data: Vector3) {.noconv, raises: [], gcsafe, - tags: [], locks: 0.} - poolVector3ArrayGet*: proc (self: GodotPoolVector3Array, idx: cint): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArraySize*: proc (self: GodotPoolVector3Array): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayDestroy*: proc (self: GodotPoolVector3Array) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - - # PoolColorArray API - poolColorArrayNew*: proc (dest: var GodotPoolColorArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayNewCopy*: proc (dest: var GodotPoolColorArray, - src: GodotPoolColorArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolColorArrayNewWithArray*: proc (dest: var GodotPoolColorArray, - src: GodotArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolColorArrayAppend*: proc (self: var GodotPoolColorArray, - val: Color) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayAppendArray*: proc (self: var GodotPoolColorArray, - arr: GodotPoolColorArray) + poolStringArrayPushBack*: proc (self: var GodotPoolStringArray, + val: GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayInsert*: proc (self: var GodotPoolColorArray, - idx: cint, val: Color): Error + poolStringArrayRemove*: proc (self: var GodotPoolStringArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArrayResize*: proc (self: var GodotPoolStringArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolStringArraySet*: proc (self: var GodotPoolStringArray, idx: cint, + data: GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayInvert*: proc (self: var GodotPoolColorArray) + poolStringArrayGet*: proc (self: GodotPoolStringArray, idx: cint): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayPushBack*: proc (self: var GodotPoolColorArray, val: Color) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - poolColorArrayRemove*: proc (self: var GodotPoolColorArray, idx: cint) + poolStringArraySize*: proc (self: GodotPoolStringArray): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayResize*: proc (self: var GodotPoolColorArray, size: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayRead: pointer - poolColorArrayWrite: pointer - poolColorArraySet*: proc (self: var GodotPoolColorArray, idx: cint, - data: Color) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayGet*: proc (self: GodotPoolColorArray, idx: cint): Color - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArraySize*: proc (self: GodotPoolColorArray): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayDestroy*: proc (self: GodotPoolColorArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - - # Pool Array Read Access API - - poolByteArrayReadAccessPtr: pointer - poolByteArrayReadAccessOperatorAssign: pointer - poolByteArrayReadAccessDestroy: pointer - poolIntArrayReadAccessPtr: pointer - poolIntArrayReadAccessOperatorAssign: pointer - poolIntArrayReadAccessDestroy: pointer - poolRealArrayReadAccessPtr: pointer - poolRealArrayReadAccessOperatorAssign: pointer - poolRealArrayReadAccessDestroy: pointer - poolStringArrayReadAccessPtr: pointer - poolStringArrayReadAccessOperatorAssign: pointer - poolStringArrayReadAccessDestroy: pointer - poolVector2ArrayReadAccessPtr: pointer - poolVector2ArrayReadAccessOperatorAssign: pointer - poolVector2ArrayReadAccessDestroy: pointer - poolVector3ArrayReadAccessPtr: pointer - poolVector3ArrayReadAccessOperatorAssign: pointer - poolVector3ArrayReadAccessDestroy: pointer - poolColorArrayReadAccessPtr: pointer - poolColorArrayReadAccessOperatorAssign: pointer - poolColorArrayReadAccessDestroy: pointer - - poolByteArrayWriteAccessPtr: pointer - poolByteArrayWriteAccessOperatorAssign: pointer - poolByteArrayWriteAccessDestroy: pointer - poolIntArrayWriteAccessPtr: pointer - poolIntArrayWriteAccessOperatorAssign: pointer - poolIntArrayWriteAccessDestroy: pointer - poolRealArrayWriteAccessPtr: pointer - poolRealArrayWriteAccessOperatorAssign: pointer - poolRealArrayWriteAccessDestroy: pointer - poolStringArrayWriteAccessPtr: pointer - poolStringArrayWriteAccessOperatorAssign: pointer - poolStringArrayWriteAccessDestroy: pointer - poolVector2ArrayWriteAccessPtr: pointer - poolVector2ArrayWriteAccessOperatorAssign: pointer - poolVector2ArrayWriteAccessDestroy: pointer - poolVector3ArrayWriteAccessPtr: pointer - poolVector3ArrayWriteAccessOperatorAssign: pointer - poolVector3ArrayWriteAccessDestroy: pointer - poolColorArrayWriteAccessPtr: pointer - poolColorArrayWriteAccessOperatorAssign: pointer - poolColorArrayWriteAccessDestroy: pointer - - # Array API - arrayNew*: proc (dest: var GodotArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayNewCopy*: proc (dest: var GodotArray, src: GodotArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayNewPoolColorArray*: proc (dest: var GodotArray, src: GodotPoolColorArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - arrayNewPoolVector3Array*: proc (dest: var GodotArray, - src: GodotPoolVector3Array) + poolStringArrayDestroy*: proc (self: GodotPoolStringArray) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayNewPoolVector2Array*: proc (dest: var GodotArray, - src: GodotPoolVector2Array) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - arrayNewPoolStringArray*: proc (dest: var GodotArray, - src: GodotPoolStringArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - arrayNewPoolRealArray*: proc (dest: var GodotArray, src: GodotPoolRealArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - arrayNewPoolIntArray*: proc (dest: var GodotArray, src: GodotPoolIntArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayNewPoolByteArray*: proc (dest: var GodotArray, src: GodotPoolByteArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - arraySet*: proc (self: var GodotArray, idx: cint, val: GodotVariant) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayGet*: proc (self: GodotArray, idx: cint): GodotVariant - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayOperatorIndex*: proc (self: var GodotArray, idx: cint): ptr GodotVariant - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayAppend*: proc (self: var GodotArray, val: GodotVariant) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayClear*: proc (self: var GodotArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayCount*: proc (self: GodotArray, val: GodotVariant): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayEmpty*: proc (self: GodotArray): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayErase*: proc (self: var GodotArray, val: GodotVariant) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayFront*: proc (self: GodotArray): GodotVariant - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayBack*: proc (self: GodotArray): GodotVariant - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayFind*: proc (self: GodotArray, what: GodotVariant, fromIdx: cint): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayFindLast*: proc (self: GodotArray, what: GodotVariant): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayHas*: proc (self: GodotArray, val: GodotVariant): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayHash*: proc (self: GodotArray): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayInsert*: proc (self: var GodotArray, pos: cint, val: GodotVariant): Error - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayInvert*: proc (self: var GodotArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayPopFront*: proc (self: GodotArray): GodotVariant - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayPopBack*: proc (self: GodotArray): GodotVariant - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayPushBack*: proc (self: var GodotArray, val: GodotVariant) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayPushFront*: proc (self: var GodotArray, val: GodotVariant) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayRemove*: proc (self: var GodotArray, idx: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayResize*: proc (self: var GodotArray, size: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayRFind*: proc (self: GodotArray, what: GodotVariant, fromIdx: cint): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arraySize*: proc (self: GodotArray): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arraySort*: proc (self: var GodotArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arraySortCustom*: proc (self: var GodotArray, obj: ptr GodotObject, - f: GodotString) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - arrayDestroy*: proc (self: var GodotArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - # Dictionary API - dictionaryNew*: proc (dest: var GodotDictionary) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryNewCopy*: proc (dest: var GodotDictionary, src: GodotDictionary) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryDestroy*: proc (self: var GodotDictionary) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionarySize*: proc (self: GodotDictionary): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryEmpty*: proc (self: GodotDictionary): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryClear*: proc (self: var GodotDictionary) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryHas*: proc (self: GodotDictionary, key: GodotVariant): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryHasAll*: proc (self: GodotDictionary, keys: GodotArray): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryErase*: proc (self: var GodotDictionary, key: GodotVariant) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryHash*: proc (self: GodotDictionary): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryKeys*: proc (self: GodotDictionary): GodotArray - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryValues*: proc (self: GodotDictionary): GodotArray - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryGet*: proc (self: GodotDictionary, key: GodotVariant): GodotVariant - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionarySet*: proc (self: var GodotDictionary, key, value: GodotVariant) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryOperatorIndex*: proc (self: var GodotDictionary, - key: GodotVariant): ptr GodotVariant - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - dictionaryNext*: proc (self: GodotDictionary, - key: GodotVariant): ptr GodotVariant - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - dictionaryOperatorEqual*: proc (self, other: GodotDictionary): bool - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - dictionaryToJson*: proc (self: GodotDictionary): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - # NodePath API - nodePathNew*: proc (dest: var GodotNodePath, src: GodotString) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathNewCopy*: proc (dest: var GodotNodePath, src: GodotNodePath) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathDestroy*: proc (self: var GodotNodePath) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathAsString*: proc (self: GodotNodePath): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathIsAbsolute*: proc (self: GodotNodePath): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathGetNameCount*: proc (self: GodotNodePath): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathGetName*: proc (self: GodotNodePath, idx: cint): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathGetSubnameCount*: proc (self: GodotNodePath): cint - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - nodePathGetSubname*: proc (self: GodotNodePath, idx: cint): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathGetProperty*: proc (self: GodotNodePath): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathIsEmpty*: proc (self: GodotNodePath): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathOperatorEqual*: proc (self, other: GodotNodePath): bool - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - - # Plane API - planeNewWithReals*: proc (dest: var Plane, a, b, c, d: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeNewWithVectors*: proc (dest: var Plane, v1, v2, v3: Vector3) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeNewWithNormal*: proc (dest: var Plane, normal: Vector3, d: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeAsString*: proc (self: Plane): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeNormalized*: proc (self: Plane): Plane - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeCenter*: proc (self: Plane): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeGetAnyPoint*: proc (self: Plane): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeIsPointOver*: proc (self: Plane, point: Vector3): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeDistanceTo*: proc (self: Plane, point: Vector3): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeHasPoint*: proc (self: Plane, point: Vector3, epsilon: float32): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeProject*: proc (self: Plane, point: Vector3): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeIntersect3*: proc (self: Plane, dest: var Vector3, b, c: Plane): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeIntersectsRay*: proc (self: Plane, dest: var Vector3, - point, dir: Vector3): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeIntersectsSegment*: proc (self: Plane, dest: var Vector3, - segmentBegin, segmentEnd: Vector3): bool - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - planeOperatorNeg*: proc (self: Plane): Plane - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeOperatorEqual*: proc (self, other: Plane): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeSetNormal*: proc (self: var Plane, normal: Vector3) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeGetNormal*: proc (self: Plane): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeGetD*: proc (self: Plane): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeSetD*: proc (self: var Plane, d: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - # Rect2 API - rect2NewWithPositionAndSize*: proc (dest: var Rect2, pos, size: Vector2) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - rect2New*: proc (dest: var Rect2, x, y, width, height: float32) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2AsString*: proc (self: Rect2): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2GetArea*: proc (self: Rect2): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Intersects*: proc (self, other: Rect2): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Encloses*: proc (self, other: Rect2): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2HasNoArea*: proc (self: Rect2): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Clip*: proc (self, other: Rect2): Rect2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Merge*: proc (self, other: Rect2): Rect2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2HasPoint*: proc (self: Rect2, point: Vector2): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Grow*: proc (self: Rect2, by: float32): Rect2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Expand*: proc (self: Rect2, to: Vector2): Rect2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2OperatorEqual*: proc (self, other: Rect2): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2GetPosition*: proc (self: Rect2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2GetSize*: proc (self: Rect2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2SetPosition*: proc (self: var Rect2, pos: Vector2) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2SetSize*: proc (self: var Rect2, size: Vector2) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - # Rect3 API - rect3New*: proc (dest: var Rect3, pos, size: Vector3) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetPosition*: proc (self: Rect3): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3SetPosition*: proc (self: var Rect3, pos: Vector3) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetSize*: proc (self: Rect3): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3SetSize*: proc (self: var Rect3, pos: Vector3) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3AsString*: proc (self: Rect3): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetArea*: proc (self: Rect3): float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3HasNoArea*: proc (self: Rect3): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3HasNoSurface*: proc (self: Rect3): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Intersects*: proc (self, other: Rect3): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Encloses*: proc (self, other: Rect3): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Merge*: proc (self, other: Rect3): Rect3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Intersection*: proc (self, other: Rect3): Rect3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3IntersectsPlane*: proc (self: Rect3, plane: Plane): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3IntersectsSegment*: proc (self: Rect3, vFrom, vTo: Vector3): bool - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - rect3HasPoint*: proc (self: Rect3, point: Vector3): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetSupport*: proc (self: Rect3, dir: Vector3): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetLongestAxis*: proc (self: Rect3): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetLongestAxisIndex*: proc (self: Rect3): cint - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - rect3GetLongestAxisSize*: proc (self: Rect3): float32 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - rect3GetShortestAxis*: proc (self: Rect3): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetShortestAxisIndex*: proc (self: Rect3): cint + # PoolVector2 API + poolVector2ArrayNew*: proc (dest: var GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArrayNewCopy*: proc (dest: var GodotPoolVector2Array, + src: GodotPoolVector2Array) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetShortestAxisSize*: proc (self: Rect3): float32 + poolVector2ArrayNewWithArray*: proc (dest: var GodotPoolVector2Array, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayAppend*: proc (self: var GodotPoolVector2Array, val: Vector2) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Expand*: proc (self: Rect3, toPoint: Vector3): Rect3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Grow*: proc (self: Rect3, by: float32): Rect3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetEndpoint*: proc (self: Rect3, idx: cint): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3OperatorEqual*: proc (self, other: Rect3): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - # RID API - ridNew*: proc (dest: var RID) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - ridGetID*: proc (self: RID): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - ridNewWithResource*: proc (dest: var RID, obj: ptr GodotObject) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - ridOperatorEqual*: proc (self, other: RID): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - ridOperatorLess*: proc (self, other: RID): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - # Transform API - transformNewWithAxisOrigin*: proc (dest: var Transform, - xAxis, yAxis, zAxis, origin: Vector3) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transformNew*: proc (dest: var Transform, basis: Basis, origin: Vector3) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformGetBasis*: proc (self: Transform): Basis - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformSetBasis*: proc (self: var Transform, basis: Basis) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformGetOrigin*: proc (self: Transform): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformSetOrigin*: proc (self: var Transform, v: Vector3) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformAsString*: proc (self: Transform): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformInverse*: proc (self: Transform): Transform - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformAffineInverse*: proc (self: Transform): Transform - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transformOrthonormalized*: proc (self: Transform): Transform - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transformRotated*: proc (self: Transform, axis: Vector3, - phi: float32): Transform - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformScaled*: proc (self: Transform, scale: Vector3): Transform - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformTranslated*: proc (self: Transform, offset: Vector3): Transform - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformLookingAt*: proc (self: Transform, target, up: Vector3): Transform - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformPlane*: proc (self: Transform, plane: Plane): Plane - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvPlane*: proc (self: Transform, plane: Plane): Plane - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transformNewIdentity*: proc (dest: var Transform) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformOperatorEqual*: proc (self, other: Transform): bool - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transformOperatorMultiply*: proc (self, other: Transform): Transform - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transformXformVector3*: proc (self: Transform, v: Vector3): Vector3 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transformXformInvVector3*: proc (self: Transform, v: Vector3): Vector3 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transformXformRect3*: proc (self: Transform, v: Rect3): Rect3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvRect3*: proc (self: Transform, v: Rect3): Rect3 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - - # Transform2D API - transform2DNew*: proc (dest: var Transform2D, rot: float32, pos: Vector2) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DNewAxisOrigin*: proc (dest: var Transform2D, - xAxis, yAxis, origin: Vector2) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DAsString*: proc (self: Transform2D): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DInverse*: proc (self: Transform2D): Transform2D - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DAffineInverse*: proc (self: Transform2D): Transform2D - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DGetRotation*: proc (self: Transform2D): float32 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DGetOrigin*: proc (self: Transform2D): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DGetScale*: proc (self: Transform2D): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DOrthonormalized*: proc (self: Transform2D): Transform2D - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DRotated*: proc (self: Transform2D, phi: float32): Transform2D - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DScaled*: proc (self: Transform2D, scale: Vector2): Transform2D - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DTranslated*: proc (self: Transform2D, offset: Vector2): Transform2D - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DXformVector2*: proc (self: Transform2D, v: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DXformInvVector2*: proc (self: Transform2D, v: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DBasisXformVector2*: proc (self: Transform2D, v: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DBasisXformInvVector2*: proc (self: Transform2D, - v: Vector2): Vector2 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DInterpolateWith*: proc (self, other: Transform2D, - t: float32): Transform2D - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DOperatorEqual*: proc (self, other: Transform2D): bool - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DOperatorMultiply*: proc (self, other: Transform2D): Transform2D - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DNewIdentity*: proc (dest: var Transform2D) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DXformRect2*: proc (self: Transform2D, v: Rect2): Rect2 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - transform2DXformInvRect2*: proc (self: Transform2D, v: Rect2): Rect2 - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - - # Variant API - variantGetType*: proc (v: GodotVariant): VariantType - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewCopy*: proc (dest: var GodotVariant, src: GodotVariant) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewNil*: proc (dest: var GodotVariant) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewBool*: proc (dest: var GodotVariant, val: bool) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewUInt*: proc (dest: var GodotVariant, val: uint64) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewInt*: proc (dest: var GodotVariant, val: int64) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewReal*: proc (dest: var GodotVariant, val: float64) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewString*: proc (dest: var GodotVariant, val: GodotString) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewVector2*: proc (dest: var GodotVariant, val: Vector2) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewRect2*: proc (dest: var GodotVariant, val: Rect2) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewVector3*: proc (dest: var GodotVariant, val: Vector3) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewTransform2D*: proc (dest: var GodotVariant, val: Transform2D) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantNewPlane*: proc (dest: var GodotVariant, val: Plane) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewQuat*: proc (dest: var GodotVariant, val: Quat) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewRect3*: proc (dest: var GodotVariant, val: Rect3) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewBasis*: proc (dest: var GodotVariant, val: Basis) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewTransform*: proc (dest: var GodotVariant, val: Transform) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewColor*: proc (dest: var GodotVariant, val: Color) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewNodePath*: proc (dest: var GodotVariant, val: GodotNodePath) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewRID*: proc (dest: var GodotVariant, val: RID) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewObject*: proc (dest: var GodotVariant, val: ptr GodotObject) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewDictionary*: proc (dest: var GodotVariant, val: GodotDictionary) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewArray*: proc (dest: var GodotVariant, val: GodotArray) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewPoolByteArray*: proc (dest: var GodotVariant, - val: GodotPoolByteArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantNewPoolIntArray*: proc (dest: var GodotVariant, val: GodotPoolIntArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantNewPoolRealArray*: proc (dest: var GodotVariant, - val: GodotPoolRealArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantNewPoolStringArray*: proc (dest: var GodotVariant, - val: GodotPoolStringArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantNewPoolVector2Array*: proc (dest: var GodotVariant, - val: GodotPoolVector2Array) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantNewPoolVector3Array*: proc (dest: var GodotVariant, - val: GodotPoolVector3Array) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantNewPoolColorArray*: proc (dest: var GodotVariant, - val: GodotPoolColorArray) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantAsBool*: proc (self: GodotVariant): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsUInt*: proc (self: GodotVariant): uint64 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsInt*: proc (self: GodotVariant): int64 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsReal*: proc (self: GodotVariant): float64 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsString*: proc (self: GodotVariant): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsVector2*: proc (self: GodotVariant): Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsRect2*: proc (self: GodotVariant): Rect2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsVector3*: proc (self: GodotVariant): Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsTransform2D*: proc (self: GodotVariant): Transform2D - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsPlane*: proc (self: GodotVariant): Plane - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsQuat*: proc (self: GodotVariant): Quat - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsRect3*: proc (self: GodotVariant): Rect3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsBasis*: proc (self: GodotVariant): Basis - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsTransform*: proc (self: GodotVariant): Transform - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsColor*: proc (self: GodotVariant): Color - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsNodePath*: proc (self: GodotVariant): GodotNodePath - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsRID*: proc (self: GodotVariant): RID - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsObject*: proc (self: GodotVariant): ptr GodotObject - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsDictionary*: proc (self: GodotVariant): GodotDictionary - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsArray*: proc (self: GodotVariant): GodotArray - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsPoolByteArray*: proc (self: GodotVariant): GodotPoolByteArray - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantAsPoolIntArray*: proc (self: GodotVariant): GodotPoolIntArray - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantAsPoolRealArray*: proc (self: GodotVariant): GodotPoolRealArray - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantAsPoolStringArray*: proc (self: GodotVariant): GodotPoolStringArray - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantAsPoolVector2Array*: proc (self: GodotVariant): GodotPoolVector2Array - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantAsPoolVector3Array*: proc (self: GodotVariant): GodotPoolVector3Array - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantAsPoolColorArray*: proc (self: GodotVariant): GodotPoolColorArray - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - variantCall*: proc (self: var GodotVariant, meth: GodotString, - args: ptr array[MAX_ARG_COUNT, ptr GodotVariant], - argcount: cint, - callError: var VariantCallError): GodotVariant - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantHasMethod*: proc (self: GodotVariant, meth: GodotString): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantOperatorEqual*: proc (self, other: GodotVariant): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantOperatorLess*: proc (self, other: GodotVariant): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantHashCompare*: proc (self, other: GodotVariant): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantBooleanize*: proc (self: GodotVariant): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantDestroy*: proc (self: var GodotVariant) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - # String API - stringNew*: proc (dest: var GodotString) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringNewCopy*: proc (dest: var GodotString, src: GodotString) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringNewData*: proc (dest: var GodotString, contents: cstring, size: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringNewUTF16Data: pointer - stringGetData*: proc (self: GodotString, dest: cstring, size: var cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringOperatorIndex: pointer - stringCStr*: proc (self: GodotString): cstring - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringOperatorIndexConst: pointer - stringUTF16Str: pointer - stringOperatorEqual*: proc (self, other: GodotString): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringOperatorLess*: proc (self, other: GodotString): bool - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringOperatorPlus*: proc (self, other: GodotString): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringLength*: proc (self: GodotString): cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringBeginsWith: pointer - stringBeginsWithCharArray: pointer - stringBigrams: pointer - stringChr: pointer - stringEndsWith: pointer - stringFind: pointer - stringFindFrom: pointer - stringFindmk: pointer - stringFindmkFrom: pointer - stringFindmkFromInPlace: pointer - stringFindn: pointer - stringFindnFrom: pointer - stringFindLast: pointer - stringFormat: pointer - stringFormatWithCustomPlaceholder: pointer - stringHexEncodeBuffer: pointer - stringHexToInt: pointer - stringHexToIntWithoutPrefix: pointer - stringInsert: pointer - stringIsNumeric: pointer - stringIsSubsequenceOf: pointer - stringIsSubsequenceOfi: pointer - stringLpad: pointer - stringLpadWithCustomCharacter: pointer - stringMatch: pointer - stringMatchn: pointer - stringMd5: pointer - stringNum: pointer - stringNumInt64: pointer - stringNumInt64Capitalized: pointer - stringNumReal: pointer - stringNumScientific: pointer - stringNumWithDecimals: pointer - stringPadDecimals: pointer - stringPadZeros: pointer - stringReplaceFirst: pointer - stringReplace: pointer - stringReplacen: pointer - stringRfind: pointer - stringRfindn: pointer - stringRfindFrom: pointer - stringRfindnFrom: pointer - stringRpad: pointer - stringRpadWithCustomCharacter: pointer - stringSimilarity: pointer - stringSprintf: pointer - stringSubstr: pointer - stringToDouble: pointer - stringToFloat: pointer - stringToInt: pointer - stringCamelcaseToUnderscore: pointer - stringCamelcaseToUnderscoreLowercased: pointer - stringCapitalize: pointer - stringCharToDouble: pointer - stringCharToInt: pointer - stringWcharToInt: pointer - stringCharToIntWithLen: pointer - stringCharToInt64WithLen: pointer - stringHexToInt64: pointer - stringHexToInt64WithPrefix: pointer - stringToInt64: pointer - stringUnicodeCharToDouble: pointer - stringGetSliceCount: pointer - stringGetSlice: pointer - stringGetSlicec: pointer - stringSplit: pointer - stringSplitAllowEmpty: pointer - stringSplitFloats: pointer - stringSplitFloatsAllowsEmpty: pointer - stringSplitFloatsMk: pointer - stringSplitFloatsMkAllowsEmpty: pointer - stringSplitInts: pointer - stringSplitIntsAllowsEmpty: pointer - stringSplitIntsMk: pointer - stringSplitIntsMkAllowsEmpty: pointer - stringSplitSpaces: pointer - stringCharLowercase: pointer - stringCharUppercase: pointer - stringToLower: pointer - stringToUpper: pointer - stringGetBasename: pointer - stringGetExtension: pointer - stringLeft: pointer - stringOrdAt: pointer - stringPlusFile: pointer - stringRight: pointer - stringStripEdges: pointer - stringStripEscapes: pointer - stringErase: pointer - stringAscii: pointer - stringAsciiExtended: pointer - stringUtf8: pointer - stringParseUtf8: pointer - stringParseUtf8WithLen: pointer - stringCharsToUtf8: pointer - stringCharsToUtf8WithLen: pointer - stringHash: pointer - stringHash64: pointer - stringHashChars: pointer - stringHashCharsWithLen: pointer - stringHashUtf8Chars: pointer - stringHashUtf8CharsWithLen: pointer - stringMd5Buffer: pointer - stringMd5Text: pointer - stringSha256Buffer: pointer - stringSha256Text: pointer - stringEmpty: pointer - stringGetBaseDir: pointer - stringGetFile: pointer - stringHumanizeSize: pointer - stringIsAbsPath: pointer - stringIsRelPath: pointer - stringIsResourceFile: pointer - stringPathTo: pointer - stringPathToFile: pointer - stringSimplifyPath: pointer - stringCEscape: pointer - stringCEscapeMultiline: pointer - stringCUnescape: pointer - stringHttpEscape: pointer - stringHttpUnescape: pointer - stringJsonEscape: pointer - stringWordWrap: pointer - stringXmlEscape: pointer - stringXmlEscapeWithQuotes: pointer - stringXmlUnescape: pointer - stringPercentDecode: pointer - stringPercentEncode: pointer - stringIsValidFloat: pointer - stringIsValidHexNumber: pointer - stringIsValidHtmlColor: pointer - stringIsValidIdentifier: pointer - stringIsValidInteger: pointer - stringIsValidIpAddress: pointer - stringDestroy*: proc (self: var GodotString) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - # StringName API - stringNameNew: pointer - stringNameNewData: pointer - stringNameGetName: pointer - stringNameGetHash: pointer - stringNameGetDataUniquePointer: pointer - stringNameOperatorEqual: pointer - stringNameOperatorLess: pointer - stringNameDestroy: pointer - - # Misc API - objectDestroy*: proc (self: ptr GodotObject) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - globalGetSingleton*: proc (name: cstring): ptr GodotObject - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - methodBindGetMethod*: proc (className, - methodName: cstring): ptr GodotMethodBind - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - methodBindPtrCall*: proc (methodBind: ptr GodotMethodBind, - obj: ptr GodotObject, - args: ptr array[MAX_ARG_COUNT, pointer], - ret: pointer) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - methodBindCall*: proc (methodBind: ptr GodotMethodBind, obj: ptr GodotObject, - args: ptr array[MAX_ARG_COUNT, ptr GodotVariant], - argCount: cint, - callError: var VariantCallError): GodotVariant - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - getClassConstructor*: proc (className: cstring): GodotClassConstructor - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - alloc*: proc (bytes: cint): pointer - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - realloc*: proc (p: pointer, bytes: cint): pointer - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - free*: proc (p: pointer) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - printError*: proc (description, function, file: cstring, line: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - printWarning*: proc (description, function, file: cstring, line: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - print*: proc (message: GodotString) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - # NativeScript API - nativeScriptRegisterClass*: proc (gdnativeHandle: pointer, - name, base: cstring, - createFunc: GodotInstanceCreateFunc, - destroyFunc: GodotInstanceDestroyFunc) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - nativeScriptRegisterToolClass*: proc (gdnativeHandle: pointer, - name, base: cstring, - createFunc: GodotInstanceCreateFunc, - destroyFunc: GodotInstanceDestroyFunc) + poolVector2ArrayAppendArray*: proc (self: var GodotPoolVector2Array, + arr: GodotPoolVector2Array) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nativeScriptRegisterMethod*: proc (gdnativeHandle: pointer, - name, functionName: cstring, - attr: GodotMethodAttributes, - meth: GodotInstanceMethod) + poolVector2ArrayInsert*: proc (self: var GodotPoolVector2Array, idx: cint, + val: Vector2): Error + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayInvert*: proc (self: var GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayPushBack*: proc (self: var GodotPoolVector2Array, + val: Vector2) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nativeScriptRegisterProperty*: proc (gdnativeHandle: pointer, - name, path: cstring, - attr: ptr GodotPropertyAttributes, - setFunc: GodotPropertySetFunc, - getFunc: GodotPropertyGetFunc) + poolVector2ArrayRemove*: proc (self: var GodotPoolVector2Array, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArrayResize*: proc (self: var GodotPoolVector2Array, size: cint) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector2ArraySet*: proc (self: var GodotPoolVector2Array, idx: cint, + data: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArrayGet*: proc (self: GodotPoolVector2Array, idx: cint): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArraySize*: proc (self: GodotPoolVector2Array): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector2ArrayDestroy*: proc (self: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # PoolVector3 API + poolVector3ArrayNew*: proc (dest: var GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector3ArrayNewCopy*: proc (dest: var GodotPoolVector3Array, + src: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayNewWithArray*: proc (dest: var GodotPoolVector3Array, + src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayAppend*: proc (self: var GodotPoolVector3Array, val: Vector3) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayAppendArray*: proc (self: var GodotPoolVector3Array, + arr: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayInsert*: proc (self: var GodotPoolVector3Array, idx: cint, + val: Vector3): Error + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayInvert*: proc (self: var GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolVector3ArrayPushBack*: proc (self: var GodotPoolVector3Array, + val: Vector3) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArrayRemove*: proc (self: var GodotPoolVector3Array, + idx: cint) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArrayResize*: proc (self: var GodotPoolVector3Array, + size: cint) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArraySet*: proc (self: var GodotPoolVector3Array, idx: cint, + data: Vector3) {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} + poolVector3ArrayGet*: proc (self: GodotPoolVector3Array, idx: cint): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector3ArraySize*: proc (self: GodotPoolVector3Array): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolVector3ArrayDestroy*: proc (self: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # PoolColorArray API + poolColorArrayNew*: proc (dest: var GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayNewCopy*: proc (dest: var GodotPoolColorArray, + src: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolColorArrayNewWithArray*: proc (dest: var GodotPoolColorArray, + src: GodotArray) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nativeScriptRegisterSignal*: proc (gdnativeHandle: pointer, name: cstring, - signal: GodotSignal) - {.noconv, raises: [], gcsafe, tags: [], - locks: 0.} - nativeScriptGetUserdata*: proc (obj: ptr GodotObject): pointer + poolColorArrayAppend*: proc (self: var GodotPoolColorArray, + val: Color) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayAppendArray*: proc (self: var GodotPoolColorArray, + arr: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolColorArrayInsert*: proc (self: var GodotPoolColorArray, + idx: cint, val: Color): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayInvert*: proc (self: var GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayPushBack*: proc (self: var GodotPoolColorArray, val: Color) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + poolColorArrayRemove*: proc (self: var GodotPoolColorArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayResize*: proc (self: var GodotPoolColorArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArraySet*: proc (self: var GodotPoolColorArray, idx: cint, + data: Color) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayGet*: proc (self: GodotPoolColorArray, idx: cint): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArraySize*: proc (self: GodotPoolColorArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + poolColorArrayDestroy*: proc (self: GodotPoolColorArray) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + # Array API + arrayNew*: proc (dest: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayNewCopy*: proc (dest: var GodotArray, src: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayNewPoolColorArray*: proc (dest: var GodotArray, src: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolVector3Array*: proc (dest: var GodotArray, + src: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolVector2Array*: proc (dest: var GodotArray, + src: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolStringArray*: proc (dest: var GodotArray, + src: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolRealArray*: proc (dest: var GodotArray, src: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arrayNewPoolIntArray*: proc (dest: var GodotArray, src: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayNewPoolByteArray*: proc (dest: var GodotArray, src: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + arraySet*: proc (self: var GodotArray, idx: cint, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayGet*: proc (self: GodotArray, idx: cint): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayOperatorIndex*: proc (self: var GodotArray, idx: cint): ptr GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayAppend*: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayClear*: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayCount*: proc (self: GodotArray, val: GodotVariant): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayEmpty*: proc (self: GodotArray): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayErase*: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayFront*: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayBack*: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayFind*: proc (self: GodotArray, what: GodotVariant, fromIdx: cint): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayFindLast*: proc (self: GodotArray, what: GodotVariant): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayHas*: proc (self: GodotArray, val: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayHash*: proc (self: GodotArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayInsert*: proc (self: var GodotArray, pos: cint, val: GodotVariant): Error + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayInvert*: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPopFront*: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPopBack*: proc (self: GodotArray): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPushBack*: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayPushFront*: proc (self: var GodotArray, val: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayRemove*: proc (self: var GodotArray, idx: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayResize*: proc (self: var GodotArray, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayRFind*: proc (self: GodotArray, what: GodotVariant, fromIdx: cint): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arraySize*: proc (self: GodotArray): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arraySort*: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arraySortCustom*: proc (self: var GodotArray, obj: ptr GodotObject, + f: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayDestroy*: proc (self: var GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + # Dictionary API + dictionaryNew*: proc (dest: var GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryNewCopy*: proc (dest: var GodotDictionary, src: GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryDestroy*: proc (self: var GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionarySize*: proc (self: GodotDictionary): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryEmpty*: proc (self: GodotDictionary): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryClear*: proc (self: var GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryHas*: proc (self: GodotDictionary, key: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryHasAll*: proc (self: GodotDictionary, keys: GodotArray): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryErase*: proc (self: var GodotDictionary, key: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryHash*: proc (self: GodotDictionary): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryKeys*: proc (self: GodotDictionary): GodotArray + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryValues*: proc (self: GodotDictionary): GodotArray + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryGet*: proc (self: GodotDictionary, key: GodotVariant): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionarySet*: proc (self: var GodotDictionary, key, value: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryOperatorIndex*: proc (self: var GodotDictionary, + key: GodotVariant): ptr GodotVariant + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + dictionaryNext*: proc (self: GodotDictionary, + key: GodotVariant): ptr GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + dictionaryOperatorEqual*: proc (self, other: GodotDictionary): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + dictionaryToJson*: proc (self: GodotDictionary): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} -var gdNativeAPI: ptr GDNativeAPI + # NodePath API + nodePathNew*: proc (dest: var GodotNodePath, src: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathNewCopy*: proc (dest: var GodotNodePath, src: GodotNodePath) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathDestroy*: proc (self: var GodotNodePath) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathAsString*: proc (self: GodotNodePath): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathIsAbsolute*: proc (self: GodotNodePath): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetNameCount*: proc (self: GodotNodePath): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetName*: proc (self: GodotNodePath, idx: cint): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetSubnameCount*: proc (self: GodotNodePath): cint + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nodePathGetSubname*: proc (self: GodotNodePath, idx: cint): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetProperty*: proc (self: GodotNodePath): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathIsEmpty*: proc (self: GodotNodePath): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathOperatorEqual*: proc (self, other: GodotNodePath): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # Plane API + planeNewWithReals*: proc (dest: var Plane, a, b, c, d: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeNewWithVectors*: proc (dest: var Plane, v1, v2, v3: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeNewWithNormal*: proc (dest: var Plane, normal: Vector3, d: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeAsString*: proc (self: Plane): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeNormalized*: proc (self: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeCenter*: proc (self: Plane): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeGetAnyPoint*: proc (self: Plane): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIsPointOver*: proc (self: Plane, point: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeDistanceTo*: proc (self: Plane, point: Vector3): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeHasPoint*: proc (self: Plane, point: Vector3, epsilon: float32): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeProject*: proc (self: Plane, point: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIntersect3*: proc (self: Plane, dest: var Vector3, b, c: Plane): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIntersectsRay*: proc (self: Plane, dest: var Vector3, + point, dir: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeIntersectsSegment*: proc (self: Plane, dest: var Vector3, + segmentBegin, segmentEnd: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + planeOperatorNeg*: proc (self: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeOperatorEqual*: proc (self, other: Plane): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeSetNormal*: proc (self: var Plane, normal: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeGetNormal*: proc (self: Plane): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeGetD*: proc (self: Plane): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + planeSetD*: proc (self: var Plane, d: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Rect2 API + rect2NewWithPositionAndSize*: proc (dest: var Rect2, pos, size: Vector2) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect2New*: proc (dest: var Rect2, x, y, width, height: float32) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2AsString*: proc (self: Rect2): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2GetArea*: proc (self: Rect2): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Intersects*: proc (self, other: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Encloses*: proc (self, other: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2HasNoArea*: proc (self: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Clip*: proc (self, other: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Merge*: proc (self, other: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2HasPoint*: proc (self: Rect2, point: Vector2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Grow*: proc (self: Rect2, by: float32): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2Expand*: proc (self: Rect2, to: Vector2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2OperatorEqual*: proc (self, other: Rect2): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2GetPosition*: proc (self: Rect2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2GetSize*: proc (self: Rect2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2SetPosition*: proc (self: var Rect2, pos: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect2SetSize*: proc (self: var Rect2, size: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Rect3 API + rect3New*: proc (dest: var Rect3, pos, size: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetPosition*: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3SetPosition*: proc (self: var Rect3, pos: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetSize*: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3SetSize*: proc (self: var Rect3, pos: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3AsString*: proc (self: Rect3): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetArea*: proc (self: Rect3): float32 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3HasNoArea*: proc (self: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3HasNoSurface*: proc (self: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Intersects*: proc (self, other: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Encloses*: proc (self, other: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Merge*: proc (self, other: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Intersection*: proc (self, other: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3IntersectsPlane*: proc (self: Rect3, plane: Plane): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3IntersectsSegment*: proc (self: Rect3, vFrom, vTo: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3HasPoint*: proc (self: Rect3, point: Vector3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetSupport*: proc (self: Rect3, dir: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetLongestAxis*: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetLongestAxisIndex*: proc (self: Rect3): cint + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3GetLongestAxisSize*: proc (self: Rect3): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3GetShortestAxis*: proc (self: Rect3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetShortestAxisIndex*: proc (self: Rect3): cint + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3GetShortestAxisSize*: proc (self: Rect3): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + rect3Expand*: proc (self: Rect3, toPoint: Vector3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3Grow*: proc (self: Rect3, by: float32): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3GetEndpoint*: proc (self: Rect3, idx: cint): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + rect3OperatorEqual*: proc (self, other: Rect3): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # RID API + ridNew*: proc (dest: var RID) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridGetID*: proc (self: RID): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridNewWithResource*: proc (dest: var RID, obj: ptr GodotObject) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridOperatorEqual*: proc (self, other: RID): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + ridOperatorLess*: proc (self, other: RID): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Transform API + transformNewWithAxisOrigin*: proc (dest: var Transform, + xAxis, yAxis, zAxis, origin: Vector3) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformNew*: proc (dest: var Transform, basis: Basis, origin: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformGetBasis*: proc (self: Transform): Basis + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformSetBasis*: proc (self: var Transform, basis: Basis) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformGetOrigin*: proc (self: Transform): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformSetOrigin*: proc (self: var Transform, v: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformAsString*: proc (self: Transform): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformInverse*: proc (self: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformAffineInverse*: proc (self: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformOrthonormalized*: proc (self: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformRotated*: proc (self: Transform, axis: Vector3, + phi: float32): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformScaled*: proc (self: Transform, scale: Vector3): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformTranslated*: proc (self: Transform, offset: Vector3): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformLookingAt*: proc (self: Transform, target, up: Vector3): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformXformPlane*: proc (self: Transform, plane: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformXformInvPlane*: proc (self: Transform, plane: Plane): Plane + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformNewIdentity*: proc (dest: var Transform) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformOperatorEqual*: proc (self, other: Transform): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformOperatorMultiply*: proc (self, other: Transform): Transform + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformXformVector3*: proc (self: Transform, v: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformXformInvVector3*: proc (self: Transform, v: Vector3): Vector3 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transformXformRect3*: proc (self: Transform, v: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transformXformInvRect3*: proc (self: Transform, v: Rect3): Rect3 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # Transform2D API + transform2DNew*: proc (dest: var Transform2D, rot: float32, pos: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DNewAxisOrigin*: proc (dest: var Transform2D, + xAxis, yAxis, origin: Vector2) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DAsString*: proc (self: Transform2D): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DInverse*: proc (self: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DAffineInverse*: proc (self: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DGetRotation*: proc (self: Transform2D): float32 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DGetOrigin*: proc (self: Transform2D): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DGetScale*: proc (self: Transform2D): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DOrthonormalized*: proc (self: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DRotated*: proc (self: Transform2D, phi: float32): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DScaled*: proc (self: Transform2D, scale: Vector2): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + transform2DTranslated*: proc (self: Transform2D, offset: Vector2): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformVector2*: proc (self: Transform2D, v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformInvVector2*: proc (self: Transform2D, v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DBasisXformVector2*: proc (self: Transform2D, v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DBasisXformInvVector2*: proc (self: Transform2D, + v: Vector2): Vector2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DInterpolateWith*: proc (self, other: Transform2D, + t: float32): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DOperatorEqual*: proc (self, other: Transform2D): bool + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DOperatorMultiply*: proc (self, other: Transform2D): Transform2D + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DNewIdentity*: proc (dest: var Transform2D) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformRect2*: proc (self: Transform2D, v: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + transform2DXformInvRect2*: proc (self: Transform2D, v: Rect2): Rect2 + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + + # Variant API + variantGetType*: proc (v: GodotVariant): VariantType + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewCopy*: proc (dest: var GodotVariant, src: GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewNil*: proc (dest: var GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewBool*: proc (dest: var GodotVariant, val: bool) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewUInt*: proc (dest: var GodotVariant, val: uint64) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewInt*: proc (dest: var GodotVariant, val: int64) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewReal*: proc (dest: var GodotVariant, val: float64) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewString*: proc (dest: var GodotVariant, val: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewVector2*: proc (dest: var GodotVariant, val: Vector2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewRect2*: proc (dest: var GodotVariant, val: Rect2) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewVector3*: proc (dest: var GodotVariant, val: Vector3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewTransform2D*: proc (dest: var GodotVariant, val: Transform2D) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPlane*: proc (dest: var GodotVariant, val: Plane) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewQuat*: proc (dest: var GodotVariant, val: Quat) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewRect3*: proc (dest: var GodotVariant, val: Rect3) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewBasis*: proc (dest: var GodotVariant, val: Basis) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewTransform*: proc (dest: var GodotVariant, val: Transform) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewColor*: proc (dest: var GodotVariant, val: Color) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewNodePath*: proc (dest: var GodotVariant, val: GodotNodePath) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewRID*: proc (dest: var GodotVariant, val: RID) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewObject*: proc (dest: var GodotVariant, val: ptr GodotObject) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewDictionary*: proc (dest: var GodotVariant, val: GodotDictionary) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewArray*: proc (dest: var GodotVariant, val: GodotArray) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantNewPoolByteArray*: proc (dest: var GodotVariant, + val: GodotPoolByteArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolIntArray*: proc (dest: var GodotVariant, val: GodotPoolIntArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolRealArray*: proc (dest: var GodotVariant, + val: GodotPoolRealArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolStringArray*: proc (dest: var GodotVariant, + val: GodotPoolStringArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolVector2Array*: proc (dest: var GodotVariant, + val: GodotPoolVector2Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolVector3Array*: proc (dest: var GodotVariant, + val: GodotPoolVector3Array) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantNewPoolColorArray*: proc (dest: var GodotVariant, + val: GodotPoolColorArray) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsBool*: proc (self: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsUInt*: proc (self: GodotVariant): uint64 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsInt*: proc (self: GodotVariant): int64 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsReal*: proc (self: GodotVariant): float64 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsString*: proc (self: GodotVariant): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsVector2*: proc (self: GodotVariant): Vector2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsRect2*: proc (self: GodotVariant): Rect2 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsVector3*: proc (self: GodotVariant): Vector3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsTransform2D*: proc (self: GodotVariant): Transform2D + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsPlane*: proc (self: GodotVariant): Plane + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsQuat*: proc (self: GodotVariant): Quat + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsRect3*: proc (self: GodotVariant): Rect3 + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsBasis*: proc (self: GodotVariant): Basis + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsTransform*: proc (self: GodotVariant): Transform + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsColor*: proc (self: GodotVariant): Color + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsNodePath*: proc (self: GodotVariant): GodotNodePath + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsRID*: proc (self: GodotVariant): RID + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsObject*: proc (self: GodotVariant): ptr GodotObject + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsDictionary*: proc (self: GodotVariant): GodotDictionary + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsArray*: proc (self: GodotVariant): GodotArray + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantAsPoolByteArray*: proc (self: GodotVariant): GodotPoolByteArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolIntArray*: proc (self: GodotVariant): GodotPoolIntArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolRealArray*: proc (self: GodotVariant): GodotPoolRealArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolStringArray*: proc (self: GodotVariant): GodotPoolStringArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolVector2Array*: proc (self: GodotVariant): GodotPoolVector2Array + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolVector3Array*: proc (self: GodotVariant): GodotPoolVector3Array + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantAsPoolColorArray*: proc (self: GodotVariant): GodotPoolColorArray + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + variantCall*: proc (self: var GodotVariant, meth: GodotString, + args: ptr array[MAX_ARG_COUNT, ptr GodotVariant], + argcount: cint, + callError: var VariantCallError): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantHasMethod*: proc (self: GodotVariant, meth: GodotString): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantOperatorEqual*: proc (self, other: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantOperatorLess*: proc (self, other: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantHashCompare*: proc (self, other: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantBooleanize*: proc (self: GodotVariant): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + variantDestroy*: proc (self: var GodotVariant) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # String API + stringNew*: proc (dest: var GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringNewCopy*: proc (dest: var GodotString, src: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringNewData*: proc (dest: var GodotString, contents: cstring, size: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringGetData*: proc (self: GodotString, dest: cstring, size: var cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringCStr*: proc (self: GodotString): cstring + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringOperatorEqual*: proc (self, other: GodotString): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringOperatorLess*: proc (self, other: GodotString): bool + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringOperatorPlus*: proc (self, other: GodotString): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringLength*: proc (self: GodotString): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringDestroy*: proc (self: var GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + # Misc API + objectDestroy*: proc (self: ptr GodotObject) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + globalGetSingleton*: proc (name: cstring): ptr GodotObject + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + methodBindGetMethod*: proc (className, + methodName: cstring): ptr GodotMethodBind + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + methodBindPtrCall*: proc (methodBind: ptr GodotMethodBind, + obj: ptr GodotObject, + args: ptr array[MAX_ARG_COUNT, pointer], + ret: pointer) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + methodBindCall*: proc (methodBind: ptr GodotMethodBind, obj: ptr GodotObject, + args: ptr array[MAX_ARG_COUNT, ptr GodotVariant], + argCount: cint, + callError: var VariantCallError): GodotVariant + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + getClassConstructor*: proc (className: cstring): GodotClassConstructor + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + alloc*: proc (bytes: cint): pointer + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + realloc*: proc (p: pointer, bytes: cint): pointer + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + free*: proc (p: pointer) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + printError*: proc (description, function, file: cstring, line: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + printWarning*: proc (description, function, file: cstring, line: cint) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + print*: proc (message: GodotString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + + nativeScriptRegisterClass*: proc (gdnativeHandle: pointer, + name, base: cstring, + createFunc: GodotInstanceCreateFunc, + destroyFunc: GodotInstanceDestroyFunc) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptRegisterToolClass*: proc (gdnativeHandle: pointer, + name, base: cstring, + createFunc: GodotInstanceCreateFunc, + destroyFunc: GodotInstanceDestroyFunc) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptRegisterMethod*: proc (gdnativeHandle: pointer, + name, functionName: cstring, + attr: GodotMethodAttributes, + meth: GodotInstanceMethod) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptRegisterProperty*: proc (gdnativeHandle: pointer, + name, path: cstring, + attr: ptr GodotPropertyAttributes, + setFunc: GodotPropertySetFunc, + getFunc: GodotPropertyGetFunc) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptRegisterSignal*: proc (gdnativeHandle: pointer, name: cstring, + signal: GodotSignal) + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + nativeScriptGetUserdata*: proc (obj: ptr GodotObject): pointer + {.noconv, raises: [], gcsafe, tags: [], + locks: 0.} + +macro assign(dest, src: typed, values: untyped): typed = + result = newStmtList() + for val in values: + result.add(newNimNode(nnkAsgn).add( + newNimNode(nnkDotExpr).add(dest, val), + newNimNode(nnkDotExpr).add(src, val))) + +var gdNativeAPI: GDNativeAPI proc getGDNativeAPI*(): ptr GDNativeAPI {.inline.} = - gdNativeAPI + addr gdNativeAPI proc setGDNativeAPI*(apiStruct: pointer) {.inline.} = - gdNativeAPI = cast[ptr GDNativeAPI](apiStruct) + let header = cast[ptr GDNativeAPIHeader](apiStruct) + + if header.typ >= ord(low(GDNativeAPIType)).cuint and header.typ <= ord(high(GDNativeAPIType)).cuint: + let typ = GDNativeAPIType(header.typ) + case typ: + of GDNativeCore: + let coreApi = cast[ptr GDNativeCoreAPI1](apiStruct) + if coreApi[].version.major == 1: + assign(gdNativeApi, coreApi[]): + # Color API + colorNewRGBA + colorNewRGB + colorGetR + colorSetR + colorGetG + colorSetG + colorGetB + colorSetB + colorGetA + colorSetA + colorGetH + colorGetS + colorGetV + colorAsString + colorToRGBA32 + colorAsARGB32 + colorGray + colorInverted + colorContrasted + colorLinearInterpolate + colorBlend + colorToHtml + colorOperatorEqual + colorOperatorLess + + # Vector 2 API + vector2New + vector2AsString + vector2Normalized + vector2Length + vector2Angle + vector2LengthSquared + vector2IsNormalized + vector2DistanceTo + vector2DistanceSquaredTo + vector2AngleTo + vector2AngleToPoint + vector2LinearInterpolate + vector2CubicInterpolate + vector2Rotated + vector2Tangent + vector2Floor + vector2Snapped + vector2Aspect + vector2Dot + vector2Slide + vector2Bounce + vector2Reflect + vector2Abs + vector2Clamped + vector2OperatorAdd + vector2OperatorSubtract + vector2OperatorMultiplyVector + vector2OperatorMultiplyScalar + vector2OperatorDivideVector + vector2OperatorDivideScalar + vector2OperatorEqual + vector2OperatorLess + vector2OperatorNeg + + # Quat API + quatNew + quatNewWithAxisAngle + quatGetX + quatSetX + quatGetY + quatSetY + quatGetZ + quatSetZ + quatGetW + quatSetW + quatAsString + quatLength + quatLengthSquared + quatNormalized + quatIsNormalized + quatInverse + quatDot + quatXform + quatSlerp + quatSlerpni + quatCubicSlerp + quatOperatorMultiply + quatOperatorAdd + quatOperatorSubtract + quatOperatorDivide + quatOperatorEqual + quatOperatorNeg + + # PoolByteArray API + poolByteArrayNew + poolByteArrayNewCopy + poolByteArrayNewWithArray + poolByteArrayAppend + poolByteArrayAppendArray + poolByteArrayInsert + poolByteArrayInvert + poolByteArrayPushBack + poolByteArrayRemove + poolByteArrayResize + poolByteArraySet + poolByteArrayGet + poolByteArraySize + poolByteArrayDestroy + + # PoolIntArray API + poolIntArrayNew + poolIntArrayNewCopy + poolIntArrayNewWithArray + poolIntArrayAppend + poolIntArrayAppendArray + poolIntArrayInsert + poolIntArrayInvert + poolIntArrayPushBack + poolIntArrayRemove + poolIntArrayResize + poolIntArraySet + poolIntArrayGet + poolIntArraySize + poolIntArrayDestroy + + # PoolRealArray API + poolRealArrayNew + poolRealArrayNewCopy + poolRealArrayNewWithArray + poolRealArrayAppend + poolRealArrayAppendArray + poolRealArrayInsert + poolRealArrayInvert + poolRealArrayPushBack + poolRealArrayRemove + poolRealArrayResize + poolRealArraySet + poolRealArrayGet + poolRealArraySize + poolRealArrayDestroy + + # PoolStringArray API + poolStringArrayNew + poolStringArrayNewCopy + poolStringArrayNewWithArray + poolStringArrayAppend + poolStringArrayAppendArray + poolStringArrayInsert + poolStringArrayInvert + poolStringArrayPushBack + poolStringArrayRemove + poolStringArrayResize + poolStringArraySet + poolStringArrayGet + poolStringArraySize + poolStringArrayDestroy + + + # PoolVector2 API + poolVector2ArrayNew + poolVector2ArrayNewCopy + poolVector2ArrayNewWithArray + poolVector2ArrayAppend + poolVector2ArrayAppendArray + poolVector2ArrayInsert + poolVector2ArrayInvert + poolVector2ArrayPushBack + poolVector2ArrayRemove + poolVector2ArrayResize + poolVector2ArraySet + poolVector2ArrayGet + poolVector2ArraySize + poolVector2ArrayDestroy + + # PoolVector3 API + poolVector3ArrayNew + poolVector3ArrayNewCopy + poolVector3ArrayNewWithArray + poolVector3ArrayAppend + poolVector3ArrayAppendArray + poolVector3ArrayInsert + poolVector3ArrayInvert + poolVector3ArrayPushBack + poolVector3ArrayRemove + poolVector3ArrayResize + poolVector3ArraySet + poolVector3ArrayGet + poolVector3ArraySize + poolVector3ArrayDestroy + + # PoolColorArray API + poolColorArrayNew + poolColorArrayNewCopy + poolColorArrayNewWithArray + poolColorArrayAppend + poolColorArrayAppendArray + poolColorArrayInsert + poolColorArrayInvert + poolColorArrayPushBack + poolColorArrayRemove + poolColorArrayResize + poolColorArraySet + poolColorArrayGet + poolColorArraySize + poolColorArrayDestroy + + # Array API + arrayNew + arrayNewCopy + arrayNewPoolColorArray + arrayNewPoolVector3Array + arrayNewPoolVector2Array + arrayNewPoolStringArray + arrayNewPoolRealArray + arrayNewPoolIntArray + arrayNewPoolByteArray + arraySet + arrayGet + arrayOperatorIndex + arrayAppend + arrayClear + arrayCount + arrayEmpty + arrayErase + arrayFront + arrayBack + arrayFind + arrayFindLast + arrayHas + arrayHash + arrayInsert + arrayInvert + arrayPopFront + arrayPopBack + arrayPushBack + arrayPushFront + arrayRemove + arrayResize + arrayRFind + arraySize + arraySort + arraySortCustom + arrayDestroy + + # Dictionary API + dictionaryNew + dictionaryNewCopy + dictionaryDestroy + dictionarySize + dictionaryEmpty + dictionaryClear + dictionaryHas + dictionaryHasAll + dictionaryErase + dictionaryHash + dictionaryKeys + dictionaryValues + dictionaryGet + dictionarySet + dictionaryOperatorIndex + dictionaryNext + dictionaryOperatorEqual + dictionaryToJson + + # NodePath API + nodePathNew + nodePathNewCopy + nodePathDestroy + nodePathAsString + nodePathIsAbsolute + nodePathGetNameCount + nodePathGetName + nodePathGetSubnameCount + nodePathGetSubname + nodePathGetProperty + nodePathIsEmpty + nodePathOperatorEqual + + # Plane API + planeNewWithReals + planeNewWithVectors + planeNewWithNormal + planeAsString + planeNormalized + planeCenter + planeGetAnyPoint + planeIsPointOver + planeDistanceTo + planeHasPoint + planeProject + planeIntersect3 + planeIntersectsRay + planeIntersectsSegment + planeOperatorNeg + planeOperatorEqual + planeSetNormal + planeGetNormal + planeGetD + planeSetD + + # Rect2 API + rect2NewWithPositionAndSize + rect2New + rect2AsString + rect2GetArea + rect2Intersects + rect2Encloses + rect2HasNoArea + rect2Clip + rect2Merge + rect2HasPoint + rect2Grow + rect2Expand + rect2OperatorEqual + rect2GetPosition + rect2GetSize + rect2SetPosition + rect2SetSize + + # Rect3 API + rect3New + rect3GetPosition + rect3SetPosition + rect3GetSize + rect3SetSize + rect3AsString + rect3GetArea + rect3HasNoArea + rect3HasNoSurface + rect3Intersects + rect3Encloses + rect3Merge + rect3Intersection + rect3IntersectsPlane + rect3IntersectsSegment + rect3HasPoint + rect3GetSupport + rect3GetLongestAxis + rect3GetLongestAxisIndex + rect3GetLongestAxisSize + rect3GetShortestAxis + rect3GetShortestAxisIndex + rect3GetShortestAxisSize + rect3Expand + rect3Grow + rect3GetEndpoint + rect3OperatorEqual + + # RID API + ridNew + ridGetID + ridNewWithResource + ridOperatorEqual + ridOperatorLess + + # Transform API + transformNewWithAxisOrigin + transformNew + transformGetBasis + transformSetBasis + transformGetOrigin + transformSetOrigin + transformAsString + transformInverse + transformAffineInverse + transformOrthonormalized + transformRotated + transformScaled + transformTranslated + transformLookingAt + transformXformPlane + transformXformInvPlane + transformNewIdentity + transformOperatorEqual + transformOperatorMultiply + transformXformVector3 + transformXformInvVector3 + transformXformRect3 + transformXformInvRect3 + + # Transform2D API + transform2DNew + transform2DNewAxisOrigin + transform2DAsString + transform2DInverse + transform2DAffineInverse + transform2DGetRotation + transform2DGetOrigin + transform2DGetScale + transform2DOrthonormalized + transform2DRotated + transform2DScaled + transform2DTranslated + transform2DXformVector2 + transform2DXformInvVector2 + transform2DBasisXformVector2 + transform2DBasisXformInvVector2 + transform2DInterpolateWith + transform2DOperatorEqual + transform2DOperatorMultiply + transform2DNewIdentity + transform2DXformRect2 + transform2DXformInvRect2 + + # Variant API + variantGetType + variantNewCopy + variantNewNil + variantNewBool + variantNewUInt + variantNewInt + variantNewReal + variantNewString + variantNewVector2 + variantNewRect2 + variantNewVector3 + variantNewTransform2D + + variantNewPlane + variantNewQuat + variantNewRect3 + variantNewBasis + variantNewTransform + variantNewColor + variantNewNodePath + variantNewRID + variantNewObject + variantNewDictionary + variantNewArray + variantNewPoolByteArray + variantNewPoolIntArray + variantNewPoolRealArray + variantNewPoolStringArray + variantNewPoolVector2Array + variantNewPoolVector3Array + variantNewPoolColorArray + variantAsBool + variantAsUInt + variantAsInt + variantAsReal + variantAsString + variantAsVector2 + variantAsRect2 + variantAsVector3 + variantAsTransform2D + variantAsPlane + variantAsQuat + variantAsRect3 + variantAsBasis + variantAsTransform + variantAsColor + variantAsNodePath + variantAsRID + variantAsObject + variantAsDictionary + variantAsArray + variantAsPoolByteArray + variantAsPoolIntArray + variantAsPoolRealArray + variantAsPoolStringArray + variantAsPoolVector2Array + variantAsPoolVector3Array + variantAsPoolColorArray + variantCall + variantHasMethod + variantOperatorEqual + variantOperatorLess + variantHashCompare + variantBooleanize + variantDestroy + + # String API + stringNew + stringNewCopy + stringNewData + stringGetData + stringCStr + stringOperatorEqual + stringOperatorLess + stringOperatorPlus + stringLength + stringDestroy + + # Misc API + objectDestroy + globalGetSingleton + methodBindGetMethod + methodBindPtrCall + methodBindCall + getClassConstructor + + alloc + realloc + free + + printError + printWarning + print + + for i in 0.cuint.. Date: Mon, 20 Nov 2017 06:52:37 +0700 Subject: [PATCH 17/82] Rename Rect3 to AABB to sync with Godot --- docs/index.rst | 2 +- godot.nimble | 2 +- godot/core/aabb.nim | 73 ++++++++++ godot/core/godotcoretypes.nim | 2 +- godot/core/rect3.nim | 73 ---------- godot/core/transforms.nim | 8 +- godot/core/variants.nim | 10 +- godot/gdnativeapi.nim | 192 +++++++++++++------------- godot/godot.nim | 4 +- godot/godotapigen.nim | 2 +- godot/internal/godotinternaltypes.nim | 2 +- godot/internal/godotvariants.nim | 8 +- godot/nim/godotnim.nim | 12 +- 13 files changed, 195 insertions(+), 195 deletions(-) create mode 100644 godot/core/aabb.nim delete mode 100644 godot/core/rect3.nim diff --git a/docs/index.rst b/docs/index.rst index 320e99a..a1607f6 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -152,7 +152,7 @@ exported and you don't have to import any of them directly. * `quats `_ Defines ``Quat`` (quaternion) describing object rotation in 3D space. * `rect2 `_ Defines ``Rect2`` - a 2D rectangle. -* `rect3 `_ Defines ``Rect3`` - a 3D box. +* `aabb `_ Defines ``AABB`` - a 3D box. * `rids `_ Defines ``RID`` - a resource identifier. * `transform2d `_ Defines ``Transform2D``. * `transforms `_ Defines ``Transform``. diff --git a/godot.nimble b/godot.nimble index 1349055..72b93a8 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.4" +version = "0.6.5" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/aabb.nim b/godot/core/aabb.nim new file mode 100644 index 0000000..5892081 --- /dev/null +++ b/godot/core/aabb.nim @@ -0,0 +1,73 @@ +# Copyright (c) 2017 Xored Software, Inc. + +import internal.godotinternaltypes, internal.godotstrings +import godotcoretypes, gdnativeapi + +proc initAABB*(pos, size: Vector3): AABB {.inline.} = + AABB(position: pos, size: size) + +proc `$`*(self: AABB): string {.inline.} = + $getGDNativeAPI().aabbAsString(self) + +proc area*(self: AABB): float32 {.inline.} = + getGDNativeAPI().aabbGetArea(self) + +proc hasNoArea*(self: AABB): bool {.inline.} = + getGDNativeAPI().aabbHasNoArea(self) + +proc hasNoSurface*(self: AABB): bool {.inline.} = + getGDNativeAPI().aabbHasNoSurface(self) + +proc intersects*(self, other: AABB): bool {.inline.} = + getGDNativeAPI().aabbIntersects(self, other) + +proc encloses*(self, other: AABB): bool {.inline.} = + getGDNativeAPI().aabbEncloses(self, other) + +proc merge*(self, other: AABB): AABB {.inline.} = + getGDNativeAPI().aabbMerge(self, other) + +proc intersection*(self, other: AABB): AABB {.inline.} = + getGDNativeAPI().aabbIntersection(self, other) + +proc intersectsPlane*(self: AABB; plane: Plane): bool {.inline.} = + getGDNativeAPI().aabbIntersectsPlane(self, plane) + +proc intersectsSegment*(self: AABB; start, to: Vector3): bool {.inline.} = + getGDNativeAPI().aabbIntersectsSegment(self, start, to) + +proc contains*(self: AABB; point: Vector3): bool {.inline.} = + getGDNativeAPI().aabbHasPoint(self, point) + +proc getSupport*(self: AABB; dir: Vector3): Vector3 {.inline.} = + getGDNativeAPI().aabbGetSupport(self, dir) + +proc getLongestAxis*(self: AABB): Vector3 {.inline.} = + getGDNativeAPI().aabbGetLongestAxis(self) + +proc getLongestAxisIndex*(self: AABB): cint {.inline.} = + getGDNativeAPI().aabbGetLongestAxisIndex(self) + +proc getLongestAxisSize*(self: AABB): float32 {.inline.} = + getGDNativeAPI().aabbGetLongestAxisSize(self) + +proc getShortestAxis*(self: AABB): Vector3 {.inline.} = + getGDNativeAPI().aabbGetShortestAxis(self) + +proc getShortestAxisIndex*(self: AABB): cint {.inline.} = + getGDNativeAPI().aabbGetShortestAxisIndex(self) + +proc getShortestAxisSize*(self: AABB): float32 {.inline.} = + getGDNativeAPI().aabbGetShortestAxisSize(self) + +proc expand*(self: AABB; toPoint: Vector3): AABB {.inline.} = + getGDNativeAPI().aabbExpand(self, toPoint) + +proc grow*(self: AABB; by: float32): AABB {.inline.} = + getGDNativeAPI().aabbGrow(self, by) + +proc getEndpoint*(self: AABB; idx: cint): Vector3 {.inline.} = + getGDNativeAPI().aabbGetEndpoint(self, idx) + +proc `==`*(a, b: AABB): bool {.inline.} = + getGDNativeAPI().aabbOperatorEqual(a, b) diff --git a/godot/core/godotcoretypes.nim b/godot/core/godotcoretypes.nim index 8b92407..cc5da9e 100644 --- a/godot/core/godotcoretypes.nim +++ b/godot/core/godotcoretypes.nim @@ -29,7 +29,7 @@ type z*: float32 w*: float32 - Rect3* {.byref.} = object + AABB* {.byref.} = object position*: Vector3 size*: Vector3 diff --git a/godot/core/rect3.nim b/godot/core/rect3.nim deleted file mode 100644 index dc2f2c2..0000000 --- a/godot/core/rect3.nim +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright (c) 2017 Xored Software, Inc. - -import internal.godotinternaltypes, internal.godotstrings -import godotcoretypes, gdnativeapi - -proc initRect3*(pos, size: Vector3): Rect3 {.inline.} = - Rect3(position: pos, size: size) - -proc `$`*(self: Rect3): string {.inline.} = - $getGDNativeAPI().rect3AsString(self) - -proc area*(self: Rect3): float32 {.inline.} = - getGDNativeAPI().rect3GetArea(self) - -proc hasNoArea*(self: Rect3): bool {.inline.} = - getGDNativeAPI().rect3HasNoArea(self) - -proc hasNoSurface*(self: Rect3): bool {.inline.} = - getGDNativeAPI().rect3HasNoSurface(self) - -proc intersects*(self, other: Rect3): bool {.inline.} = - getGDNativeAPI().rect3Intersects(self, other) - -proc encloses*(self, other: Rect3): bool {.inline.} = - getGDNativeAPI().rect3Encloses(self, other) - -proc merge*(self, other: Rect3): Rect3 {.inline.} = - getGDNativeAPI().rect3Merge(self, other) - -proc intersection*(self, other: Rect3): Rect3 {.inline.} = - getGDNativeAPI().rect3Intersection(self, other) - -proc intersectsPlane*(self: Rect3; plane: Plane): bool {.inline.} = - getGDNativeAPI().rect3IntersectsPlane(self, plane) - -proc intersectsSegment*(self: Rect3; start, to: Vector3): bool {.inline.} = - getGDNativeAPI().rect3IntersectsSegment(self, start, to) - -proc contains*(self: Rect3; point: Vector3): bool {.inline.} = - getGDNativeAPI().rect3HasPoint(self, point) - -proc getSupport*(self: Rect3; dir: Vector3): Vector3 {.inline.} = - getGDNativeAPI().rect3GetSupport(self, dir) - -proc getLongestAxis*(self: Rect3): Vector3 {.inline.} = - getGDNativeAPI().rect3GetLongestAxis(self) - -proc getLongestAxisIndex*(self: Rect3): cint {.inline.} = - getGDNativeAPI().rect3GetLongestAxisIndex(self) - -proc getLongestAxisSize*(self: Rect3): float32 {.inline.} = - getGDNativeAPI().rect3GetLongestAxisSize(self) - -proc getShortestAxis*(self: Rect3): Vector3 {.inline.} = - getGDNativeAPI().rect3GetShortestAxis(self) - -proc getShortestAxisIndex*(self: Rect3): cint {.inline.} = - getGDNativeAPI().rect3GetShortestAxisIndex(self) - -proc getShortestAxisSize*(self: Rect3): float32 {.inline.} = - getGDNativeAPI().rect3GetShortestAxisSize(self) - -proc expand*(self: Rect3; toPoint: Vector3): Rect3 {.inline.} = - getGDNativeAPI().rect3Expand(self, toPoint) - -proc grow*(self: Rect3; by: float32): Rect3 {.inline.} = - getGDNativeAPI().rect3Grow(self, by) - -proc getEndpoint*(self: Rect3; idx: cint): Vector3 {.inline.} = - getGDNativeAPI().rect3GetEndpoint(self, idx) - -proc `==`*(a, b: Rect3): bool {.inline.} = - getGDNativeAPI().rect3OperatorEqual(a, b) diff --git a/godot/core/transforms.nim b/godot/core/transforms.nim index f70a1f8..fe43ccb 100644 --- a/godot/core/transforms.nim +++ b/godot/core/transforms.nim @@ -55,11 +55,11 @@ proc xformVector3*(self: Transform; v: Vector3): Vector3 {.inline.} = proc xformInvVector3*(self: Transform; v: Vector3): Vector3 {.inline.} = getGDNativeAPI().transformXformInvVector3(self, v) -proc xformRect3*(self: Transform; rect: Rect3): Rect3 {.inline.} = - getGDNativeAPI().transformXformRect3(self, rect) +proc xformAABB*(self: Transform; rect: AABB): AABB {.inline.} = + getGDNativeAPI().transformXformAABB(self, rect) -proc xformInvRect3*(self: Transform; rect: Rect3): Rect3 {.inline.} = - getGDNativeAPI().transformXformInvRect3(self, rect) +proc xformInvAABB*(self: Transform; rect: AABB): AABB {.inline.} = + getGDNativeAPI().transformXformInvAABB(self, rect) proc `==`*(self: Transform; b: Transform): bool {.inline.} = getGDNativeAPI().transformOperatorEqual(self, b) diff --git a/godot/core/variants.nim b/godot/core/variants.nim index 2dcc8d8..55284a1 100644 --- a/godot/core/variants.nim +++ b/godot/core/variants.nim @@ -80,7 +80,7 @@ proc newVariant*(s: string): Variant {.inline.} = godotStr.deinit() import basis, nodepaths -import planes, quats, rect2, rect3, rids +import planes, quats, rect2, aabb, rids import transforms, transform2d, vector2 import vector3, colors @@ -108,9 +108,9 @@ proc newVariant*(quat: Quat): Variant {.inline.} = new(result, variantFinalizer) initGodotVariant(result.godotVariant, quat) -proc newVariant*(rect3: Rect3): Variant {.inline.} = +proc newVariant*(aabb: AABB): Variant {.inline.} = new(result, variantFinalizer) - initGodotVariant(result.godotVariant, rect3) + initGodotVariant(result.godotVariant, aabb) proc newVariant*(basis: Basis): Variant {.inline.} = new(result, variantFinalizer) @@ -207,8 +207,8 @@ proc asPlane*(self: Variant): Plane = proc asQuat*(self: Variant): Quat = self.godotVariant.asQuat() -proc asRect3*(self: Variant): Rect3 = - self.godotVariant.asRect3() +proc asAABB*(self: Variant): AABB = + self.godotVariant.asAABB() proc asBasis*(self: Variant): Basis = self.godotVariant.asBasis() diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index ee7f6ad..64ea7eb 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -910,65 +910,65 @@ type rect2SetSize: proc (self: var Rect2, size: Vector2) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - # Rect3 API - rect3New: proc (dest: var Rect3, pos, size: Vector3) + # AABB API + aabbNew: proc (dest: var AABB, pos, size: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetPosition: proc (self: Rect3): Vector3 + aabbGetPosition: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3SetPosition: proc (self: var Rect3, pos: Vector3) + aabbSetPosition: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetSize: proc (self: Rect3): Vector3 + aabbGetSize: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3SetSize: proc (self: var Rect3, pos: Vector3) + aabbSetSize: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3AsString: proc (self: Rect3): GodotString + aabbAsString: proc (self: AABB): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetArea: proc (self: Rect3): float32 + aabbGetArea: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3HasNoArea: proc (self: Rect3): bool + aabbHasNoArea: proc (self: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3HasNoSurface: proc (self: Rect3): bool + aabbHasNoSurface: proc (self: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Intersects: proc (self, other: Rect3): bool + aabbIntersects: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Encloses: proc (self, other: Rect3): bool + aabbEncloses: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Merge: proc (self, other: Rect3): Rect3 + aabbMerge: proc (self, other: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Intersection: proc (self, other: Rect3): Rect3 + aabbIntersection: proc (self, other: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3IntersectsPlane: proc (self: Rect3, plane: Plane): bool + aabbIntersectsPlane: proc (self: AABB, plane: Plane): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3IntersectsSegment: proc (self: Rect3, vFrom, vTo: Vector3): bool + aabbIntersectsSegment: proc (self: AABB, vFrom, vTo: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3HasPoint: proc (self: Rect3, point: Vector3): bool + aabbHasPoint: proc (self: AABB, point: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetSupport: proc (self: Rect3, dir: Vector3): Vector3 + aabbGetSupport: proc (self: AABB, dir: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetLongestAxis: proc (self: Rect3): Vector3 + aabbGetLongestAxis: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetLongestAxisIndex: proc (self: Rect3): cint + aabbGetLongestAxisIndex: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetLongestAxisSize: proc (self: Rect3): float32 + aabbGetLongestAxisSize: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetShortestAxis: proc (self: Rect3): Vector3 + aabbGetShortestAxis: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetShortestAxisIndex: proc (self: Rect3): cint + aabbGetShortestAxisIndex: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetShortestAxisSize: proc (self: Rect3): float32 + aabbGetShortestAxisSize: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Expand: proc (self: Rect3, toPoint: Vector3): Rect3 + aabbExpand: proc (self: AABB, toPoint: Vector3): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Grow: proc (self: Rect3, by: float32): Rect3 + aabbGrow: proc (self: AABB, by: float32): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetEndpoint: proc (self: Rect3, idx: cint): Vector3 + aabbGetEndpoint: proc (self: AABB, idx: cint): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3OperatorEqual: proc (self, other: Rect3): bool + aabbOperatorEqual: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} # RID API @@ -1036,9 +1036,9 @@ type transformXformInvVector3: proc (self: Transform, v: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformRect3: proc (self: Transform, v: Rect3): Rect3 + transformXformAABB: proc (self: Transform, v: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvRect3: proc (self: Transform, v: Rect3): Rect3 + transformXformInvAABB: proc (self: Transform, v: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1136,7 +1136,7 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantNewQuat: proc (dest: var GodotVariant, val: Quat) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewRect3: proc (dest: var GodotVariant, val: Rect3) + variantNewAABB: proc (dest: var GodotVariant, val: AABB) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantNewBasis: proc (dest: var GodotVariant, val: Basis) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1203,7 +1203,7 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsQuat: proc (self: GodotVariant): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsRect3: proc (self: GodotVariant): Rect3 + variantAsAABB: proc (self: GodotVariant): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsBasis: proc (self: GodotVariant): Basis {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2176,65 +2176,65 @@ type rect2SetSize*: proc (self: var Rect2, size: Vector2) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - # Rect3 API - rect3New*: proc (dest: var Rect3, pos, size: Vector3) + # AABB API + aabbNew*: proc (dest: var AABB, pos, size: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetPosition*: proc (self: Rect3): Vector3 + aabbGetPosition*: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3SetPosition*: proc (self: var Rect3, pos: Vector3) + aabbSetPosition*: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetSize*: proc (self: Rect3): Vector3 + aabbGetSize*: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3SetSize*: proc (self: var Rect3, pos: Vector3) + aabbSetSize*: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3AsString*: proc (self: Rect3): GodotString + aabbAsString*: proc (self: AABB): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetArea*: proc (self: Rect3): float32 + aabbGetArea*: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3HasNoArea*: proc (self: Rect3): bool + aabbHasNoArea*: proc (self: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3HasNoSurface*: proc (self: Rect3): bool + aabbHasNoSurface*: proc (self: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Intersects*: proc (self, other: Rect3): bool + aabbIntersects*: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Encloses*: proc (self, other: Rect3): bool + aabbEncloses*: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Merge*: proc (self, other: Rect3): Rect3 + aabbMerge*: proc (self, other: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Intersection*: proc (self, other: Rect3): Rect3 + aabbIntersection*: proc (self, other: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3IntersectsPlane*: proc (self: Rect3, plane: Plane): bool + aabbIntersectsPlane*: proc (self: AABB, plane: Plane): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3IntersectsSegment*: proc (self: Rect3, vFrom, vTo: Vector3): bool + aabbIntersectsSegment*: proc (self: AABB, vFrom, vTo: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3HasPoint*: proc (self: Rect3, point: Vector3): bool + aabbHasPoint*: proc (self: AABB, point: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetSupport*: proc (self: Rect3, dir: Vector3): Vector3 + aabbGetSupport*: proc (self: AABB, dir: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetLongestAxis*: proc (self: Rect3): Vector3 + aabbGetLongestAxis*: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetLongestAxisIndex*: proc (self: Rect3): cint + aabbGetLongestAxisIndex*: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetLongestAxisSize*: proc (self: Rect3): float32 + aabbGetLongestAxisSize*: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetShortestAxis*: proc (self: Rect3): Vector3 + aabbGetShortestAxis*: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetShortestAxisIndex*: proc (self: Rect3): cint + aabbGetShortestAxisIndex*: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetShortestAxisSize*: proc (self: Rect3): float32 + aabbGetShortestAxisSize*: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Expand*: proc (self: Rect3, toPoint: Vector3): Rect3 + aabbExpand*: proc (self: AABB, toPoint: Vector3): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3Grow*: proc (self: Rect3, by: float32): Rect3 + aabbGrow*: proc (self: AABB, by: float32): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3GetEndpoint*: proc (self: Rect3, idx: cint): Vector3 + aabbGetEndpoint*: proc (self: AABB, idx: cint): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect3OperatorEqual*: proc (self, other: Rect3): bool + aabbOperatorEqual*: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} # RID API @@ -2302,9 +2302,9 @@ type transformXformInvVector3*: proc (self: Transform, v: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformRect3*: proc (self: Transform, v: Rect3): Rect3 + transformXformAABB*: proc (self: Transform, v: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvRect3*: proc (self: Transform, v: Rect3): Rect3 + transformXformInvAABB*: proc (self: Transform, v: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2402,7 +2402,7 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantNewQuat*: proc (dest: var GodotVariant, val: Quat) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantNewRect3*: proc (dest: var GodotVariant, val: Rect3) + variantNewAABB*: proc (dest: var GodotVariant, val: AABB) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantNewBasis*: proc (dest: var GodotVariant, val: Basis) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2469,7 +2469,7 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsQuat*: proc (self: GodotVariant): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsRect3*: proc (self: GodotVariant): Rect3 + variantAsAABB*: proc (self: GodotVariant): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsBasis*: proc (self: GodotVariant): Basis {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2953,34 +2953,34 @@ proc setGDNativeAPI*(apiStruct: pointer) {.inline.} = rect2SetPosition rect2SetSize - # Rect3 API - rect3New - rect3GetPosition - rect3SetPosition - rect3GetSize - rect3SetSize - rect3AsString - rect3GetArea - rect3HasNoArea - rect3HasNoSurface - rect3Intersects - rect3Encloses - rect3Merge - rect3Intersection - rect3IntersectsPlane - rect3IntersectsSegment - rect3HasPoint - rect3GetSupport - rect3GetLongestAxis - rect3GetLongestAxisIndex - rect3GetLongestAxisSize - rect3GetShortestAxis - rect3GetShortestAxisIndex - rect3GetShortestAxisSize - rect3Expand - rect3Grow - rect3GetEndpoint - rect3OperatorEqual + # AABB API + aabbNew + aabbGetPosition + aabbSetPosition + aabbGetSize + aabbSetSize + aabbAsString + aabbGetArea + aabbHasNoArea + aabbHasNoSurface + aabbIntersects + aabbEncloses + aabbMerge + aabbIntersection + aabbIntersectsPlane + aabbIntersectsSegment + aabbHasPoint + aabbGetSupport + aabbGetLongestAxis + aabbGetLongestAxisIndex + aabbGetLongestAxisSize + aabbGetShortestAxis + aabbGetShortestAxisIndex + aabbGetShortestAxisSize + aabbExpand + aabbGrow + aabbGetEndpoint + aabbOperatorEqual # RID API ridNew @@ -3011,8 +3011,8 @@ proc setGDNativeAPI*(apiStruct: pointer) {.inline.} = transformOperatorMultiply transformXformVector3 transformXformInvVector3 - transformXformRect3 - transformXformInvRect3 + transformXformAABB + transformXformInvAABB # Transform2D API transform2DNew @@ -3054,7 +3054,7 @@ proc setGDNativeAPI*(apiStruct: pointer) {.inline.} = variantNewPlane variantNewQuat - variantNewRect3 + variantNewAABB variantNewBasis variantNewTransform variantNewColor @@ -3081,7 +3081,7 @@ proc setGDNativeAPI*(apiStruct: pointer) {.inline.} = variantAsTransform2D variantAsPlane variantAsQuat - variantAsRect3 + variantAsAABB variantAsBasis variantAsTransform variantAsColor diff --git a/godot/godot.nim b/godot/godot.nim index bab24f7..d72c4f1 100644 --- a/godot/godot.nim +++ b/godot/godot.nim @@ -4,14 +4,14 @@ import core.godotbase, godotinternal import core.godotcoretypes import core.vector2, core.rect2, core.vector3, core.transform2d, core.planes, core.quats -import core.rect3, core.basis, core.transforms, core.colors, core.nodepaths, +import core.aabb, core.basis, core.transforms, core.colors, core.nodepaths, core.rids import core.dictionaries, core.arrays, core.poolarrays, core.variants import nim.godotmacros, nim.godotnim export godotbase, godotcoretypes, vector2, rect2, vector3, transform2d, planes, - quats, rect3, basis, transforms, colors, nodepaths, rids, dictionaries, + quats, aabb, basis, transforms, colors, nodepaths, rids, dictionaries, arrays, poolarrays, variants export godotmacros, godotnim diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 526a1f8..6d12c64 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -274,7 +274,7 @@ const standardTypes = toSet( ["bool", "cint", "int", "uint8", "int8", "uint16", "int16", "uint32", "int32", "uint64", "int64", "float32", "cfloat", "float64", "GodotString", "Vector2", "Rect2", - "Vector3", "Transform2D", "Plane", "Quat", "Rect3", "Basis", "Transform", + "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform", "Color", "RID", "NodePath", "Dictionary", "Variant", "Array", "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray", "PoolVector2Array", "PoolVector3Array", "PoolColorArray"]) diff --git a/godot/internal/godotinternaltypes.nim b/godot/internal/godotinternaltypes.nim index 29b0e00..ba661ad 100644 --- a/godot/internal/godotinternaltypes.nim +++ b/godot/internal/godotinternaltypes.nim @@ -45,7 +45,7 @@ type Transform2D, Plane, Quat, ## 10 - Rect3, + AABB, Basis, Transform, ## misc types Color, diff --git a/godot/internal/godotvariants.nim b/godot/internal/godotvariants.nim index 5e9ebb8..d48e876 100644 --- a/godot/internal/godotvariants.nim +++ b/godot/internal/godotvariants.nim @@ -44,8 +44,8 @@ proc initGodotVariant*(dest: var GodotVariant; plane: Plane) {.inline.} = proc initGodotVariant*(dest: var GodotVariant; quat: Quat) {.inline.} = getGDNativeAPI().variantNewQuat(dest, quat) -proc initGodotVariant*(dest: var GodotVariant; rect3: Rect3) {.inline.} = - getGDNativeAPI().variantNewRect3(dest, rect3) +proc initGodotVariant*(dest: var GodotVariant; aabb: AABB) {.inline.} = + getGDNativeAPI().variantNewAABB(dest, aabb) proc initGodotVariant*(dest: var GodotVariant; basis: Basis) {.inline.} = getGDNativeAPI().variantNewBasis(dest, basis) @@ -138,8 +138,8 @@ proc asPlane*(self: GodotVariant): Plane {.inline.} = proc asQuat*(self: GodotVariant): Quat {.inline.} = getGDNativeAPI().variantAsQuat(self) -proc asRect3*(self: GodotVariant): Rect3 {.inline.} = - getGDNativeAPI().variantAsRect3(self) +proc asAABB*(self: GodotVariant): AABB {.inline.} = + getGDNativeAPI().variantAsAABB(self) proc asBasis*(self: GodotVariant): Basis {.inline.} = getGDNativeAPI().variantAsBasis(self) diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 54d8d23..b1c4be5 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -5,7 +5,7 @@ import gdnativeapi import core.godotcoretypes import core.vector2, core.rect2, core.vector3, core.transform2d, - core.planes, core.quats, core.rect3, + core.planes, core.quats, core.aabb, core.basis, core.transforms, core.colors, core.nodepaths, core.rids, core.dictionaries, core.arrays, core.poolarrays, core.variants @@ -57,7 +57,7 @@ type SomeFloat = float32 or float64 or cfloat SomeGodot = bool or Vector2 or Rect2 or Vector3 or - Transform2D or Plane or Quat or Rect3 or + Transform2D or Plane or Quat or AABB or Basis or Transform or Color or NodePath or RID or GodotObject or Dictionary or Array or PoolByteArray or PoolIntArray or PoolRealArray or @@ -497,8 +497,8 @@ proc godotTypeInfo*(T: typedesc[SomeGodotOrNum]): GodotTypeInfo {.inline.} = VariantType.Plane elif T is Quat: VariantType.Quat - elif T is Rect3: - VariantType.Rect3 + elif T is AABB: + VariantType.AABB elif T is Basis: VariantType.Basis elif T is Transform: @@ -614,8 +614,8 @@ proc fromVariant*[T: SomeGodot](self: var T, val: Variant): ConversionResult = self = val.asPlane() elif self is Quat: self = val.asQuat() - elif self is Rect3: - self = val.asRect3() + elif self is AABB: + self = val.asAABB() elif self is Basis: self = val.asBasis() elif self is Transform: From a1c378301a993d533d74f8793e46c15e6fb4414f Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Tue, 21 Nov 2017 02:44:32 +0700 Subject: [PATCH 18/82] Update for latest Godot --- godot.nimble | 2 +- godot/gdnativeapi.nim | 29 +++++++++++++++------------ godot/godotinternal.nim | 6 ++---- godot/internal/godotinternaltypes.nim | 11 ++++++++-- godot/internal/godotstrings.nim | 3 --- godot/nim/godotnim.nim | 6 +++--- 6 files changed, 31 insertions(+), 26 deletions(-) diff --git a/godot.nimble b/godot.nimble index 72b93a8..fc2f0b3 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.5" +version = "0.6.6" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index 64ea7eb..7283ed7 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -9,10 +9,6 @@ type GDNativeExtPluginScript, GDNativeExtNativeARVR - GDNativeAPIVersion = object - major: cuint - minor: cuint - GDNativeAPIHeader = object typ: cuint version: GDNativeAPIVersion @@ -1271,8 +1267,6 @@ type stringGetData: proc (self: GodotString, dest: cstring, size: var cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringOperatorIndex: pointer - stringCStr: proc (self: GodotString): cstring - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringOperatorIndexConst: pointer stringUTF16Str: pointer stringOperatorEqual: proc (self, other: GodotString): bool @@ -1450,7 +1444,10 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} getClassConstructor: proc (className: cstring): GodotClassConstructor {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - + registerNativeCallType: proc (callType: cstring, + cb: proc (procHandle: pointer, + args: ptr GodotArray): GodotVariant + {.noconv.}) {.noconv.} alloc: proc (bytes: cint): pointer {.noconv, raises: [], gcsafe, tags: [], locks: 0.} realloc: proc (p: pointer, bytes: cint): pointer @@ -2535,8 +2532,6 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringGetData*: proc (self: GodotString, dest: cstring, size: var cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringCStr*: proc (self: GodotString): cstring - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringOperatorEqual*: proc (self, other: GodotString): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringOperatorLess*: proc (self, other: GodotString): bool @@ -2627,7 +2622,7 @@ var gdNativeAPI: GDNativeAPI proc getGDNativeAPI*(): ptr GDNativeAPI {.inline.} = addr gdNativeAPI -proc setGDNativeAPI*(apiStruct: pointer) {.inline.} = +proc setGDNativeAPI*(apiStruct: pointer, initOptions: ptr GDNativeInitOptions) = let header = cast[ptr GDNativeAPIHeader](apiStruct) if header.typ >= ord(low(GDNativeAPIType)).cuint and header.typ <= ord(high(GDNativeAPIType)).cuint: @@ -3110,7 +3105,6 @@ proc setGDNativeAPI*(apiStruct: pointer) {.inline.} = stringNewCopy stringNewData stringGetData - stringCStr stringOperatorEqual stringOperatorLess stringOperatorPlus @@ -3134,7 +3128,11 @@ proc setGDNativeAPI*(apiStruct: pointer) {.inline.} = print for i in 0.cuint.. Date: Wed, 22 Nov 2017 12:28:54 +0700 Subject: [PATCH 19/82] Update for latest Godot --- godot.nimble | 2 +- godot/core/nodepaths.nim | 4 ++-- godot/gdnativeapi.nim | 28 +++++++++++++++++++++++----- godot/internal/godotarrays.nim | 9 +++++++++ godot/internal/godotnodepaths.nim | 4 ++-- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/godot.nimble b/godot.nimble index fc2f0b3..3e778fd 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.6" +version = "0.6.7" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/nodepaths.nim b/godot/core/nodepaths.nim index 62e30f8..537d93e 100644 --- a/godot/core/nodepaths.nim +++ b/godot/core/nodepaths.nim @@ -51,8 +51,8 @@ proc getSubname*(self: NodePath; idx: int): string {.inline.} = result = $s s.deinit() -proc property*(self: NodePath): string {.inline.} = - var s = self.path.property() +proc getConcatenatedSubnames*(self: NodePath): string {.inline.} = + var s = self.path.getConcatenatedSubnames() result = $s s.deinit() diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index 7283ed7..2d6d98b 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -750,6 +750,13 @@ type arraySortCustom: proc (self: var GodotArray, obj: ptr GodotObject, f: GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayBSearch: proc (self: var GodotArray, val: ptr GodotVariant, + before: bool) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayBSearchCustom: proc (self: var GodotArray, val: ptr GodotVariant, + obj: ptr GodotObject, f: GodotString, + before: bool) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} arrayDestroy: proc (self: var GodotArray) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -816,8 +823,9 @@ type locks: 0.} nodePathGetSubname: proc (self: GodotNodePath, idx: cint): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathGetProperty: proc (self: GodotNodePath): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetConcatenatedSubnames: proc (self: GodotNodePath): GodotString + {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} nodePathIsEmpty: proc (self: GodotNodePath): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} nodePathOperatorEqual: proc (self, other: GodotNodePath): bool @@ -2018,6 +2026,13 @@ type arraySortCustom*: proc (self: var GodotArray, obj: ptr GodotObject, f: GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayBSearch*: proc (self: var GodotArray, val: ptr GodotVariant, + before: bool) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + arrayBSearchCustom*: proc (self: var GodotArray, val: ptr GodotVariant, + obj: ptr GodotObject, f: GodotString, + before: bool) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} arrayDestroy*: proc (self: var GodotArray) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2083,8 +2098,9 @@ type locks: 0.} nodePathGetSubname*: proc (self: GodotNodePath, idx: cint): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - nodePathGetProperty*: proc (self: GodotNodePath): GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + nodePathGetConcatenatedSubnames*: proc (self: GodotNodePath): GodotString + {.noconv, raises: [], gcsafe, + tags: [], locks: 0.} nodePathIsEmpty*: proc (self: GodotNodePath): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} nodePathOperatorEqual*: proc (self, other: GodotNodePath): bool @@ -2871,6 +2887,8 @@ proc setGDNativeAPI*(apiStruct: pointer, initOptions: ptr GDNativeInitOptions) = arraySize arraySort arraySortCustom + arrayBSearch + arrayBSearchCustom arrayDestroy # Dictionary API @@ -2903,7 +2921,7 @@ proc setGDNativeAPI*(apiStruct: pointer, initOptions: ptr GDNativeInitOptions) = nodePathGetName nodePathGetSubnameCount nodePathGetSubname - nodePathGetProperty + nodePathGetConcatenatedSubnames nodePathIsEmpty nodePathOperatorEqual diff --git a/godot/internal/godotarrays.nim b/godot/internal/godotarrays.nim index 676e6cd..607474f 100644 --- a/godot/internal/godotarrays.nim +++ b/godot/internal/godotarrays.nim @@ -126,6 +126,15 @@ proc sortCustom*(self: var GodotArray; obj: ptr GodotObject; funcName: GodotString) {.inline.} = getGDNativeAPI().arraySortCustom(self, obj, funcName) +proc binarySearch*(self: var GodotArray, val: ptr GodotVariant, + before: bool) {.inline.} = + getGDNativeAPI().arrayBSearch(self, val, before) + +proc binarySearchCustom*(self: var GodotArray, val: ptr GodotVariant, + obj: ptr GodotObject, funcName: GodotString, + before: bool) {.inline.} = + getGDNativeAPI().arrayBSearchCustom(self, val, obj, funcName, before) + iterator items*(self: GodotArray): GodotVariant = for i in 0.. Date: Wed, 22 Nov 2017 16:36:39 +0700 Subject: [PATCH 20/82] Update for latest Nim --- docs/index.rst | 2 +- godot.nimble | 2 +- godot/internal/godotarrays.nim | 8 ++++---- godot/internal/godotpoolarrays.nim | 4 ++-- godot/nim/godotmacros.nim | 11 ++++++----- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index a1607f6..bffe100 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -55,7 +55,7 @@ about compiling Godot can be found in `Godot documentation Installing Nim ------------- -The library requires Nim version 0.17.2 or newer, which you can get here: +The library requires Nim version 0.18.0 or newer, which you can get here: https://nim-lang.org/install.html Make sure you also have ``nimble`` (Nim's package manager) installed. diff --git a/godot.nimble b/godot.nimble index 3e778fd..cac30be 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.7" +version = "0.6.8" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/internal/godotarrays.nim b/godot/internal/godotarrays.nim index 607474f..32bcefa 100644 --- a/godot/internal/godotarrays.nim +++ b/godot/internal/godotarrays.nim @@ -136,20 +136,20 @@ proc binarySearchCustom*(self: var GodotArray, val: ptr GodotVariant, getGDNativeAPI().arrayBSearchCustom(self, val, obj, funcName, before) iterator items*(self: GodotArray): GodotVariant = - for i in 0.. Date: Wed, 22 Nov 2017 16:48:37 +0700 Subject: [PATCH 21/82] Repair Travis build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3dbd69a..d0b4bfa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ addons: - libxrandr-dev before_install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install scons ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rvm --default use 2.3; brew update; brew install scons ; fi install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export GODOT_PLATFORM=osx; else export GODOT_PLATFORM=x11; fi From 0d21c361d00d528e3fb678ae409899ff643ab853 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Tue, 28 Nov 2017 12:04:07 +0700 Subject: [PATCH 22/82] Use setStackBottom for methods called from outside --- godot.nimble | 2 +- godot/nim/godotmacros.nim | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index cac30be..968dac3 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.8" +version = "0.6.9" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index ef478f9..682f8ec 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -541,10 +541,17 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = template registerGodotMethod(classNameLit, classNameIdent, methodNameIdent, methodNameLit, minArgs, maxArgs, argTypes, methFuncIdent, hasReturnValue) = + {.emit: """/*TYPESECTION*/ +N_NOINLINE(void, setStackBottom)(void* thestackbottom); +""".} proc methFuncIdent(obj: ptr GodotObject, methodData: pointer, userData: pointer, numArgs: cint, args: var array[MAX_ARG_COUNT, ptr GodotVariant]): GodotVariant {.noconv.} = + var stackBottom {.volatile.}: pointer + {.emit: """ + setStackBottom((void*)(&`stackBottom`)); + """.} let self = cast[classNameIdent](userData) const isStaticCall = methodNameLit == cstring"_ready" or methodNameLit == cstring"_process" or From 8d6972f729603291c9d7b20f0475430ab41e85c7 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Fri, 8 Dec 2017 13:21:01 +0700 Subject: [PATCH 23/82] Fix doc generation --- docs/docbuild.nim | 4 ++-- godot/godotapigen.nim | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docbuild.nim b/docs/docbuild.nim index b48368d..653b685 100644 --- a/docs/docbuild.nim +++ b/docs/docbuild.nim @@ -94,7 +94,7 @@ proc buildDocs*(outDir, godotNimDir, godotBin: string) = allNimFiles.add(file) for file in allNimFiles: spawn execOrFail( - "nim doc -o:" & quoted(outName(outDirAbs, file)) & + "nim doc -d:useRealtimeGc -o:" & quoted(outName(outDirAbs, file)) & " --git.url:" & quoted(gitHubUrl) & " --git.commit:" & quoted(gitCommit) & ' ' & quoted(file)) @@ -103,7 +103,7 @@ proc buildDocs*(outDir, godotNimDir, godotBin: string) = createDir(godotApiFolder) genApiFiles(godotApiFolder, godotBinAbs) for file in walkDirRec(godotApiFolder, {pcFile, pcDir}, [".nim"]): - spawn execOrFail("nim doc " & quoted(file)) + spawn execOrFail("nim doc -d:useRealtimeGc " & quoted(file)) sync() diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 6d12c64..15fd9fc 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -2,7 +2,7 @@ import streams, json, os, strutils, times, sets, tables import sequtils, algorithm -import compiler / [ast, renderer, idents, astalgo] +import compiler.ast, compiler.renderer, compiler.idents, compiler.astalgo proc ident(ident: string): PNode = result = newNode(nkIdent) From c06792df8d846084a3c99d63ee42c110318b56e9 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Fri, 8 Dec 2017 16:07:23 +0700 Subject: [PATCH 24/82] Add vec2(). Closes #12 --- godot/core/vector2.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/godot/core/vector2.nim b/godot/core/vector2.nim index 9eca64d..7cf3ee5 100644 --- a/godot/core/vector2.nim +++ b/godot/core/vector2.nim @@ -3,6 +3,9 @@ import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi +proc vec2*(): Vector2 {.inline.} = + Vector2() + proc vec2*(x, y: float32): Vector2 {.inline.} = Vector2(x: x, y: y) From 50835baca82b8c55c123364ada16696938501598 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Fri, 8 Dec 2017 15:44:28 +0700 Subject: [PATCH 25/82] Fix travis --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d0b4bfa..b0b27d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,5 @@ script: - set -e - mkdir godotapi - nim c -d:release -r godot/godotapigen.nim "$GODOT_BIN" godotapi - - nimble install -y - - nim c -d:useRealtimeGc -c godotapi/godotall.nim + - nim c -d:useRealtimeGc --path:godot -c godotapi/godotall.nim - nim c -d:release -r docs/docpublish.nim From 72dd992e6644846c84363af3baab3c4020abdcca Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Fri, 8 Dec 2017 21:23:32 +0700 Subject: [PATCH 26/82] Fix docbuild --- docs/docbuild.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/docbuild.nim b/docs/docbuild.nim index 653b685..fb957f5 100644 --- a/docs/docbuild.nim +++ b/docs/docbuild.nim @@ -94,7 +94,8 @@ proc buildDocs*(outDir, godotNimDir, godotBin: string) = allNimFiles.add(file) for file in allNimFiles: spawn execOrFail( - "nim doc -d:useRealtimeGc -o:" & quoted(outName(outDirAbs, file)) & + "nim doc -d:useRealtimeGc --path:godot -o:" & + quoted(outName(outDirAbs, file)) & " --git.url:" & quoted(gitHubUrl) & " --git.commit:" & quoted(gitCommit) & ' ' & quoted(file)) @@ -103,7 +104,7 @@ proc buildDocs*(outDir, godotNimDir, godotBin: string) = createDir(godotApiFolder) genApiFiles(godotApiFolder, godotBinAbs) for file in walkDirRec(godotApiFolder, {pcFile, pcDir}, [".nim"]): - spawn execOrFail("nim doc -d:useRealtimeGc " & quoted(file)) + spawn execOrFail("nim doc -d:useRealtimeGc --path:godot " & quoted(file)) sync() From 4d19140d7c8d1ae7ba84325d86351472cd87e187 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 18 Dec 2017 13:48:01 +0700 Subject: [PATCH 27/82] Update for latest GDNative API changes --- godot.nimble | 2 +- godot/gdnativeapi.nim | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index 968dac3..a059e73 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.9" +version = "0.6.10" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index 2d6d98b..c6282ae 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -1452,6 +1452,7 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} getClassConstructor: proc (className: cstring): GodotClassConstructor {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + getGlobalConstants: pointer registerNativeCallType: proc (callType: cstring, cb: proc (procHandle: pointer, args: ptr GodotArray): GodotVariant From e2feb0646889d908dc3a54ff57a285eaa01aa2f8 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 18 Dec 2017 17:22:12 +0700 Subject: [PATCH 28/82] Add indexed property support --- godot.nimble | 2 +- godot/godotapigen.nim | 62 +++++++++++++++++++++++++++++++------------ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/godot.nimble b/godot.nimble index a059e73..75c518a 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.10" +version = "0.6.11" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 15fd9fc..6d7eae5 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -259,7 +259,17 @@ proc makeConstSection(constObj: JsonNode): PNode = result.add(def) type - MethodArg = tuple[name, typ: string, defaultVal: JsonNode, isVarargs: bool] + ArgKind = enum + Normal, + VarArgs + Bound + + MethodArg = object + name: string + typ: string + defaultVal: JsonNode + kind: ArgKind + MethodInfo = ref object name: PNode godotName: string @@ -349,6 +359,9 @@ proc makeDefaultValue(arg: MethodArg): PNode = "Cannot build default value from $# ($#)" % [$arg.defaultVal, arg.typ]) +proc boundArgName(idx: int): string = + "godotBoundArg" & $idx + proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], meth: MethodInfo, withImplementation: bool) = var body: PNode @@ -390,12 +403,16 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], var argLenNode = newIntLit(0) let argsName = ident("argsToPassToGodot") if meth.args.len > 0: - for arg in meth.args: - if arg.isVarargs: + for idx, arg in meth.args: + if arg.kind == ArgKind.VarArgs: varargsName = arg.name isVarargs = true vars.add(newIdentDefs(ident("callError"), ident("VariantCallError"))) - break + elif arg.kind == ArgKind.Bound: + let argName = boundArgName(idx) + vars.add(newIdentDefs( + ident(argName), newNode(nkEmpty), arg.makeDefaultValue())) + let argsAlloc = newNode(nkCast).addChain( newNode(nkPtrTy).addChain( newNode(nkBracketExpr).addChain( @@ -425,12 +442,13 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], let argConversions = newNode(nkStmtList) for idx, arg in meth.args: - var argName = ident(arg.name) - if arg.isVarargs: + var argName = if arg.kind == ArgKind.Bound: ident(boundArgName(idx)) + else: ident(arg.name) + if arg.kind == ArgKind.VarArgs: argName = newNode(nkBracketExpr).addChain( ident(varargsName), infix(ident("idx"), ident("-"), newIntLit(staticArgsLen))) - let argIdx = if arg.isVarargs: ident("idx") else: newIntLit(idx) + let argIdx = if arg.kind == ArgKind.VarArgs: ident("idx") else: newIntLit(idx) let isStandardType = arg.typ in standardTypes let isWrappedType = arg.typ in wrapperTypes let convArg = if not varargsName.isNil: @@ -440,7 +458,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], elif arg.typ == "string": newCall("unsafeAddr", ident("argToPassToGodot" & $idx)) else: ident("argToPassToGodot" & $idx) # object - if not isStandardType and arg.isVarargs: + if not isStandardType and arg.kind == ArgKind.VarArgs: raise newException(ValueError, "Non-standard type $# for varargs params of method $# of type $#" % [arg.typ, meth.godotName, meth.typ.godotName]) @@ -458,7 +476,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], newNode(nkBracketExpr).addChain(argsName), argIdx), convArg ) - if not arg.isVarargs: + if arg.kind != ArgKind.VarArgs: argConversions.add( argAsgn ) @@ -610,12 +628,16 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], params.add(newIdentDefs(ident("self"), ident(toNimType(meth.typ.name)))) for arg in meth.args: - if arg.isVarargs: - params.add(newIdentDefs(ident(arg.name), - newNode(nkBracketExpr).addChain(ident("varargs"), ident(arg.typ)))) - else: + case arg.kind: + of ArgKind.Normal: let defaultValue = arg.makeDefaultValue() params.add(newIdentDefs(ident(arg.name), ident(arg.typ), defaultValue)) + of ArgKind.VarArgs: + params.add(newIdentDefs(ident(arg.name), + newNode(nkBracketExpr).addChain(ident("varargs"), ident(arg.typ)))) + of ArgKind.Bound: + discard + let procDecl = newProc(if not withImplementation: postfix(meth.name, "*") else: meth.name, params, body, procType) @@ -656,8 +678,13 @@ proc makeProperty(types: Table[string, GodotType], tree: PNode, name: setterName, typ: typ, godotName: propertyObj["setter"].str, - args: @[("val", nimType, JsonNode(nil), false)] + args: @[MethodArg(name: "val", typ: nimType)] ) + if "index" in propertyObj and propertyObj["index"] != newJInt(-1): + getterInfo.args = @[MethodArg(defaultVal: newJString($propertyObj["index"]), + typ: "int", kind: ArgKind.Bound)] & getterInfo.args + setterInfo.args = @[MethodArg(defaultVal: newJString($propertyObj["index"]), + typ: "int", kind: ArgKind.Bound)] & setterInfo.args generateMethod(tree, methodBindRegistry, getterInfo, withImplementation) generateMethod(tree, methodBindRegistry, setterInfo, withImplementation) @@ -694,10 +721,11 @@ proc makeMethod(types: Table[string, GodotType], tree: PNode, let typ = toNimType(types, arg["type"].str) let defaultVal = if arg["has_default_value"].bval: arg["default_value"] else: nil - args.add((toNimStyle(arg["name"].str), typ, - defaultVal, false)) + args.add(MethodArg( + name: toNimStyle(arg["name"].str), typ: typ, + defaultVal: defaultVal)) if methodObj["has_varargs"].bval: - args.add(("variantArgs", "Variant", JsonNode(nil), true)) + args.add(MethodArg(name: "variantArgs", typ: "Variant", kind: ArgKind.VarArgs)) let godotName = methodObj["name"].str var nimName = toNimStyle(godotName) From d89073bac8affc5b0d90ea7fe4078442d6aa4d3e Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Fri, 29 Dec 2017 11:50:56 +0700 Subject: [PATCH 29/82] Do not depend on asyncdispatch Instead, allow to register frame callbacks. --- godot.nimble | 2 +- godot/nim/godotnim.nim | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/godot.nimble b/godot.nimble index 75c518a..b2d68a7 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.6.11" +version = "0.7.0" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 0eccb6b..5a346c6 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -1,6 +1,6 @@ # Copyright 2017 Xored Software, Inc. -import tables, typetraits, macros, asyncdispatch +import tables, typetraits, macros import gdnativeapi import core.godotcoretypes import core.vector2, core.rect2, @@ -811,15 +811,30 @@ proc godot_gdnative_terminate(options: ptr GDNativeTerminateOptions) {. deallocHeap(runFinalizers = not options[].inEditor, allowGcAfterwards = false) const nimGcStepLengthUs {.intdefine.} = 2000 + +var idleCallbacks {.threadvar.}: seq[proc () {.closure.}] +idleCallbacks = newSeq[proc () {.closure.}]() + +var isMainThread {.threadvar.}: bool +isMainThread = true + +proc registerFrameCallback*(cb: proc () {.closure.}) = + # Registers a callback to be called on the main thread at the end + # of each frame. + if not isMainThread: + const err = cstring"registerFrameIdleCallback is called from non-main thread. Ignoring." + godotPrintError(err, cstring"registerFrameCallback", + cstring"godotnim.nim", 0) + else: + idleCallbacks.add(cb) + proc godot_nativescript_frame() {.cdecl, exportc, dynlib.} = var stackBottom {.volatile.}: pointer {.emit: """ setStackBottom((void*)(&`stackBottom`)); """.} - for _ in 1..10: - if not asyncdispatch.hasPendingOperations(): - break - poll(0) + for cb in idleCallbacks: + cb() GC_step(nimGcStepLengthUs, true, 0) when not defined(release): From 09326f5104bdf6290a9b3f071e69bf650347758e Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 11 Jan 2018 16:52:41 +0700 Subject: [PATCH 30/82] Fix Reference leak and improve gdnew performance --- godot.nimble | 2 +- godot/godotapigen.nim | 3 ++- godot/nim/godotnim.nim | 24 +++++++++++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/godot.nimble b/godot.nimble index b2d68a7..8415020 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.0" +version = "0.7.1" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 6d7eae5..f8c06e3 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -612,7 +612,8 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], elif isObjRet: body.add(newNode(nkAsgn).addChain(ident("result"), newCall(newBracketExpr(ident("asNimGodotObject"), - newCall("type", ident("result"))), retValIdent))) + newCall("type", ident("result"))), + retValIdent, ident("false"), ident("true")))) elif isStringRet: body.add(newNode(nkAsgn).addChain(ident("result"), newCall("$", retValIdent))) diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 5a346c6..01da5ac 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -140,6 +140,13 @@ proc reference(o: ptr GodotObject): bool {.discardable.} = cstring"reference") referenceMethodBind.ptrCall(o, nil, addr result) +var initRefMethodBind {.threadvar.}: ptr GodotMethodBind +proc initRef(o: ptr GodotObject): bool {.discardable.} = + if isNil(initRefMethodBind): + initRefMethodBind = getMethod(cstring"Reference", + cstring"init_ref") + initRefMethodBind.ptrCall(o, nil, addr result) + proc deinit*(obj: NimGodotObject) = ## Destroy the object. You only need to call this for objects not inherited ## from Reference, where manual lifecycle control is necessary. @@ -240,7 +247,7 @@ proc newNimGodotObject[T: NimGodotObject]( result.godotObject.reference() proc asNimGodotObject*[T: NimGodotObject]( - godotObject: ptr GodotObject, forceNativeObject: bool = false): T = + godotObject: ptr GodotObject, forceNativeObject, noRef: bool = false): T = ## Wraps ``godotObject`` into Nim type ``T``. ## This is used by `godotapigen `_ and should rarely be ## used by anything else. @@ -253,7 +260,8 @@ proc asNimGodotObject*[T: NimGodotObject]( result = nil if result.isNil: result = newNimGodotObject[T]( - godotObject, cstring(godotObject.getClassName()), forceNativeObject) + godotObject, cstring(godotObject.getClassName()), + forceNativeObject or noRef) proc newVariant*(obj: NimGodotObject): Variant {.inline.} = newVariant(obj.godotObject) @@ -377,9 +385,15 @@ proc gdnew*[T: NimGodotObject](): T = ## Instantiates new object of type ``T``. const godotName = asCString(toGodotName(T)) const objInfo = classRegistryStatic[godotName] - result = when objInfo.isNative: - asNimGodotObject[T](getClassConstructor(godotName)()) - else: newOwnObj[T](godotName) + when objInfo.isNative: + let godotObject = getClassConstructor(godotName)() + new(result, nimGodotObjectFinalizer[T]) + result.godotObject = godotObject + when objInfo.isRef: + godotObject.initRef() + result.isRef = true + else: + result = newOwnObj[T](godotName) proc newCallError*(err: VariantCallError): ref CallError = ## Instantiates ``CallError`` from Godot ``err``. From d4ab8a5524b767610e4b87787386af7ada801911 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Fri, 12 Jan 2018 23:22:50 +0700 Subject: [PATCH 31/82] Update after recent GDNative API changes --- godot.nimble | 2 +- godot/gdnativeapi.nim | 51 +++++++++++++++++++-------- godot/godotapigen.nim | 26 ++++++++------ godot/internal/godotinternaltypes.nim | 3 ++ godot/internal/godotstrings.nim | 20 ++++------- 5 files changed, 62 insertions(+), 40 deletions(-) diff --git a/godot.nimble b/godot.nimble index 8415020..dd4f14d 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.1" +version = "0.7.2" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index c6282ae..3028b96 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -1265,18 +1265,20 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} # String API + charStringLength: proc (self: GodotCharString): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + charStringGetData: proc (self: GodotCharString): cstring + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + charStringDestroy: proc (self: var GodotCharString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringNew: proc (dest: var GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringNewCopy: proc (dest: var GodotString, src: GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringNewData: proc (dest: var GodotString, contents: cstring, size: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringNewUTF16Data: pointer - stringGetData: proc (self: GodotString, dest: cstring, size: var cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringNewWithWideString: pointer stringOperatorIndex: pointer stringOperatorIndexConst: pointer - stringUTF16Str: pointer + stringWideStr: pointer stringOperatorEqual: proc (self, other: GodotString): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringOperatorLess: proc (self, other: GodotString): bool @@ -1285,6 +1287,9 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringLength: proc (self: GodotString): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringCasecmpTo: pointer + stringNocasecmpTo: pointer + stringNaturalnocasecmpTo: pointer stringBeginsWith: pointer stringBeginsWithCharArray: pointer stringBigrams: pointer @@ -1376,11 +1381,14 @@ type stringErase: pointer stringAscii: pointer stringAsciiExtended: pointer - stringUtf8: pointer + stringUtf8: proc (self: GodotString): GodotCharString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringParseUtf8: pointer stringParseUtf8WithLen: pointer - stringCharsToUtf8: pointer - stringCharsToUtf8WithLen: pointer + stringCharsToUtf8: proc (str: cstring): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringCharsToUtf8WithLen: proc (str: cstring, len: cint): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringHash: pointer stringHash64: pointer stringHashChars: pointer @@ -2541,14 +2549,16 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} # String API + charStringLength*: proc (self: GodotCharString): cint + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + charStringGetData*: proc (self: GodotCharString): cstring + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + charStringDestroy*: proc (self: var GodotCharString) + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringNew*: proc (dest: var GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringNewCopy*: proc (dest: var GodotString, src: GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringNewData*: proc (dest: var GodotString, contents: cstring, size: cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - stringGetData*: proc (self: GodotString, dest: cstring, size: var cint) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringOperatorEqual*: proc (self, other: GodotString): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringOperatorLess*: proc (self, other: GodotString): bool @@ -2559,6 +2569,12 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringDestroy*: proc (self: var GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringUtf8*: proc (self: GodotString): GodotCharString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringCharsToUtf8*: proc (str: cstring): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringCharsToUtf8WithLen*: proc (str: cstring, len: cint): GodotString + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} # Misc API objectDestroy*: proc (self: ptr GodotObject) @@ -3120,15 +3136,20 @@ proc setGDNativeAPI*(apiStruct: pointer, initOptions: ptr GDNativeInitOptions) = variantDestroy # String API + charStringLength + charStringGetData + charStringDestroy + stringNew stringNewCopy - stringNewData - stringGetData stringOperatorEqual stringOperatorLess stringOperatorPlus stringLength stringDestroy + stringUtf8 + stringCharsToUtf8 + stringCharsToUtf8WithLen # Misc API objectDestroy diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index f8c06e3..4075229 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -697,10 +697,14 @@ proc makeMethod(types: Table[string, GodotType], tree: PNode, toNimType(types, methodObj["return_type"].str) else: nil - for prop in typ.jsonNode["properties"]: - if prop["getter"].str == methodObj["name"].str or - prop["setter"].str == methodObj["name"].str: - return + if not typ.isSingleton: + # for singletons we don't generate Nim setters/getters, + # but use plain procedures instead. That's because setter syntax is + # supposed to be used on an object (have at least 2 params). + for prop in typ.jsonNode["properties"]: + if prop["getter"].str == methodObj["name"].str or + prop["setter"].str == methodObj["name"].str: + return var args = newSeqOfCap[MethodArg](methodObj["arguments"].len + 1) var origArgs = methodObj["arguments"] @@ -924,16 +928,18 @@ proc genApi*(targetDir: string, apiJsonFile: string) = # first, generate declarations only for ease of # human readability of the file - for property in obj["properties"]: - makeProperty(types, tree, methodBindRegsitry, typ, property, - withImplementation = false) + if not typ.isSingleton: + for property in obj["properties"]: + makeProperty(types, tree, methodBindRegsitry, typ, property, + withImplementation = false) for meth in obj["methods"]: makeMethod(types, tree, methodBindRegsitry, typ, meth, withImplementation = false) - for property in obj["properties"]: - makeProperty(types, tree, methodBindRegsitry, typ, - property, withImplementation = true) + if not typ.isSingleton: + for property in obj["properties"]: + makeProperty(types, tree, methodBindRegsitry, typ, + property, withImplementation = true) for meth in obj["methods"]: makeMethod(types, tree, methodBindRegsitry, typ, meth, withImplementation = true) diff --git a/godot/internal/godotinternaltypes.nim b/godot/internal/godotinternaltypes.nim index 508c39e..2ae38c3 100644 --- a/godot/internal/godotinternaltypes.nim +++ b/godot/internal/godotinternaltypes.nim @@ -32,6 +32,9 @@ type GodotString* {.byref.} = object data: array[sizeof(int), byte] + GodotCharString* {.byref.} = object + data: array[sizeof(int), byte] + VariantType* {.size: sizeof(cint), pure.} = enum Nil, ## atomic types Bool, diff --git a/godot/internal/godotstrings.nim b/godot/internal/godotstrings.nim index 58e4a24..fce9a41 100644 --- a/godot/internal/godotstrings.nim +++ b/godot/internal/godotstrings.nim @@ -8,16 +8,7 @@ proc initGodotString(dest: var GodotString) {.inline, raises: [].} = proc initGodotString(dest: var GodotString; contents: cstring; size: cint) {.inline.} = ## Initializes ``dest`` from UTF-8 ``contents`` - getGDNativeAPI().stringNewData(dest, contents, size) - -proc getData(self: GodotString; dest: cstring; - size: var cint) {.inline.} = - ## Converts ``self`` into UTF-8 encoding, putting the result into ``dest``. - getGDNativeAPI().stringGetData(self, dest, size) - -proc len*(self: GodotString): cint {.inline.} = - ## Returns the length of string in bytes if it is represented as UTF-8. - getData(self, nil, result) + dest = getGDNativeAPI().stringCharsToUtf8WithLen(contents, size) proc `==`*(self, b: GodotString): bool {.inline.} = getGDNativeAPI().stringOperatorEqual(self, b) @@ -33,10 +24,11 @@ proc deinit*(self: var GodotString) {.inline.} = proc `$`*(self: GodotString): string = ## Converts the ``GodotString`` into Nim string - var length = self.len - result = newStringOfCap(length) - getData(self, addr result[0], length) - result.setLen(length) + var charStr = getGDNativeAPI().stringUtf8(self) + let length = getGDNativeAPI().charStringLength(charStr) + result = newString(length) + copyMem(addr result[0], getGDNativeAPI().charStringGetData(charStr), length) + getGDNativeAPI().charStringDestroy(charStr) assert(result[length] == '\0') proc toGodotString*(s: string): GodotString {.inline.} = From ae3171cb98a1bf9e005615c0ced636590af4dc9b Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 15 Jan 2018 11:01:48 +0700 Subject: [PATCH 32/82] Fix Vector2 += --- godot.nimble | 2 +- godot/core/vector2.nim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/godot.nimble b/godot.nimble index dd4f14d..3cdedab 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.2" +version = "0.7.3" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/vector2.nim b/godot/core/vector2.nim index 7cf3ee5..86c8a7e 100644 --- a/godot/core/vector2.nim +++ b/godot/core/vector2.nim @@ -83,7 +83,7 @@ proc `+`*(self, other: Vector2): Vector2 {.inline.} = getGDNativeAPI().vector2OperatorAdd(self, other) proc `+=`*(self: var Vector2, other: Vector2) {.inline.} = - self += other + self = self + other proc `-`*(self, other: Vector2): Vector2 = getGDNativeAPI().vector2OperatorSubtract(self, other) From e3216f09d00f11e18194db7afa5b410ae002552f Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 25 Jan 2018 17:39:01 +0700 Subject: [PATCH 33/82] Update ref types not to be var in parameters --- godot/core/arrays.nim | 26 +++++++++++++------------- godot/core/dictionaries.nim | 6 +++--- godot/core/poolarrays.nim | 20 ++++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/godot/core/arrays.nim b/godot/core/arrays.nim index 414ac99..a2b4580 100644 --- a/godot/core/arrays.nim +++ b/godot/core/arrays.nim @@ -62,16 +62,16 @@ proc newArray*(pba: PoolByteArray): Array {.inline.} = new(result, arrayFinalizer) initGodotArray(result.godotArray, pba.godotPoolByteArray[]) -proc `[]=`*(self: var Array; idx: int; value: Variant) {.inline.} = +proc `[]=`*(self: Array; idx: int; value: Variant) {.inline.} = self.godotArray[idx.cint] = value.godotVariant[] proc `[]`*(self: Array; idx: int): Variant {.inline.} = newVariant(self.godotArray[idx.cint]) -proc add*(self: var Array; value: Variant) {.inline.} = +proc add*(self: Array; value: Variant) {.inline.} = self.godotArray.add(value.godotVariant[]) -proc clear*(self: var Array) {.inline.} = +proc clear*(self: Array) {.inline.} = self.godotArray.clear() proc count*(self: Array; value: Variant): int {.inline.} = @@ -80,7 +80,7 @@ proc count*(self: Array; value: Variant): int {.inline.} = proc isEmpty*(self: Array): bool {.inline.} = self.godotArray.isEmpty() -proc erase*(self: var Array; value: Variant) {.inline.} = +proc erase*(self: Array; value: Variant) {.inline.} = self.godotArray.erase(value.godotVariant[]) proc first*(self: Array): Variant {.inline.} = @@ -101,28 +101,28 @@ proc contains*(self: Array; value: Variant): bool {.inline.} = proc hash*(self: Array): Hash {.inline.} = hash(self.godotArray.godotHash()) -proc insert*(self: var Array; pos: int; value: Variant) {.inline.} = +proc insert*(self: Array; pos: int; value: Variant) {.inline.} = self.godotArray.insert(pos.cint, value.godotVariant[]) -proc reverse*(self: var Array) {.inline.} = +proc reverse*(self: Array) {.inline.} = self.godotArray.reverse() -proc popLast*(self: var Array): Variant {.inline.} = +proc popLast*(self: Array): Variant {.inline.} = newVariant(self.godotArray.popLast()) -proc popFirst*(self: var Array): Variant {.inline.} = +proc popFirst*(self: Array): Variant {.inline.} = newVariant(self.godotArray.popFirst()) -proc addLast*(self: var Array; value: Variant) {.inline.} = +proc addLast*(self: Array; value: Variant) {.inline.} = self.godotArray.addLast(value.godotVariant[]) -proc addFirst*(self: var Array; value: Variant) {.inline.} = +proc addFirst*(self: Array; value: Variant) {.inline.} = self.godotArray.addFirst(value.godotVariant[]) -proc delete*(self: var Array; idx: int) {.inline.} = +proc delete*(self: Array; idx: int) {.inline.} = self.godotArray.delete(idx.cint) -proc setLen*(self: var Array; size: int) {.inline.} = +proc setLen*(self: Array; size: int) {.inline.} = self.godotArray.setLen(size.cint) proc rfind*(self: Array; what: Variant; fromIdx: int): int {.inline.} = @@ -131,7 +131,7 @@ proc rfind*(self: Array; what: Variant; fromIdx: int): int {.inline.} = proc len*(self: Array): int {.inline.} = self.godotArray.len.int -proc sort*(self: var Array) {.inline.} = +proc sort*(self: Array) {.inline.} = self.godotArray.sort() iterator items*(self: Array): Variant = diff --git a/godot/core/dictionaries.nim b/godot/core/dictionaries.nim index 5445d27..9897814 100644 --- a/godot/core/dictionaries.nim +++ b/godot/core/dictionaries.nim @@ -30,7 +30,7 @@ proc len*(self: Dictionary): int {.inline.} = proc isEmpty*(self: Dictionary): bool {.inline.} = self.godotDictionary.isEmpty() -proc clear*(self: var Dictionary) {.inline.} = +proc clear*(self: Dictionary) {.inline.} = self.godotDictionary.clear() import variants, arrays @@ -48,7 +48,7 @@ proc contains*(self: Dictionary; key: Variant): bool {.inline.}= proc contains*(self: Dictionary; keys: Array): bool {.inline.} = self.godotDictionary.contains(keys.godotArray[]) -proc del*(self: var Dictionary; key: Variant) {.inline.} = +proc del*(self: Dictionary; key: Variant) {.inline.} = self.godotDictionary.del(key.godotVariant[]) proc hash*(self: Dictionary): Hash {.inline.} = @@ -71,7 +71,7 @@ proc `[]`*(self: Dictionary; keyStr: string): Variant {.inline.} = godotStr.deinit() godotVariant.deinit() -proc `[]=`*(self: var Dictionary; key, value: Variant) {.inline.} = +proc `[]=`*(self: Dictionary; key, value: Variant) {.inline.} = self.godotDictionary[key.godotVariant[]] = value.godotVariant[] proc `==`*(self, other: Dictionary): bool {.inline.} = diff --git a/godot/core/poolarrays.nim b/godot/core/poolarrays.nim index dd3f544..6d412f5 100644 --- a/godot/core/poolarrays.nim +++ b/godot/core/poolarrays.nim @@ -33,29 +33,29 @@ template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName; new(result, poolArrayFinalizer) initProcName(result.fieldName, arr.godotArray[]) - proc add*(self: var T; arr: T) {.inline.} = + proc add*(self: T; arr: T) {.inline.} = self.fieldName.add(arr.fieldName) - proc delete*(self: var T; idx: int) {.inline.} = + proc delete*(self: T; idx: int) {.inline.} = self.fieldName.delete(idx.cint) - proc reverse*(self: var T) {.inline.} = + proc reverse*(self: T) {.inline.} = self.fieldName.reverse() - proc setLen*(self: var T; size: int) {.inline.} = + proc setLen*(self: T; size: int) {.inline.} = self.fieldName.setLen(size.cint) proc len*(self: T): int {.inline.} = self.fieldName.len.int when not noData: - proc add*(self: var T; data: DataT) {.inline.} = + proc add*(self: T; data: DataT) {.inline.} = self.fieldName.add(data) - proc insert*(self: var T; idx: int; data: DataT): Error {.inline.} = + proc insert*(self: T; idx: int; data: DataT): Error {.inline.} = self.fieldName.insert(idx.cint, data) - proc `[]=`*(self: var T; idx: int; data: DataT) {.inline.} = + proc `[]=`*(self: T; idx: int; data: DataT) {.inline.} = self.fieldName[idx.cint] = data proc `[]`*(self: T; idx: int): DataT {.inline.} = @@ -115,17 +115,17 @@ definePoolArray(PoolStringArray, GodotPoolStringArray, string, godotPoolStringArray, newPoolStringArray, initGodotPoolStringArray, true) -proc add*(self: var PoolStringArray; data: string) = +proc add*(self: PoolStringArray; data: string) = var s = data.toGodotString() self.godotPoolStringArray.add(s) s.deinit() -proc insert*(self: var PoolStringArray; idx: int; data: string): Error = +proc insert*(self: PoolStringArray; idx: int; data: string): Error = var s = data.toGodotString() result = self.godotPoolStringArray.insert(idx.cint, s) s.deinit() -proc `[]=`*(self: var PoolStringArray; idx: int; data: string) = +proc `[]=`*(self: PoolStringArray; idx: int; data: string) = var s = data.toGodotString() self.godotPoolStringArray[idx.cint] = s s.deinit() From f05eb090f710df4aed71e6502da8258c5abbb6d9 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 25 Jan 2018 17:52:58 +0700 Subject: [PATCH 34/82] Update after GDNative API changes --- godot.nimble | 2 +- godot/gdnativeapi.nim | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index 3cdedab..7cd8c26 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.3" +version = "0.7.4" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index 3028b96..53aba0e 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -624,46 +624,60 @@ type # Pool Array Read Access API + poolByteArrayReadAccessCopy: pointer poolByteArrayReadAccessPtr: pointer poolByteArrayReadAccessOperatorAssign: pointer poolByteArrayReadAccessDestroy: pointer + poolIntArrayReadAccessCopy: pointer poolIntArrayReadAccessPtr: pointer poolIntArrayReadAccessOperatorAssign: pointer poolIntArrayReadAccessDestroy: pointer + poolRealArrayReadAccessCopy: pointer poolRealArrayReadAccessPtr: pointer poolRealArrayReadAccessOperatorAssign: pointer poolRealArrayReadAccessDestroy: pointer + poolStringArrayReadAccessCopy: pointer poolStringArrayReadAccessPtr: pointer poolStringArrayReadAccessOperatorAssign: pointer poolStringArrayReadAccessDestroy: pointer + poolVector2ArrayReadAccessCopy: pointer poolVector2ArrayReadAccessPtr: pointer poolVector2ArrayReadAccessOperatorAssign: pointer poolVector2ArrayReadAccessDestroy: pointer + poolVector3ArrayReadAccessCopy: pointer poolVector3ArrayReadAccessPtr: pointer poolVector3ArrayReadAccessOperatorAssign: pointer poolVector3ArrayReadAccessDestroy: pointer + poolColorArrayReadAccessCopy: pointer poolColorArrayReadAccessPtr: pointer poolColorArrayReadAccessOperatorAssign: pointer poolColorArrayReadAccessDestroy: pointer + poolByteArrayWriteAccessCopy: pointer poolByteArrayWriteAccessPtr: pointer poolByteArrayWriteAccessOperatorAssign: pointer poolByteArrayWriteAccessDestroy: pointer + poolIntArrayWriteAccessCopy: pointer poolIntArrayWriteAccessPtr: pointer poolIntArrayWriteAccessOperatorAssign: pointer poolIntArrayWriteAccessDestroy: pointer + poolRealArrayWriteAccessCopy: pointer poolRealArrayWriteAccessPtr: pointer poolRealArrayWriteAccessOperatorAssign: pointer poolRealArrayWriteAccessDestroy: pointer + poolStringArrayWriteAccessCopy: pointer poolStringArrayWriteAccessPtr: pointer poolStringArrayWriteAccessOperatorAssign: pointer poolStringArrayWriteAccessDestroy: pointer + poolVector2ArrayWriteAccessCopy: pointer poolVector2ArrayWriteAccessPtr: pointer poolVector2ArrayWriteAccessOperatorAssign: pointer poolVector2ArrayWriteAccessDestroy: pointer + poolVector3ArrayWriteAccessCopy: pointer poolVector3ArrayWriteAccessPtr: pointer poolVector3ArrayWriteAccessOperatorAssign: pointer poolVector3ArrayWriteAccessDestroy: pointer + poolColorArrayWriteAccessCopy: pointer poolColorArrayWriteAccessPtr: pointer poolColorArrayWriteAccessOperatorAssign: pointer poolColorArrayWriteAccessDestroy: pointer From 5ccf351b5a49b148a24be0c971d63edecc03a905 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 31 Jan 2018 20:30:13 +0700 Subject: [PATCH 35/82] Fix Variant export --- godot/nim/godotnim.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 01da5ac..f9da831 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -483,7 +483,7 @@ proc toVariant*(self: Variant): Variant {.inline.} = if self.isNil: newVariant() else: - self + newVariant(self) proc fromVariant*(self: var Variant, val: Variant): ConversionResult {.inline.} = From 0aab6e17efd99253912889a222c7878ba3208e4c Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 31 Jan 2018 20:52:15 +0700 Subject: [PATCH 36/82] Update license year and fix doc to have Godot 3.0 download URL --- .vscode/settings.json | 2 +- LICENSE | 2 +- README.md | 2 +- docs/docbuild.nim | 2 +- docs/docpublish.nim | 2 +- docs/index.rst | 25 ++++++------------------- godot.nimble | 2 +- godot/core/aabb.nim | 2 +- godot/core/arrays.nim | 2 +- godot/core/basis.nim | 2 +- godot/core/colors.nim | 2 +- godot/core/dictionaries.nim | 2 +- godot/core/godotbase.nim | 2 +- godot/core/godotcoretypes.nim | 2 +- godot/core/nodepaths.nim | 2 +- godot/core/planes.nim | 2 +- godot/core/poolarrays.nim | 2 +- godot/core/quats.nim | 2 +- godot/core/rect2.nim | 2 +- godot/core/rids.nim | 2 +- godot/core/transform2d.nim | 2 +- godot/core/transforms.nim | 2 +- godot/core/vector2.nim | 2 +- godot/core/vector3.nim | 2 +- godot/gdnativeapi.nim | 2 +- godot/godot.nim | 2 +- godot/godotapigen.nim | 2 +- godot/godotinternal.nim | 2 +- godot/internal/godotarrays.nim | 2 +- godot/internal/godotdictionaries.nim | 2 +- godot/internal/godotinternaltypes.nim | 2 +- godot/internal/godotnodepaths.nim | 2 +- godot/internal/godotpoolarrays.nim | 2 +- godot/internal/godotstrings.nim | 2 +- godot/internal/godotvariants.nim | 2 +- godot/nim/godotmacros.nim | 2 +- godot/nim/godotnim.nim | 2 +- 37 files changed, 42 insertions(+), 55 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index aa6f1c7..6960f9a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,7 +9,7 @@ "godot/godotapigen.nim"], "nim.buildOnSave": false, "nim.lintOnSave": true, - "nim.licenseString": "# Copyright 2017 Xored Software, Inc.\n\n", + "nim.licenseString": "# Copyright 2018 Xored Software, Inc.\n\n", "files.exclude": { "**/nimcache/**": true } diff --git a/LICENSE b/LICENSE index 16a448a..07ecdb6 100644 --- a/LICENSE +++ b/LICENSE @@ -2,7 +2,7 @@ godot-nim - Nim bindings for Godot Engine The MIT License -Copyright (c) 2017 Xored Software Inc. +Copyright (c) 2018 Xored Software Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, diff --git a/README.md b/README.md index 7c518a2..891a920 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,4 @@ Documentation: https://pragmagic.github.io/godot-nim/ This project is licensed under the MIT license. Read [LICENSE](LICENSE) file for details. -Copyright (c) 2017 Xored Software, Inc. \ No newline at end of file +Copyright (c) 2018 Xored Software, Inc. \ No newline at end of file diff --git a/docs/docbuild.nim b/docs/docbuild.nim index fb957f5..bb3e21c 100644 --- a/docs/docbuild.nim +++ b/docs/docbuild.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import threadpool, os, osproc, strutils, sequtils, pegs diff --git a/docs/docpublish.nim b/docs/docpublish.nim index d682aec..e55974c 100644 --- a/docs/docpublish.nim +++ b/docs/docpublish.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import os, pegs, strutils import docbuild diff --git a/docs/index.rst b/docs/index.rst index bffe100..e14d38d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -5,6 +5,7 @@ Nim bindings for Godot Engine :Author: Ruslan Mustakov :Version: |godotnimversion| :GitHub: `$GODOTNIM_GITHUB_URL <$GODOTNIM_GITHUB_URL>`_ +:License: MIT .. contents:: @@ -32,25 +33,11 @@ which adds features for editing GDScript and Godot resource files. Getting Started =============== -Building Godot +Getting Godot -------------- -The library requires a not yet released Godot version 3.0, which you can -build yourself by running the commands below (requires -`Git `_, -`Python 2.7 `_, -`SCons `_): - -.. code-block:: bash - git clone https://github.com/godotengine/godot.git - cd godot - scons platform= - -where ```` can be ``windows``, ``osx``, ``x11``. After build -is finished, Godot binaries will be under the ``bin`` folder. More details -about compiling Godot can be found in `Godot documentation -`_. - +The library requires Godot version 3.0, which you can get here: +https://godotengine.org/download Installing Nim ------------- @@ -63,7 +50,7 @@ Make sure you also have ``nimble`` (Nim's package manager) installed. Creating Project ---------------- -The fastest way to set up a Godot-Nim project is to use an existing stub: +The fastest way to set up a Godot-Nim project is to use the existing stub: .. code-block:: bash git clone --depth=1 https://github.com/pragmagic/godot-nim-stub.git myproject @@ -88,7 +75,7 @@ If you would like to use Nim in an existing project: build scripts (``nakefile.nim``, ``src/stub.nimble``) according to your own project structure. -2. Copy ``project/nimlib.tres`` to your Godot project folder. It is a +2. Copy ``nimlib.gdnlib`` to your Godot project folder. It is a GDNative library resource that contains paths to dynamic libraries compiled by Nim. diff --git a/godot.nimble b/godot.nimble index 7cd8c26..ba9987f 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.4" +version = "0.7.5" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/aabb.nim b/godot/core/aabb.nim index 5892081..88bf66a 100644 --- a/godot/core/aabb.nim +++ b/godot/core/aabb.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi diff --git a/godot/core/arrays.nim b/godot/core/arrays.nim index a2b4580..afe8131 100644 --- a/godot/core/arrays.nim +++ b/godot/core/arrays.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import hashes import internal.godotinternaltypes, internal.godotarrays diff --git a/godot/core/basis.nim b/godot/core/basis.nim index 6f7e9d9..1d4f33c 100644 --- a/godot/core/basis.nim +++ b/godot/core/basis.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import math import godotbase, vector3, quats diff --git a/godot/core/colors.nim b/godot/core/colors.nim index dedb1a2..46fcaf3 100644 --- a/godot/core/colors.nim +++ b/godot/core/colors.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import godotcoretypes, gdnativeapi diff --git a/godot/core/dictionaries.nim b/godot/core/dictionaries.nim index 9897814..85970e5 100644 --- a/godot/core/dictionaries.nim +++ b/godot/core/dictionaries.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import hashes import internal.godotinternaltypes, internal.godotdictionaries, diff --git a/godot/core/godotbase.nim b/godot/core/godotbase.nim index 0f410b8..7871a87 100644 --- a/godot/core/godotbase.nim +++ b/godot/core/godotbase.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import math diff --git a/godot/core/godotcoretypes.nim b/godot/core/godotcoretypes.nim index cc5da9e..c4c4b71 100644 --- a/godot/core/godotcoretypes.nim +++ b/godot/core/godotcoretypes.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. type Color* {.byref.} = object diff --git a/godot/core/nodepaths.nim b/godot/core/nodepaths.nim index 537d93e..428e261 100644 --- a/godot/core/nodepaths.nim +++ b/godot/core/nodepaths.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import internal.godotinternaltypes, internal.godotnodepaths, internal.godotstrings diff --git a/godot/core/planes.nim b/godot/core/planes.nim index 99dd652..66de34e 100644 --- a/godot/core/planes.nim +++ b/godot/core/planes.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import vector3 diff --git a/godot/core/poolarrays.nim b/godot/core/poolarrays.nim index 6d412f5..55ce845 100644 --- a/godot/core/poolarrays.nim +++ b/godot/core/poolarrays.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import godotcoretypes import internal.godotinternaltypes, internal.godotpoolarrays, diff --git a/godot/core/quats.nim b/godot/core/quats.nim index ea8cad4..a60efc8 100644 --- a/godot/core/quats.nim +++ b/godot/core/quats.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi diff --git a/godot/core/rect2.nim b/godot/core/rect2.nim index ad813a9..6e7c99e 100644 --- a/godot/core/rect2.nim +++ b/godot/core/rect2.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import vector2 import internal.godotinternaltypes, internal.godotstrings diff --git a/godot/core/rids.nim b/godot/core/rids.nim index a113f60..35e054a 100644 --- a/godot/core/rids.nim +++ b/godot/core/rids.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import godotcoretypes, internal.godotinternaltypes, gdnativeapi diff --git a/godot/core/transform2d.nim b/godot/core/transform2d.nim index 922b24b..6fa4619 100644 --- a/godot/core/transform2d.nim +++ b/godot/core/transform2d.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi diff --git a/godot/core/transforms.nim b/godot/core/transforms.nim index fe43ccb..c9021d6 100644 --- a/godot/core/transforms.nim +++ b/godot/core/transforms.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi diff --git a/godot/core/vector2.nim b/godot/core/vector2.nim index 86c8a7e..b665dbd 100644 --- a/godot/core/vector2.nim +++ b/godot/core/vector2.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi diff --git a/godot/core/vector3.nim b/godot/core/vector3.nim index ded30ce..f90bcfa 100644 --- a/godot/core/vector3.nim +++ b/godot/core/vector3.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import math import godotbase, godotcoretypes diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index 53aba0e..0037b8a 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import internal.godotinternaltypes, core.godotcoretypes, macros diff --git a/godot/godot.nim b/godot/godot.nim index d72c4f1..f4a9bf8 100644 --- a/godot/godot.nim +++ b/godot/godot.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import core.godotbase, godotinternal import core.godotcoretypes diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 4075229..c3c07cd 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import streams, json, os, strutils, times, sets, tables import sequtils, algorithm diff --git a/godot/godotinternal.nim b/godot/godotinternal.nim index 90903a7..0314624 100644 --- a/godot/godotinternal.nim +++ b/godot/godotinternal.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import internal.godotinternaltypes, internal.godotarrays, internal.godotnodepaths, internal.godotpoolarrays, internal.godotstrings, diff --git a/godot/internal/godotarrays.nim b/godot/internal/godotarrays.nim index 32bcefa..c0736b5 100644 --- a/godot/internal/godotarrays.nim +++ b/godot/internal/godotarrays.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import godotinternaltypes, gdnativeapi, core.godotcoretypes diff --git a/godot/internal/godotdictionaries.nim b/godot/internal/godotdictionaries.nim index 7c61b76..447647a 100644 --- a/godot/internal/godotdictionaries.nim +++ b/godot/internal/godotdictionaries.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import godotinternaltypes, gdnativeapi diff --git a/godot/internal/godotinternaltypes.nim b/godot/internal/godotinternaltypes.nim index 2ae38c3..cfba553 100644 --- a/godot/internal/godotinternaltypes.nim +++ b/godot/internal/godotinternaltypes.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. const MAX_ARG_COUNT* = 256 diff --git a/godot/internal/godotnodepaths.nim b/godot/internal/godotnodepaths.nim index 11a0280..b4578c0 100644 --- a/godot/internal/godotnodepaths.nim +++ b/godot/internal/godotnodepaths.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import godotinternaltypes, gdnativeapi diff --git a/godot/internal/godotpoolarrays.nim b/godot/internal/godotpoolarrays.nim index e655adb..52b1f3a 100644 --- a/godot/internal/godotpoolarrays.nim +++ b/godot/internal/godotpoolarrays.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import godotinternaltypes, gdnativeapi import core.godotcoretypes diff --git a/godot/internal/godotstrings.nim b/godot/internal/godotstrings.nim index fce9a41..d3eb287 100644 --- a/godot/internal/godotstrings.nim +++ b/godot/internal/godotstrings.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright (c) 2018 Xored Software, Inc. import godotinternaltypes, gdnativeapi diff --git a/godot/internal/godotvariants.nim b/godot/internal/godotvariants.nim index d48e876..3f961ca 100644 --- a/godot/internal/godotvariants.nim +++ b/godot/internal/godotvariants.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import core.godotcoretypes, godotinternaltypes, gdnativeapi diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index 682f8ec..384aa2b 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import macros, tables, typetraits import godotinternal, internal.godotvariants diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index f9da831..b989bda 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -1,4 +1,4 @@ -# Copyright 2017 Xored Software, Inc. +# Copyright 2018 Xored Software, Inc. import tables, typetraits, macros import gdnativeapi From d11856377e05212663c72dd06947f9e40456cff3 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Sat, 17 Feb 2018 23:44:07 +0700 Subject: [PATCH 37/82] Implement Vector2 and Rect2 procs This allows compiler to inline/optimize them, which cannot be done if these procs are invoked via GDNative API. --- godot.nimble | 2 +- godot/core/basis.nim | 4 + godot/core/godotbase.nim | 45 ++++++- godot/core/rect2.nim | 148 +++++++++++++++++---- godot/core/vector2.nim | 270 +++++++++++++++++++++++++-------------- godot/core/vector3.nim | 4 + godot/nim/godotnim.nim | 21 +-- 7 files changed, 346 insertions(+), 148 deletions(-) diff --git a/godot.nimble b/godot.nimble index ba9987f..e562fca 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.5" +version = "0.7.6" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/basis.nim b/godot/core/basis.nim index 1d4f33c..538ca60 100644 --- a/godot/core/basis.nim +++ b/godot/core/basis.nim @@ -4,6 +4,8 @@ import math import godotbase, vector3, quats import godotcoretypes +{.push stackTrace: off.} + proc setCells*(basis: var Basis, xx, xy, xz, yx, yy, yz, zx, zy, zz: float32) = basis.elements[0].x = xx basis.elements[0].y = xy @@ -449,3 +451,5 @@ proc rotate*(self: var Vector3; axis: Vector3; phi: float32) = proc rotated*(self: Vector3; axis: Vector3; phi: float32): Vector3 = result = self result.rotate(axis, phi) + +{.pop.} # stackTrace: off \ No newline at end of file diff --git a/godot/core/godotbase.nim b/godot/core/godotbase.nim index 7871a87..38cca0f 100644 --- a/godot/core/godotbase.nim +++ b/godot/core/godotbase.nim @@ -1,30 +1,61 @@ # Copyright (c) 2018 Xored Software, Inc. -import math +import math, godotinternal # math helpers +{.push stackTrace: off.} const EPSILON = 0.00001'f32 -proc isEqualApprox*(a, b: float32): bool {.inline.} = +proc isEqualApprox*(a, b: float32): bool {.inline, noinit.} = abs(a - b) < EPSILON -proc isEqualApprox*(a, b: float64): bool {.inline.} = +proc isEqualApprox*(a, b: float64): bool {.inline, noinit.} = abs(a - b) < EPSILON -proc sign*(a: float32): float32 {.inline.} = +proc sign*(a: float32): float32 {.inline, noinit.} = if a < 0: -1.0'f32 else: 1.0'f32 -proc sign*(a: float64): float64 {.inline.} = +proc sign*(a: float64): float64 {.inline, noinit.} = if a < 0: -1.0'f64 else: 1.0'f64 -proc stepify*(value, step: float64): float64 = +proc stepify*(value, step: float64): float64 {.inline, noinit.} = if step != 0'f64: floor(value / step + 0.5'f64) * step else: value -proc stepify*(value, step: float32): float32 = +proc stepify*(value, step: float32): float32 {.inline, noinit.} = if step != 0'f32: floor(value / step + 0.5'f32) * step else: value + +proc min*(x, y: float32): float32 {.inline, noinit.} = + if x <= y: x else: y + +proc abs*(x: float32): float32 {.inline, noinit.} = + if x < 0.0: -x else: x + +proc max*(x, y: float32): float32 {.inline, noinit.} = + if y <= x: x else: y + +{.pop.} # stackTrace: off + +template printWarning*(warning: typed) = + ## Prints ``warning`` to Godot log, adding filename and line information. + let (filename, line) = instantiationInfo() + godotPrintWarning(cstring($warning), cstring"", cstring(filename), line.cint) + +template printError*(error: typed) = + ## Prints ``error`` to Godot log, adding filename and line information. + let (filename, line) = instantiationInfo() + godotPrintError(cstring($error), cstring"", cstring(filename), line.cint) + +proc print*(parts: varargs[string, `$`]) = + ## Prints concatenated ``parts`` to Godot log. + var combined = "" + for v in parts: + combined.add(v) + var s = combined.toGodotString() + godotPrint(s) + s.deinit() diff --git a/godot/core/rect2.nim b/godot/core/rect2.nim index 6e7c99e..2e73571 100644 --- a/godot/core/rect2.nim +++ b/godot/core/rect2.nim @@ -4,41 +4,145 @@ import vector2 import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi -proc initRect2*(pos, size: Vector2): Rect2 {.inline.} = +{.push stackTrace: off.} + +proc initRect2*(): Rect2 {.inline, noinit.} = + Rect2() + +proc initRect2*(pos, size: Vector2): Rect2 {.inline, noinit.} = Rect2(position: pos, size: size) -proc initRect2*(x, y, sizeX, sizeY: float32): Rect2 {.inline.} = +proc initRect2*(x, y, sizeX, sizeY: float32): Rect2 {.inline, noinit.} = Rect2(position: vec2(x, y), size: vec2(sizeX, sizeY)) proc `$`*(self: Rect2): string {.inline.} = $getGDNativeAPI().rect2AsString(self) -proc area*(self: Rect2): float32 {.inline.} = - getGDNativeAPI().rect2GetArea(self) +proc area*(self: Rect2): float32 {.inline, noinit.} = + self.size.x * self.size.y -proc intersects*(a, b: Rect2): bool {.inline.} = - getGDNativeAPI().rect2Intersects(a, b) +proc intersects*(a, b: Rect2): bool {.inline, noinit.} = + if a.position.x >= (b.position.x + b.size.x): + return false + if a.position.x + a.size.x <= b.position.x: + return false + if a.position.y >= (b.position.y + b.size.y): + return false + if a.position.y + a.size.y <= b.position.y: + return false + result = true -proc encloses*(a, b: Rect2): bool {.inline.} = - getGDNativeAPI().rect2Encloses(a, b) +proc distanceTo*(self: Rect2, p: Vector2): float32 {.noinit.} = + var inside = true + if p.x < self.position.x: + let d = self.position.x - p.x + result = d + inside = false + if p.y < self.position.y: + let d = self.position.y - p.y + result = if inside: d else: min(result, d) + inside = false + if p.x >= (self.position.x + self.size.x): + let d = p.x - (self.position.x + self.size.x) + result = if inside: d else: min(result, d) + inside = false + if p.y >= (self.position.y + self.size.y): + let d = p.y - (self.position.y + self.size.y) + result = if inside: d else: min(result, d) + inside = false -proc hasNoArea*(self: Rect2): bool {.inline.} = - getGDNativeAPI().rect2HasNoArea(self) + if inside: + result = 0'f32 -proc clip*(self, b: Rect2): Rect2 {.inline.} = - getGDNativeAPI().rect2Clip(self, b) +proc encloses*(a, b: Rect2): bool {.inline, noinit.} = + b.position.x >= a.position.x and b.position.y >= a.position.y and + (b.position.x + b.size.x) < (a.position.x + a.size.x) and + (b.position.y + b.size.y) < (a.position.y + a.size.y) -proc merge*(self, b: Rect2): Rect2 {.inline.} = - getGDNativeAPI().rect2Merge(self, b) +proc hasNoArea*(self: Rect2): bool {.inline, noinit.} = + self.size.x <= 0 or self.size.y <= 0 -proc contains*(self: Rect2; point: Vector2): bool {.inline.} = - getGDNativeAPI().rect2HasPoint(self, point) +proc clip*(self, b: Rect2): Rect2 {.inline, noinit.} = + if not self.intersects(b): + return initRect2() -proc grow*(self: Rect2; by: float32): Rect2 {.inline.} = - getGDNativeAPI().rect2Grow(self, by) + result = self -proc expand*(self: Rect2; to: Vector2): Rect2 {.inline.} = - getGDNativeAPI().rect2Expand(self, to) + result.position.x = max(b.position.x, self.position.x) + result.position.y = max(b.position.y, self.position.y) -proc `==`*(a, b: Rect2): bool {.inline.} = - getGDNativeAPI().rect2OperatorEqual(a, b) + let bEnd = b.position + b.size + let selfEnd = self.position + self.size + + result.size.x = min(bEnd.x, selfEnd.x) - result.position.x + result.size.y = min(bEnd.y, selfEnd.y) - result.position.y + +proc merge*(self, b: Rect2): Rect2 {.inline, noinit.} = + result.position.x = min(b.position.x, self.position.x) + result.position.y = min(b.position.y, self.position.y) + + result.size.x = max(b.position.x + b.size.x, self.position.x + self.size.x) + result.size.y = max(b.position.y + b.size.y, self.position.y + self.size.y) + result.size -= result.position + +proc contains*(self: Rect2; point: Vector2): bool {.inline, noinit.} = + if point.x < self.position.x: + return false + if point.y < self.position.y: + return false + + if point.x >= self.position.x + self.size.x: + return false + if point.y >= self.position.y + self.size.y: + return false + + result = true + +proc grow*(self: Rect2; by: float32): Rect2 {.inline, noinit.} = + ## Returns Rect2 enlarged by the specified size in every direction. + result = self + + result.position.x -= by + result.position.y -= by + + result.size.x += by * 2 + result.size.y += by * 2 + +proc growIndividual*(self: Rect2, left, top: float32, + right, bottom: float32): Rect2 {.inline, noinit.} = + result = self + result.position.x -= left + result.position.y -= top + result.size.x += left + right + result.size.y += top + bottom + +proc expandTo*(self: var Rect2, to: Vector2) {.inline.} = + var startPoint = self.position + var endPoint = self.position + self.size + + if to.x < startPoint.x: + startPoint.x = to.x + if to.y < startPoint.y: + startPoint.y = to.y + + if to.x > endPoint.x: + endPoint.x = to.x + if to.y > endPoint.y: + endPoint.y = to.y + + self.position = startPoint + self.size = endPoint - startPoint + +proc expand*(self: Rect2; to: Vector2): Rect2 {.inline, noinit.} = + result = self + result.expandTo(to) + +proc abs*(self: Rect2): Rect2 {.inline, noinit.} = + Rect2(position: vec2(self.position.x + min(self.size.x, 0'f32), + self.position.y + min(self.size.y, 0'f32)), + size: abs(self.size)) + +proc `==`*(a, b: Rect2): bool {.inline, noinit.} = + a.position == b.position and a.size == b.size + +{.pop.} # stackTrace: off \ No newline at end of file diff --git a/godot/core/vector2.nim b/godot/core/vector2.nim index b665dbd..f15bd2f 100644 --- a/godot/core/vector2.nim +++ b/godot/core/vector2.nim @@ -1,125 +1,199 @@ # Copyright (c) 2018 Xored Software, Inc. +import math, godotbase + import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi -proc vec2*(): Vector2 {.inline.} = +{.push stackTrace: off.} + +proc vec2*(): Vector2 {.inline, noinit.} = Vector2() -proc vec2*(x, y: float32): Vector2 {.inline.} = +proc vec2*(x, y: float32): Vector2 {.inline, noinit.} = Vector2(x: x, y: y) -proc `$`*(self: Vector2): string {.inline.} = +proc `$`*(self: Vector2): string {.inline, noinit.} = $getGDNativeAPI().vector2AsString(self) -proc normalized*(self: Vector2): Vector2 {.inline.} = - getGDNativeAPI().vector2Normalized(self) +proc `+`*(self, other: Vector2): Vector2 {.inline, noinit.} = + Vector2(x: self.x + other.x, y: self.y + other.y) -proc length*(self: Vector2): float32 {.inline.} = - getGDNativeAPI().vector2Length(self) +proc `+=`*(self: var Vector2, other: Vector2) {.inline, noinit.} = + self.x += other.x + self.y += other.y -proc angle*(self: Vector2): float32 {.inline.} = - getGDNativeAPI().vector2Angle(self) +proc `-`*(self, other: Vector2): Vector2 {.inline, noinit.} = + Vector2(x: self.x - other.x, y: self.y - other.y) -proc lengthSquared*(self: Vector2): float32 {.inline.} = - getGDNativeAPI().vector2LengthSquared(self) +proc `-=`*(self: var Vector2, other: Vector2) {.inline, noinit.} = + self.x -= other.x + self.y -= other.y -proc isNormalized*(self: Vector2): bool {.inline.} = - getGDNativeAPI().vector2IsNormalized(self) +proc `*`*(self, other: Vector2): Vector2 {.inline, noinit.} = + Vector2(x: self.x * other.x, y: self.y * other.y) -proc distanceTo*(self, to: Vector2): float32 {.inline.} = - getGDNativeAPI().vector2DistanceTo(self, to) +proc `*=`*(self: var Vector2, other: Vector2) {.inline, noinit.} = + self.x *= other.x + self.y *= other.y -proc distanceSquaredTo*(self, to: Vector2): float32 {.inline.} = - getGDNativeAPI().vector2DistanceSquaredTo(self, to) +proc `*`*(self: Vector2, scalar: float32): Vector2 {.inline, noinit.} = + Vector2(x: self.x * scalar, y: self.y * scalar) -proc angleTo*(self, to: Vector2): float32 {.inline.} = - getGDNativeAPI().vector2AngleTo(self, to) +proc `*`*(scalar: float32, v: Vector2): Vector2 {.inline, noinit.} = + v * scalar -proc angleToPoint*(self, to: Vector2): float32 {.inline.} = - getGDNativeAPI().vector2AngleToPoint(self, to) +proc `*=`*(self: var Vector2, scalar: float32) {.inline, noinit.} = + self.x *= scalar + self.y *= scalar -proc lerp*(self, b: Vector2; t: float32): Vector2 {.inline.} = - getGDNativeAPI().vector2LinearInterpolate(self, b, t) +proc `/`*(self, other: Vector2): Vector2 {.inline, noinit.} = + Vector2(x: self.x / other.x, y: self.y / other.y) -proc cubicInterpolate*(self, b, preA, postB: Vector2; - t: float32): Vector2 {.inline.} = - getGDNativeAPI().vector2CubicInterpolate(self, b, preA, postB, t) +proc `/=`*(self: var Vector2, other: Vector2) {.inline, noinit.} = + self.x /= other.x + self.y /= other.y -proc rotated*(self: Vector2; phi: float32): Vector2 {.inline.} = - getGDNativeAPI().vector2Rotated(self, phi) +proc `/`*(self: Vector2; scalar: float32): Vector2 {.inline, noinit.} = + Vector2(x: self.x / scalar, y: self.y / scalar) -proc tangent*(self: Vector2): Vector2 {.inline.} = - getGDNativeAPI().vector2Tangent(self) - -proc floor*(self: Vector2): Vector2 {.inline.} = - getGDNativeAPI().vector2Floor(self) - -proc snapped*(self: Vector2; by: Vector2): Vector2 {.inline.} = - getGDNativeAPI().vector2Snapped(self, by) - -proc aspect*(self: Vector2): float32 {.inline.} = - getGDNativeAPI().vector2Aspect(self) - -proc dot*(a, b: Vector2): float32 {.inline.} = - getGDNativeAPI().vector2Dot(a, b) - -proc slide*(self, n: Vector2): Vector2 {.inline.} = - getGDNativeAPI().vector2Slide(self, n) - -proc bounce*(self, n: Vector2): Vector2 {.inline.} = - getGDNativeAPI().vector2Bounce(self, n) - -proc reflect*(self, n: Vector2): Vector2 {.inline.} = - getGDNativeAPI().vector2Reflect(self, n) - -proc abs*(self: Vector2): Vector2 {.inline.} = - getGDNativeAPI().vector2Abs(self) - -proc clamped*(self: Vector2; length: float32): Vector2 {.inline.} = - getGDNativeAPI().vector2Clamped(self, length) - -proc `+`*(self, other: Vector2): Vector2 {.inline.} = - getGDNativeAPI().vector2OperatorAdd(self, other) - -proc `+=`*(self: var Vector2, other: Vector2) {.inline.} = - self = self + other - -proc `-`*(self, other: Vector2): Vector2 = - getGDNativeAPI().vector2OperatorSubtract(self, other) - -proc `-=`*(self: var Vector2, other: Vector2) {.inline.} = - self = self - other - -proc `*`*(self, other: Vector2): Vector2 = - getGDNativeAPI().vector2OperatorMultiplyVector(self, other) - -proc `*=`*(self: var Vector2, other: Vector2) {.inline.} = - self = self * other - -proc `*`*(self: Vector2, scalar: float32): Vector2 = - getGDNativeAPI().vector2OperatorMultiplyScalar(self, scalar) - -proc `*=`*(self: var Vector2, scalar: float32) {.inline.} = - self = self * scalar - -proc `/`*(self, other: Vector2): Vector2 = - getGDNativeAPI().vector2OperatorDivideVector(self, other) - -proc `/=`*(self: var Vector2, other: Vector2) {.inline.} = - self = self / other - -proc `/`*(self: Vector2; scalar: float32): Vector2 = - getGDNativeAPI().vector2OperatorDivideScalar(self, scalar) - -proc `/=`*(self: var Vector2; scalar: float32) {.inline.} = +proc `/=`*(self: var Vector2; scalar: float32) {.inline, noinit.} = self = self / scalar -proc `==`*(self, other: Vector2): bool {.inline.} = - getGDNativeAPI().vector2OperatorEqual(self, other) +proc `==`*(self, other: Vector2): bool {.inline, noinit.} = + self.x == other.x and self.y == other.y -proc `<`*(self, other: Vector2): bool {.inline.} = - getGDNativeAPI().vector2OperatorLess(self, other) +proc `<`*(self, other: Vector2): bool {.inline, noinit.} = + if self.x == other.x: + self.y < other.y + else: + self.x < other.x -proc `-`*(self: Vector2): Vector2 {.inline.} = - getGDNativeAPI().vector2OperatorNeg(self) +proc `>`*(self, other: Vector2): bool {.inline, noinit.} = + if self.x == other.x: + self.y > other.y + else: + self.x > other.x + +proc `-`*(self: Vector2): Vector2 {.inline, noinit.} = + Vector2(x: -self.x, y: -self.y) + +proc length*(self: Vector2): float32 {.inline, noinit.} = + sqrt(self.x * self.x + self.y * self.y) + +proc lengthSquared*(self: Vector2): float32 {.inline, noinit.} = + self.x * self.x + self.y * self.y + +proc normalize(self: var Vector2) {.inline.} = + var len = self.x * self.x + self.y * self.y + if len != 0: + len = sqrt(len) + self.x /= len + self.y /= len + +proc normalized*(self: Vector2): Vector2 {.inline, noinit.} = + result = self + result.normalize() + +proc angle*(self: Vector2): float32 {.inline, noinit.} = + arctan2(self.y, self.x) + +proc isNormalized*(self: Vector2): bool {.inline, noinit.} = + isEqualApprox(self.lengthSquared(), 1.0) + +proc distanceTo*(self, to: Vector2): float32 {.inline, noinit.} = + sqrt((self.x - to.x) * (self.x - to.x) + (self.y - to.y) * (self.y - to.y)) + +proc distanceSquaredTo*(self, to: Vector2): float32 {.inline, noinit.} = + (self.x - to.x) * (self.x - to.x) + (self.y - to.y) * (self.y - to.y) + +proc dot*(a, b: Vector2): float32 {.inline, noinit.} = + a.x * b.x + a.y * b.y + +proc cross*(a, b: Vector2): float32 {.inline, noinit.} = + a.x * b.y - a.y * b.x + +proc cross*(self: Vector2, scalar: float32): Vector2 {.inline, noinit.} = + Vector2(x: scalar * self.y, y: -scalar * self.x) + +proc angleTo*(self, to: Vector2): float32 {.noinit.} = + arctan2(cross(self, to), dot(self, to)) + +proc angleToPoint*(self, to: Vector2): float32 {.inline, noinit.} = + arctan2(self.y - to.y, self.x - to.x) + +proc floor*(self: Vector2): Vector2 {.inline, noinit.} = + Vector2(x: floor(self.x), y: floor(self.y)) + +proc planeProject*(self: Vector2, d: float32, + vec: Vector2): Vector2 {.noinit.} = + vec - self * (self.dot(vec) - d) + +proc project*(self, other: Vector2): Vector2 {.noinit.} = + self * (other.dot(self) / self.dot(self)) + +proc lerp*(self, b: Vector2; t: float32): Vector2 {.inline, noinit.} = + result = self + result.x += t * (b.x - self.x) + result.y += t * (b.y - self.y) + +proc cubicInterpolate*(self, b, preA, postB: Vector2; + t: float32): Vector2 {.noinit.} = + let p0 = preA + let p1 = self + let p2 = b + let p3 = postB + + let t2 = t * t + let t3 = t2 * t + + result = 0.5'f32 * ((p1 * 2.0'f32)) + + (-p0 + p2) * t + + (2.0 * p0 - 5.0 * p1 + 4 * p2 - p3) * t2 + + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3 + +proc setRotation*(self: var Vector2, radians: float32) {.inline, noinit.} = + self.x = cos(radians) + self.y = sin(radians) + +proc rotated*(self: Vector2; phi: float32): Vector2 {.inline, noinit.} = + result.setRotation(phi) + result *= self.length() + +proc tangent*(self: Vector2): Vector2 {.inline, noinit.} = + Vector2(x: self.y, y: -self.x) + +proc snapped*(self: Vector2; by: Vector2): Vector2 {.inline, noinit.} = + Vector2(x: stepify(self.x, by.x), y: stepify(self.y, by.y)) + +proc aspect*(self: Vector2): float32 {.inline, noinit.} = + self.x / self.y + +proc slide*(self, n: Vector2): Vector2 {.noinit.} = + when not defined(release): + if not n.isNormalized(): + printError("Normal not normalized in slide. " & getStackTrace()) + return vec2() + result = self - n * self.dot(n) + +proc reflect*(self, n: Vector2): Vector2 {.noinit.} = + when not defined(release): + if not n.isNormalized(): + printError("Normal not normalized in bounce. " & getStackTrace()) + return vec2() + result = 2.0 * n * self.dot(n) - self + +proc bounce*(self, n: Vector2): Vector2 {.inline, noinit.} = + -self.reflect(n) + +proc abs*(self: Vector2): Vector2 {.inline, noinit.} = + Vector2(x: abs(self.x), y: abs(self.y)) + +proc clamped*(self: Vector2; length: float32): Vector2 {.noinit.} = + let len = self.length() + result = self + if len > 0 and length < len: + result /= len + result *= length + +{.pop.} # stackTrace: off diff --git a/godot/core/vector3.nim b/godot/core/vector3.nim index f90bcfa..4ed9922 100644 --- a/godot/core/vector3.nim +++ b/godot/core/vector3.nim @@ -3,6 +3,8 @@ import math import godotbase, godotcoretypes +{.push stackTrace: off.} + proc vec3*(): Vector3 {.inline.} = Vector3() @@ -233,3 +235,5 @@ proc cubicInterpolate*(self, b, preA, postB: Vector3; (-p0 + p2) * t + (2.0 * p0 - 5.0 * p1 + 4 * p2 - p3) * t2 + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3) + +{.pop.} # stackTrace: off \ No newline at end of file diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index b989bda..3d64f1f 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -2,7 +2,7 @@ import tables, typetraits, macros import gdnativeapi -import core.godotcoretypes +import core.godotcoretypes, core.godotbase import core.vector2, core.rect2, core.vector3, core.transform2d, core.planes, core.quats, core.aabb, @@ -92,25 +92,6 @@ type proc isFinalized*(obj: NimGodotObject): bool {.inline.} = obj.isFinalized -template printWarning*(warning: typed) = - ## Prints ``warning`` to Godot log, adding filename and line information. - let (filename, line) = instantiationInfo() - godotPrintWarning(cstring($warning), cstring"", cstring(filename), line.cint) - -template printError*(error: typed) = - ## Prints ``error`` to Godot log, adding filename and line information. - let (filename, line) = instantiationInfo() - godotPrintError(cstring($error), cstring"", cstring(filename), line.cint) - -proc print*(parts: varargs[string, `$`]) = - ## Prints concatenated ``parts`` to Godot log. - var combined = "" - for v in parts: - combined.add(v) - var s = combined.toGodotString() - godotPrint(s) - s.deinit() - var classRegistry {.threadvar.}: TableRef[cstring, ObjectInfo] var classRegistryStatic* {.compileTime.}: TableRef[cstring, ObjectInfo] ## Compile-time variable used for implementation of several procedures From be6f01e3b7517f1a6dff17fb0fea84a1b7c94c03 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 22 Feb 2018 18:55:52 +0700 Subject: [PATCH 38/82] More pool array features: subarray, mitems, mpairs --- godot.nimble | 2 +- godot/core/poolarrays.nim | 26 +- godot/gdnativeapi.nim | 466 ++++++++++++++++++++++---- godot/internal/godotinternaltypes.nim | 34 ++ godot/internal/godotpoolarrays.nim | 123 ++++++- 5 files changed, 559 insertions(+), 92 deletions(-) diff --git a/godot.nimble b/godot.nimble index e562fca..b60be93 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.6" +version = "0.7.7" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/poolarrays.nim b/godot/core/poolarrays.nim index 55ce845..8206662 100644 --- a/godot/core/poolarrays.nim +++ b/godot/core/poolarrays.nim @@ -48,6 +48,12 @@ template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName; proc len*(self: T): int {.inline.} = self.fieldName.len.int + proc subarray*(self: T, idxFrom, idxTo: int): T {.inline.} = + ## Indexes are inclusive, negative values count from the end of the array. + assert(idxFrom >= low(cint) and idxFrom <= high(cint) and + idxTo >= low(cint) and idxTo <= high(cint)) + newProcName(self.fieldName.subarray(idxFrom.cint, idxTo.cint)) + when not noData: proc add*(self: T; data: DataT) {.inline.} = self.fieldName.add(data) @@ -62,12 +68,20 @@ template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName; self.fieldName[idx.cint] iterator items*(arr: T): DataT = - for i in 0..= ownLen: + let (file, line) = instantiationInfo() + getGDNativeAPI().printError( + cstring"Invalid subarray begin index", cstring"subarray", file, line.cint) + return + if actualIdxTo < 0 or actualIdxTo >= ownLen: + let (file, line) = instantiationInfo() + getGDNativeAPI().printError( + cstring"Invalid subarray end index", cstring"subarray", file, line.cint) + return + let span = actualIdxTo - actualIdxFrom + 1 + result.setLen(span) + let readAccess = getGDNativeAPI().readProc(self) + let writeAccess = getGDNativeAPI().writeProc(result) + let readPtr = getGDNativeAPI().readAccessPtrProc(readAccess).offset(actualIdxFrom) + copyMem(getGDNativeAPI().writeAccessPtrProc(writeAccess), readPtr, span) + getGDNativeAPI().readAccessDestroyProc(readAccess) + getGDNativeAPI().writeAccessDestroyProc(writeAccess) genPoolArrayAPI(GodotPoolByteArray, initGodotPoolByteArray, byte, poolByteArrayNew, @@ -70,7 +123,13 @@ genPoolArrayAPI(GodotPoolByteArray, initGodotPoolByteArray, byte, poolByteArraySet, poolByteArrayGet, poolByteArraySize, - poolByteArrayDestroy) + poolByteArrayDestroy, + poolByteArrayRead, + poolByteArrayWrite, + poolByteArrayReadAccessPtr, + poolByteArrayWriteAccessPtr, + poolByteArrayReadAccessDestroy, + poolByteArrayWriteAccessDestroy) genPoolArrayAPI(GodotPoolIntArray, initGodotPoolIntArray, cint, poolIntArrayNew, @@ -86,7 +145,13 @@ genPoolArrayAPI(GodotPoolIntArray, initGodotPoolIntArray, cint, poolIntArraySet, poolIntArrayGet, poolIntArraySize, - poolIntArrayDestroy) + poolIntArrayDestroy, + poolIntArrayRead, + poolIntArrayWrite, + poolIntArrayReadAccessPtr, + poolIntArrayWriteAccessPtr, + poolIntArrayReadAccessDestroy, + poolIntArrayWriteAccessDestroy) genPoolArrayAPI(GodotPoolRealArray, initGodotPoolRealArray, float32, poolRealArrayNew, @@ -102,7 +167,13 @@ genPoolArrayAPI(GodotPoolRealArray, initGodotPoolRealArray, float32, poolRealArraySet, poolRealArrayGet, poolRealArraySize, - poolRealArrayDestroy) + poolRealArrayDestroy, + poolRealArrayRead, + poolRealArrayWrite, + poolRealArrayReadAccessPtr, + poolRealArrayWriteAccessPtr, + poolRealArrayReadAccessDestroy, + poolRealArrayWriteAccessDestroy) genPoolArrayAPI(GodotPoolStringArray, initGodotPoolStringArray, GodotString, poolStringArrayNew, @@ -118,7 +189,13 @@ genPoolArrayAPI(GodotPoolStringArray, initGodotPoolStringArray, GodotString, poolStringArraySet, poolStringArrayGet, poolStringArraySize, - poolStringArrayDestroy) + poolStringArrayDestroy, + poolStringArrayRead, + poolStringArrayWrite, + poolStringArrayReadAccessPtr, + poolStringArrayWriteAccessPtr, + poolStringArrayReadAccessDestroy, + poolStringArrayWriteAccessDestroy) genPoolArrayAPI(GodotPoolVector2Array, initGodotPoolVector2Array, Vector2, poolVector2ArrayNew, @@ -134,7 +211,13 @@ genPoolArrayAPI(GodotPoolVector2Array, initGodotPoolVector2Array, Vector2, poolVector2ArraySet, poolVector2ArrayGet, poolVector2ArraySize, - poolVector2ArrayDestroy) + poolVector2ArrayDestroy, + poolVector2ArrayRead, + poolVector2ArrayWrite, + poolVector2ArrayReadAccessPtr, + poolVector2ArrayWriteAccessPtr, + poolVector2ArrayReadAccessDestroy, + poolVector2ArrayWriteAccessDestroy) genPoolArrayAPI(GodotPoolVector3Array, initGodotPoolVector3Array, Vector3, poolVector3ArrayNew, @@ -150,7 +233,13 @@ genPoolArrayAPI(GodotPoolVector3Array, initGodotPoolVector3Array, Vector3, poolVector3ArraySet, poolVector3ArrayGet, poolVector3ArraySize, - poolVector3ArrayDestroy) + poolVector3ArrayDestroy, + poolVector3ArrayRead, + poolVector3ArrayWrite, + poolVector3ArrayReadAccessPtr, + poolVector3ArrayWriteAccessPtr, + poolVector3ArrayReadAccessDestroy, + poolVector3ArrayWriteAccessDestroy) genPoolArrayAPI(GodotPoolColorArray, initGodotPoolColorArray, Color, poolColorArrayNew, @@ -166,4 +255,10 @@ genPoolArrayAPI(GodotPoolColorArray, initGodotPoolColorArray, Color, poolColorArraySet, poolColorArrayGet, poolColorArraySize, - poolColorArrayDestroy) + poolColorArrayDestroy, + poolColorArrayRead, + poolColorArrayWrite, + poolColorArrayReadAccessPtr, + poolColorArrayWriteAccessPtr, + poolColorArrayReadAccessDestroy, + poolColorArrayWriteAccessDestroy) From dc6ebaf5757b82436d714a779855207c6009afe4 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Sat, 31 Mar 2018 17:43:46 +0700 Subject: [PATCH 39/82] Fix GDNative API version check Fixes #18. --- godot.nimble | 2 +- godot/gdnativeapi.nim | 44 +++++++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/godot.nimble b/godot.nimble index b60be93..772875c 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.7" +version = "0.7.8" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index 5090813..3ece69b 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -2907,7 +2907,8 @@ var gdNativeAPI: GDNativeAPI proc getGDNativeAPI*(): ptr GDNativeAPI {.inline.} = addr gdNativeAPI -proc setGDNativeAPI*(apiStruct: pointer, initOptions: ptr GDNativeInitOptions) = +proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOptions, + foundCoreApi: var bool, foundNativeScriptApi: var bool) = let header = cast[ptr GDNativeAPIHeader](apiStruct) if header.typ >= ord(low(GDNativeAPIType)).cuint and header.typ <= ord(high(GDNativeAPIType)).cuint: @@ -2915,7 +2916,7 @@ proc setGDNativeAPI*(apiStruct: pointer, initOptions: ptr GDNativeInitOptions) = case typ: of GDNativeCore: let coreApi = cast[ptr GDNativeCoreAPI1](apiStruct) - if coreApi[].version.major == 1: + if coreApi[].version.major == 1 and coreApi[].version.minor == 0: assign(gdNativeApi, coreApi[]): # Color API colorNewRGBA @@ -3505,15 +3506,14 @@ proc setGDNativeAPI*(apiStruct: pointer, initOptions: ptr GDNativeInitOptions) = printWarning print + foundCoreApi = true for i in 0.cuint.. Date: Tue, 24 Apr 2018 11:12:49 +0700 Subject: [PATCH 40/82] Make godotapigen use getter return type for property types Fixes #20. --- godot.nimble | 2 +- godot/godotapigen.nim | 120 +++++++++++++++++++++++------------------- 2 files changed, 66 insertions(+), 56 deletions(-) diff --git a/godot.nimble b/godot.nimble index 772875c..d0814d8 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.8" +version = "0.7.9" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index c3c07cd..7d19d8e 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -659,15 +659,73 @@ proc generateMethod(tree: PNode, methodBindRegistry: var HashSet[string], meth: MethodInfo, withImplementation: bool) = doGenerateMethod(tree, methodBindRegistry, meth, withImplementation) +proc getMethodInfo(methodObj: JsonNode, types: Table[string, GodotType], + typ: GodotType): MethodInfo = + var origArgs = methodObj["arguments"] + var isBase = methodObj["is_virtual"].bval + if methodObj["is_virtual"].bval: + proc getMethod(typNode: JsonNode, methName: string): JsonNode = + for meth in typNode["methods"]: + if meth["is_virtual"].bval and + meth["name"].str == methName: return meth + var curTyp = types.getOrDefault(typ.baseName) + while not curTyp.isNil: + let meth = curTyp.jsonNode.getMethod(methodObj["name"].str) + if not meth.isNil: + origArgs = meth["arguments"] + isBase = false + curTyp = types.getOrDefault(curTyp.baseName) + + var args = newSeqOfCap[MethodArg](methodObj["arguments"].len + 1) + for arg in origArgs: + let typ = toNimType(types, arg["type"].str) + let defaultVal = if arg["has_default_value"].bval: arg["default_value"] + else: nil + args.add(MethodArg( + name: toNimStyle(arg["name"].str), typ: typ, + defaultVal: defaultVal)) + if methodObj["has_varargs"].bval: + args.add(MethodArg(name: "variantArgs", typ: "Variant", kind: ArgKind.VarArgs)) + + let godotName = methodObj["name"].str + var nimName = toNimStyle(godotName) + if not godotName.startsWith('_'): + for meth in typ.jsonNode["methods"]: + if meth["name"].str == '_' & godotName: + nimName = nimName & "Impl" + + let returnType = if methodObj["return_type"].str != "void": + toNimType(types, methodObj["return_type"].str) + else: nil + const discardableMethods = toSet(["emit_signal"]) + result = MethodInfo( + name: ident(nimName), + typ: typ, + godotName: methodObj["name"].str, + args: args, + returnType: returnType, + isVirtual: methodObj["is_virtual"].bval, + isBase: isBase, + isDiscardable: typ.godotName == "Object" and + methodObj["name"].str in discardableMethods + ) + +proc findMethod(obj: JsonNode, methName: string): JsonNode = + for meth in obj["methods"]: + if meth["name"].str == methName: + return meth + proc makeProperty(types: Table[string, GodotType], tree: PNode, methodBindRegistry: var HashSet[string], - typ: GodotType, - propertyObj: JsonNode, withImplementation: bool) = + typ: GodotType, propertyObj: JsonNode, obj: JsonNode, + withImplementation: bool) = let getterNameStr = toNimStyle(propertyObj["name"].str) - let getterName = ident(toNimStyle(propertyObj["name"].str)) + let getterName = ident(getterNameStr) let setterName = newNode(nkAccQuoted).addChain(ident(getterNameStr & "=")) - let nimType = toNimType(types, propertyObj["type"].str) + let getter = findMethod(obj, propertyObj["getter"].str) + let nimType = if getter.isNil: toNimType(types, propertyObj["type"].str) + else: getMethodInfo(getter, types, typ).returnType let getterInfo = MethodInfo( name: getterName, typ: typ, @@ -693,10 +751,6 @@ proc makeMethod(types: Table[string, GodotType], tree: PNode, methodBindRegistry: var HashSet[string], typ: GodotType, methodObj: JsonNode, withImplementation: bool) = - let returnType = if methodObj["return_type"].str != "void": - toNimType(types, methodObj["return_type"].str) - else: nil - if not typ.isSingleton: # for singletons we don't generate Nim setters/getters, # but use plain procedures instead. That's because setter syntax is @@ -706,51 +760,7 @@ proc makeMethod(types: Table[string, GodotType], tree: PNode, prop["setter"].str == methodObj["name"].str: return - var args = newSeqOfCap[MethodArg](methodObj["arguments"].len + 1) - var origArgs = methodObj["arguments"] - var isBase = methodObj["is_virtual"].bval - if methodObj["is_virtual"].bval: - proc getMethod(typNode: JsonNode, methName: string): JsonNode = - for meth in typNode["methods"]: - if meth["is_virtual"].bval and - meth["name"].str == methName: return meth - var curTyp = types.getOrDefault(typ.baseName) - while not curTyp.isNil: - let meth = curTyp.jsonNode.getMethod(methodObj["name"].str) - if not meth.isNil: - origArgs = meth["arguments"] - isBase = false - curTyp = types.getOrDefault(curTyp.baseName) - - for arg in origArgs: - let typ = toNimType(types, arg["type"].str) - let defaultVal = if arg["has_default_value"].bval: arg["default_value"] - else: nil - args.add(MethodArg( - name: toNimStyle(arg["name"].str), typ: typ, - defaultVal: defaultVal)) - if methodObj["has_varargs"].bval: - args.add(MethodArg(name: "variantArgs", typ: "Variant", kind: ArgKind.VarArgs)) - - let godotName = methodObj["name"].str - var nimName = toNimStyle(godotName) - if not godotName.startsWith('_'): - for meth in typ.jsonNode["methods"]: - if meth["name"].str == '_' & godotName: - nimName = nimName & "Impl" - - const discardableMethods = toSet(["emit_signal"]) - let methodInfo = MethodInfo( - name: ident(nimName), - typ: typ, - godotName: methodObj["name"].str, - args: args, - returnType: returnType, - isVirtual: methodObj["is_virtual"].bval, - isBase: isBase, - isDiscardable: typ.godotName == "Object" and - methodObj["name"].str in discardableMethods - ) + let methodInfo = getMethodInfo(methodObj, types, typ) generateMethod(tree, methodBindRegistry, methodInfo, withImplementation) @@ -931,7 +941,7 @@ proc genApi*(targetDir: string, apiJsonFile: string) = if not typ.isSingleton: for property in obj["properties"]: makeProperty(types, tree, methodBindRegsitry, typ, property, - withImplementation = false) + obj, withImplementation = false) for meth in obj["methods"]: makeMethod(types, tree, methodBindRegsitry, typ, meth, withImplementation = false) @@ -939,7 +949,7 @@ proc genApi*(targetDir: string, apiJsonFile: string) = if not typ.isSingleton: for property in obj["properties"]: makeProperty(types, tree, methodBindRegsitry, typ, - property, withImplementation = true) + property, obj, withImplementation = true) for meth in obj["methods"]: makeMethod(types, tree, methodBindRegsitry, typ, meth, withImplementation = true) From a1d14819678b9406e5927f73019fdb67dbcf7a62 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 14 May 2018 21:15:11 +0700 Subject: [PATCH 41/82] Add a remark to thread enter warning --- godot.nimble | 2 +- godot/nim/godotnim.nim | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/godot.nimble b/godot.nimble index d0814d8..aab9b94 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.9" +version = "0.7.10" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 3d64f1f..2d66ebd 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -823,6 +823,8 @@ proc registerFrameCallback*(cb: proc () {.closure.}) = else: idleCallbacks.add(cb) +{.push stackTrace: off.} + proc godot_nativescript_frame() {.cdecl, exportc, dynlib.} = var stackBottom {.volatile.}: pointer {.emit: """ @@ -840,7 +842,7 @@ proc godot_nativescript_thread_enter() {.cdecl, exportc, dynlib.} = when compileOption("threads"): setupForeignThreadGc() else: - const err = cstring"A foreign thread is created, but app is compiled without --threads:on. Bad things will happen if Nim code is invoked from this thread." + const err = cstring"A foreign thread is created, but app is compiled without --threads:on. Bad things will happen if Nim code is invoked from this thread. If you see this warning when running the editor and you don't actually use threads, ignore it." var s = err.toGodotString() godotPrint(s) s.deinit() @@ -848,3 +850,5 @@ proc godot_nativescript_thread_enter() {.cdecl, exportc, dynlib.} = proc godot_nativescript_thread_exit() {.cdecl, exportc, dynlib.} = when compileOption("threads"): teardownForeignThreadGc() + +{.pop.} # stackTrace: off From 96dfc7de904d36fe93321e41df861aacd9d205f4 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 16 May 2018 15:06:43 +0700 Subject: [PATCH 42/82] Fix for latest Nim --- godot.nimble | 2 +- godot/core/godotbase.nim | 8 ++++---- godot/internal/godotpoolarrays.nim | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/godot.nimble b/godot.nimble index aab9b94..b8bfed5 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.10" +version = "0.7.11" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/godotbase.nim b/godot/core/godotbase.nim index 38cca0f..d76f544 100644 --- a/godot/core/godotbase.nim +++ b/godot/core/godotbase.nim @@ -43,13 +43,13 @@ proc max*(x, y: float32): float32 {.inline, noinit.} = template printWarning*(warning: typed) = ## Prints ``warning`` to Godot log, adding filename and line information. - let (filename, line) = instantiationInfo() - godotPrintWarning(cstring($warning), cstring"", cstring(filename), line.cint) + let instInfo = instantiationInfo() + godotPrintWarning(cstring($warning), cstring"", cstring(instInfo.filename), instInfo.line.cint) template printError*(error: typed) = ## Prints ``error`` to Godot log, adding filename and line information. - let (filename, line) = instantiationInfo() - godotPrintError(cstring($error), cstring"", cstring(filename), line.cint) + let instInfo = instantiationInfo() + godotPrintError(cstring($error), cstring"", cstring(instInfo.filename), instInfo.line.cint) proc print*(parts: varargs[string, `$`]) = ## Prints concatenated ``parts`` to Godot log. diff --git a/godot/internal/godotpoolarrays.nim b/godot/internal/godotpoolarrays.nim index ede392c..fb80ad0 100644 --- a/godot/internal/godotpoolarrays.nim +++ b/godot/internal/godotpoolarrays.nim @@ -91,14 +91,14 @@ template genPoolArrayAPI(ArrayT, initIdent, DataT, initIdent(result) if actualIdxFrom < 0 or actualIdxFrom >= ownLen: - let (file, line) = instantiationInfo() + let instInfo = instantiationInfo() getGDNativeAPI().printError( - cstring"Invalid subarray begin index", cstring"subarray", file, line.cint) + cstring"Invalid subarray begin index", cstring"subarray", instInfo.filename, instInfo.line.cint) return if actualIdxTo < 0 or actualIdxTo >= ownLen: - let (file, line) = instantiationInfo() + let instInfo = instantiationInfo() getGDNativeAPI().printError( - cstring"Invalid subarray end index", cstring"subarray", file, line.cint) + cstring"Invalid subarray end index", cstring"subarray", instInfo.filename, instInfo.line.cint) return let span = actualIdxTo - actualIdxFrom + 1 result.setLen(span) From 21ca9a088b605f47284e846ddce1ed1dad1a3728 Mon Sep 17 00:00:00 2001 From: Jon Renner Date: Fri, 18 May 2018 17:34:53 -0500 Subject: [PATCH 43/82] export Vector2 normalize proc --- godot/core/vector2.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot/core/vector2.nim b/godot/core/vector2.nim index f15bd2f..e7e77d0 100644 --- a/godot/core/vector2.nim +++ b/godot/core/vector2.nim @@ -84,7 +84,7 @@ proc length*(self: Vector2): float32 {.inline, noinit.} = proc lengthSquared*(self: Vector2): float32 {.inline, noinit.} = self.x * self.x + self.y * self.y -proc normalize(self: var Vector2) {.inline.} = +proc normalize*(self: var Vector2) {.inline.} = var len = self.x * self.x + self.y * self.y if len != 0: len = sqrt(len) From 8b1ac6d83526633faeadc9149510a5d35d8c8f34 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 4 Jun 2018 08:48:08 +0700 Subject: [PATCH 44/82] Fix compilation with C++ backend. Fixes #25. --- godot/nim/godotnim.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 2d66ebd..8f3d6fb 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -774,7 +774,7 @@ proc fromVariant*[T: Table or TableRef](t: var T, result = ConversionResult.TypeError {.emit: """/*TYPESECTION*/ -void NimMain(void); +N_LIB_EXPORT N_CDECL(void, NimMain)(void); N_NOINLINE(void, setStackBottom)(void* thestackbottom); """.} From 651c2d823c44e57d12b295291e6f7dd3e25cd77e Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 4 Jun 2018 09:24:54 +0700 Subject: [PATCH 45/82] Handle nil object references properly Fixes #26. --- godot/godotapigen.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 7d19d8e..32275b4 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -468,9 +468,12 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(), newCall("toGodotString", argName)))) else: + let objVal = newIfStmt( + prefix("not", newDotExpr(argName, ident"isNil")), + newDotExpr(argName, ident("godotObject")) + ).addChain(newNode(nkElse).addChain(newNilLit())) argConversions.add(newNode(nkLetSection).addChain( - newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(), - newDotExpr(argName, ident("godotObject"))))) + newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(), objVal))) let argAsgn = newNode(nkAsgn).addChain( newNode(nkBracketExpr).addChain( newNode(nkBracketExpr).addChain(argsName), argIdx), From 2dd0130c784161a6a2cf983b5d0ba86cd40497aa Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 4 Jun 2018 09:51:07 +0700 Subject: [PATCH 46/82] Avoid name clashes between properties and methods Fixes #19. --- godot/godotapigen.nim | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 32275b4..ed444ff 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -722,6 +722,11 @@ proc makeProperty(types: Table[string, GodotType], tree: PNode, methodBindRegistry: var HashSet[string], typ: GodotType, propertyObj: JsonNode, obj: JsonNode, withImplementation: bool) = + for meth in obj["methods"]: + if meth["name"].str == '_' & propertyObj["name"].str: + # Don't generate properties if there is a name clash - otherwise + # using the property would not compile due to ambiguity. + return let getterNameStr = toNimStyle(propertyObj["name"].str) let getterName = ident(getterNameStr) let setterName = newNode(nkAccQuoted).addChain(ident(getterNameStr & "=")) @@ -760,8 +765,14 @@ proc makeMethod(types: Table[string, GodotType], tree: PNode, # supposed to be used on an object (have at least 2 params). for prop in typ.jsonNode["properties"]: if prop["getter"].str == methodObj["name"].str or - prop["setter"].str == methodObj["name"].str: - return + prop["setter"].str == methodObj["name"].str: + var hasDuplicateMethod = false + for meth in typ.jsonNode["methods"]: + if meth["name"].str == '_' & prop["name"].str: + hasDuplicateMethod = true + break + if not hasDuplicateMethod: + return let methodInfo = getMethodInfo(methodObj, types, typ) From 4eb771e9be50d6be5ede9783d13bfc41eb5b0a57 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 4 Jun 2018 10:34:47 +0700 Subject: [PATCH 47/82] Support all the default values --- godot/godotapigen.nim | 45 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index ed444ff..ae9a8fa 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -319,6 +319,7 @@ proc singletonName(typ: string): PNode = proc makeDefaultValue(arg: MethodArg): PNode = result = newEmptyNode() if not arg.defaultVal.isNil: + var failed = false if arg.typ == "bool": result = ident(arg.defaultVal.str.toLowerAscii()) elif arg.typ in intTypes: @@ -335,15 +336,15 @@ proc makeDefaultValue(arg: MethodArg): PNode = elif arg.typ == "Color": result = newCall("initColor", arg.defaultVal.str.split(',').mapIt(newFloatLit(parseFloat(it)))) - # elif arg.typ in arrayTypes and (arg.defaultVal.str == "[]" or - # arg.defaultVal.str == "[" & arg.typ & "]"): - # result = newCall("init" & arg.typ) elif arg.typ == "RID" and arg.defaultVal.str == "[RID]": result = newCall("initRID") + elif arg.typ in arrayTypes and (arg.defaultVal.str == "[]" or + arg.defaultVal.str == "[" & arg.typ & "]"): + result = newCall("new" & arg.typ) elif arg.typ == "Vector2" or arg.typ == "Vector3" or arg.typ == "Rect2": let parts = arg.defaultVal.str.replace("(", "").replace(")", ""). replace(" ", ""). - split(",").mapIt(newFloatLit(parseFloat(it))) + split(',').mapIt(newFloatLit(parseFloat(it))) if arg.typ.endsWith("r2"): result = newCall("vec2", parts) elif arg.typ.endsWith('3'): @@ -352,11 +353,41 @@ proc makeDefaultValue(arg: MethodArg): PNode = result = newCall("initRect2", parts) elif arg.defaultVal.str == "[Object:null]": result = newNilLit() - elif arg.typ != "Transform" and arg.typ != "Transform2D" and - arg.typ != "Variant" and arg.typ notin arrayTypes: # TODO + elif arg.typ == "Transform": + let transformParts = arg.defaultVal.str.replace(" ", "").split('-') + doAssert(transformParts.len == 2) + let basisParts = transformParts[0].split(',').mapIt( + newFloatLit(parseFloat(it))) + let originParts = transformParts[1].split(',').mapIt( + newFloatLit(parseFloat(it))) + let basis = newCall("initBasis", basisParts) + let origin = newCall("vec3", originParts) + result = newCall("initTransform", basis, origin) + elif arg.typ == "Transform2D": + let parts = arg.defaultVal.str. + replace(" ", ""). + replace(")", ""). + replace("(", ""). + split(',').mapIt(newFloatLit(parseFloat(it))) + doAssert(parts.len == 6) + let xAxis = newCall("vec2", parts[0..1]) + let yAxis = newCall("vec2", parts[2..3]) + let origin = newCall("vec2", parts[4..5]) + result = newCall("initTransform2D", xAxis, yAxis, origin) + elif arg.typ == "Variant": + if arg.defaultVal.str == "0": + result = newCall("newVariant", newIntLit(0)) + elif arg.defaultVal.str == "Null": + result = newCall("newVariant") + else: + failed = true + else: + failed = true + + if failed: raise newException( ValueError, - "Cannot build default value from $# ($#)" % + "Cannot build default value from \"$#\" ($#) - please report this at https://github.com/pragmagic/godot-nim/issues" % [$arg.defaultVal, arg.typ]) proc boundArgName(idx: int): string = From 76de026b4fb7f3402a47d47b9b2fac9a48b643df Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 4 Jun 2018 11:23:23 +0700 Subject: [PATCH 48/82] Implement hash proc for Godot types --- godot/core/aabb.nim | 6 +++ godot/core/basis.nim | 6 ++- godot/core/colors.nim | 5 +++ godot/core/dictionaries.nim | 9 ++-- godot/core/nodepaths.nim | 5 +++ godot/core/planes.nim | 5 +++ godot/core/poolarrays.nim | 13 ++++++ godot/core/quats.nim | 5 +++ godot/core/rect2.nim | 7 ++- godot/core/rids.nim | 5 +++ godot/core/transform2d.nim | 5 +++ godot/core/transforms.nim | 7 ++- godot/core/variants.nim | 89 ++++++++++++++++++++++++++----------- godot/core/vector2.nim | 5 ++- godot/core/vector3.nim | 5 ++- 15 files changed, 139 insertions(+), 38 deletions(-) diff --git a/godot/core/aabb.nim b/godot/core/aabb.nim index 88bf66a..2e9e7f0 100644 --- a/godot/core/aabb.nim +++ b/godot/core/aabb.nim @@ -1,5 +1,8 @@ # Copyright (c) 2018 Xored Software, Inc. +import hashes + +import vector3 import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi @@ -9,6 +12,9 @@ proc initAABB*(pos, size: Vector3): AABB {.inline.} = proc `$`*(self: AABB): string {.inline.} = $getGDNativeAPI().aabbAsString(self) +proc hash*(self: AABB): Hash {.inline.} = + !$(self.position.hash() !& self.size.hash()) + proc area*(self: AABB): float32 {.inline.} = getGDNativeAPI().aabbGetArea(self) diff --git a/godot/core/basis.nim b/godot/core/basis.nim index 538ca60..704f666 100644 --- a/godot/core/basis.nim +++ b/godot/core/basis.nim @@ -1,6 +1,7 @@ # Copyright (c) 2018 Xored Software, Inc. -import math +import math, hashes + import godotbase, vector3, quats import godotcoretypes @@ -201,6 +202,9 @@ proc `$`*(self: Basis): string {.inline.} = result.add(", ") result.add($self[i][j]) +proc hash*(self: Basis): Hash {.inline.} = + !$(self.elements[0].hash() !& self.elements[1].hash() !& self.elements[2].hash()) + template cofac(row1, col1, row2, col2: int): float32 = self.elements[row1][col1] * self.elements[row2][col2] - self.elements[row1][col2] * self.elements[row2][col1] diff --git a/godot/core/colors.nim b/godot/core/colors.nim index 46fcaf3..9079dad 100644 --- a/godot/core/colors.nim +++ b/godot/core/colors.nim @@ -1,5 +1,7 @@ # Copyright (c) 2018 Xored Software, Inc. +import hashes + import godotcoretypes, gdnativeapi proc initColor*(r, g, b: float32; a: float32 = 1.0'f32): Color {.inline.} = @@ -33,6 +35,9 @@ proc `$`*(self: Color): string {.inline.} = result.add(", ") result.add($self.a) +proc hash*(self: Color): Hash {.inline.} = + !$(self.r.hash() !& self.g.hash() !& self.b.hash() !& self.a.hash()) + proc toHex(val: float32, target: var string, targetIdx: int) = let val = clamp(int(val * 255), 0, 255) let nums = [(val and 0xF0) shr 4, val and 0xF] diff --git a/godot/core/dictionaries.nim b/godot/core/dictionaries.nim index 85970e5..99ecf6a 100644 --- a/godot/core/dictionaries.nim +++ b/godot/core/dictionaries.nim @@ -33,15 +33,15 @@ proc isEmpty*(self: Dictionary): bool {.inline.} = proc clear*(self: Dictionary) {.inline.} = self.godotDictionary.clear() +proc hash*(self: Dictionary): Hash {.inline.} = + hash(self.godotDictionary.godotHash()) + import variants, arrays proc newVariant*(dict: Dictionary): Variant {.inline.} = new(result, variantFinalizer) initGodotVariant(result.godotVariant[], dict.godotDictionary) -proc asDictionary*(self: Variant): Dictionary {.inline.} = - newDictionary(self.godotVariant[].asGodotDictionary) - proc contains*(self: Dictionary; key: Variant): bool {.inline.}= self.godotDictionary.contains(key.godotVariant[]) @@ -51,9 +51,6 @@ proc contains*(self: Dictionary; keys: Array): bool {.inline.} = proc del*(self: Dictionary; key: Variant) {.inline.} = self.godotDictionary.del(key.godotVariant[]) -proc hash*(self: Dictionary): Hash {.inline.} = - hash(self.godotDictionary.godotHash()) - proc keys*(self: Dictionary): Array {.inline.} = newArray(self.godotDictionary.keys()) diff --git a/godot/core/nodepaths.nim b/godot/core/nodepaths.nim index 428e261..831c855 100644 --- a/godot/core/nodepaths.nim +++ b/godot/core/nodepaths.nim @@ -1,5 +1,7 @@ # Copyright 2018 Xored Software, Inc. +import hashes + import internal.godotinternaltypes, internal.godotnodepaths, internal.godotstrings @@ -32,6 +34,9 @@ proc `$`*(self: NodePath): string {.inline.} = result = $s s.deinit() +proc hash*(self: NodePath): Hash {.inline.} = + ($self).hash() + proc isAbsolute*(self: NodePath): bool {.inline.} = self.path.isAbsolute() diff --git a/godot/core/planes.nim b/godot/core/planes.nim index 66de34e..b9420eb 100644 --- a/godot/core/planes.nim +++ b/godot/core/planes.nim @@ -1,5 +1,7 @@ # Copyright (c) 2018 Xored Software, Inc. +import hashes + import vector3 import internal.godotinternaltypes, internal.godotstrings @@ -20,6 +22,9 @@ proc initPlane*(normal: Vector3; d: float32): Plane {.inline.} = proc `$`*(self: Plane): string {.inline.} = $getGDNativeAPI().planeAsString(self) +proc hash*(self: Plane): Hash {.inline, noinit.} = + !$(self.normal.hash() !& self.d.hash()) + proc normalized*(self: Plane): Plane {.inline.} = getGDNativeAPI().planeNormalized(self) diff --git a/godot/core/poolarrays.nim b/godot/core/poolarrays.nim index 8206662..3e7b73e 100644 --- a/godot/core/poolarrays.nim +++ b/godot/core/poolarrays.nim @@ -1,8 +1,11 @@ # Copyright 2018 Xored Software, Inc. +import hashes + import godotcoretypes import internal.godotinternaltypes, internal.godotpoolarrays, internal.godotstrings +import vector2, vector3, colors template definePoolArrayBase(T, GodotT, DataT, fieldName, newProcName, initProcName) = @@ -83,6 +86,11 @@ template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName; for pair in arr.fieldName.mpairs: yield (pair[0].int, pair[1]) + proc hash*(arr: T): Hash = + for item in arr.items(): + result = result !& item.hash() + result = !$result + definePoolArrayBase(PoolByteArray, GodotPoolByteArray, uint8, godotPoolByteArray, newPoolByteArray, initGodotPoolByteArray) @@ -156,3 +164,8 @@ iterator items*(arr: PoolStringArray): string = iterator pairs*(arr: PoolStringArray): tuple[key: int, val: string] = for i in 0.. Date: Mon, 4 Jun 2018 11:47:17 +0700 Subject: [PATCH 49/82] Fix for latest Nim Closes #23. --- godot/internal/godotstrings.nim | 3 +-- godot/nim/godotnim.nim | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/godot/internal/godotstrings.nim b/godot/internal/godotstrings.nim index d3eb287..17443cb 100644 --- a/godot/internal/godotstrings.nim +++ b/godot/internal/godotstrings.nim @@ -29,14 +29,13 @@ proc `$`*(self: GodotString): string = result = newString(length) copyMem(addr result[0], getGDNativeAPI().charStringGetData(charStr), length) getGDNativeAPI().charStringDestroy(charStr) - assert(result[length] == '\0') proc toGodotString*(s: string): GodotString {.inline.} = ## Converts the Nim string into ``GodotString`` if s.isNil: initGodotString(result) else: - initGodotString(result, unsafeAddr s[0], cint(s.len + 1)) + initGodotString(result, cstring(s), cint(s.len + 1)) proc toGodotString*(s: cstring): GodotString {.inline.} = ## Converts the cstring into ``GodotString`` diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 8f3d6fb..0b13477 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -297,8 +297,8 @@ macro toGodotName(T: typedesc): string = godotName = "float" elif T is SomeUnsignedInt or T is SomeSignedInt: godotName = "int" - if godotName.isNil: - let nameStr: string = (($T.getType()[1][1].symbol).split(':')[0]) + if godotName.isNil or godotName.len == 0: + let nameStr = (($T.getType()[1][1].symbol).split(':')[0]) godotName = case nameStr: of "File", "Directory", "Thread", "Mutex", "Semaphore": "_" & nameStr From 9e610308172d24d8adc8083e950eb90aec5df063 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 4 Jun 2018 11:50:09 +0700 Subject: [PATCH 50/82] Up version to 0.7.12 --- godot.nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index b8bfed5..17968f8 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.11" +version = "0.7.12" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" From 1e8ccfea2b8b25b78d4a5cd7ebcc4f29ff73b255 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 4 Jun 2018 14:28:07 +0700 Subject: [PATCH 51/82] Fix handling of Error as an argument in Godot API --- godot/godotapigen.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index ae9a8fa..707154a 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -282,7 +282,7 @@ type const standardTypes = toSet( ["bool", "cint", "int", "uint8", "int8", "uint16", "int16", "uint32", "int32", - "uint64", + "uint64", "Error", "int64", "float32", "cfloat", "float64", "GodotString", "Vector2", "Rect2", "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform", "Color", "RID", "NodePath", "Dictionary", "Variant", "Array", From b3ad6134d90aafd9da58050fd89943c492cc5351 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 4 Jun 2018 16:24:52 +0700 Subject: [PATCH 52/82] Fix doc generation --- docs/docbuild.nim | 3 ++- godot/core/dictionaries.nim | 3 +++ godot/core/poolarrays.nim | 16 ++++++---------- godot/core/variants.nim | 28 ++++++++++++++-------------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/docs/docbuild.nim b/docs/docbuild.nim index bb3e21c..10823a5 100644 --- a/docs/docbuild.nim +++ b/docs/docbuild.nim @@ -104,7 +104,8 @@ proc buildDocs*(outDir, godotNimDir, godotBin: string) = createDir(godotApiFolder) genApiFiles(godotApiFolder, godotBinAbs) for file in walkDirRec(godotApiFolder, {pcFile, pcDir}, [".nim"]): - spawn execOrFail("nim doc -d:useRealtimeGc --path:godot " & quoted(file)) + spawn execOrFail("nim doc -d:useRealtimeGc --path:godot -o:" & + quoted(outName(godotApiFolder, file)) & ' ' & quoted(file)) sync() diff --git a/godot/core/dictionaries.nim b/godot/core/dictionaries.nim index 99ecf6a..4a160f2 100644 --- a/godot/core/dictionaries.nim +++ b/godot/core/dictionaries.nim @@ -42,6 +42,9 @@ proc newVariant*(dict: Dictionary): Variant {.inline.} = new(result, variantFinalizer) initGodotVariant(result.godotVariant[], dict.godotDictionary) +proc asDictionary*(self: Variant): Dictionary {.inline.} = + newDictionary(self.godotVariant[].asGodotDictionary()) + proc contains*(self: Dictionary; key: Variant): bool {.inline.}= self.godotDictionary.contains(key.godotVariant[]) diff --git a/godot/core/poolarrays.nim b/godot/core/poolarrays.nim index 3e7b73e..29aca98 100644 --- a/godot/core/poolarrays.nim +++ b/godot/core/poolarrays.nim @@ -29,6 +29,12 @@ template definePoolArrayBase(T, GodotT, DataT, fieldName, newProcName, new(result, poolArrayFinalizer) result.fieldName = arr + proc hash*(arr: T): Hash = + for item in arr.fieldName.items(): + result = result !& + (when type(item) is GodotString: ($item).hash() else: item.hash()) + result = !$result + template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName; noData = false) = @@ -86,11 +92,6 @@ template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName; for pair in arr.fieldName.mpairs: yield (pair[0].int, pair[1]) - proc hash*(arr: T): Hash = - for item in arr.items(): - result = result !& item.hash() - result = !$result - definePoolArrayBase(PoolByteArray, GodotPoolByteArray, uint8, godotPoolByteArray, newPoolByteArray, initGodotPoolByteArray) @@ -164,8 +165,3 @@ iterator items*(arr: PoolStringArray): string = iterator pairs*(arr: PoolStringArray): tuple[key: int, val: string] = for i in 0.. Date: Mon, 4 Jun 2018 17:26:26 +0700 Subject: [PATCH 53/82] Up version to 0.7.13 --- godot.nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index 17968f8..26afffa 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.12" +version = "0.7.13" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" From 8d68051f23f54f343443bc025b06f162c654e90a Mon Sep 17 00:00:00 2001 From: Evgeny Zuev Date: Thu, 21 Jun 2018 16:46:00 +0700 Subject: [PATCH 54/82] Fix `system.of` being preferred over `godot.of` in some cases Fix `as` fails when argument `obj` is not convertible to `T` Up version to 0.7.14 --- godot.nimble | 2 +- godot/nim/godotnim.nim | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/godot.nimble b/godot.nimble index 26afffa..e6c397f 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.13" +version = "0.7.14" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 0b13477..4702a42 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -267,9 +267,9 @@ proc `as`*[T: NimGodotObject](obj: NimGodotObject, t: typedesc[T]): T = ## This can be used either in dot notation (``node.as(Button)``) or ## infix notation (``node as Button``). if obj.isNil: return nil - if obj of T: + if system.`of`(obj, T): result = T(obj) - elif not obj.linkedObject.isNil and obj.linkedObject of T: + elif not obj.linkedObject.isNil and system.`of`(obj.linkedObject, T): result = T(obj.linkedObject) else: when not defined(release): @@ -277,10 +277,9 @@ proc `as`*[T: NimGodotObject](obj: NimGodotObject, t: typedesc[T]): T = T.name & "\n" & getStackTrace()) result = nil -proc `of`*[T: NimGodotObject](obj: NimGodotObject, - t: typedesc[T]): bool {.inline.} = +proc `of`*[T1, T2: NimGodotObject](obj: T1, t: typedesc[T2]): bool {.inline.} = ## Godot-specific inheritance check. - not obj.isNil and (system.`of`(obj, T) or system.`of`(obj.linkedObject, T)) + not obj.isNil and (system.`of`(obj, T2) or system.`of`(obj.linkedObject, T2)) proc newRStrLit(s: string): NimNode {.compileTime.} = result = newNimNode(nnkRStrLit) From fd5f77e7c2ce68f17d5b50fc273b54112bf5aa55 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Tue, 14 Aug 2018 17:59:24 +0700 Subject: [PATCH 55/82] Fix gdobj to properly handle var block --- godot.nimble | 2 +- godot/nim/godotmacros.nim | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/godot.nimble b/godot.nimble index e6c397f..fade4f8 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.14" +version = "0.7.15" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index 384aa2b..3f1001b 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -172,7 +172,11 @@ proc parseMethod(meth: NimNode): MethodDecl = proc parseVarSection(decl: NimNode): seq[VarDecl] = assert(decl.kind == nnkVarSection) - result = identDefsToVarDecls(decl[0]) + for i in 0.. Date: Tue, 28 Aug 2018 14:05:33 +0700 Subject: [PATCH 56/82] Make `classRegistry` use hashes instead of strings as keys for faster lookup Up version to 0.7.16 --- godot.nimble | 2 +- godot/gdnativeapi.nim | 6 +- godot/godotapigen.nim | 4 +- godot/godotinternal.nim | 5 ++ godot/internal/godotinternaltypes.nim | 5 ++ godot/internal/godotpoolarrays.nim | 3 - godot/internal/godotstrings.nim | 6 ++ godot/nim/godotmacros.nim | 2 +- godot/nim/godotnim.nim | 91 ++++++++++++++++++++++----- 9 files changed, 101 insertions(+), 23 deletions(-) diff --git a/godot.nimble b/godot.nimble index fade4f8..60a1136 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.15" +version = "0.7.16" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index 3ece69b..b24fc6f 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -1374,7 +1374,8 @@ type stringNewWithWideString: pointer stringOperatorIndex: pointer stringOperatorIndexConst: pointer - stringWideStr: pointer + stringWideStr: proc (self: GodotString): ptr cwchar_t + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringOperatorEqual: proc (self, other: GodotString): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringOperatorLess: proc (self, other: GodotString): bool @@ -2811,6 +2812,8 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringNewCopy*: proc (dest: var GodotString, src: GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringWideStr*: proc (self: GodotString): ptr cwchar_t + {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringOperatorEqual*: proc (self, other: GodotString): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} stringOperatorLess*: proc (self, other: GodotString): bool @@ -3481,6 +3484,7 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt stringNew stringNewCopy + stringWideStr stringOperatorEqual stringOperatorLess stringOperatorPlus diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 707154a..876e770 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -839,7 +839,7 @@ proc typeNameToModuleName(name: string): string = proc newRegisterClassNode(typ: GodotType): PNode = newCall("registerClass", ident(typ.name), - newCStringLit(typ.godotName), + newStrLit(typ.godotName), ident("true") # isNative ) @@ -877,7 +877,7 @@ proc genTypeFile(types: Table[string, GodotType], targetDir: string) = if not typ.shouldExport(types): continue let regNode = newCall("registerClass", ident(typ.name), - newCStringLit(typ.godotName), + newStrLit(typ.godotName), ident("true") # isNative ) godotApiTypesTree.add(regNode) diff --git a/godot/godotinternal.nim b/godot/godotinternal.nim index 0314624..ce83428 100644 --- a/godot/godotinternal.nim +++ b/godot/godotinternal.nim @@ -93,6 +93,11 @@ proc getClassName*(o: ptr GodotObject): string = # There are physics type not known by ClassDB result = result[0..result.len-3] +proc getClassNameRaw*(o: ptr GodotObject): GodotString = + if getClassMethodBind.isNil: + getClassMethodBind = getMethod(cstring"Object", cstring"get_class") + getClassMethodBind.ptrCall(o, nil, addr result) + proc getGodotSingleton*(name: cstring): ptr GodotObject {.inline.} = getGDNativeAPI().globalGetSingleton(name) diff --git a/godot/internal/godotinternaltypes.nim b/godot/internal/godotinternaltypes.nim index 192b6cd..8474af8 100644 --- a/godot/internal/godotinternaltypes.nim +++ b/godot/internal/godotinternaltypes.nim @@ -66,6 +66,8 @@ type GodotString* {.byref.} = object data: array[sizeof(int), byte] + cwchar_t* {.importc: "wchar_t", nodecl.} = object + GodotCharString* {.byref.} = object data: array[sizeof(int), byte] @@ -305,3 +307,6 @@ type GodotClassConstructor* = proc (): ptr GodotObject {. noconv, gcsafe, locks: 0, raises: [], tags: [].} + +template offset*[T](p: ptr T, offset: int): ptr T = + cast[ptr T](cast[ByteAddress](p) +% (offset * sizeof(T))) \ No newline at end of file diff --git a/godot/internal/godotpoolarrays.nim b/godot/internal/godotpoolarrays.nim index fb80ad0..e03e1ff 100644 --- a/godot/internal/godotpoolarrays.nim +++ b/godot/internal/godotpoolarrays.nim @@ -3,9 +3,6 @@ import godotinternaltypes, gdnativeapi import core.godotcoretypes -proc offset[T](p: ptr T, offset: int): ptr T {.inline.} = - cast[ptr T](cast[ByteAddress](p) +% (offset * sizeof(T))) - template genPoolArrayAPI(ArrayT, initIdent, DataT, newProc, newCopyProc, newWithArrayProc, appendProc, appendArrayProc, insertProc, invertProc, pushBackProc, diff --git a/godot/internal/godotstrings.nim b/godot/internal/godotstrings.nim index 17443cb..be18df0 100644 --- a/godot/internal/godotstrings.nim +++ b/godot/internal/godotstrings.nim @@ -22,6 +22,12 @@ proc `&`*(self, b: GodotString): GodotString {.inline.} = proc deinit*(self: var GodotString) {.inline.} = getGDNativeAPI().stringDestroy(self) +proc len*(self: GodotString): cint {.inline.} = + getGDNativeAPI().stringLength(self) + +proc dataPtr*(self: GodotString): ptr cwchar_t {.inline.} = + getGDNativeAPI().stringWideStr(self) + proc `$`*(self: GodotString): string = ## Converts the ``GodotString`` into Nim string var charStr = getGDNativeAPI().stringUtf8(self) diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index 3f1001b..352925a 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -508,7 +508,7 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = # Register Godot object let parentName = if obj.parentName.isNil: newStrLitNode("Object") else: newStrLitNode(obj.parentName) - let classNameLit = newCStringLit(obj.name) + let classNameLit = newStrLitNode(obj.name) let classNameIdent = ident(obj.name) let isRef: bool = if obj.parentName.isNil: false else: obj.parentName in refClasses diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 4702a42..df682ca 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -1,6 +1,6 @@ # Copyright 2018 Xored Software, Inc. -import tables, typetraits, macros +import tables, typetraits, macros, unicode import gdnativeapi import core.godotcoretypes, core.godotbase import core.vector2, core.rect2, @@ -89,21 +89,71 @@ type ## values. ## See documentation of ``GodotPropertyHint`` for description of formats. + FNV1Hash = uint32 + proc isFinalized*(obj: NimGodotObject): bool {.inline.} = obj.isFinalized -var classRegistry {.threadvar.}: TableRef[cstring, ObjectInfo] -var classRegistryStatic* {.compileTime.}: TableRef[cstring, ObjectInfo] +var classRegistry {.threadvar.}: TableRef[FNV1Hash, ObjectInfo] +var classRegistryStatic* {.compileTime.}: TableRef[FNV1Hash, ObjectInfo] ## Compile-time variable used for implementation of several procedures ## and macros static: - classRegistryStatic = newTable[cstring, ObjectInfo]() + classRegistryStatic = newTable[FNV1Hash, ObjectInfo]() static: import sets, strutils var nativeClasses {.compileTime.} = newSeq[string]() var refClasses* {.compileTime.} = newSeq[string]() +template initFNV1Hash(hash: var FNV1Hash) = + hash = 0x811c9dc5'u32 + +template appendFNV1Hash(hash: var FNV1Hash, val: uint8) = + block: + let u64hash = hash.uint64 + hash = ( + u64hash + + (u64hash shl 1'u64) + + (u64hash shl 4'u64) + + (u64hash shl 7'u64) + + (u64hash shl 8'u64) + + (u64hash shl 24'u64)).uint32 xor val + +{.push stackTrace:off.} +proc lsb(c: ptr cwchar_t): char {.noinit, inline.} = + {.emit: [result, " = (char)(", c[]," & 0xFF);"]} +{.pop.} + +proc fnv1Hash(godotClassName: GodotString): FNV1Hash = + var charsCount = godotClassName.len + let charsPtr = godotClassName.dataPtr + if charsCount > 2 and + charsPtr.offset(charsCount - 2).lsb == 'S' and + charsPtr.offset(charsCount - 1).lsb == 'W': + charsCount -= 2 + + initFNV1Hash(result) + for i in 0..= charsCount: + break + let firstByte = uint8(rune.uint64 and 0xFF'u64) + appendFNV1Hash(result, firstByte) + # We don't really need to calculate hash of other bytes, + # since we only use hashes of ASCII strings + inc i + proc getClassName*(o: NimGodotObject): string = o.godotObject.getClassName() @@ -179,12 +229,12 @@ macro isResource(T: typedesc): bool = result = if inherits(getType(T), "Resource"): ident("true") else: ident("false") -template registerClass*(T: typedesc; godotClassName: cstring, +template registerClass*(T: typedesc; godotClassName: string or cstring, native: bool) = ## Registers the specified Godot type. ## Used by ``gdobj`` macro and `godotapigen `_. if classRegistry.isNil: - classRegistry = newTable[cstring, ObjectInfo]() + classRegistry = newTable[FNV1Hash, ObjectInfo]() let constructor = proc(): NimGodotObject = var t: T new(t, nimGodotObjectFinalizer[T]) @@ -198,14 +248,22 @@ template registerClass*(T: typedesc; godotClassName: cstring, isNative: native, isRef: isRef ) - classRegistry[godotClassName] = objInfo + classRegistry[fnv1Hash($godotClassName)] = objInfo static: let objInfoStatic = ObjectInfo( baseNativeClass: base, isNative: native, isRef: isRef, ) - classRegistryStatic[godotClassName] = objInfoStatic + let nameHash = fnv1Hash($godotClassName) + if not classRegistryStatic.contains(nameHash): + classRegistryStatic[nameHash] = objInfoStatic + elif not endsWith($godotClassName, "SW"): + # For simplicity we assume that all class names must have + # different hashes + # If this exception is ever raised, I guess, we should + # implement a proper collision resolving + raise newException(Exception, "Hash collision " & $godotClassName) when isRef: static: refClasses.add(T.name) @@ -214,10 +272,10 @@ template registerClass*(T: typedesc; godotClassName: cstring, nativeClasses.add(T.name) proc newNimGodotObject[T: NimGodotObject]( - godotObject: ptr GodotObject, godotClassName: cstring, noRef: bool): T = + godotObject: ptr GodotObject, godotClassName: GodotString, noRef: bool): T = assert(not classRegistry.isNil) assert(not godotObject.isNil) - let objInfo = classRegistry.getOrDefault(godotClassName) + let objInfo = classRegistry.getOrDefault(fnv1Hash(godotClassName)) if objInfo.constructor.isNil: printError("Nim constructor not found for class " & $godotClassName) else: @@ -240,9 +298,11 @@ proc asNimGodotObject*[T: NimGodotObject]( # Could be data from other bindings result = nil if result.isNil: + var classNameStr = godotObject.getClassNameRaw() result = newNimGodotObject[T]( - godotObject, cstring(godotObject.getClassName()), + godotObject, classNameStr, forceNativeObject or noRef) + deinit(classNameStr) proc newVariant*(obj: NimGodotObject): Variant {.inline.} = newVariant(obj.godotObject) @@ -363,17 +423,18 @@ proc newOwnObj[T: NimGodotObject](name: cstring): T = proc gdnew*[T: NimGodotObject](): T = ## Instantiates new object of type ``T``. - const godotName = asCString(toGodotName(T)) - const objInfo = classRegistryStatic[godotName] + const godotName = toGodotName(T) + const cGodotName = asCString(godotName) + const objInfo = classRegistryStatic[fnv1Hash(godotName)] when objInfo.isNative: - let godotObject = getClassConstructor(godotName)() + let godotObject = getClassConstructor(cGodotName)() new(result, nimGodotObjectFinalizer[T]) result.godotObject = godotObject when objInfo.isRef: godotObject.initRef() result.isRef = true else: - result = newOwnObj[T](godotName) + result = newOwnObj[T](cGodotName) proc newCallError*(err: VariantCallError): ref CallError = ## Instantiates ``CallError`` from Godot ``err``. From 859f9f04fb764fc81eae3e531c64a58cd5dfadaa Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Fri, 21 Sep 2018 16:34:09 +0700 Subject: [PATCH 57/82] OrderedTable to Variant conversion support --- godot.nimble | 2 +- godot/nim/godotnim.nim | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/godot.nimble b/godot.nimble index 60a1136..daabda8 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.16" +version = "0.7.17" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index df682ca..665b715 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -791,10 +791,10 @@ proc fromVariant*[T: array](s: var T, val: Variant): ConversionResult = else: result = ConversionResult.TypeError -proc godotTypeInfo*(T: typedesc[Table|TableRef]): GodotTypeInfo {.inline.} = +proc godotTypeInfo*(T: typedesc[Table|TableRef|OrderedTable|OrderedTableRef]): GodotTypeInfo {.inline.} = result.variantType = VariantType.Dictionary -proc toVariant*[T: Table or TableRef](t: T): Variant = +proc toVariant*[T: Table or TableRef or OrderedTable or OrderedTableRef](t: T): Variant = when t is ref: if t.isNil: return newVariant() @@ -804,7 +804,7 @@ proc toVariant*[T: Table or TableRef](t: T): Variant = dict[toVariant(k)] = toVariant(v) result = newVariant(dict) -proc fromVariant*[T: Table or TableRef](t: var T, +proc fromVariant*[T: Table or TableRef or OrderedTable or OrderedTableRef](t: var T, val: Variant): ConversionResult = if val.getType() == VariantType.Nil: when t is ref: @@ -814,8 +814,12 @@ proc fromVariant*[T: Table or TableRef](t: var T, mixin fromVariant when t is Table: t = initTable[type(t.keys()), type(t.values())]() - else: + elif t is TableRef: t = newTable[type(t.keys()), type(t.values())]() + elif t is OrderedTable: + t = initOrderedTable[type(t.keys()), type(t.values())]() + else: + t = newOrderedTable[type(t.keys()), type(t.values())]() for k, v in dict: var nimKey: type(t.keys()) var nimVal: type(t.values()) From e9d73d8ec4612250f306737506e4507414f3d53e Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 11 Oct 2018 19:06:05 +0700 Subject: [PATCH 58/82] Fix GDNative API procedure declarations Earlier signature mismatch caused problems on macOS with Godot 3.1. --- godot.nimble | 2 +- godot/core/aabb.nim | 16 +- godot/core/colors.nim | 8 +- godot/core/planes.nim | 10 +- godot/core/quats.nim | 22 +- godot/core/transform2d.nim | 32 +- godot/core/transforms.nim | 28 +- godot/gdnativeapi.nim | 466 ++++++++++++++++------------- godot/internal/godotpoolarrays.nim | 10 +- godot/internal/godotvariants.nim | 20 +- 10 files changed, 342 insertions(+), 272 deletions(-) diff --git a/godot.nimble b/godot.nimble index daabda8..8e4c8c0 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.17" +version = "0.7.18" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/aabb.nim b/godot/core/aabb.nim index 2e9e7f0..66425a2 100644 --- a/godot/core/aabb.nim +++ b/godot/core/aabb.nim @@ -31,10 +31,10 @@ proc encloses*(self, other: AABB): bool {.inline.} = getGDNativeAPI().aabbEncloses(self, other) proc merge*(self, other: AABB): AABB {.inline.} = - getGDNativeAPI().aabbMerge(self, other) + getGDNativeAPI().aabbMerge(self, other).toAABB() proc intersection*(self, other: AABB): AABB {.inline.} = - getGDNativeAPI().aabbIntersection(self, other) + getGDNativeAPI().aabbIntersection(self, other).toAABB() proc intersectsPlane*(self: AABB; plane: Plane): bool {.inline.} = getGDNativeAPI().aabbIntersectsPlane(self, plane) @@ -46,10 +46,10 @@ proc contains*(self: AABB; point: Vector3): bool {.inline.} = getGDNativeAPI().aabbHasPoint(self, point) proc getSupport*(self: AABB; dir: Vector3): Vector3 {.inline.} = - getGDNativeAPI().aabbGetSupport(self, dir) + getGDNativeAPI().aabbGetSupport(self, dir).toVector3() proc getLongestAxis*(self: AABB): Vector3 {.inline.} = - getGDNativeAPI().aabbGetLongestAxis(self) + getGDNativeAPI().aabbGetLongestAxis(self).toVector3() proc getLongestAxisIndex*(self: AABB): cint {.inline.} = getGDNativeAPI().aabbGetLongestAxisIndex(self) @@ -58,7 +58,7 @@ proc getLongestAxisSize*(self: AABB): float32 {.inline.} = getGDNativeAPI().aabbGetLongestAxisSize(self) proc getShortestAxis*(self: AABB): Vector3 {.inline.} = - getGDNativeAPI().aabbGetShortestAxis(self) + getGDNativeAPI().aabbGetShortestAxis(self).toVector3() proc getShortestAxisIndex*(self: AABB): cint {.inline.} = getGDNativeAPI().aabbGetShortestAxisIndex(self) @@ -67,13 +67,13 @@ proc getShortestAxisSize*(self: AABB): float32 {.inline.} = getGDNativeAPI().aabbGetShortestAxisSize(self) proc expand*(self: AABB; toPoint: Vector3): AABB {.inline.} = - getGDNativeAPI().aabbExpand(self, toPoint) + getGDNativeAPI().aabbExpand(self, toPoint).toAABB() proc grow*(self: AABB; by: float32): AABB {.inline.} = - getGDNativeAPI().aabbGrow(self, by) + getGDNativeAPI().aabbGrow(self, by).toAABB() proc getEndpoint*(self: AABB; idx: cint): Vector3 {.inline.} = - getGDNativeAPI().aabbGetEndpoint(self, idx) + getGDNativeAPI().aabbGetEndpoint(self, idx).toVector3() proc `==`*(a, b: AABB): bool {.inline.} = getGDNativeAPI().aabbOperatorEqual(a, b) diff --git a/godot/core/colors.nim b/godot/core/colors.nim index 9079dad..8e01b7a 100644 --- a/godot/core/colors.nim +++ b/godot/core/colors.nim @@ -64,16 +64,16 @@ proc gray*(self: Color): float32 {.inline.} = getGDNativeAPI().colorGray(self) proc inverted*(self: Color): Color {.inline.} = - getGDNativeAPI().colorInverted(self) + getGDNativeAPI().colorInverted(self).toColor() proc contrasted*(self: Color): Color {.inline.} = - getGDNativeAPI().colorContrasted(self) + getGDNativeAPI().colorContrasted(self).toColor() proc lerp*(self: Color; b: Color; t: float32): Color {.inline.} = - getGDNativeAPI().colorLinearInterpolate(self, b, t) + getGDNativeAPI().colorLinearInterpolate(self, b, t).toColor() proc blend*(self: Color; over: Color): Color {.inline.} = - getGDNativeAPI().colorBlend(self, over) + getGDNativeAPI().colorBlend(self, over).toColor() proc `==`*(a, b: Color): bool {.inline.} = a.r == b.r and a.g == b.g and a.b == b.b and a.a == b.a diff --git a/godot/core/planes.nim b/godot/core/planes.nim index b9420eb..815a5c6 100644 --- a/godot/core/planes.nim +++ b/godot/core/planes.nim @@ -26,13 +26,13 @@ proc hash*(self: Plane): Hash {.inline, noinit.} = !$(self.normal.hash() !& self.d.hash()) proc normalized*(self: Plane): Plane {.inline.} = - getGDNativeAPI().planeNormalized(self) + getGDNativeAPI().planeNormalized(self).toPlane() proc center*(self: Plane): Vector3 {.inline.} = - getGDNativeAPI().planeCenter(self) + getGDNativeAPI().planeCenter(self).toVector3() proc getAnyPoint*(self: Plane): Vector3 {.inline.} = - getGDNativeAPI().planeGetAnyPoint(self) + getGDNativeAPI().planeGetAnyPoint(self).toVector3() proc isPointOver*(self: Plane; point: Vector3): bool {.inline.} = getGDNativeAPI().planeIsPointOver(self, point) @@ -45,7 +45,7 @@ proc contains*(self: Plane; point: Vector3; getGDNativeAPI().planeHasPoint(self, point, epsilon) proc project*(self: Plane; point: Vector3): Vector3 {.inline.} = - getGDNativeAPI().planeProject(self, point) + getGDNativeAPI().planeProject(self, point).toVector3() proc intersect3*(self: Plane; dest: var Vector3; b, c: Plane): bool {.inline.} = @@ -60,7 +60,7 @@ proc intersectsSegment*(self: Plane; dest: var Vector3; getGDNativeAPI().planeIntersectsSegment(self, dest, segmentBegin, segmentEnd) proc `-`*(self: Plane): Plane {.inline.} = - getGDNativeAPI().planeOperatorNeg(self) + getGDNativeAPI().planeOperatorNeg(self).toPlane() proc `==`*(a, b: Plane): bool {.inline.} = getGDNativeAPI().planeOperatorEqual(a, b) diff --git a/godot/core/quats.nim b/godot/core/quats.nim index 560a341..1a8da82 100644 --- a/godot/core/quats.nim +++ b/godot/core/quats.nim @@ -29,50 +29,50 @@ proc lengthSquared*(self: Quat): float32 {.inline.} = getGDNativeAPI().quatLengthSquared(self) proc normalized*(self: Quat): Quat {.inline.} = - getGDNativeAPI().quatNormalized(self) + getGDNativeAPI().quatNormalized(self).toQuat() proc isNormalized*(self: Quat): bool {.inline.} = getGDNativeAPI().quatIsNormalized(self) proc inverse*(self: Quat): Quat {.inline.} = - getGDNativeAPI().quatInverse(self) + getGDNativeAPI().quatInverse(self).toQuat() proc dot*(a, b: Quat): float32 {.inline.} = getGDNativeAPI().quatDot(a, b) proc xform*(self: Quat; v: Vector3): Vector3 {.inline.} = - getGDNativeAPI().quatXform(self, v) + getGDNativeAPI().quatXform(self, v).toVector3() proc slerp*(self: Quat; b: Quat; t: float32): Quat {.inline.} = - getGDNativeAPI().quatSlerp(self, b, t) + getGDNativeAPI().quatSlerp(self, b, t).toQuat() proc slerpni*(self: Quat; b: Quat; t: float32): Quat {.inline.} = - getGDNativeAPI().quatSlerpni(self, b, t) + getGDNativeAPI().quatSlerpni(self, b, t).toQuat() proc cubicSlerp*(self, b, preA, postB: Quat; t: float32): Quat {.inline.} = - getGDNativeAPI().quatCubicSlerp(self, b, preA, postB, t) + getGDNativeAPI().quatCubicSlerp(self, b, preA, postB, t).toQuat() proc `*`*(a: Quat, b: float32): Quat {.inline.} = - getGDNativeAPI().quatOperatorMultiply(a, b) + getGDNativeAPI().quatOperatorMultiply(a, b).toQuat() proc `*=`*(a: var Quat, b: float32) {.inline.} = a = a * b proc `+`*(a, b: Quat): Quat {.inline.} = - getGDNativeAPI().quatOperatorAdd(a, b) + getGDNativeAPI().quatOperatorAdd(a, b).toQuat() proc `+=`*(a: var Quat, b: Quat) {.inline.} = a = a + b proc `-`*(a, b: Quat): Quat {.inline.} = - getGDNativeAPI().quatOperatorSubtract(a, b) + getGDNativeAPI().quatOperatorSubtract(a, b).toQuat() proc `-=`* (a: var Quat, b: Quat) {.inline.} = a = a - b proc `/`*(self: Quat; b: float32): Quat {.inline.} = - getGDNativeAPI().quatOperatorDivide(self, b) + getGDNativeAPI().quatOperatorDivide(self, b).toQuat() proc `/=`*(self: var Quat, b: float32) {.inline.} = self = self / b @@ -81,4 +81,4 @@ proc `==`*(a, b: Quat): bool {.inline.} = getGDNativeAPI().quatOperatorEqual(a, b) proc `-`*(self: Quat): Quat {.inline.} = - getGDNativeAPI().quatOperatorNeg(self) + getGDNativeAPI().quatOperatorNeg(self).toQuat() diff --git a/godot/core/transform2d.nim b/godot/core/transform2d.nim index af3e9b4..16f62bd 100644 --- a/godot/core/transform2d.nim +++ b/godot/core/transform2d.nim @@ -21,59 +21,59 @@ proc hash*(self: Transform2D): Hash {.inline, noinit.} = !$(self.elements[0].hash() !& self.elements[1].hash() !& self.elements[2].hash()) proc inverse*(self: Transform2D): Transform2D {.inline.} = - getGDNativeAPI().transform2DInverse(self) + getGDNativeAPI().transform2DInverse(self).toTransform2D() proc affineInverse*(self: Transform2D): Transform2D {.inline.} = - getGDNativeAPI().transform2DAffineInverse(self) + getGDNativeAPI().transform2DAffineInverse(self).toTransform2D() proc rotation*(self: Transform2D): float32 {.inline.} = getGDNativeAPI().transform2DGetRotation(self) proc origin*(self: Transform2D): Vector2 {.inline.} = - getGDNativeAPI().transform2DGetOrigin(self) + getGDNativeAPI().transform2DGetOrigin(self).toVector2() proc scale*(self: Transform2D): Vector2 {.inline.} = - getGDNativeAPI().transform2DGetScale(self) + getGDNativeAPI().transform2DGetScale(self).toVector2() proc orthonormalized*(self: Transform2D): Transform2D {.inline.} = - getGDNativeAPI().transform2DOrthonormalized(self) + getGDNativeAPI().transform2DOrthonormalized(self).toTransform2D() proc rotated*(self: Transform2D; phi: float32): Transform2D {.inline.} = - getGDNativeAPI().transform2DRotated(self, phi) + getGDNativeAPI().transform2DRotated(self, phi).toTransform2D() proc scaled*(self: Transform2D; scale: Vector2): Transform2D {.inline.} = - getGDNativeAPI().transform2DScaled(self, scale) + getGDNativeAPI().transform2DScaled(self, scale).toTransform2D() proc translated*(self: Transform2D; offset: Vector2): Transform2D {.inline.} = - getGDNativeAPI().transform2DTranslated(self, offset) + getGDNativeAPI().transform2DTranslated(self, offset).toTransform2D() proc xformVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = - getGDNativeAPI().transform2DXformVector2(self, v) + getGDNativeAPI().transform2DXformVector2(self, v).toVector2() proc xformInvVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = - getGDNativeAPI().transform2DXformInvVector2(self, v) + getGDNativeAPI().transform2DXformInvVector2(self, v).toVector2() proc basisXformVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = - getGDNativeAPI().transform2DBasisXformVector2(self, v) + getGDNativeAPI().transform2DBasisXformVector2(self, v).toVector2() proc basisXformInvVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = - getGDNativeAPI().transform2DBasisXformInvVector2(self, v) + getGDNativeAPI().transform2DBasisXformInvVector2(self, v).toVector2() proc xformRect2*(self: Transform2D; rect: Rect2): Rect2 {.inline.} = - getGDNativeAPI().transform2DXformRect2(self, rect) + getGDNativeAPI().transform2DXformRect2(self, rect).toRect2() proc xformInvRect2*(self: Transform2D; rect: Rect2): Rect2 {.inline.} = - getGDNativeAPI().transform2DXformInvRect2(self, rect) + getGDNativeAPI().transform2DXformInvRect2(self, rect).toRect2() proc interpolateWith*(self, m: Transform2D; c: float32): Transform2D {.inline.} = - getGDNativeAPI().transform2DInterpolateWith(self, m, c) + getGDNativeAPI().transform2DInterpolateWith(self, m, c).toTransform2D() proc `==`*(a, b: Transform2D): bool {.inline.} = getGDNativeAPI().transform2DOperatorEqual(a, b) proc `*`*(a, b: Transform2D): Transform2D {.inline.} = - getGDNativeAPI().transform2DOperatorMultiply(a, b) + getGDNativeAPI().transform2DOperatorMultiply(a, b).toTransform2D() proc `*=`*(a: var Transform2D, b: Transform2D) {.inline.} = a = a * b diff --git a/godot/core/transforms.nim b/godot/core/transforms.nim index bb3aa05..4a21466 100644 --- a/godot/core/transforms.nim +++ b/godot/core/transforms.nim @@ -27,50 +27,50 @@ proc hash*(self: Transform): Hash {.inline.} = !$(self.basis.hash() !& self.origin.hash()) proc inverse*(self: Transform): Transform {.inline.} = - getGDNativeAPI().transformInverse(self) + getGDNativeAPI().transformInverse(self).toTransform() proc affineInverse*(self: Transform): Transform {.inline.} = - getGDNativeAPI().transformAffineInverse(self) + getGDNativeAPI().transformAffineInverse(self).toTransform() proc orthonormalized*(self: Transform): Transform {.inline.} = - getGDNativeAPI().transformOrthonormalized(self) + getGDNativeAPI().transformOrthonormalized(self).toTransform() proc rotated*(self: Transform; axis: Vector3; phi: float32): Transform {.inline.} = - getGDNativeAPI().transformRotated(self, axis, phi) + getGDNativeAPI().transformRotated(self, axis, phi).toTransform() proc scaled*(self: Transform; scale: Vector3): Transform {.inline.} = - getGDNativeAPI().transformScaled(self, scale) + getGDNativeAPI().transformScaled(self, scale).toTransform() proc translated*(self: Transform; offset: Vector3): Transform {.inline.} = - getGDNativeAPI().transformTranslated(self, offset) + getGDNativeAPI().transformTranslated(self, offset).toTransform() proc lookingAt*(self: Transform; target, up: Vector3): Transform {.inline.} = - getGDNativeAPI().transformLookingAt(self, target, up) + getGDNativeAPI().transformLookingAt(self, target, up).toTransform() proc xformPlane*(self: Transform; plane: Plane): Plane {.inline.} = - getGDNativeAPI().transformXformPlane(self, plane) + getGDNativeAPI().transformXformPlane(self, plane).toPlane() proc xformInvPlane*(self: Transform; plane: Plane): Plane {.inline.} = - getGDNativeAPI().transformXformInvPlane(self, plane) + getGDNativeAPI().transformXformInvPlane(self, plane).toPlane() proc xformVector3*(self: Transform; v: Vector3): Vector3 {.inline.} = - getGDNativeAPI().transformXformVector3(self, v) + getGDNativeAPI().transformXformVector3(self, v).toVector3() proc xformInvVector3*(self: Transform; v: Vector3): Vector3 {.inline.} = - getGDNativeAPI().transformXformInvVector3(self, v) + getGDNativeAPI().transformXformInvVector3(self, v).toVector3() proc xformAABB*(self: Transform; rect: AABB): AABB {.inline.} = - getGDNativeAPI().transformXformAABB(self, rect) + getGDNativeAPI().transformXformAABB(self, rect).toAABB() proc xformInvAABB*(self: Transform; rect: AABB): AABB {.inline.} = - getGDNativeAPI().transformXformInvAABB(self, rect) + getGDNativeAPI().transformXformInvAABB(self, rect).toAABB() proc `==`*(self: Transform; b: Transform): bool {.inline.} = getGDNativeAPI().transformOperatorEqual(self, b) proc `*`*(self, other: Transform): Transform {.inline.} = - getGDNativeAPI().transformOperatorMultiply(self, other) + getGDNativeAPI().transformOperatorMultiply(self, other).toTransform() proc `*=`*(self: var Transform, other: Transform) {.inline.} = self = self * other diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index b24fc6f..591d45e 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -3,6 +3,36 @@ import internal.godotinternaltypes, core.godotcoretypes, macros type + ColorData* {.byref.} = object + data: array[16, uint8] + + Vector3Data* {.byref.} = object + data: array[12, uint8] + + Vector2Data* {.byref.} = object + data: array[8, uint8] + + PlaneData* {.byref.} = object + data: array[16, uint8] + + BasisData* {.byref.} = object + data: array[36, uint8] + + QuatData* {.byref.} = object + data: array[16, uint8] + + AABBData* {.byref.} = object + data: array[24, uint8] + + Rect2Data* {.byref.} = object + data: array[16, uint8] + + Transform2DData* {.byref.} = object + data: array[24, uint8] + + TransformData* {.byref.} = object + data: array[48, uint8] + GDNativeAPIType {.size: sizeof(cuint).} = enum GDNativeCore, GDNativeExtNativeScript, @@ -93,14 +123,14 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} colorGray: proc (self: Color): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorInverted: proc (self: Color): Color + colorInverted: proc (self: Color): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorContrasted: proc (self: Color): Color + colorContrasted: proc (self: Color): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorLinearInterpolate: proc (self, other: Color, t: float32): Color + colorLinearInterpolate: proc (self, other: Color, t: float32): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorBlend: proc (self, other: Color): Color + colorBlend: proc (self, other: Color): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} colorToHtml: proc (self: Color, withAlpha: bool): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -114,7 +144,7 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2AsString: proc (self: Vector2): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Normalized: proc (self: Vector2): Vector2 + vector2Normalized: proc (self: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2Length: proc (self: Vector2): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -133,57 +163,57 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2AngleToPoint: proc (self, to: Vector2): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2LinearInterpolate: proc (self, b: Vector2, t: float32): Vector2 + vector2LinearInterpolate: proc (self, b: Vector2, t: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2CubicInterpolate: proc (self, b, preA, postB: Vector2, - t: float32): Vector2 + t: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Rotated: proc (self: Vector2, phi: float32): Vector2 + vector2Rotated: proc (self: Vector2, phi: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Tangent: proc (self: Vector2): Vector2 + vector2Tangent: proc (self: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Floor: proc (self: Vector2): Vector2 + vector2Floor: proc (self: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Snapped: proc (self, by: Vector2): Vector2 + vector2Snapped: proc (self, by: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2Aspect: proc (self: Vector2): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2Dot: proc (self, other: Vector2): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Slide: proc (self, n: Vector2): Vector2 + vector2Slide: proc (self, n: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Bounce: proc (self, n: Vector2): Vector2 + vector2Bounce: proc (self, n: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Reflect: proc (self, n: Vector2): Vector2 + vector2Reflect: proc (self, n: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Abs: proc (self: Vector2): Vector2 + vector2Abs: proc (self: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Clamped: proc (self: Vector2, length: float32): Vector2 + vector2Clamped: proc (self: Vector2, length: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorAdd: proc (self, other: Vector2): Vector2 + vector2OperatorAdd: proc (self, other: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorSubtract: proc (self, other: Vector2): Vector2 + vector2OperatorSubtract: proc (self, other: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorMultiplyVector: proc (self, other: Vector2): Vector2 + vector2OperatorMultiplyVector: proc (self, other: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorMultiplyScalar: proc (self: Vector2, scalar: float32): Vector2 + vector2OperatorMultiplyScalar: proc (self: Vector2, scalar: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorDivideVector: proc (self, other: Vector2): Vector2 + vector2OperatorDivideVector: proc (self, other: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorDivideScalar: proc (self: Vector2, scalar: float32): Vector2 + vector2OperatorDivideScalar: proc (self: Vector2, scalar: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2OperatorEqual: proc (self, other: Vector2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2OperatorLess: proc (self, other: Vector2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorNeg: proc (self: Vector2): Vector2 + vector2OperatorNeg: proc (self: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2SetX: pointer vector2SetY: pointer @@ -218,33 +248,33 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} quatLengthSquared: proc (self: Quat): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatNormalized: proc (self: Quat): Quat + quatNormalized: proc (self: Quat): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} quatIsNormalized: proc (self: Quat): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatInverse: proc (self: Quat): Quat + quatInverse: proc (self: Quat): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} quatDot: proc (self, other: Quat): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatXform: proc (self: Quat, v: Vector3): Vector3 + quatXform: proc (self: Quat, v: Vector3): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSlerp: proc (self, other: Quat, t: float32): Quat + quatSlerp: proc (self, other: Quat, t: float32): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSlerpni: proc (self, other: Quat, t: float32): Quat + quatSlerpni: proc (self, other: Quat, t: float32): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatCubicSlerp: proc (self, other, preA, postB: Quat, t: float32): Quat + quatCubicSlerp: proc (self, other, preA, postB: Quat, t: float32): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorMultiply: proc (self: Quat, b: float32): Quat + quatOperatorMultiply: proc (self: Quat, b: float32): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorAdd: proc (self, other: Quat): Quat + quatOperatorAdd: proc (self, other: Quat): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorSubtract: proc (self, other: Quat): Quat + quatOperatorSubtract: proc (self, other: Quat): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorDivide: proc (self: Quat, divider: float32): Quat + quatOperatorDivide: proc (self: Quat, divider: float32): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} quatOperatorEqual: proc (self, other: Quat): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorNeg: proc (self: Quat): Quat + quatOperatorNeg: proc (self: Quat): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} # Basis API @@ -534,7 +564,7 @@ type poolVector2ArraySet: proc (self: var GodotPoolVector2Array, idx: cint, data: Vector2) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayGet: proc (self: GodotPoolVector2Array, idx: cint): Vector2 + poolVector2ArrayGet: proc (self: GodotPoolVector2Array, idx: cint): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolVector2ArraySize: proc (self: GodotPoolVector2Array): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -583,7 +613,7 @@ type poolVector3ArraySet: proc (self: var GodotPoolVector3Array, idx: cint, data: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayGet: proc (self: GodotPoolVector3Array, idx: cint): Vector3 + poolVector3ArrayGet: proc (self: GodotPoolVector3Array, idx: cint): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolVector3ArraySize: proc (self: GodotPoolVector3Array): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -628,7 +658,7 @@ type poolColorArraySet: proc (self: var GodotPoolColorArray, idx: cint, data: Color) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayGet: proc (self: GodotPoolColorArray, idx: cint): Color + poolColorArrayGet: proc (self: GodotPoolColorArray, idx: cint): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolColorArraySize: proc (self: GodotPoolColorArray): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -937,11 +967,11 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeAsString: proc (self: Plane): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeNormalized: proc (self: Plane): Plane + planeNormalized: proc (self: Plane): PlaneData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeCenter: proc (self: Plane): Vector3 + planeCenter: proc (self: Plane): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeGetAnyPoint: proc (self: Plane): Vector3 + planeGetAnyPoint: proc (self: Plane): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeIsPointOver: proc (self: Plane, point: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -949,7 +979,7 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeHasPoint: proc (self: Plane, point: Vector3, epsilon: float32): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeProject: proc (self: Plane, point: Vector3): Vector3 + planeProject: proc (self: Plane, point: Vector3): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeIntersect3: proc (self: Plane, dest: var Vector3, b, c: Plane): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -960,13 +990,13 @@ type segmentBegin, segmentEnd: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeOperatorNeg: proc (self: Plane): Plane + planeOperatorNeg: proc (self: Plane): PlaneData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeOperatorEqual: proc (self, other: Plane): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeSetNormal: proc (self: var Plane, normal: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeGetNormal: proc (self: Plane): Vector3 + planeGetNormal: proc (self: Plane): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeGetD: proc (self: Plane): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -989,21 +1019,21 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2HasNoArea: proc (self: Rect2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Clip: proc (self, other: Rect2): Rect2 + rect2Clip: proc (self, other: Rect2): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Merge: proc (self, other: Rect2): Rect2 + rect2Merge: proc (self, other: Rect2): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2HasPoint: proc (self: Rect2, point: Vector2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Grow: proc (self: Rect2, by: float32): Rect2 + rect2Grow: proc (self: Rect2, by: float32): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Expand: proc (self: Rect2, to: Vector2): Rect2 + rect2Expand: proc (self: Rect2, to: Vector2): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2OperatorEqual: proc (self, other: Rect2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2GetPosition: proc (self: Rect2): Vector2 + rect2GetPosition: proc (self: Rect2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2GetSize: proc (self: Rect2): Vector2 + rect2GetSize: proc (self: Rect2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2SetPosition: proc (self: var Rect2, pos: Vector2) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1013,11 +1043,11 @@ type # AABB API aabbNew: proc (dest: var AABB, pos, size: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetPosition: proc (self: AABB): Vector3 + aabbGetPosition: proc (self: AABB): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbSetPosition: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetSize: proc (self: AABB): Vector3 + aabbGetSize: proc (self: AABB): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbSetSize: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1033,9 +1063,9 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbEncloses: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbMerge: proc (self, other: AABB): AABB + aabbMerge: proc (self, other: AABB): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbIntersection: proc (self, other: AABB): AABB + aabbIntersection: proc (self, other: AABB): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbIntersectsPlane: proc (self: AABB, plane: Plane): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1044,9 +1074,9 @@ type locks: 0.} aabbHasPoint: proc (self: AABB, point: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetSupport: proc (self: AABB, dir: Vector3): Vector3 + aabbGetSupport: proc (self: AABB, dir: Vector3): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetLongestAxis: proc (self: AABB): Vector3 + aabbGetLongestAxis: proc (self: AABB): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbGetLongestAxisIndex: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], @@ -1054,7 +1084,7 @@ type aabbGetLongestAxisSize: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetShortestAxis: proc (self: AABB): Vector3 + aabbGetShortestAxis: proc (self: AABB): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbGetShortestAxisIndex: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], @@ -1062,11 +1092,11 @@ type aabbGetShortestAxisSize: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbExpand: proc (self: AABB, toPoint: Vector3): AABB + aabbExpand: proc (self: AABB, toPoint: Vector3): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGrow: proc (self: AABB, by: float32): AABB + aabbGrow: proc (self: AABB, by: float32): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetEndpoint: proc (self: AABB, idx: cint): Vector3 + aabbGetEndpoint: proc (self: AABB, idx: cint): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbOperatorEqual: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1090,36 +1120,36 @@ type locks: 0.} transformNew: proc (dest: var Transform, basis: Basis, origin: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformGetBasis: proc (self: Transform): Basis + transformGetBasis: proc (self: Transform): BasisData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformSetBasis: proc (self: var Transform, basis: Basis) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformGetOrigin: proc (self: Transform): Vector3 + transformGetOrigin: proc (self: Transform): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformSetOrigin: proc (self: var Transform, v: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformAsString: proc (self: Transform): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformInverse: proc (self: Transform): Transform + transformInverse: proc (self: Transform): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformAffineInverse: proc (self: Transform): Transform + transformAffineInverse: proc (self: Transform): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformOrthonormalized: proc (self: Transform): Transform + transformOrthonormalized: proc (self: Transform): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformRotated: proc (self: Transform, axis: Vector3, - phi: float32): Transform + phi: float32): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformScaled: proc (self: Transform, scale: Vector3): Transform + transformScaled: proc (self: Transform, scale: Vector3): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformTranslated: proc (self: Transform, offset: Vector3): Transform + transformTranslated: proc (self: Transform, offset: Vector3): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformLookingAt: proc (self: Transform, target, up: Vector3): Transform + transformLookingAt: proc (self: Transform, target, up: Vector3): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformPlane: proc (self: Transform, plane: Plane): Plane + transformXformPlane: proc (self: Transform, plane: Plane): PlaneData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvPlane: proc (self: Transform, plane: Plane): Plane + transformXformInvPlane: proc (self: Transform, plane: Plane): PlaneData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformNewIdentity: proc (dest: var Transform) @@ -1127,18 +1157,18 @@ type transformOperatorEqual: proc (self, other: Transform): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformOperatorMultiply: proc (self, other: Transform): Transform + transformOperatorMultiply: proc (self, other: Transform): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformVector3: proc (self: Transform, v: Vector3): Vector3 + transformXformVector3: proc (self: Transform, v: Vector3): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvVector3: proc (self: Transform, v: Vector3): Vector3 + transformXformInvVector3: proc (self: Transform, v: Vector3): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformAABB: proc (self: Transform, v: AABB): AABB + transformXformAABB: proc (self: Transform, v: AABB): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvAABB: proc (self: Transform, v: AABB): AABB + transformXformInvAABB: proc (self: Transform, v: AABB): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1151,58 +1181,58 @@ type locks: 0.} transform2DAsString: proc (self: Transform2D): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DInverse: proc (self: Transform2D): Transform2D + transform2DInverse: proc (self: Transform2D): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DAffineInverse: proc (self: Transform2D): Transform2D + transform2DAffineInverse: proc (self: Transform2D): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DGetRotation: proc (self: Transform2D): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DGetOrigin: proc (self: Transform2D): Vector2 + transform2DGetOrigin: proc (self: Transform2D): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DGetScale: proc (self: Transform2D): Vector2 + transform2DGetScale: proc (self: Transform2D): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DOrthonormalized: proc (self: Transform2D): Transform2D + transform2DOrthonormalized: proc (self: Transform2D): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DRotated: proc (self: Transform2D, phi: float32): Transform2D + transform2DRotated: proc (self: Transform2D, phi: float32): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DScaled: proc (self: Transform2D, scale: Vector2): Transform2D + transform2DScaled: proc (self: Transform2D, scale: Vector2): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DTranslated: proc (self: Transform2D, offset: Vector2): Transform2D + transform2DTranslated: proc (self: Transform2D, offset: Vector2): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformVector2: proc (self: Transform2D, v: Vector2): Vector2 + transform2DXformVector2: proc (self: Transform2D, v: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformInvVector2: proc (self: Transform2D, v: Vector2): Vector2 + transform2DXformInvVector2: proc (self: Transform2D, v: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DBasisXformVector2: proc (self: Transform2D, v: Vector2): Vector2 + transform2DBasisXformVector2: proc (self: Transform2D, v: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DBasisXformInvVector2: proc (self: Transform2D, - v: Vector2): Vector2 + v: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DInterpolateWith: proc (self, other: Transform2D, - t: float32): Transform2D + t: float32): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DOperatorEqual: proc (self, other: Transform2D): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DOperatorMultiply: proc (self, other: Transform2D): Transform2D + transform2DOperatorMultiply: proc (self, other: Transform2D): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DNewIdentity: proc (dest: var Transform2D) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformRect2: proc (self: Transform2D, v: Rect2): Rect2 + transform2DXformRect2: proc (self: Transform2D, v: Rect2): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformInvRect2: proc (self: Transform2D, v: Rect2): Rect2 + transform2DXformInvRect2: proc (self: Transform2D, v: Rect2): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1291,25 +1321,25 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsString: proc (self: GodotVariant): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsVector2: proc (self: GodotVariant): Vector2 + variantAsVector2: proc (self: GodotVariant): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsRect2: proc (self: GodotVariant): Rect2 + variantAsRect2: proc (self: GodotVariant): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsVector3: proc (self: GodotVariant): Vector3 + variantAsVector3: proc (self: GodotVariant): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsTransform2D: proc (self: GodotVariant): Transform2D + variantAsTransform2D: proc (self: GodotVariant): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsPlane: proc (self: GodotVariant): Plane + variantAsPlane: proc (self: GodotVariant): PlaneData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsQuat: proc (self: GodotVariant): Quat + variantAsQuat: proc (self: GodotVariant): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsAABB: proc (self: GodotVariant): AABB + variantAsAABB: proc (self: GodotVariant): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsBasis: proc (self: GodotVariant): Basis + variantAsBasis: proc (self: GodotVariant): BasisData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsTransform: proc (self: GodotVariant): Transform + variantAsTransform: proc (self: GodotVariant): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsColor: proc (self: GodotVariant): Color + variantAsColor: proc (self: GodotVariant): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsNodePath: proc (self: GodotVariant): GodotNodePath {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1611,14 +1641,14 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} colorGray*: proc (self: Color): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorInverted*: proc (self: Color): Color + colorInverted*: proc (self: Color): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorContrasted*: proc (self: Color): Color + colorContrasted*: proc (self: Color): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorLinearInterpolate*: proc (self, other: Color, t: float32): Color + colorLinearInterpolate*: proc (self, other: Color, t: float32): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorBlend*: proc (self, other: Color): Color + colorBlend*: proc (self, other: Color): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} colorToHtml*: proc (self: Color, withAlpha: bool): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1632,7 +1662,7 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2AsString*: proc (self: Vector2): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Normalized*: proc (self: Vector2): Vector2 + vector2Normalized*: proc (self: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2Length*: proc (self: Vector2): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1651,57 +1681,57 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2AngleToPoint*: proc (self, to: Vector2): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2LinearInterpolate*: proc (self, b: Vector2, t: float32): Vector2 + vector2LinearInterpolate*: proc (self, b: Vector2, t: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2CubicInterpolate*: proc (self, b, preA, postB: Vector2, - t: float32): Vector2 + t: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Rotated*: proc (self: Vector2, phi: float32): Vector2 + vector2Rotated*: proc (self: Vector2, phi: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Tangent*: proc (self: Vector2): Vector2 + vector2Tangent*: proc (self: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Floor*: proc (self: Vector2): Vector2 + vector2Floor*: proc (self: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Snapped*: proc (self, by: Vector2): Vector2 + vector2Snapped*: proc (self, by: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2Aspect*: proc (self: Vector2): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2Dot*: proc (self, other: Vector2): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Slide*: proc (self, n: Vector2): Vector2 + vector2Slide*: proc (self, n: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Bounce*: proc (self, n: Vector2): Vector2 + vector2Bounce*: proc (self, n: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Reflect*: proc (self, n: Vector2): Vector2 + vector2Reflect*: proc (self, n: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Abs*: proc (self: Vector2): Vector2 + vector2Abs*: proc (self: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Clamped*: proc (self: Vector2, length: float32): Vector2 + vector2Clamped*: proc (self: Vector2, length: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorAdd*: proc (self, other: Vector2): Vector2 + vector2OperatorAdd*: proc (self, other: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorSubtract*: proc (self, other: Vector2): Vector2 + vector2OperatorSubtract*: proc (self, other: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorMultiplyVector*: proc (self, other: Vector2): Vector2 + vector2OperatorMultiplyVector*: proc (self, other: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorMultiplyScalar*: proc (self: Vector2, scalar: float32): Vector2 + vector2OperatorMultiplyScalar*: proc (self: Vector2, scalar: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorDivideVector*: proc (self, other: Vector2): Vector2 + vector2OperatorDivideVector*: proc (self, other: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorDivideScalar*: proc (self: Vector2, scalar: float32): Vector2 + vector2OperatorDivideScalar*: proc (self: Vector2, scalar: float32): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2OperatorEqual*: proc (self, other: Vector2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2OperatorLess*: proc (self, other: Vector2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorNeg*: proc (self: Vector2): Vector2 + vector2OperatorNeg*: proc (self: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} # Quat API @@ -1732,33 +1762,33 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} quatLengthSquared*: proc (self: Quat): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatNormalized*: proc (self: Quat): Quat + quatNormalized*: proc (self: Quat): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} quatIsNormalized*: proc (self: Quat): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatInverse*: proc (self: Quat): Quat + quatInverse*: proc (self: Quat): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} quatDot*: proc (self, other: Quat): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatXform*: proc (self: Quat, v: Vector3): Vector3 + quatXform*: proc (self: Quat, v: Vector3): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSlerp*: proc (self, other: Quat, t: float32): Quat + quatSlerp*: proc (self, other: Quat, t: float32): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSlerpni*: proc (self, other: Quat, t: float32): Quat + quatSlerpni*: proc (self, other: Quat, t: float32): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatCubicSlerp*: proc (self, other, preA, postB: Quat, t: float32): Quat + quatCubicSlerp*: proc (self, other, preA, postB: Quat, t: float32): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorMultiply*: proc (self: Quat, b: float32): Quat + quatOperatorMultiply*: proc (self: Quat, b: float32): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorAdd*: proc (self, other: Quat): Quat + quatOperatorAdd*: proc (self, other: Quat): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorSubtract*: proc (self, other: Quat): Quat + quatOperatorSubtract*: proc (self, other: Quat): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorDivide*: proc (self: Quat, divider: float32): Quat + quatOperatorDivide*: proc (self: Quat, divider: float32): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} quatOperatorEqual*: proc (self, other: Quat): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorNeg*: proc (self: Quat): Quat + quatOperatorNeg*: proc (self: Quat): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} # PoolByteArray API @@ -1977,7 +2007,7 @@ type poolVector2ArraySet*: proc (self: var GodotPoolVector2Array, idx: cint, data: Vector2) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayGet*: proc (self: GodotPoolVector2Array, idx: cint): Vector2 + poolVector2ArrayGet*: proc (self: GodotPoolVector2Array, idx: cint): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolVector2ArraySize*: proc (self: GodotPoolVector2Array): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2026,7 +2056,7 @@ type poolVector3ArraySet*: proc (self: var GodotPoolVector3Array, idx: cint, data: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayGet*: proc (self: GodotPoolVector3Array, idx: cint): Vector3 + poolVector3ArrayGet*: proc (self: GodotPoolVector3Array, idx: cint): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolVector3ArraySize*: proc (self: GodotPoolVector3Array): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2071,7 +2101,7 @@ type poolColorArraySet*: proc (self: var GodotPoolColorArray, idx: cint, data: Color) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayGet*: proc (self: GodotPoolColorArray, idx: cint): Color + poolColorArrayGet*: proc (self: GodotPoolColorArray, idx: cint): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolColorArraySize*: proc (self: GodotPoolColorArray): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2378,11 +2408,11 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeAsString*: proc (self: Plane): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeNormalized*: proc (self: Plane): Plane + planeNormalized*: proc (self: Plane): PlaneData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeCenter*: proc (self: Plane): Vector3 + planeCenter*: proc (self: Plane): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeGetAnyPoint*: proc (self: Plane): Vector3 + planeGetAnyPoint*: proc (self: Plane): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeIsPointOver*: proc (self: Plane, point: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2390,7 +2420,7 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeHasPoint*: proc (self: Plane, point: Vector3, epsilon: float32): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeProject*: proc (self: Plane, point: Vector3): Vector3 + planeProject*: proc (self: Plane, point: Vector3): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeIntersect3*: proc (self: Plane, dest: var Vector3, b, c: Plane): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2401,13 +2431,13 @@ type segmentBegin, segmentEnd: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeOperatorNeg*: proc (self: Plane): Plane + planeOperatorNeg*: proc (self: Plane): PlaneData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeOperatorEqual*: proc (self, other: Plane): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeSetNormal*: proc (self: var Plane, normal: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeGetNormal*: proc (self: Plane): Vector3 + planeGetNormal*: proc (self: Plane): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeGetD*: proc (self: Plane): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2430,21 +2460,21 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2HasNoArea*: proc (self: Rect2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Clip*: proc (self, other: Rect2): Rect2 + rect2Clip*: proc (self, other: Rect2): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Merge*: proc (self, other: Rect2): Rect2 + rect2Merge*: proc (self, other: Rect2): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2HasPoint*: proc (self: Rect2, point: Vector2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Grow*: proc (self: Rect2, by: float32): Rect2 + rect2Grow*: proc (self: Rect2, by: float32): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Expand*: proc (self: Rect2, to: Vector2): Rect2 + rect2Expand*: proc (self: Rect2, to: Vector2): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2OperatorEqual*: proc (self, other: Rect2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2GetPosition*: proc (self: Rect2): Vector2 + rect2GetPosition*: proc (self: Rect2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2GetSize*: proc (self: Rect2): Vector2 + rect2GetSize*: proc (self: Rect2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2SetPosition*: proc (self: var Rect2, pos: Vector2) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2454,11 +2484,11 @@ type # AABB API aabbNew*: proc (dest: var AABB, pos, size: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetPosition*: proc (self: AABB): Vector3 + aabbGetPosition*: proc (self: AABB): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbSetPosition*: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetSize*: proc (self: AABB): Vector3 + aabbGetSize*: proc (self: AABB): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbSetSize*: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2474,9 +2504,9 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbEncloses*: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbMerge*: proc (self, other: AABB): AABB + aabbMerge*: proc (self, other: AABB): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbIntersection*: proc (self, other: AABB): AABB + aabbIntersection*: proc (self, other: AABB): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbIntersectsPlane*: proc (self: AABB, plane: Plane): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2485,9 +2515,9 @@ type locks: 0.} aabbHasPoint*: proc (self: AABB, point: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetSupport*: proc (self: AABB, dir: Vector3): Vector3 + aabbGetSupport*: proc (self: AABB, dir: Vector3): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetLongestAxis*: proc (self: AABB): Vector3 + aabbGetLongestAxis*: proc (self: AABB): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbGetLongestAxisIndex*: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], @@ -2495,7 +2525,7 @@ type aabbGetLongestAxisSize*: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetShortestAxis*: proc (self: AABB): Vector3 + aabbGetShortestAxis*: proc (self: AABB): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbGetShortestAxisIndex*: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], @@ -2503,11 +2533,11 @@ type aabbGetShortestAxisSize*: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbExpand*: proc (self: AABB, toPoint: Vector3): AABB + aabbExpand*: proc (self: AABB, toPoint: Vector3): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGrow*: proc (self: AABB, by: float32): AABB + aabbGrow*: proc (self: AABB, by: float32): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetEndpoint*: proc (self: AABB, idx: cint): Vector3 + aabbGetEndpoint*: proc (self: AABB, idx: cint): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbOperatorEqual*: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2531,36 +2561,36 @@ type locks: 0.} transformNew*: proc (dest: var Transform, basis: Basis, origin: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformGetBasis*: proc (self: Transform): Basis + transformGetBasis*: proc (self: Transform): BasisData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformSetBasis*: proc (self: var Transform, basis: Basis) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformGetOrigin*: proc (self: Transform): Vector3 + transformGetOrigin*: proc (self: Transform): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformSetOrigin*: proc (self: var Transform, v: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformAsString*: proc (self: Transform): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformInverse*: proc (self: Transform): Transform + transformInverse*: proc (self: Transform): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformAffineInverse*: proc (self: Transform): Transform + transformAffineInverse*: proc (self: Transform): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformOrthonormalized*: proc (self: Transform): Transform + transformOrthonormalized*: proc (self: Transform): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformRotated*: proc (self: Transform, axis: Vector3, - phi: float32): Transform + phi: float32): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformScaled*: proc (self: Transform, scale: Vector3): Transform + transformScaled*: proc (self: Transform, scale: Vector3): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformTranslated*: proc (self: Transform, offset: Vector3): Transform + transformTranslated*: proc (self: Transform, offset: Vector3): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformLookingAt*: proc (self: Transform, target, up: Vector3): Transform + transformLookingAt*: proc (self: Transform, target, up: Vector3): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformPlane*: proc (self: Transform, plane: Plane): Plane + transformXformPlane*: proc (self: Transform, plane: Plane): PlaneData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvPlane*: proc (self: Transform, plane: Plane): Plane + transformXformInvPlane*: proc (self: Transform, plane: Plane): PlaneData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformNewIdentity*: proc (dest: var Transform) @@ -2568,18 +2598,18 @@ type transformOperatorEqual*: proc (self, other: Transform): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformOperatorMultiply*: proc (self, other: Transform): Transform + transformOperatorMultiply*: proc (self, other: Transform): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformVector3*: proc (self: Transform, v: Vector3): Vector3 + transformXformVector3*: proc (self: Transform, v: Vector3): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvVector3*: proc (self: Transform, v: Vector3): Vector3 + transformXformInvVector3*: proc (self: Transform, v: Vector3): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformAABB*: proc (self: Transform, v: AABB): AABB + transformXformAABB*: proc (self: Transform, v: AABB): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvAABB*: proc (self: Transform, v: AABB): AABB + transformXformInvAABB*: proc (self: Transform, v: AABB): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2592,58 +2622,58 @@ type locks: 0.} transform2DAsString*: proc (self: Transform2D): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DInverse*: proc (self: Transform2D): Transform2D + transform2DInverse*: proc (self: Transform2D): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DAffineInverse*: proc (self: Transform2D): Transform2D + transform2DAffineInverse*: proc (self: Transform2D): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DGetRotation*: proc (self: Transform2D): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DGetOrigin*: proc (self: Transform2D): Vector2 + transform2DGetOrigin*: proc (self: Transform2D): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DGetScale*: proc (self: Transform2D): Vector2 + transform2DGetScale*: proc (self: Transform2D): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DOrthonormalized*: proc (self: Transform2D): Transform2D + transform2DOrthonormalized*: proc (self: Transform2D): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DRotated*: proc (self: Transform2D, phi: float32): Transform2D + transform2DRotated*: proc (self: Transform2D, phi: float32): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DScaled*: proc (self: Transform2D, scale: Vector2): Transform2D + transform2DScaled*: proc (self: Transform2D, scale: Vector2): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DTranslated*: proc (self: Transform2D, offset: Vector2): Transform2D + transform2DTranslated*: proc (self: Transform2D, offset: Vector2): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformVector2*: proc (self: Transform2D, v: Vector2): Vector2 + transform2DXformVector2*: proc (self: Transform2D, v: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformInvVector2*: proc (self: Transform2D, v: Vector2): Vector2 + transform2DXformInvVector2*: proc (self: Transform2D, v: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DBasisXformVector2*: proc (self: Transform2D, v: Vector2): Vector2 + transform2DBasisXformVector2*: proc (self: Transform2D, v: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DBasisXformInvVector2*: proc (self: Transform2D, - v: Vector2): Vector2 + v: Vector2): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DInterpolateWith*: proc (self, other: Transform2D, - t: float32): Transform2D + t: float32): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DOperatorEqual*: proc (self, other: Transform2D): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DOperatorMultiply*: proc (self, other: Transform2D): Transform2D + transform2DOperatorMultiply*: proc (self, other: Transform2D): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DNewIdentity*: proc (dest: var Transform2D) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformRect2*: proc (self: Transform2D, v: Rect2): Rect2 + transform2DXformRect2*: proc (self: Transform2D, v: Rect2): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformInvRect2*: proc (self: Transform2D, v: Rect2): Rect2 + transform2DXformInvRect2*: proc (self: Transform2D, v: Rect2): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2732,25 +2762,25 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsString*: proc (self: GodotVariant): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsVector2*: proc (self: GodotVariant): Vector2 + variantAsVector2*: proc (self: GodotVariant): Vector2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsRect2*: proc (self: GodotVariant): Rect2 + variantAsRect2*: proc (self: GodotVariant): Rect2Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsVector3*: proc (self: GodotVariant): Vector3 + variantAsVector3*: proc (self: GodotVariant): Vector3Data {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsTransform2D*: proc (self: GodotVariant): Transform2D + variantAsTransform2D*: proc (self: GodotVariant): Transform2DData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsPlane*: proc (self: GodotVariant): Plane + variantAsPlane*: proc (self: GodotVariant): PlaneData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsQuat*: proc (self: GodotVariant): Quat + variantAsQuat*: proc (self: GodotVariant): QuatData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsAABB*: proc (self: GodotVariant): AABB + variantAsAABB*: proc (self: GodotVariant): AABBData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsBasis*: proc (self: GodotVariant): Basis + variantAsBasis*: proc (self: GodotVariant): BasisData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsTransform*: proc (self: GodotVariant): Transform + variantAsTransform*: proc (self: GodotVariant): TransformData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsColor*: proc (self: GodotVariant): Color + variantAsColor*: proc (self: GodotVariant): ColorData {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsNodePath*: proc (self: GodotVariant): GodotNodePath {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2898,6 +2928,38 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} +{.push stackTrace: off.} +proc toColor*(val: ColorData): Color {.inline, noinit.} = + cast[Color](val) + +proc toVector3*(val: Vector3Data): Vector3 {.inline, noinit.} = + cast[Vector3](val) + +proc toVector2*(val: Vector2Data): Vector2 {.inline, noinit.} = + cast[Vector2](val) + +proc toPlane*(val: PlaneData): Plane {.inline, noinit.} = + cast[Plane](val) + +proc toBasis*(val: BasisData): Basis {.inline, noinit.} = + cast[Basis](val) + +proc toQuat*(val: QuatData): Quat {.inline, noinit.} = + cast[Quat](val) + +proc toAABB*(val: AABBData): AABB {.inline, noinit.} = + cast[AABB](val) + +proc toRect2*(val: Rect2Data): Rect2 {.inline, noinit.} = + cast[Rect2](val) + +proc toTransform2D*(val: Transform2DData): Transform2D {.inline, noinit.} = + cast[Transform2D](val) + +proc toTransform*(val: TransformData): Transform {.inline, noinit.} = + cast[Transform](val) +{.pop.} + macro assign(dest, src: typed, values: untyped): typed = result = newStmtList() for val in values: diff --git a/godot/internal/godotpoolarrays.nim b/godot/internal/godotpoolarrays.nim index e03e1ff..5fe9419 100644 --- a/godot/internal/godotpoolarrays.nim +++ b/godot/internal/godotpoolarrays.nim @@ -45,7 +45,15 @@ template genPoolArrayAPI(ArrayT, initIdent, DataT, getGDNativeAPI().setProc(self, idx, data) proc `[]`*(self: ArrayT; idx: cint): DataT {.inline.} = - getGDNativeAPI().getProc(self, idx) + let data = getGDNativeAPI().getProc(self, idx) + when DataT is Color: + data.toColor() + elif DataT is Vector2: + data.toVector2() + elif DataT is Vector3: + data.toVector3() + else: + data proc len*(self: ArrayT): cint {.inline.} = getGDNativeAPI().sizeProc(self) diff --git a/godot/internal/godotvariants.nim b/godot/internal/godotvariants.nim index 3f961ca..fec75cd 100644 --- a/godot/internal/godotvariants.nim +++ b/godot/internal/godotvariants.nim @@ -121,34 +121,34 @@ proc asGodotString*(self: GodotVariant): GodotString {.inline.} = getGDNativeAPI().variantAsString(self) proc asVector2*(self: GodotVariant): Vector2 {.inline.} = - getGDNativeAPI().variantAsVector2(self) + getGDNativeAPI().variantAsVector2(self).toVector2() proc asRect2*(self: GodotVariant): Rect2 {.inline.} = - getGDNativeAPI().variantAsRect2(self) + getGDNativeAPI().variantAsRect2(self).toRect2() proc asVector3*(self: GodotVariant): Vector3 {.inline.} = - getGDNativeAPI().variantAsVector3(self) + getGDNativeAPI().variantAsVector3(self).toVector3() proc asTransform2D*(self: GodotVariant): Transform2D {.inline.} = - getGDNativeAPI().variantAsTransform2D(self) + getGDNativeAPI().variantAsTransform2D(self).toTransform2D() proc asPlane*(self: GodotVariant): Plane {.inline.} = - getGDNativeAPI().variantAsPlane(self) + getGDNativeAPI().variantAsPlane(self).toPlane() proc asQuat*(self: GodotVariant): Quat {.inline.} = - getGDNativeAPI().variantAsQuat(self) + getGDNativeAPI().variantAsQuat(self).toQuat() proc asAABB*(self: GodotVariant): AABB {.inline.} = - getGDNativeAPI().variantAsAABB(self) + getGDNativeAPI().variantAsAABB(self).toAABB() proc asBasis*(self: GodotVariant): Basis {.inline.} = - getGDNativeAPI().variantAsBasis(self) + getGDNativeAPI().variantAsBasis(self).toBasis() proc asTransform*(self: GodotVariant): Transform {.inline.} = - getGDNativeAPI().variantAsTransform(self) + getGDNativeAPI().variantAsTransform(self).toTransform() proc asColor*(self: GodotVariant): Color {.inline.} = - getGDNativeAPI().variantAsColor(self) + getGDNativeAPI().variantAsColor(self).toColor() proc asNodePath*(self: GodotVariant): GodotNodePath {.inline.} = getGDNativeAPI().variantAsNodePath(self) From db4bb91765b5502d9f660eaef8c59583c6b3756f Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Tue, 9 Jul 2019 13:48:54 +0700 Subject: [PATCH 59/82] Fix editor crash in multithreaded mode --- godot.nimble | 2 +- godot/nim/godotnim.nim | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/godot.nimble b/godot.nimble index 8e4c8c0..6964c83 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.18" +version = "0.7.19" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 665b715..979613f 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -867,7 +867,8 @@ proc godot_gdnative_init(options: ptr GDNativeInitOptions) {. proc godot_gdnative_terminate(options: ptr GDNativeTerminateOptions) {. cdecl, exportc, dynlib.} = - deallocHeap(runFinalizers = not options[].inEditor, allowGcAfterwards = false) + if not options[].inEditor or not compileOption("threads"): + deallocHeap(runFinalizers = not options[].inEditor, allowGcAfterwards = false) const nimGcStepLengthUs {.intdefine.} = 2000 From f45281f5a0cdb9e1de482a047aa49156fbc8f92f Mon Sep 17 00:00:00 2001 From: Konstantin Zaitsev Date: Thu, 12 Sep 2019 14:50:02 +0700 Subject: [PATCH 60/82] Fix possible double free memory on exit --- godot.nimble | 2 +- godot/nim/godotnim.nim | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/godot.nimble b/godot.nimble index 6964c83..66794fc 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.19" +version = "0.7.20" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 979613f..d3fa9cf 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -189,8 +189,8 @@ proc nimGodotObjectFinalizer*[T: NimGodotObject](obj: T) = if obj.godotObject.isNil or obj.isNative: return # important to set it before so that ``unreference`` is aware obj.isFinalized = true - if obj.isRef and obj.godotObject.unreference() or - not obj.linkedObject.isNil: + if (obj.isRef or not obj.linkedObject.isNil and obj.linkedObject.isRef) and + obj.godotObject.unreference(): obj.deinit() macro baseNativeType(T: typedesc): cstring = From 3a935b93087682867f9e5278fbd32c781bbda923 Mon Sep 17 00:00:00 2001 From: Fabian Keller Date: Sun, 30 Dec 2018 12:40:10 +0100 Subject: [PATCH 61/82] attempt to make 0.19 compatible workaround for nim/macro/typedesc issue work-around for nim-lang/Nim#7375 fixed more isNil usages fixed new name of setStackBottom --- docs/docbuild.nim | 4 +- godot/core/variants.nim | 9 ++-- godot/godotapigen.nim | 95 ++++++++++++++++++--------------- godot/internal/godotstrings.nim | 5 +- godot/nim/godotmacros.nim | 41 +++++++------- godot/nim/godotnim.nim | 40 ++++++-------- 6 files changed, 94 insertions(+), 100 deletions(-) diff --git a/docs/docbuild.nim b/docs/docbuild.nim index 10823a5..477c45b 100644 --- a/docs/docbuild.nim +++ b/docs/docbuild.nim @@ -71,7 +71,7 @@ proc fixupHrefs(file: string) = proc getGitHash(): string = result = execProcess("git rev-parse HEAD") - if not result.isNil and result.len > 0: + if result.len > 0: result = result.replace("\L", "").replace("\r", "") proc buildDocs*(outDir, godotNimDir, godotBin: string) = @@ -112,7 +112,7 @@ proc buildDocs*(outDir, godotNimDir, godotBin: string) = var gitHash: string withDir(godotBinAbs.parentDir()): gitHash = getGitHash() - if gitHash.isNil or gitHash.len == 0: + if gitHash.len == 0: raise newException(Exception, "Godot executable is not under Git repository") diff --git a/godot/core/variants.nim b/godot/core/variants.nim index ace8aac..8c2488d 100644 --- a/godot/core/variants.nim +++ b/godot/core/variants.nim @@ -73,12 +73,9 @@ proc newVariant*(r: cdouble): Variant {.inline.} = proc newVariant*(s: string): Variant {.inline.} = new(result, variantFinalizer) - if s.isNil: - initGodotVariant(result.godotVariant) - else: - var godotStr = s.toGodotString() - initGodotVariant(result.godotVariant, godotStr) - godotStr.deinit() + var godotStr = s.toGodotString() + initGodotVariant(result.godotVariant, godotStr) + godotStr.deinit() import basis, nodepaths import planes, quats, rect2, aabb, rids diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 876e770..5ec1c73 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -1,9 +1,15 @@ # Copyright 2018 Xored Software, Inc. -import streams, json, os, strutils, times, sets, tables +import streams, json, os, strutils, times, sets, tables, options import sequtils, algorithm import compiler.ast, compiler.renderer, compiler.idents, compiler.astalgo +when (NimMajor, NimMinor, NimPatch) >= (0, 19, 0): + var gic* = newIdentCache() + + proc getIdent(ident: string): PIdent = + getIdent(gic, ident) + proc ident(ident: string): PNode = result = newNode(nkIdent) result.ident = getIdent(ident) @@ -139,19 +145,19 @@ proc findCommonRoot(typeRegistry: Table[string, GodotType], var idx = 0 while true: - var curType: string + var curType = none(string) var allEqual = true for chain in chains: if idx >= chain.len: allEqual = false break - if curType.isNil: - curType = chain[idx] - elif curType != chain[idx]: + if curType.isNone: + curType = some(chain[idx]) + elif curType.get != chain[idx]: allEqual = false break if allEqual: - result = curType + result = curType.get else: break inc idx @@ -224,7 +230,7 @@ proc newRefTypeNode(typeSection: PNode, typ, base, doc: string, inherit.add(ident(base)) objTy.add(inherit) - if not doc.isNil: + if doc.len > 0: let recList = newNode(nkRecList) let docNode = newNode(nkCommentStmt) docNode.comment = doc @@ -275,7 +281,7 @@ type godotName: string typ: GodotType args: seq[MethodArg] - returnType: string + returnType: Option[string] isVirtual: bool isBase: bool isDiscardable: bool @@ -428,7 +434,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], newCStringLit(meth.godotName)) ) let vars = newNode(nkVarSection) - var varargsName: string + var varargsName = none(string) var isVarargs: bool var staticArgsLen: int var argLenNode = newIntLit(0) @@ -436,7 +442,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], if meth.args.len > 0: for idx, arg in meth.args: if arg.kind == ArgKind.VarArgs: - varargsName = arg.name + varargsName = some(arg.name) isVarargs = true vars.add(newIdentDefs(ident("callError"), ident("VariantCallError"))) elif arg.kind == ArgKind.Bound: @@ -450,13 +456,13 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], ident("array"), ident("MAX_ARG_COUNT"), if isVarargs: newNode(nkPtrTy).addChain(ident("GodotVariant")) else: ident("pointer")))) - staticArgsLen = if varargsName.isNil: meth.args.len + staticArgsLen = if varargsName.isSome: meth.args.len else: meth.args.len - 1 - if not varargsName.isNil: + if varargsName.isSome: argLenNode = newCall("cint", infix(newIntLit(staticArgsLen), ident("+"), - newDotExpr(ident(varargsName), ident("len")))) + newDotExpr(ident(varargsName.get), ident("len")))) argsAlloc.add(newCall("godotAlloc", newCall("cint", infix( newCall("sizeof", ident("Variant")), ident("*"), newNode(nkPar).addChain(argLenNode)))) @@ -477,12 +483,12 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], else: ident(arg.name) if arg.kind == ArgKind.VarArgs: argName = newNode(nkBracketExpr).addChain( - ident(varargsName), + ident(varargsName.get), infix(ident("idx"), ident("-"), newIntLit(staticArgsLen))) let argIdx = if arg.kind == ArgKind.VarArgs: ident("idx") else: newIntLit(idx) let isStandardType = arg.typ in standardTypes let isWrappedType = arg.typ in wrapperTypes - let convArg = if not varargsName.isNil: + let convArg = if varargsName.isSome: getInternalPtr(newCall("toVariant", argName), "Variant") elif isWrappedType: getInternalPtr(argName, arg.typ) elif isStandardType: newCall("unsafeAddr", argName) @@ -493,7 +499,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], raise newException(ValueError, "Non-standard type $# for varargs params of method $# of type $#" % [arg.typ, meth.godotName, meth.typ.godotName]) - if not isStandardType and varargsName.isNil: + if not isStandardType and varargsName.isNone: if arg.typ == "string": argConversions.add(newNode(nkVarSection).addChain( newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(), @@ -560,31 +566,32 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], var isStringRet: bool var isWrapperRet: bool let retValIdent = if not isVarargs: ident("ptrCallVal") else: ident(retName) - if not meth.returnType.isNil and not isVarargs: + if meth.returnType.isSome and not isVarargs: + let returnType = meth.returnType.get var addrToAssign = newCall("addr", retValIdent) - if meth.returnType in smallIntTypes: + if returnType in smallIntTypes: isConversionRet = true body.add(newNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("int64"), ))) - elif meth.returnType in float32Types: + elif returnType in float32Types: isConversionRet = true body.add(newNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("float64"), ))) - elif meth.returnType in wrapperTypes: + elif returnType in wrapperTypes: isWrapperRet = true body.add(newNode(nkVarSection).addChain(newIdentDefs( - retValIdent, ident("Godot" & meth.returnType), + retValIdent, ident("Godot" & returnType), ))) - elif meth.returnType in standardTypes: + elif returnType in standardTypes: addrToAssign = newCall("addr", ident("result")) - elif meth.returnType == "string": + elif returnType == "string": isStringRet = true body.add(newNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("GodotString"), ))) - elif meth.returnType != "void": + elif returnType != "void": isObjRet = true body.add(newNode(nkVarSection).addChain(newIdentDefs( retValIdent, newNode(nkPtrTy).addChain(ident("GodotObject")), @@ -594,7 +601,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], if not isVarargs: body.add(theCall) else: - if not meth.returnType.isNil: + if meth.returnType.isSome: isVariantRet = true let callStmt = newNode(nkLetSection).addChain( newIdentDefs( @@ -603,14 +610,14 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], newNode(nkEmpty), theCall)) body.add(callStmt) - if varargsName.isNil: + if varargsName.isNone: for idx, arg in meth.args: if arg.typ == "string": body.add(newCall("deinit", ident("argToPassToGodot" & $idx))) - if meth.args.len > 0 and not varargsName.isNil: + if meth.args.len > 0 and varargsName.isSome: body.add(freeCall) - if not varargsName.isNil: + if varargsName.isSome: let errCheck = newIfStmt( infix(newDotExpr(ident("callError"), ident("error")), ident("!="), newDotExpr(ident("VariantCallErrorType"), ident("OK"))), @@ -638,11 +645,11 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], elif isConversionRet: body.add(newNode(nkAsgn).addChain( ident("result"), - newCall(meth.returnType, retValIdent))) + newCall(meth.returnType.get, retValIdent))) elif isWrapperRet: body.add(newNode(nkAsgn).addChain( ident("result"), - newCall("new" & meth.returnType, retValIdent))) + newCall("new" & meth.returnType.get, retValIdent))) elif isObjRet: body.add(newNode(nkAsgn).addChain(ident("result"), newCall(newBracketExpr(ident("asNimGodotObject"), @@ -655,8 +662,8 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], let procType = if meth.isVirtual: nkMethodDef else: nkProcDef var params = newSeqOfCap[PNode](meth.args.len + 2) - if not meth.returnType.isNil: - params.add(ident(meth.returnType)) + if meth.returnType.isSome: + params.add(ident(meth.returnType.get)) else: params.add(newNode(nkEmpty)) if not meth.typ.isSingleton: @@ -684,7 +691,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], if meth.isVirtual and meth.isBase and meth.typ.name != "PhysicsBody": # Nim doesn't like `base` on PhysicsBody methods - wtf pragma.add(ident("base")) - if meth.isDiscardable and not meth.returnType.isNil: + if meth.isDiscardable and meth.returnType.isSome: pragma.add(ident("discardable")) procDecl.sons[4] = pragma tree.add(procDecl) @@ -729,8 +736,8 @@ proc getMethodInfo(methodObj: JsonNode, types: Table[string, GodotType], nimName = nimName & "Impl" let returnType = if methodObj["return_type"].str != "void": - toNimType(types, methodObj["return_type"].str) - else: nil + some(toNimType(types, methodObj["return_type"].str)) + else: none(string) const discardableMethods = toSet(["emit_signal"]) result = MethodInfo( name: ident(nimName), @@ -764,13 +771,13 @@ proc makeProperty(types: Table[string, GodotType], tree: PNode, let getter = findMethod(obj, propertyObj["getter"].str) let nimType = if getter.isNil: toNimType(types, propertyObj["type"].str) - else: getMethodInfo(getter, types, typ).returnType + else: getMethodInfo(getter, types, typ).returnType.get("void") let getterInfo = MethodInfo( name: getterName, typ: typ, godotName: propertyObj["getter"].str, - args: @[], - returnType: nimType + args: newSeq[MethodArg](), + returnType: some(nimType) ) let setterInfo = MethodInfo( name: setterName, @@ -779,10 +786,12 @@ proc makeProperty(types: Table[string, GodotType], tree: PNode, args: @[MethodArg(name: "val", typ: nimType)] ) if "index" in propertyObj and propertyObj["index"] != newJInt(-1): - getterInfo.args = @[MethodArg(defaultVal: newJString($propertyObj["index"]), - typ: "int", kind: ArgKind.Bound)] & getterInfo.args - setterInfo.args = @[MethodArg(defaultVal: newJString($propertyObj["index"]), - typ: "int", kind: ArgKind.Bound)] & setterInfo.args + getterInfo.args = + @[MethodArg(defaultVal: newJString($propertyObj["index"]), + typ: "int", kind: ArgKind.Bound)] & getterInfo.args + setterInfo.args = + @[MethodArg(defaultVal: newJString($propertyObj["index"]), + typ: "int", kind: ArgKind.Bound)] & setterInfo.args generateMethod(tree, methodBindRegistry, getterInfo, withImplementation) generateMethod(tree, methodBindRegistry, setterInfo, withImplementation) @@ -920,7 +929,7 @@ proc genApi*(targetDir: string, apiJsonFile: string) = let className = godotClassName.replace("_", "") var baseClassName = obj["base_class"].str baseClassName = toNimType(baseClassName.replace("_", "")) - if baseClassName.isNil or baseClassName.len == 0: + if baseClassName.len == 0: baseClassName = "NimGodotObject" var doc = "" for attr in classAttributes: diff --git a/godot/internal/godotstrings.nim b/godot/internal/godotstrings.nim index be18df0..18bcf63 100644 --- a/godot/internal/godotstrings.nim +++ b/godot/internal/godotstrings.nim @@ -38,10 +38,7 @@ proc `$`*(self: GodotString): string = proc toGodotString*(s: string): GodotString {.inline.} = ## Converts the Nim string into ``GodotString`` - if s.isNil: - initGodotString(result) - else: - initGodotString(result, cstring(s), cint(s.len + 1)) + initGodotString(result, cstring(s), cint(s.len + 1)) proc toGodotString*(s: cstring): GodotString {.inline.} = ## Converts the cstring into ``GodotString`` diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index 352925a..052b2fc 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -1,6 +1,6 @@ # Copyright 2018 Xored Software, Inc. -import macros, tables, typetraits +import macros, tables, typetraits, strutils, sets, sequtils, options import godotinternal, internal.godotvariants import godotnim, core.variants @@ -10,8 +10,8 @@ type typ: NimNode defaultValue: NimNode isNoGodot: bool - hint: string - hintStr: string + hint: Option[string] + hintStr: Option[string] usage: NimNode isExported: bool @@ -111,12 +111,12 @@ proc removePragma(statement: NimNode, pname: string): bool = return true proc removeStrPragma(statement: NimNode, - pname: string): string {.compileTime.} = + pname: string): Option[string] {.compileTime.} = ## Removes the pragma from the node and returns value of the pragma ## Works for routine nodes or nnkPragmaExpr let node = removePragmaNode(statement, pname) - result = if node.isNil: nil - else: $node + result = if node.isNil: none(string) + else: some($node) proc isExported(node: NimNode): bool {.compileTime.} = if node.kind == nnkPragmaExpr: @@ -197,7 +197,7 @@ proc parseType(definition, callSite: NimNode): ObjectDecl = parseError(option, "valid type specifier expected") result.isTool = isTool - if result.parentName.isNil: result.parentName = "Object" + if result.parentName == "": result.parentName = "Object" for statement in body: case statement.kind: of nnkVarSection: @@ -424,9 +424,6 @@ template registerGodotField(classNameLit, classNameIdent, propNameLit, unsafeAddr attr, setFunc, getFunc) hintStrGodot.deinit() -static: - import strutils, sets, sequtils - proc toGodotStyle(s: string): string {.compileTime.} = result = newStringOfCap(s.len + 10) for c in s: @@ -447,7 +444,7 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = let objTy = newNimNode(nnkObjectTy) typeDef.add(newNimNode(nnkRefTy).add(objTy)) objTy.add(newEmptyNode()) - if obj.parentName.isNil: + if obj.parentName == "": objTy.add(newEmptyNode()) else: objTy.add(newNimNode(nnkOfInherit).add(ident(obj.parentName))) @@ -506,23 +503,25 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = result.add(meth.nimNode) # Register Godot object - let parentName = if obj.parentName.isNil: newStrLitNode("Object") + let parentName = if obj.parentName == "": newStrLitNode("Object") else: newStrLitNode(obj.parentName) let classNameLit = newStrLitNode(obj.name) let classNameIdent = ident(obj.name) - let isRef: bool = if obj.parentName.isNil: false + let isRef: bool = if obj.parentName == "": false else: obj.parentName in refClasses + # Wrapping bools with a newLit is required as a temporary workaround for + # https://github.com/nim-lang/Nim/issues/7375 result.add(getAst( - registerGodotClass(classNameIdent, classNameLit, isRef, parentName, - genSym(nskProc, "createFunc"), obj.isTool))) + registerGodotClass(classNameIdent, classNameLit, newLit(isRef), parentName, + genSym(nskProc, "createFunc"), newLit(obj.isTool)))) # Register fields (properties) for field in obj.fields: if field.isNoGodot: continue - let hintStr = if field.hintStr.isNil: "NIM" - else: field.hintStr - let hint = if field.hint.isNil: "NIM" - else: field.hint + let hintStr = if field.hintStr.isNone: "NIM" + else: field.hintStr.get + let hint = if field.hint.isNone: "NIM" + else: field.hint.get let usage = if field.usage.isNil: newLit(ord(GodotPropertyUsage.Default) or @@ -546,7 +545,7 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = methodNameLit, minArgs, maxArgs, argTypes, methFuncIdent, hasReturnValue) = {.emit: """/*TYPESECTION*/ -N_NOINLINE(void, setStackBottom)(void* thestackbottom); +N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom); """.} proc methFuncIdent(obj: ptr GodotObject, methodData: pointer, userData: pointer, numArgs: cint, @@ -554,7 +553,7 @@ N_NOINLINE(void, setStackBottom)(void* thestackbottom); GodotVariant {.noconv.} = var stackBottom {.volatile.}: pointer {.emit: """ - setStackBottom((void*)(&`stackBottom`)); + nimGC_setStackBottom((void*)(&`stackBottom`)); """.} let self = cast[classNameIdent](userData) const isStaticCall = methodNameLit == cstring"_ready" or diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index d3fa9cf..41ef51e 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -1,6 +1,6 @@ # Copyright 2018 Xored Software, Inc. -import tables, typetraits, macros, unicode +import tables, typetraits, macros, unicode, strutils, sets import gdnativeapi import core.godotcoretypes, core.godotbase import core.vector2, core.rect2, @@ -101,8 +101,6 @@ var classRegistryStatic* {.compileTime.}: TableRef[FNV1Hash, ObjectInfo] static: classRegistryStatic = newTable[FNV1Hash, ObjectInfo]() -static: - import sets, strutils var nativeClasses {.compileTime.} = newSeq[string]() var refClasses* {.compileTime.} = newSeq[string]() @@ -204,7 +202,7 @@ macro baseNativeType(T: typedesc): cstring = if typeName == "NimGodotObject": break t = getType(t[1][1]) - if baseT.isNil: + if baseT == "": result = newNilLit() else: let rStr = newNimNode(nnkRStrLit) @@ -345,26 +343,20 @@ proc newRStrLit(s: string): NimNode {.compileTime.} = result = newNimNode(nnkRStrLit) result.strVal = s -static: - import strutils - -macro toGodotName(T: typedesc): string = - var godotName: string +proc toGodotName(T: typedesc): string = if T is GodotString or T is string: - godotName = "String" + "String" elif T is SomeFloat: - godotName = "float" + "float" elif T is SomeUnsignedInt or T is SomeSignedInt: - godotName = "int" - if godotName.isNil or godotName.len == 0: + "int" + else: let nameStr = (($T.getType()[1][1].symbol).split(':')[0]) - godotName = case nameStr: - of "File", "Directory", "Thread", "Mutex", "Semaphore": - "_" & nameStr - else: - nameStr - - result = newLit(godotName) + case nameStr: + of "File", "Directory", "Thread", "Mutex", "Semaphore": + "_" & nameStr + else: + nameStr macro asCString(s: static[string]): cstring = result = newNimNode(nnkCallStrLit).add( @@ -717,7 +709,7 @@ proc fromVariant*(s: var string, val: Variant): ConversionResult = if val.getType() == VariantType.String: s = val.asString() elif val.getType() == VariantType.Nil: - s = nil + s = "" else: result = ConversionResult.TypeError @@ -839,7 +831,7 @@ proc fromVariant*[T: Table or TableRef or OrderedTable or OrderedTableRef](t: va {.emit: """/*TYPESECTION*/ N_LIB_EXPORT N_CDECL(void, NimMain)(void); -N_NOINLINE(void, setStackBottom)(void* thestackbottom); +N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom); """.} var nativeLibHandle: pointer @@ -855,7 +847,7 @@ proc godot_nativescript_init(handle: pointer) {. var stackBottom {.volatile.}: pointer {.emit: """ NimMain(); - setStackBottom((void*)(&`stackBottom`)); + nimGC_setStackBottom((void*)(&`stackBottom`)); """.} GC_fullCollect() GC_disable() @@ -893,7 +885,7 @@ proc registerFrameCallback*(cb: proc () {.closure.}) = proc godot_nativescript_frame() {.cdecl, exportc, dynlib.} = var stackBottom {.volatile.}: pointer {.emit: """ - setStackBottom((void*)(&`stackBottom`)); + nimGC_setStackBottom((void*)(&`stackBottom`)); """.} for cb in idleCallbacks: cb() From 34fda99def2cdae837b4bccc153c17e9a86de98e Mon Sep 17 00:00:00 2001 From: zetashift Date: Fri, 1 Mar 2019 02:18:00 +0100 Subject: [PATCH 62/82] Small changes to add 0.18.0 compatibility Change toGodotName back to macro because that got fixed in devel change isSome to isNone in godotapigen --- godot/godotapigen.nim | 2 +- godot/nim/godotmacros.nim | 16 +++++++++++----- godot/nim/godotnim.nim | 30 +++++++++++++++++++++--------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 5ec1c73..71a52ff 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -456,7 +456,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], ident("array"), ident("MAX_ARG_COUNT"), if isVarargs: newNode(nkPtrTy).addChain(ident("GodotVariant")) else: ident("pointer")))) - staticArgsLen = if varargsName.isSome: meth.args.len + staticArgsLen = if varargsName.isNone: meth.args.len else: meth.args.len - 1 if varargsName.isSome: argLenNode = newCall("cint", diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index 052b2fc..4389859 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -197,7 +197,7 @@ proc parseType(definition, callSite: NimNode): ObjectDecl = parseError(option, "valid type specifier expected") result.isTool = isTool - if result.parentName == "": result.parentName = "Object" + if result.parentName.len == 0: result.parentName = "Object" for statement in body: case statement.kind: of nnkVarSection: @@ -444,7 +444,7 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = let objTy = newNimNode(nnkObjectTy) typeDef.add(newNimNode(nnkRefTy).add(objTy)) objTy.add(newEmptyNode()) - if obj.parentName == "": + if obj.parentName.len == 0: objTy.add(newEmptyNode()) else: objTy.add(newNimNode(nnkOfInherit).add(ident(obj.parentName))) @@ -503,11 +503,11 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = result.add(meth.nimNode) # Register Godot object - let parentName = if obj.parentName == "": newStrLitNode("Object") + let parentName = if obj.parentName.len == 0: newStrLitNode("Object") else: newStrLitNode(obj.parentName) let classNameLit = newStrLitNode(obj.name) let classNameIdent = ident(obj.name) - let isRef: bool = if obj.parentName == "": false + let isRef: bool = if obj.parentName.len == 0: false else: obj.parentName in refClasses # Wrapping bools with a newLit is required as a temporary workaround for # https://github.com/nim-lang/Nim/issues/7375 @@ -544,9 +544,15 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = template registerGodotMethod(classNameLit, classNameIdent, methodNameIdent, methodNameLit, minArgs, maxArgs, argTypes, methFuncIdent, hasReturnValue) = - {.emit: """/*TYPESECTION*/ + when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): + {.emit: """/*TYPESECTION*/ +N_NOINLINE(void, setStackBottom)(void* thestackbottom); +""".} + else: + {.emit: """ N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom); """.} + proc methFuncIdent(obj: ptr GodotObject, methodData: pointer, userData: pointer, numArgs: cint, args: var array[MAX_ARG_COUNT, ptr GodotVariant]): diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 41ef51e..e58c330 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -202,7 +202,7 @@ macro baseNativeType(T: typedesc): cstring = if typeName == "NimGodotObject": break t = getType(t[1][1]) - if baseT == "": + if baseT.len == 0: result = newNilLit() else: let rStr = newNimNode(nnkRStrLit) @@ -343,7 +343,7 @@ proc newRStrLit(s: string): NimNode {.compileTime.} = result = newNimNode(nnkRStrLit) result.strVal = s -proc toGodotName(T: typedesc): string = +macro toGodotName(T: typedesc): string = if T is GodotString or T is string: "String" elif T is SomeFloat: @@ -708,10 +708,16 @@ proc toVariant*(s: string): Variant {.inline.} = proc fromVariant*(s: var string, val: Variant): ConversionResult = if val.getType() == VariantType.String: s = val.asString() - elif val.getType() == VariantType.Nil: - s = "" + when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): + if val.getType() == VariantType.Nil: + s = nil + else: + result = ConversionResult.TypeError else: - result = ConversionResult.TypeError + if val.getType() == VariantType.Nil: + s = "" + else: + result = ConversionResult.TypeError template arrTypeInfo(T) = result.variantType = VariantType.Array @@ -829,10 +835,16 @@ proc fromVariant*[T: Table or TableRef or OrderedTable or OrderedTableRef](t: va else: result = ConversionResult.TypeError -{.emit: """/*TYPESECTION*/ -N_LIB_EXPORT N_CDECL(void, NimMain)(void); -N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom); -""".} +when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): + {.emit: """/*TYPESECTION*/ + N_LIB_EXPORT N_CDECL(void, NimMain)(void); + N_NOINLINE(void, setStackBottom)(void* thestackbottom); + """.} +else: + {.emit: """/*TYPESECTION*/ + N_LIB_EXPORT N_CDECL(void, NimMain)(void); + N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom); + """.} var nativeLibHandle: pointer proc getNativeLibHandle*(): pointer = From 0fecfdb3b85922f7a0be0e132be48ca430ba0ad1 Mon Sep 17 00:00:00 2001 From: Dwana Games Date: Fri, 21 Jun 2019 20:11:29 -0500 Subject: [PATCH 63/82] Updated to work with nim 0.20 - Attempt to fix deprecated this:self pragma by injecting self to methods and properties (needs more testing) - Changed import headers to use / (slash) instead of . (period) - Fixed object branch in godotapigen.nim - Fixed deprecated nimNode.ident with nimNode.strVal Fix toGodotName function Consider procCall calls as special cases, otherwise it gives problems in _init function Fix infinite recursive call in Godot 3.2 --- godot/core/aabb.nim | 2 +- godot/core/arrays.nim | 2 +- godot/core/dictionaries.nim | 4 +- godot/core/nodepaths.nim | 4 +- godot/core/planes.nim | 2 +- godot/core/poolarrays.nim | 4 +- godot/core/quats.nim | 2 +- godot/core/rect2.nim | 2 +- godot/core/rids.nim | 2 +- godot/core/transform2d.nim | 2 +- godot/core/transforms.nim | 2 +- godot/core/variants.nim | 6 +- godot/core/vector2.nim | 2 +- godot/gdnativeapi.nim | 4 +- godot/godot.nim | 16 +- godot/godotapigen.nim | 262 +++++++++++++++-------------- godot/godotinternal.nim | 6 +- godot/internal/godotarrays.nim | 2 +- godot/internal/godotpoolarrays.nim | 2 +- godot/internal/godotvariants.nim | 2 +- godot/nim/godotmacros.nim | 144 ++++++++++++---- godot/nim/godotnim.nim | 28 +-- godot/nim/nim.cfg | 3 +- 23 files changed, 294 insertions(+), 211 deletions(-) diff --git a/godot/core/aabb.nim b/godot/core/aabb.nim index 66425a2..2d816da 100644 --- a/godot/core/aabb.nim +++ b/godot/core/aabb.nim @@ -3,7 +3,7 @@ import hashes import vector3 -import internal.godotinternaltypes, internal.godotstrings +import internal/godotinternaltypes, internal/godotstrings import godotcoretypes, gdnativeapi proc initAABB*(pos, size: Vector3): AABB {.inline.} = diff --git a/godot/core/arrays.nim b/godot/core/arrays.nim index afe8131..fcbafb2 100644 --- a/godot/core/arrays.nim +++ b/godot/core/arrays.nim @@ -1,7 +1,7 @@ # Copyright 2018 Xored Software, Inc. import hashes -import internal.godotinternaltypes, internal.godotarrays +import internal/godotinternaltypes, internal/godotarrays type Array* = ref object diff --git a/godot/core/dictionaries.nim b/godot/core/dictionaries.nim index 4a160f2..3aea17a 100644 --- a/godot/core/dictionaries.nim +++ b/godot/core/dictionaries.nim @@ -1,8 +1,8 @@ # Copyright 2018 Xored Software, Inc. import hashes -import internal.godotinternaltypes, internal.godotdictionaries, - internal.godotvariants, internal.godotstrings +import internal/godotinternaltypes, internal/godotdictionaries, + internal/godotvariants, internal/godotstrings type Dictionary* = ref object diff --git a/godot/core/nodepaths.nim b/godot/core/nodepaths.nim index 831c855..bf690d7 100644 --- a/godot/core/nodepaths.nim +++ b/godot/core/nodepaths.nim @@ -2,8 +2,8 @@ import hashes -import internal.godotinternaltypes, internal.godotnodepaths, - internal.godotstrings +import internal/godotinternaltypes, internal/godotnodepaths, + internal/godotstrings type NodePath* = ref object diff --git a/godot/core/planes.nim b/godot/core/planes.nim index 815a5c6..2d15c79 100644 --- a/godot/core/planes.nim +++ b/godot/core/planes.nim @@ -4,7 +4,7 @@ import hashes import vector3 -import internal.godotinternaltypes, internal.godotstrings +import internal/godotinternaltypes, internal/godotstrings import godotcoretypes, gdnativeapi proc initPlane*(a, b, c, d: float32): Plane {.inline.} = diff --git a/godot/core/poolarrays.nim b/godot/core/poolarrays.nim index 29aca98..eac4cf4 100644 --- a/godot/core/poolarrays.nim +++ b/godot/core/poolarrays.nim @@ -3,8 +3,8 @@ import hashes import godotcoretypes -import internal.godotinternaltypes, internal.godotpoolarrays, - internal.godotstrings +import internal/godotinternaltypes, internal/godotpoolarrays, + internal/godotstrings import vector2, vector3, colors template definePoolArrayBase(T, GodotT, DataT, fieldName, newProcName, diff --git a/godot/core/quats.nim b/godot/core/quats.nim index 1a8da82..db88b10 100644 --- a/godot/core/quats.nim +++ b/godot/core/quats.nim @@ -2,7 +2,7 @@ import hashes -import internal.godotinternaltypes, internal.godotstrings +import internal/godotinternaltypes, internal/godotstrings import godotcoretypes, gdnativeapi proc initQuat*(x, y, z, w: float32): Quat {.inline.} = diff --git a/godot/core/rect2.nim b/godot/core/rect2.nim index 8a0a1c8..19b8cbf 100644 --- a/godot/core/rect2.nim +++ b/godot/core/rect2.nim @@ -3,7 +3,7 @@ import hashes import vector2 -import internal.godotinternaltypes, internal.godotstrings +import internal/godotinternaltypes, internal/godotstrings import godotcoretypes, gdnativeapi {.push stackTrace: off.} diff --git a/godot/core/rids.nim b/godot/core/rids.nim index 800207f..a64137d 100644 --- a/godot/core/rids.nim +++ b/godot/core/rids.nim @@ -2,7 +2,7 @@ import hashes -import godotcoretypes, internal.godotinternaltypes, gdnativeapi +import godotcoretypes, internal/godotinternaltypes, gdnativeapi proc initRID*(): RID {.inline.} = getGDNativeAPI().ridNew(result) diff --git a/godot/core/transform2d.nim b/godot/core/transform2d.nim index 16f62bd..a8db09e 100644 --- a/godot/core/transform2d.nim +++ b/godot/core/transform2d.nim @@ -2,7 +2,7 @@ import hashes, vector2 -import internal.godotinternaltypes, internal.godotstrings +import internal/godotinternaltypes, internal/godotstrings import godotcoretypes, gdnativeapi proc initTransform2D*(): Transform2D {.inline.} = diff --git a/godot/core/transforms.nim b/godot/core/transforms.nim index 4a21466..501f743 100644 --- a/godot/core/transforms.nim +++ b/godot/core/transforms.nim @@ -2,7 +2,7 @@ import hashes -import internal.godotinternaltypes, internal.godotstrings +import internal/godotinternaltypes, internal/godotstrings import godotcoretypes, gdnativeapi import basis, vector3 diff --git a/godot/core/variants.nim b/godot/core/variants.nim index 8c2488d..ce1d945 100644 --- a/godot/core/variants.nim +++ b/godot/core/variants.nim @@ -1,9 +1,9 @@ import tables, hashes import godotcoretypes -import internal.godotinternaltypes, internal.godotvariants, - internal.godotstrings, internal.godotdictionaries, - internal.godotarrays +import internal/godotinternaltypes, internal/godotvariants, + internal/godotstrings, internal/godotdictionaries, + internal/godotarrays type Variant* = ref object diff --git a/godot/core/vector2.nim b/godot/core/vector2.nim index 1c8aa5e..01c0312 100644 --- a/godot/core/vector2.nim +++ b/godot/core/vector2.nim @@ -2,7 +2,7 @@ import math, godotbase, hashes -import internal.godotinternaltypes, internal.godotstrings +import internal/godotinternaltypes, internal/godotstrings import godotcoretypes, gdnativeapi {.push stackTrace: off.} diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index 591d45e..bb05425 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -1,6 +1,6 @@ # Copyright 2018 Xored Software, Inc. -import internal.godotinternaltypes, core.godotcoretypes, macros +import internal/godotinternaltypes, core/godotcoretypes, macros type ColorData* {.byref.} = object @@ -3593,7 +3593,7 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt # Not used discard - if not header.next.isNil: + if not header.next.isNil and header != header.next: setGDNativeAPIInternal(header.next, initOptions, foundCoreApi, foundNativeScriptApi) diff --git a/godot/godot.nim b/godot/godot.nim index f4a9bf8..809f58f 100644 --- a/godot/godot.nim +++ b/godot/godot.nim @@ -1,14 +1,14 @@ # Copyright 2018 Xored Software, Inc. -import core.godotbase, godotinternal -import core.godotcoretypes -import core.vector2, core.rect2, core.vector3, core.transform2d, core.planes, - core.quats -import core.aabb, core.basis, core.transforms, core.colors, core.nodepaths, - core.rids -import core.dictionaries, core.arrays, core.poolarrays, core.variants +import core/godotbase, godotinternal +import core/godotcoretypes +import core/vector2, core/rect2, core/vector3, core/transform2d, core/planes, + core/quats +import core/aabb, core/basis, core/transforms, core/colors, core/nodepaths, + core/rids +import core/dictionaries, core/arrays, core/poolarrays, core/variants -import nim.godotmacros, nim.godotnim +import nim/godotmacros, nim/godotnim export godotbase, godotcoretypes, vector2, rect2, vector3, transform2d, planes, quats, aabb, basis, transforms, colors, nodepaths, rids, dictionaries, diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 71a52ff..a53ee6f 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -2,17 +2,22 @@ import streams, json, os, strutils, times, sets, tables, options import sequtils, algorithm -import compiler.ast, compiler.renderer, compiler.idents, compiler.astalgo +import compiler/ast, compiler/renderer, compiler/idents, compiler/astalgo, compiler/lineinfos when (NimMajor, NimMinor, NimPatch) >= (0, 19, 0): - var gic* = newIdentCache() + var gic = newIdentCache() proc getIdent(ident: string): PIdent = getIdent(gic, ident) proc ident(ident: string): PNode = - result = newNode(nkIdent) - result.ident = getIdent(ident) + result = PNode(kind: nkIdent, ident: getIdent(ident)) + +proc newPNode(kind: TNodeKind): PNode = + result = PNode(kind: kind) + result.info.fileIndex = InvalidFileIdx + result.info.col = int16(-1) + result.info.line = uint16(0) proc addChain(node: PNode, others: varargs[PNode]): PNode {.discardable.} = for other in others: @@ -21,37 +26,37 @@ proc addChain(node: PNode, others: varargs[PNode]): PNode {.discardable.} = proc newIdentDefs(name, typ: PNode, defaultVal: PNode = nil): PNode = - result = newNode(nkIdentDefs) + result = newPNode(nkIdentDefs) result.add(name) result.add(typ) if defaultVal.isNil: - result.add(newNode(nkEmpty)) + result.add(newPNode(nkEmpty)) else: result.add(defaultVal) -proc newProc(name: PNode, params: openArray[PNode], body = newNode(nkEmpty), +proc newProc(name: PNode, params: openArray[PNode], body = newPNode(nkEmpty), procType = nkProcDef): PNode = - result = newNode(procType) + result = newPNode(procType) result.add(name) - result.add(newNode(nkEmpty)) - result.add(newNode(nkEmpty)) - let formalParams = newNode(nkFormalParams) + result.add(newPNode(nkEmpty)) + result.add(newPNode(nkEmpty)) + let formalParams = newPNode(nkFormalParams) for param in params: formalParams.add(param) result.add(formalParams) - result.add(newNode(nkEmpty)) - result.add(newNode(nkEmpty)) + result.add(newPNode(nkEmpty)) + result.add(newPNode(nkEmpty)) result.add(body) proc newIfStmt(condition, body: PNode): PNode = - result = newNode(nkIfStmt) - let branch = newNode(nkElifBranch) + result = newPNode(nkIfStmt) + let branch = newPNode(nkElifBranch) result.add(branch) branch.add(condition) branch.add(body) proc newCall(theProc: PNode, args: varargs[PNode]): PNode = - result = newNode(nkCall) + result = newPNode(nkCall) result.add(theProc) for arg in args: result.add(arg) @@ -60,66 +65,66 @@ proc newCall(theProc: string, args: varargs[PNode]): PNode = newCall(ident(theProc), args) proc newStrLit(s: string): PNode = - result = newNode(nkStrLit) + result = newPNode(nkStrLit) result.strVal = s proc newRStrLit(s: string): PNode = - result = newNode(nkRStrLit) + result = newPNode(nkRStrLit) result.strVal = s proc newCStringLit(s: string): PNode = - newNode(nkCallStrLit).addChain(ident("cstring"), newRStrLit(s)) + newPNode(nkCallStrLit).addChain(ident("cstring"), newRStrLit(s)) proc newIntLit(val: BiggestInt): PNode = - result = newNode(nkIntLit) + result = newPNode(nkIntLit) result.intVal = val proc newInt64Lit(val: BiggestInt): PNode = - result = newNode(nkInt64Lit) + result = newPNode(nkInt64Lit) result.intVal = val proc newFloatLit(val: BiggestFloat): PNode = - result = newNode(nkFloatLit) + result = newPNode(nkFloatLit) result.floatVal = val proc newFloat64Lit(val: BiggestFloat): PNode = - result = newNode(nkFloat64Lit) + result = newPNode(nkFloat64Lit) result.floatVal = val proc newNilLit(): PNode = - result = newNode(nkNilLit) + result = newPNode(nkNilLit) proc newDotExpr(left, right: PNode): PNode = - result = newNode(nkDotExpr) + result = newPNode(nkDotExpr) result.add(left) result.add(right) proc newCommand(left, right: PNode): PNode = - result = newNode(nkCommand) + result = newPNode(nkCommand) result.add(left) result.add(right) proc infix(left, op, right: PNode): PNode = - result = newNode(nkInfix) + result = newPNode(nkInfix) result.add(op) result.add(left) result.add(right) proc postfix(left: PNode, op: string): PNode = - result = newNode(nkPostfix) + result = newPNode(nkPostfix) result.add(ident(op)) result.add(left) proc prefix(op: string, right: PNode): PNode = - result = newNode(nkPrefix) + result = newPNode(nkPrefix) result.add(ident(op)) result.add(right) proc newBracketExpr(first, bracket: PNode): PNode = - newNode(nkBracketExpr).addChain(first, bracket) + newPNode(nkBracketExpr).addChain(first, bracket) proc newEmptyNode(): PNode = - newNode(nkEmpty) + newPNode(nkEmpty) type GodotType = ref object name: string @@ -212,42 +217,42 @@ proc toNimStyle(name: string): string = proc newRefTypeNode(typeSection: PNode, typ, base, doc: string, isExported = true) = - let typeDef = newNode(nkTypeDef) + let typeDef = newPNode(nkTypeDef) typeSection.add(typeDef) if isExported: typeDef.add(postfix(ident(typ), "*")) else: typeDef.add(ident(typ)) - typeDef.add(newNode(nkEmpty)) # generic - let objTy = newNode(nkObjectTy) - let refTy = newNode(nkRefTy) + typeDef.add(newPNode(nkEmpty)) # generic + let objTy = newPNode(nkObjectTy) + let refTy = newPNode(nkRefTy) refTy.add(objTy) typeDef.add(refTy) - objTy.add(newNode(nkEmpty)) - let inherit = newNode(nkOfInherit) + objTy.add(newPNode(nkEmpty)) + let inherit = newPNode(nkOfInherit) inherit.add(ident(base)) objTy.add(inherit) if doc.len > 0: - let recList = newNode(nkRecList) - let docNode = newNode(nkCommentStmt) + let recList = newPNode(nkRecList) + let docNode = newPNode(nkCommentStmt) docNode.comment = doc recList.add(docNode) objTy.add(recList) else: - objTy.add(newNode(nkEmpty)) + objTy.add(newPNode(nkEmpty)) proc makeConstSection(constObj: JsonNode): PNode = if constObj.len == 0: - return newNode(nkEmpty) + return newPNode(nkEmpty) - result = newNode(nkConstSection) + result = newPNode(nkConstSection) for field, val in constObj: - let def = newNode(nkConstDef) + let def = newPNode(nkConstDef) def.add(postfix(ident(field), "*")) - def.add(newNode(nkEmpty)) # infer type + def.add(newPNode(nkEmpty)) # infer type var valNode: PNode if val.kind == JInt: valNode = newInt64Lit(val.num) @@ -257,7 +262,7 @@ proc makeConstSection(constObj: JsonNode): PNode = elif val.kind == JBool: valNode = ident($val.bval) elif val.kind == JString: - valNode = newNode(nkStrLit) + valNode = newPNode(nkStrLit) valNode.strVal = val.str else: raise newException(ValueError, "Unexpected constant kind: " & $val.kind) @@ -286,7 +291,7 @@ type isBase: bool isDiscardable: bool -const standardTypes = toSet( +const standardTypes = toHashSet( ["bool", "cint", "int", "uint8", "int8", "uint16", "int16", "uint32", "int32", "uint64", "Error", "int64", "float32", "cfloat", "float64", "GodotString", "Vector2", "Rect2", @@ -295,18 +300,18 @@ const standardTypes = toSet( "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray", "PoolVector2Array", "PoolVector3Array", "PoolColorArray"]) -const smallIntTypes = toSet(["uint8", "int8", "uint16", "int16", "uint32", - "int32", "cint", "int", "Error"]) -const int64Types = toSet(["uint64", "int64"]) +const smallIntTypes = toHashSet(["uint8", "int8", "uint16", "int16", "uint32", + "int32", "cint", "int", "Error"]) +const int64Types = toHashSet(["uint64", "int64"]) const intTypes = union(smallIntTypes, int64Types) -const float64Types = toSet(["float64", "cdouble"]) -const float32Types = toSet(["float32", "cfloat"]) +const float64Types = toHashSet(["float64", "cdouble"]) +const float32Types = toHashSet(["float32", "cfloat"]) const floatTypes = union(float64Types, float32Types) -const arrayTypes = toSet(["Array", "PoolByteArray", +const arrayTypes = toHashSet(["Array", "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray", "PoolVector2Array", "PoolVector3Array", "PoolColorArray"]) const wrapperTypes = union(arrayTypes, - toSet(["NodePath", "Dictionary", "Variant"])) + toHashSet(["NodePath", "Dictionary", "Variant"])) proc getInternalPtr(varName: PNode, typ: string): PNode = assert(typ in wrapperTypes) @@ -314,7 +319,7 @@ proc getInternalPtr(varName: PNode, typ: string): PNode = proc newNilCheck(ident, toAssign: PNode): PNode = newIfStmt(newCall("isNil", ident), - newNode(nkAsgn).addChain(ident).addChain( + newPNode(nkAsgn).addChain(ident).addChain( toAssign ) ) @@ -387,6 +392,8 @@ proc makeDefaultValue(arg: MethodArg): PNode = result = newCall("newVariant") else: failed = true + elif arg.typ == "Dictionary": + result = newCall("newDictionary") else: failed = true @@ -403,12 +410,12 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], meth: MethodInfo, withImplementation: bool) = var body: PNode if not withImplementation: - body = newNode(nkEmpty) + body = newPNode(nkEmpty) elif meth.godotName == "_init" and meth.typ.godotName == "Object": # It's not real (calling it crashes) and will be removed later, # but we use init() convention in Nim, so it needs to work. - body = newNode(nkStmtList).addChain( - newNode(nkDiscardStmt).addChain(newNode(nkEmpty))) + body = newPNode(nkStmtList).addChain( + newPNode(nkDiscardStmt).addChain(newPNode(nkEmpty))) else: let methGodotName = if meth.godotName.startsWith('_'): "underscore" & meth.godotName[1..^1] @@ -419,12 +426,12 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], if methodBindName[0].isUpperAscii(): methodBindName[0] = methodBindName[0].toLowerAscii() if methodBindName notin methodBindRegistry: - let methodBindDecl = newNode(nkVarSection).addChain( + let methodBindDecl = newPNode(nkVarSection).addChain( newIdentDefs( - newNode(nkPragmaExpr).addChain( + newPNode(nkPragmaExpr).addChain( ident(methodBindName)).addChain( - newNode(nkPragma).addChain(ident("threadvar"))), - newNode(nkPtrTy).addChain(ident("GodotMethodBind")) + newPNode(nkPragma).addChain(ident("threadvar"))), + newPNode(nkPtrTy).addChain(ident("GodotMethodBind")) )) tree.add(methodBindDecl) methodBindRegistry.incl(methodBindName) @@ -433,7 +440,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], newCall("getMethod", newCStringLit(meth.typ.godotName), newCStringLit(meth.godotName)) ) - let vars = newNode(nkVarSection) + let vars = newPNode(nkVarSection) var varargsName = none(string) var isVarargs: bool var staticArgsLen: int @@ -448,13 +455,13 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], elif arg.kind == ArgKind.Bound: let argName = boundArgName(idx) vars.add(newIdentDefs( - ident(argName), newNode(nkEmpty), arg.makeDefaultValue())) + ident(argName), newPNode(nkEmpty), arg.makeDefaultValue())) - let argsAlloc = newNode(nkCast).addChain( - newNode(nkPtrTy).addChain( - newNode(nkBracketExpr).addChain( + let argsAlloc = newPNode(nkCast).addChain( + newPNode(nkPtrTy).addChain( + newPNode(nkBracketExpr).addChain( ident("array"), ident("MAX_ARG_COUNT"), - if isVarargs: newNode(nkPtrTy).addChain(ident("GodotVariant")) + if isVarargs: newPNode(nkPtrTy).addChain(ident("GodotVariant")) else: ident("pointer")))) staticArgsLen = if varargsName.isNone: meth.args.len else: meth.args.len - 1 @@ -465,24 +472,24 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], newDotExpr(ident(varargsName.get), ident("len")))) argsAlloc.add(newCall("godotAlloc", newCall("cint", infix( newCall("sizeof", ident("Variant")), ident("*"), - newNode(nkPar).addChain(argLenNode)))) + newPNode(nkPar).addChain(argLenNode)))) ) else: argLenNode = newCall("cint", newIntLit(staticArgsLen)) vars.add(newIdentDefs( ident("argsStatic"), - newNode(nkBracketExpr).addChain( + newPNode(nkBracketExpr).addChain( ident("array"), newIntLit(staticArgsLen), ident("pointer")), - newNode(nkEmpty))) + newPNode(nkEmpty))) argsAlloc.add(newCommand(ident("addr"), ident("argsStatic"))) - vars.add(newIdentDefs(argsName, newNode(nkEmpty), argsAlloc)) + vars.add(newIdentDefs(argsName, newPNode(nkEmpty), argsAlloc)) - let argConversions = newNode(nkStmtList) + let argConversions = newPNode(nkStmtList) for idx, arg in meth.args: var argName = if arg.kind == ArgKind.Bound: ident(boundArgName(idx)) else: ident(arg.name) if arg.kind == ArgKind.VarArgs: - argName = newNode(nkBracketExpr).addChain( + argName = newPNode(nkBracketExpr).addChain( ident(varargsName.get), infix(ident("idx"), ident("-"), newIntLit(staticArgsLen))) let argIdx = if arg.kind == ArgKind.VarArgs: ident("idx") else: newIntLit(idx) @@ -501,19 +508,19 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], [arg.typ, meth.godotName, meth.typ.godotName]) if not isStandardType and varargsName.isNone: if arg.typ == "string": - argConversions.add(newNode(nkVarSection).addChain( + argConversions.add(newPNode(nkVarSection).addChain( newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(), newCall("toGodotString", argName)))) else: let objVal = newIfStmt( prefix("not", newDotExpr(argName, ident"isNil")), newDotExpr(argName, ident("godotObject")) - ).addChain(newNode(nkElse).addChain(newNilLit())) - argConversions.add(newNode(nkLetSection).addChain( + ).addChain(newPNode(nkElse).addChain(newNilLit())) + argConversions.add(newPNode(nkLetSection).addChain( newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(), objVal))) - let argAsgn = newNode(nkAsgn).addChain( - newNode(nkBracketExpr).addChain( - newNode(nkBracketExpr).addChain(argsName), argIdx), + let argAsgn = newPNode(nkAsgn).addChain( + newPNode(nkBracketExpr).addChain( + newPNode(nkBracketExpr).addChain(argsName), argIdx), convArg ) if arg.kind != ArgKind.VarArgs: @@ -521,14 +528,14 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], argAsgn ) else: - argConversions.add(newNode(nkVarSection).addChain( - newIdentDefs(ident("idx"), newNode(nkEmpty), + argConversions.add(newPNode(nkVarSection).addChain( + newIdentDefs(ident("idx"), newPNode(nkEmpty), newIntLit(staticArgsLen)))) - let argLoop = newNode(nkWhileStmt) + let argLoop = newPNode(nkWhileStmt) argConversions.add(argLoop) argLoop.add(infix(ident("idx"), ident("<"), argLenNode) ) - argLoop.add(newNode(nkStmtList).addChain( + argLoop.add(newPNode(nkStmtList).addChain( argAsgn, newCommand(ident("inc"), ident("idx")))) @@ -537,26 +544,26 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], newDotExpr(ident(methodBindName), ident(if isVarargs: "call" else: "ptrCall")), newDotExpr(ident("self"), ident("godotObject")), - if meth.args.len > 0: argsName else: newNode(nkNilLit), + if meth.args.len > 0: argsName else: newPNode(nkNilLit), argLenNode, if not isVarargs: ident(retName) else: ident("callError") ) if not isVarargs: theCall.sons.delete(3) let freeCall = newCall("godotFree", argsName) - body = newNode(nkStmtList) + body = newPNode(nkStmtList) if meth.typ.isSingleton: let varName = singletonName(meth.typ.name) body.add(newNilCheck(varName, newCall( newBracketExpr(ident("getSingleton"), ident(meth.typ.name))))) - body.add(newNode(nkLetSection).addChain(newIdentDefs( - ident("self"), newNode(nkEmpty), varName + body.add(newPNode(nkLetSection).addChain(newIdentDefs( + ident("self"), newPNode(nkEmpty), varName ))) body.add(nilCheck) body.add(vars) body.add(argConversions) if not isVarargs: - let retPtrDecl = newNode(nkVarSection).addChain( + let retPtrDecl = newPNode(nkVarSection).addChain( newIdentDefs(ident(retName), ident("pointer"), newEmptyNode()) ) body.add(retPtrDecl) @@ -571,43 +578,43 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], var addrToAssign = newCall("addr", retValIdent) if returnType in smallIntTypes: isConversionRet = true - body.add(newNode(nkVarSection).addChain(newIdentDefs( + body.add(newPNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("int64"), ))) elif returnType in float32Types: isConversionRet = true - body.add(newNode(nkVarSection).addChain(newIdentDefs( + body.add(newPNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("float64"), ))) elif returnType in wrapperTypes: isWrapperRet = true - body.add(newNode(nkVarSection).addChain(newIdentDefs( + body.add(newPNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("Godot" & returnType), ))) elif returnType in standardTypes: addrToAssign = newCall("addr", ident("result")) elif returnType == "string": isStringRet = true - body.add(newNode(nkVarSection).addChain(newIdentDefs( + body.add(newPNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("GodotString"), ))) elif returnType != "void": isObjRet = true - body.add(newNode(nkVarSection).addChain(newIdentDefs( - retValIdent, newNode(nkPtrTy).addChain(ident("GodotObject")), + body.add(newPNode(nkVarSection).addChain(newIdentDefs( + retValIdent, newPNode(nkPtrTy).addChain(ident("GodotObject")), ))) - body.add(newNode(nkAsgn).addChain(ident(retName), addrToAssign)) + body.add(newPNode(nkAsgn).addChain(ident(retName), addrToAssign)) if not isVarargs: body.add(theCall) else: if meth.returnType.isSome: isVariantRet = true - let callStmt = newNode(nkLetSection).addChain( + let callStmt = newPNode(nkLetSection).addChain( newIdentDefs( - newNode(nkPragmaExpr).addChain( - ident(retName), newNode(nkPragma).addChain(ident("used"))), - newNode(nkEmpty), theCall)) + newPNode(nkPragmaExpr).addChain( + ident(retName), newPNode(nkPragma).addChain(ident("used"))), + newPNode(nkEmpty), theCall)) body.add(callStmt) if varargsName.isNone: @@ -621,42 +628,42 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], let errCheck = newIfStmt( infix(newDotExpr(ident("callError"), ident("error")), ident("!="), newDotExpr(ident("VariantCallErrorType"), ident("OK"))), - newNode(nkRaiseStmt).addChain( + newPNode(nkRaiseStmt).addChain( newCall("newCallError", ident("callError"))) ) body.add(errCheck) if isVariantRet: - let convErrDef = newNode(nkLetSection).addChain( - newIdentDefs(ident("convErr"), newNode(nkEmpty), + let convErrDef = newPNode(nkLetSection).addChain( + newIdentDefs(ident("convErr"), newPNode(nkEmpty), newCall("fromVariant", ident("result"), newCall("newVariant", retValIdent)))) let convCheck = newIfStmt( infix(ident("convErr"), ident("!="), newDotExpr(ident("ConversionResult"), ident("OK"))), - newNode(nkRaiseStmt).addChain( + newPNode(nkRaiseStmt).addChain( newCall("newConversionError", ident("convErr"))) ) body.add(convErrDef) body.add(convCheck) if isStringRet: - body.add(newNode(nkAsgn).addChain( + body.add(newPNode(nkAsgn).addChain( ident("result"), prefix("$", retValIdent))) body.add(newCall("deinit", retValIdent)) elif isConversionRet: - body.add(newNode(nkAsgn).addChain( + body.add(newPNode(nkAsgn).addChain( ident("result"), newCall(meth.returnType.get, retValIdent))) elif isWrapperRet: - body.add(newNode(nkAsgn).addChain( + body.add(newPNode(nkAsgn).addChain( ident("result"), newCall("new" & meth.returnType.get, retValIdent))) elif isObjRet: - body.add(newNode(nkAsgn).addChain(ident("result"), + body.add(newPNode(nkAsgn).addChain(ident("result"), newCall(newBracketExpr(ident("asNimGodotObject"), newCall("type", ident("result"))), retValIdent, ident("false"), ident("true")))) elif isStringRet: - body.add(newNode(nkAsgn).addChain(ident("result"), + body.add(newPNode(nkAsgn).addChain(ident("result"), newCall("$", retValIdent))) let procType = if meth.isVirtual: nkMethodDef @@ -665,7 +672,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], if meth.returnType.isSome: params.add(ident(meth.returnType.get)) else: - params.add(newNode(nkEmpty)) + params.add(newPNode(nkEmpty)) if not meth.typ.isSingleton: params.add(newIdentDefs(ident("self"), ident(toNimType(meth.typ.name)))) @@ -676,7 +683,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], params.add(newIdentDefs(ident(arg.name), ident(arg.typ), defaultValue)) of ArgKind.VarArgs: params.add(newIdentDefs(ident(arg.name), - newNode(nkBracketExpr).addChain(ident("varargs"), ident(arg.typ)))) + newPNode(nkBracketExpr).addChain(ident("varargs"), ident(arg.typ)))) of ArgKind.Bound: discard @@ -684,9 +691,9 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], else: meth.name, params, body, procType) if not withImplementation: - let pragma = newNode(nkPragma) + let pragma = newPNode(nkPragma) pragma.add(ident("gcsafe")) - pragma.add(newNode(nkExprColonExpr).addChain(ident("locks"), + pragma.add(newPNode(nkExprColonExpr).addChain(ident("locks"), newIntLit(0))) if meth.isVirtual and meth.isBase and meth.typ.name != "PhysicsBody": # Nim doesn't like `base` on PhysicsBody methods - wtf @@ -738,7 +745,7 @@ proc getMethodInfo(methodObj: JsonNode, types: Table[string, GodotType], let returnType = if methodObj["return_type"].str != "void": some(toNimType(types, methodObj["return_type"].str)) else: none(string) - const discardableMethods = toSet(["emit_signal"]) + const discardableMethods = toHashSet(["emit_signal"]) result = MethodInfo( name: ident(nimName), typ: typ, @@ -767,7 +774,7 @@ proc makeProperty(types: Table[string, GodotType], tree: PNode, return let getterNameStr = toNimStyle(propertyObj["name"].str) let getterName = ident(getterNameStr) - let setterName = newNode(nkAccQuoted).addChain(ident(getterNameStr & "=")) + let setterName = newPNode(nkAccQuoted).addChain(ident(getterNameStr & "=")) let getter = findMethod(obj, propertyObj["getter"].str) let nimType = if getter.isNil: toNimType(types, propertyObj["type"].str) @@ -853,10 +860,10 @@ proc newRegisterClassNode(typ: GodotType): PNode = ) proc genSingletonDecl(typ: string): PNode = - result = newNode(nkVarSection) + result = newPNode(nkVarSection) let name = singletonName(typ) - let threadvar = newNode(nkPragma).addChain(ident("threadvar")) - result.add(newIdentDefs(newNode(nkPragmaExpr).addChain(name, threadvar), + let threadvar = newPNode(nkPragma).addChain(ident("threadvar")) + result.add(newIdentDefs(newPNode(nkPragmaExpr).addChain(name, threadvar), ident(typ))) proc shouldExport(typ: GodotType, types: Table[string, GodotType]): bool = @@ -873,9 +880,9 @@ proc sortByDerivedCount(types: Table[string, GodotType]): seq[GodotType] = proc genTypeFile(types: Table[string, GodotType], targetDir: string) = let sortedTypes = sortByDerivedCount(types) - let godotApiTypesTree = newNode(nkStmtList) - godotApiTypesTree.add(newNode(nkImportStmt).addChain(ident("godot"))) - let typeSection = newNode(nkTypeSection) + let godotApiTypesTree = newPNode(nkStmtList) + godotApiTypesTree.add(newPNode(nkImportStmt).addChain(ident("godot"))) + let typeSection = newPNode(nkTypeSection) godotApiTypesTree.add(typeSection) for typ in sortedTypes: @@ -897,10 +904,10 @@ proc genSingletonWithDerived(tree: PNode, typ: GodotType, types: Table[string, GodotType]) = let sortedTypes = sortByDerivedCount(types) - var parents = initSet[string]() + var parents = initHashSet[string]() parents.incl(typ.name) - let typeDecl = newNode(nkTypeSection) + let typeDecl = newPNode(nkTypeSection) tree.add(typeDecl) proc genDecl(typ: GodotType) = newRefTypeNode(typeDecl, typ.name, typ.baseName, typ.doc, @@ -950,17 +957,17 @@ proc genApi*(targetDir: string, apiJsonFile: string) = for typ in types.values(): let moduleName = typeNameToModuleName(typ.name) echo "Generating ", moduleName, ".nim..." - let tree = newNode(nkStmtList) - let importStmt = newNode(nkImportStmt) + let tree = newPNode(nkStmtList) + let importStmt = newPNode(nkImportStmt) importStmt.add(ident("godot")) importStmt.add(ident("godottypes")) importStmt.add(ident("godotinternal")) tree.add(importStmt) - let exportStmt = newNode(nkExportStmt) + let exportStmt = newPNode(nkExportStmt) exportStmt.add(ident("godottypes")) tree.add(exportStmt) - var methodBindRegsitry = initSet[string]() + var methodBindRegsitry = initHashSet[string]() let obj = typ.jsonNode if typ.baseName != "NimGodotObject": let baseModule = typeNameToModuleName(typ.baseName) @@ -1021,7 +1028,6 @@ when isMainModule: import os const usage = """Tool for wrapping Godot API into Nim - godotapigen [godot binary path] [target directory]""" proc main() = @@ -1052,4 +1058,4 @@ when isMainModule: genApi(targetDir, jsonFile) - main() + main() \ No newline at end of file diff --git a/godot/godotinternal.nim b/godot/godotinternal.nim index ce83428..207d76f 100644 --- a/godot/godotinternal.nim +++ b/godot/godotinternal.nim @@ -1,8 +1,8 @@ # Copyright 2018 Xored Software, Inc. -import internal.godotinternaltypes, internal.godotarrays, - internal.godotnodepaths, internal.godotpoolarrays, internal.godotstrings, - internal.godotvariants, internal.godotdictionaries +import internal/godotinternaltypes, internal/godotarrays, + internal/godotnodepaths, internal/godotpoolarrays, internal/godotstrings, + internal/godotvariants, internal/godotdictionaries import gdnativeapi export godotinternaltypes, godotarrays, godotnodepaths, godotpoolarrays, diff --git a/godot/internal/godotarrays.nim b/godot/internal/godotarrays.nim index c0736b5..c7e451d 100644 --- a/godot/internal/godotarrays.nim +++ b/godot/internal/godotarrays.nim @@ -1,6 +1,6 @@ # Copyright (c) 2018 Xored Software, Inc. -import godotinternaltypes, gdnativeapi, core.godotcoretypes +import godotinternaltypes, gdnativeapi, core/godotcoretypes proc len*(self: GodotArray): cint {.inline.} = getGDNativeAPI().arraySize(self) diff --git a/godot/internal/godotpoolarrays.nim b/godot/internal/godotpoolarrays.nim index 5fe9419..119848f 100644 --- a/godot/internal/godotpoolarrays.nim +++ b/godot/internal/godotpoolarrays.nim @@ -1,7 +1,7 @@ # Copyright (c) 2018 Xored Software, Inc. import godotinternaltypes, gdnativeapi -import core.godotcoretypes +import core/godotcoretypes template genPoolArrayAPI(ArrayT, initIdent, DataT, newProc, newCopyProc, newWithArrayProc, appendProc, diff --git a/godot/internal/godotvariants.nim b/godot/internal/godotvariants.nim index fec75cd..0a0980f 100644 --- a/godot/internal/godotvariants.nim +++ b/godot/internal/godotvariants.nim @@ -1,6 +1,6 @@ # Copyright 2018 Xored Software, Inc. -import core.godotcoretypes, godotinternaltypes, gdnativeapi +import core/godotcoretypes, godotinternaltypes, gdnativeapi proc getType*(p: GodotVariant): VariantType {.inline.} = getGDNativeAPI().variantGetType(p) diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index 4389859..f6a613a 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -1,8 +1,8 @@ # Copyright 2018 Xored Software, Inc. -import macros, tables, typetraits, strutils, sets, sequtils, options -import godotinternal, internal.godotvariants -import godotnim, core.variants +import macros, tables, typetraits, strutils, sets, sequtils, options, algorithm +import godotinternal, internal/godotvariants +import godotnim, core/variants type VarDecl = ref object @@ -51,15 +51,15 @@ template parseError(node: NimNode, msg: string) = proc extractNames(definition: NimNode): tuple[name, parentName: string] = if definition.kind == nnkIdent: - result.name = $(definition.ident) + result.name = definition.strVal else: if not (definition.kind == nnkInfix and - definition[0].ident == toNimIdent("of")): + definition[0].strVal == "of"): parseError(definition, "invalid type definition") - result.name = $(definition[1].ident) + result.name = definition[1].strVal case definition[2].kind: of nnkIdent: - result.parentName = $definition[2].ident + result.parentName = definition[2].strVal else: parseError(definition[2], "parent type expected") @@ -72,13 +72,13 @@ proc newCStringLit(s: string): NimNode {.compileTime.} = newNimNode(nnkCallStrLit).add(ident("cstring"), newRStrLit(s)) iterator pragmas(node: NimNode): - tuple[key: NimIdent, value: NimNode, index: int] = + tuple[key: string, value: NimNode, index: int] = assert node.kind in {nnkPragma, nnkEmpty} for index in countdown(node.len - 1, 0): if node[index].kind == nnkExprColonExpr: - yield (node[index][0].ident, node[index][1], index) + yield (node[index][0].strVal, node[index][1], index) elif node[index].kind == nnkIdent: - yield (node[index].ident, nil, index) + yield (node[index].strVal, nil, index) proc removePragmaNode(statement: NimNode, pname: string): NimNode {.compileTime.} = @@ -91,9 +91,8 @@ proc removePragmaNode(statement: NimNode, result = nil var pragmas = if RoutineNodes.contains(statement.kind): statement.pragma() else: statement[1] - let pnameIdent = toNimIdent(pname) for ident, val, i in pragmas(pragmas): - if ident == pnameIdent: + if ident == pname: pragmas.del(i) return val @@ -104,9 +103,8 @@ proc removePragma(statement: NimNode, pname: string): bool = return false var pragmas = if RoutineNodes.contains(statement.kind): statement.pragma() else: statement[1] - let pnameIdent = toNimIdent(pname) for ident, val, i in pragmas(pragmas): - if ident == pnameIdent: + if ident == pname: pragmas.del(i) return true @@ -178,8 +176,9 @@ proc parseVarSection(decl: NimNode): seq[VarDecl] = else: result.add(identDefsToVarDecls(decl[i])) -proc parseType(definition, callSite: NimNode): ObjectDecl = - let body = callSite[^1] +proc parseType(ast: NimNode): ObjectDecl = + let definition = ast[0] + let body = ast[^1] result = ObjectDecl( fields: newSeq[VarDecl](), methods: newSeq[MethodDecl]() @@ -187,11 +186,11 @@ proc parseType(definition, callSite: NimNode): ObjectDecl = (result.name, result.parentName) = extractNames(definition) var isTool = false - for i in 2..(callSite.len - 2): - let option = callSite[i] + for i in 1..(ast.len - 2): + let option = ast[i] if option.kind != nnkIdent: parseError(option, "type specifier expected") - if option.ident == toNimIdent("tool"): + if option.strVal == "tool": isTool = true else: parseError(option, "valid type specifier expected") @@ -214,7 +213,7 @@ proc parseType(definition, callSite: NimNode): ObjectDecl = macro invokeVarArgs(procIdent, objIdent; minArgs, maxArgs: static[int], numArgsIdent, argSeqIdent; argTypes: seq[NimNode], - hasReturnValue, isStaticCall: static[bool]): typed = + hasReturnValue, isStaticCall: static[bool]): untyped = ## Produces statement in form: ## ## .. code-block:: nim @@ -287,7 +286,7 @@ macro invokeVarArgs(procIdent, objIdent; " arguments, but got " & $numArgs) result.add(newNimNode(nnkElse).add(getAst( - printInvokeErr($procIdent.ident, minArgs, maxArgs, numArgsIdent)))) + printInvokeErr(procIdent.strVal, minArgs, maxArgs, numArgsIdent)))) proc typeError(nimType: string, value: string, godotType: VariantType, className: cstring, propertyName: cstring): string = @@ -433,6 +432,73 @@ proc toGodotStyle(s: string): string {.compileTime.} = else: result.add(c) +proc checkReplaceSelfVar(node: NimNode, childIndex: int, varsList, propsList: seq[string]) {.compileTime.} = + let identName = node[childIndex].strVal + if varsList.binarySearch(identName) == -1 and propsList.binarySearch(identName) != -1: + var newChild = newDotExpr(ident("self"), node[childIndex]) + node.del childIndex + node.insert(childIndex, newChild) + +proc checkReplaceSelfMethod(node: NimNode, childIndex: int, methodsList: seq[string]) {.compileTime.} = + if methodsList.binarySearch(node[childIndex].strVal) != -1: + var newChild = newDotExpr(ident("self"), node[childIndex]) + node.del childIndex + node.insert(childIndex, newChild) + +proc applySelf(node: NimNode, varsList: ref seq[string], propsList, methodsList: seq[string]) {.compileTime.} = + var lowIndx = -1 + var highIndx = node.len - 1 + var isBlock: bool = false + case node.kind: + of nnkCommand, nnkCall: + if node[0].kind == nnkDotExpr: + lowIndx = 0 + elif node[0].kind == nnkIdent: + if node[0].strVal != "procCall": + checkReplaceSelfMethod(node, 0, methodsList) + lowIndx = 1 + else: + lowIndx = 1 + of nnkInfix..nnkPostfix, nnkExprColonExpr, nnkObjConstr, nnkCast: + lowIndx = 1 + of nnkExprEqExpr, nnkPar, nnkCurly..nnkBracketExpr, nnkRange, nnkDerefExpr, nnkIfExpr, nnkTableConstr, nnkAddr, nnkAsgn, + nnkIfStmt, nnkCaseStmt, nnkVarSection, nnkLetSection, nnkConstSection, nnkDefer, nnkRaiseStmt, nnkReturnStmt, nnkStmtList, + nnkStmtListExpr, nnkTupleConstr: + lowIndx = 0 + of nnkIdentDefs: + lowIndx = 2 + if node[0].kind == nnkIdent: + let index = lowerBound(varsList[], node[0].strVal) + varsList[].insert(node[0].strVal, index) + of nnkVarTuple: + lowIndx = node.len - 1 + for i in 0..node.len - 3: + if node[i].kind == nnkIdent: + let index = lowerBound(varsList[], node[i].strVal) + varsList[].insert(node[i].strVal, index) + of nnkDotExpr: + lowIndx = 0 + highIndx = 0 + of nnkElifExpr, nnkElseExpr, nnkOfBranch..nnkElse, nnkWhenStmt..nnkWhileStmt, nnkTryStmt, nnkFinally, nnkBlockStmt, nnkBlockExpr: + isBlock = true + lowIndx = 0 + of nnkConstDef: + if node[0].kind == nnkIdent: + let index = lowerBound(varsList[], node[0].strVal) + varsList[].insert(node[0].strVal, index) + else: + discard + if lowIndx != -1: + var nodeVars = varsList + for i in lowIndx..highIndx: + if isBlock and i == highIndx: + new(nodeVars) + nodeVars[] = varsList[] + if node[i].kind == nnkIdent: + checkReplaceSelfVar(node, i, nodeVars[], propsList) + else: + applySelf(node[i], nodeVars, propsList, methodsList) + proc genType(obj: ObjectDecl): NimNode {.compileTime.} = result = newNimNode(nnkStmtList) @@ -480,11 +546,6 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = else: initMethod.body.insert(0, initBody) - # {.this: self.} for convenience - result.add(newNimNode(nnkPragma).add(newNimNode(nnkExprColonExpr).add( - ident("this"), ident("self") - ))) - # Nim proc defintions var decls = newSeqOfCap[NimNode](obj.methods.len) for meth in obj.methods: @@ -539,6 +600,25 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = genSym(nskProc, "getFunc"), newStrLitNode(hintStr), hintIdent, usage, ident($hasDefaultValue), field.defaultValue))) + + # Keep track of object's fields and methods (used instead of deprecated this:self pragma) + var propsList: seq[string] = @[] + for field in obj.fields: + let indx = lowerBound(propsList, field.name.strVal) + propsList.insert(field.name.strVal, indx) + var methodsList: seq[string] = @[] + for meth in obj.methods: + let indx = lowerBound(methodsList, meth.name) + methodsList.insert(meth.name, indx) + + # Inject self to properties and methods + for meth in obj.methods: + let varsList = new(seq[string]) + for v in meth.nimNode[3]: + if v.kind == nnkIdentDefs: + varsList[].add v[0].strVal + applySelf(meth.nimNode[6], varsList, propsList, methodsList) + # Register methods template registerGodotMethod(classNameLit, classNameIdent, methodNameIdent, @@ -604,7 +684,7 @@ N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom); let hasReturnValueBool = not (meth.returnType.isNil or meth.returnType.kind == nnkEmpty or (meth.returnType.kind == nnkIdent and - meth.returnType.ident == toNimIdent("void"))) + meth.returnType.strVal == "void")) let hasReturnValue = if hasReturnValueBool: ident("true") else: ident("false") result.add(getAst( @@ -630,11 +710,7 @@ N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom); GodotMethodAttributes(), refDec) result.add(getAst(registerRefIncDec(classNameLit))) -{.push warning[Deprecated]: off.} -# immediate macros are deprecated, but `untyped` doesn't make it immediate, -# as the warning and the documentation claim. - -macro gdobj*(definition: untyped, body: typed): typed {.immediate.} = +macro gdobj*(ast: varargs[untyped]): untyped = ## Generates Godot type. Self-documenting example: ## ## .. code-block:: nim @@ -678,7 +754,7 @@ macro gdobj*(definition: untyped, body: typed): typed {.immediate.} = ## `gdnew `_ or by using ## `load `_ or any other way ## that you can find in `Godot API `_. - let typeDef = parseType(definition, callsite()) + let typeDef = parseType(ast) result = genType(typeDef) -{.push warning[Deprecated]: on.} + diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index e58c330..1361450 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -2,13 +2,13 @@ import tables, typetraits, macros, unicode, strutils, sets import gdnativeapi -import core.godotcoretypes, core.godotbase -import core.vector2, core.rect2, - core.vector3, core.transform2d, - core.planes, core.quats, core.aabb, - core.basis, core.transforms, core.colors, - core.nodepaths, core.rids, core.dictionaries, - core.arrays, core.poolarrays, core.variants +import core/godotcoretypes, core/godotbase +import core/vector2, core/rect2, + core/vector3, core/transform2d, + core/planes, core/quats, core/aabb, + core/basis, core/transforms, core/colors, + core/nodepaths, core/rids, core/dictionaries, + core/arrays, core/poolarrays, core/variants import godotinternal ## This module defines ``NimGodotObject`` and ``toVariant``/``fromVariant`` @@ -343,20 +343,20 @@ proc newRStrLit(s: string): NimNode {.compileTime.} = result = newNimNode(nnkRStrLit) result.strVal = s -macro toGodotName(T: typedesc): string = +macro toGodotName(T: typedesc): untyped = if T is GodotString or T is string: - "String" + newStrLitNode"String" elif T is SomeFloat: - "float" + newStrLitNode"float" elif T is SomeUnsignedInt or T is SomeSignedInt: - "int" + newStrLitNode"int" else: - let nameStr = (($T.getType()[1][1].symbol).split(':')[0]) + let nameStr = ((T.getType()[1][1].strVal).split(':')[0]) case nameStr: of "File", "Directory", "Thread", "Mutex", "Semaphore": - "_" & nameStr + newStrLitNode("_" & nameStr) else: - nameStr + newStrLitNode(nameStr) macro asCString(s: static[string]): cstring = result = newNimNode(nnkCallStrLit).add( diff --git a/godot/nim/nim.cfg b/godot/nim/nim.cfg index f1fb6a7..1f12860 100644 --- a/godot/nim/nim.cfg +++ b/godot/nim/nim.cfg @@ -1 +1,2 @@ ---path:"$projectdir/../" \ No newline at end of file +--path:"$projectdir/../" +-d:userealtimeGC \ No newline at end of file From 19b0c23d6223e448d512d6637531b53e943f76e7 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Sun, 15 Sep 2019 15:39:10 +0700 Subject: [PATCH 64/82] Finalize support for Nim 0.20 Closes #32, closes #41. --- godot.nimble | 2 +- godot/core/godotbase.nim | 15 ++-- godot/godotapigen.nim | 18 ++-- godot/internal/backwardcompat.inc.nim | 19 +++++ godot/internal/godotstrings.nim | 8 +- godot/nim/godotmacros.nim | 116 ++++---------------------- godot/nim/godotnim.nim | 42 +++++----- godot/nim/nim.cfg | 2 +- 8 files changed, 91 insertions(+), 131 deletions(-) create mode 100644 godot/internal/backwardcompat.inc.nim diff --git a/godot.nimble b/godot.nimble index 66794fc..c5472c9 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.20" +version = "0.7.21" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/godotbase.nim b/godot/core/godotbase.nim index d76f544..7b5b804 100644 --- a/godot/core/godotbase.nim +++ b/godot/core/godotbase.nim @@ -30,14 +30,17 @@ proc stepify*(value, step: float32): float32 {.inline, noinit.} = else: value -proc min*(x, y: float32): float32 {.inline, noinit.} = - if x <= y: x else: y +when (NimMajor, NimMinor, NimPatch) < (0, 20, 4): + # Newer Nim has these procs in system module -proc abs*(x: float32): float32 {.inline, noinit.} = - if x < 0.0: -x else: x + proc min*(x, y: float32): float32 {.inline, noinit.} = + if x <= y: x else: y -proc max*(x, y: float32): float32 {.inline, noinit.} = - if y <= x: x else: y + proc abs*(x: float32): float32 {.inline, noinit.} = + if x < 0.0: -x else: x + + proc max*(x, y: float32): float32 {.inline, noinit.} = + if y <= x: x else: y {.pop.} # stackTrace: off diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index a53ee6f..ca0dfaf 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -2,7 +2,12 @@ import streams, json, os, strutils, times, sets, tables, options import sequtils, algorithm -import compiler/ast, compiler/renderer, compiler/idents, compiler/astalgo, compiler/lineinfos +import compiler/ast, compiler/renderer, compiler/idents, compiler/astalgo + +include "internal/backwardcompat.inc.nim" + +when (NimMajor, NimMinor, NimPatch) >= (0, 19, 0): + import compiler/lineinfos when (NimMajor, NimMinor, NimPatch) >= (0, 19, 0): var gic = newIdentCache() @@ -14,10 +19,13 @@ proc ident(ident: string): PNode = result = PNode(kind: nkIdent, ident: getIdent(ident)) proc newPNode(kind: TNodeKind): PNode = - result = PNode(kind: kind) - result.info.fileIndex = InvalidFileIdx - result.info.col = int16(-1) - result.info.line = uint16(0) + when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): + result = newNode(kind) + else: + result = PNode(kind: kind) + result.info.fileIndex = InvalidFileIdx + result.info.col = int16(-1) + result.info.line = uint16(0) proc addChain(node: PNode, others: varargs[PNode]): PNode {.discardable.} = for other in others: diff --git a/godot/internal/backwardcompat.inc.nim b/godot/internal/backwardcompat.inc.nim new file mode 100644 index 0000000..9d31844 --- /dev/null +++ b/godot/internal/backwardcompat.inc.nim @@ -0,0 +1,19 @@ +# Copyright 2019 Xored Software, Inc. + +when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): + import macros, sets + + proc strVal(n: NimNode): string {.used.} = + case n.kind + of nnkIdent: + $n.ident + of nnkSym: + $n.symbol + else: + macros.strVal(n) + + proc toHashSet[A](keys: openArray[A]): HashSet[A] {.inline, used.} = + toSet(keys) + + proc initHashSet[A](): HashSet[A] {.inline, used.} = + initSet[A]() diff --git a/godot/internal/godotstrings.nim b/godot/internal/godotstrings.nim index 18bcf63..e67acfd 100644 --- a/godot/internal/godotstrings.nim +++ b/godot/internal/godotstrings.nim @@ -38,7 +38,13 @@ proc `$`*(self: GodotString): string = proc toGodotString*(s: string): GodotString {.inline.} = ## Converts the Nim string into ``GodotString`` - initGodotString(result, cstring(s), cint(s.len + 1)) + when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): + if s.isNil: + initGodotString(result) + else: + initGodotString(result, cstring(s), cint(s.len + 1)) + else: + initGodotString(result, cstring(s), cint(s.len + 1)) proc toGodotString*(s: cstring): GodotString {.inline.} = ## Converts the cstring into ``GodotString`` diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index f6a613a..90e9ea7 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -32,6 +32,8 @@ type ParseError = object of Exception +include "internal/backwardcompat.inc.nim" + proc godotToNim[T](val: Variant): (T, ConversionResult) = mixin fromVariant result[1] = fromVariant(result[0], val) @@ -432,73 +434,6 @@ proc toGodotStyle(s: string): string {.compileTime.} = else: result.add(c) -proc checkReplaceSelfVar(node: NimNode, childIndex: int, varsList, propsList: seq[string]) {.compileTime.} = - let identName = node[childIndex].strVal - if varsList.binarySearch(identName) == -1 and propsList.binarySearch(identName) != -1: - var newChild = newDotExpr(ident("self"), node[childIndex]) - node.del childIndex - node.insert(childIndex, newChild) - -proc checkReplaceSelfMethod(node: NimNode, childIndex: int, methodsList: seq[string]) {.compileTime.} = - if methodsList.binarySearch(node[childIndex].strVal) != -1: - var newChild = newDotExpr(ident("self"), node[childIndex]) - node.del childIndex - node.insert(childIndex, newChild) - -proc applySelf(node: NimNode, varsList: ref seq[string], propsList, methodsList: seq[string]) {.compileTime.} = - var lowIndx = -1 - var highIndx = node.len - 1 - var isBlock: bool = false - case node.kind: - of nnkCommand, nnkCall: - if node[0].kind == nnkDotExpr: - lowIndx = 0 - elif node[0].kind == nnkIdent: - if node[0].strVal != "procCall": - checkReplaceSelfMethod(node, 0, methodsList) - lowIndx = 1 - else: - lowIndx = 1 - of nnkInfix..nnkPostfix, nnkExprColonExpr, nnkObjConstr, nnkCast: - lowIndx = 1 - of nnkExprEqExpr, nnkPar, nnkCurly..nnkBracketExpr, nnkRange, nnkDerefExpr, nnkIfExpr, nnkTableConstr, nnkAddr, nnkAsgn, - nnkIfStmt, nnkCaseStmt, nnkVarSection, nnkLetSection, nnkConstSection, nnkDefer, nnkRaiseStmt, nnkReturnStmt, nnkStmtList, - nnkStmtListExpr, nnkTupleConstr: - lowIndx = 0 - of nnkIdentDefs: - lowIndx = 2 - if node[0].kind == nnkIdent: - let index = lowerBound(varsList[], node[0].strVal) - varsList[].insert(node[0].strVal, index) - of nnkVarTuple: - lowIndx = node.len - 1 - for i in 0..node.len - 3: - if node[i].kind == nnkIdent: - let index = lowerBound(varsList[], node[i].strVal) - varsList[].insert(node[i].strVal, index) - of nnkDotExpr: - lowIndx = 0 - highIndx = 0 - of nnkElifExpr, nnkElseExpr, nnkOfBranch..nnkElse, nnkWhenStmt..nnkWhileStmt, nnkTryStmt, nnkFinally, nnkBlockStmt, nnkBlockExpr: - isBlock = true - lowIndx = 0 - of nnkConstDef: - if node[0].kind == nnkIdent: - let index = lowerBound(varsList[], node[0].strVal) - varsList[].insert(node[0].strVal, index) - else: - discard - if lowIndx != -1: - var nodeVars = varsList - for i in lowIndx..highIndx: - if isBlock and i == highIndx: - new(nodeVars) - nodeVars[] = varsList[] - if node[i].kind == nnkIdent: - checkReplaceSelfVar(node, i, nodeVars[], propsList) - else: - applySelf(node[i], nodeVars, propsList, methodsList) - proc genType(obj: ObjectDecl): NimNode {.compileTime.} = result = newNimNode(nnkStmtList) @@ -546,6 +481,12 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = else: initMethod.body.insert(0, initBody) + when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): + # {.this: self.} for convenience + result.add(newNimNode(nnkPragma).add(newNimNode(nnkExprColonExpr).add( + ident("this"), ident("self") + ))) + # Nim proc defintions var decls = newSeqOfCap[NimNode](obj.methods.len) for meth in obj.methods: @@ -600,25 +541,6 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = genSym(nskProc, "getFunc"), newStrLitNode(hintStr), hintIdent, usage, ident($hasDefaultValue), field.defaultValue))) - - # Keep track of object's fields and methods (used instead of deprecated this:self pragma) - var propsList: seq[string] = @[] - for field in obj.fields: - let indx = lowerBound(propsList, field.name.strVal) - propsList.insert(field.name.strVal, indx) - var methodsList: seq[string] = @[] - for meth in obj.methods: - let indx = lowerBound(methodsList, meth.name) - methodsList.insert(meth.name, indx) - - # Inject self to properties and methods - for meth in obj.methods: - let varsList = new(seq[string]) - for v in meth.nimNode[3]: - if v.kind == nnkIdentDefs: - varsList[].add v[0].strVal - applySelf(meth.nimNode[6], varsList, propsList, methodsList) - # Register methods template registerGodotMethod(classNameLit, classNameIdent, methodNameIdent, @@ -627,10 +549,6 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): {.emit: """/*TYPESECTION*/ N_NOINLINE(void, setStackBottom)(void* thestackbottom); -""".} - else: - {.emit: """ -N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom); """.} proc methFuncIdent(obj: ptr GodotObject, methodData: pointer, @@ -638,9 +556,13 @@ N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom); args: var array[MAX_ARG_COUNT, ptr GodotVariant]): GodotVariant {.noconv.} = var stackBottom {.volatile.}: pointer - {.emit: """ - nimGC_setStackBottom((void*)(&`stackBottom`)); - """.} + stackBottom = addr(stackBottom) + when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): + {.emit: """ + setStackBottom((void*)(&`stackBottom`)); + """.} + else: + nimGC_setStackBottom(stackBottom) let self = cast[classNameIdent](userData) const isStaticCall = methodNameLit == cstring"_ready" or methodNameLit == cstring"_process" or @@ -718,7 +640,7 @@ macro gdobj*(ast: varargs[untyped]): untyped = ## ## gdobj MyObj of Node: ## var myField: int - ## ## Not exported to Godot (i.e. editor will not see this field). + ## ## Not exported to Godot (i.e. editor and scripts will not see this field). ## ## var myString* {.gdExport, hint: Length, hintStr: "20".}: string ## ## Exported to Godot as ``my_string``. @@ -731,12 +653,12 @@ macro gdobj*(ast: varargs[untyped]): untyped = ## ## Exported methods are exported to Godot by default, ## ## and their Godot names are prefixed with ``_`` ## ## (in this case ``_ready``) - ## print("I am ready! myString is: " & myString) + ## print("I am ready! myString is: " & self.myString) ## ## proc myProc*() {.gdExport.} = ## ## Exported to Godot as ``my_proc`` ## print("myProc is called! Incrementing myField.") - ## inc myField + ## inc self.myField ## ## If parent type is omitted, the type is inherited from ``Object``. ## @@ -756,5 +678,3 @@ macro gdobj*(ast: varargs[untyped]): untyped = ## that you can find in `Godot API `_. let typeDef = parseType(ast) result = genType(typeDef) - - diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 1361450..bba8b98 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -91,6 +91,8 @@ type FNV1Hash = uint32 +include "internal/backwardcompat.inc.nim" + proc isFinalized*(obj: NimGodotObject): bool {.inline.} = obj.isFinalized @@ -110,13 +112,13 @@ template initFNV1Hash(hash: var FNV1Hash) = template appendFNV1Hash(hash: var FNV1Hash, val: uint8) = block: let u64hash = hash.uint64 - hash = ( + hash = (( u64hash + (u64hash shl 1'u64) + (u64hash shl 4'u64) + (u64hash shl 7'u64) + (u64hash shl 8'u64) + - (u64hash shl 24'u64)).uint32 xor val + (u64hash shl 24'u64)) and 0xFFFFFFFF'u32).uint32 xor val {.push stackTrace:off.} proc lsb(c: ptr cwchar_t): char {.noinit, inline.} = @@ -187,7 +189,7 @@ proc nimGodotObjectFinalizer*[T: NimGodotObject](obj: T) = if obj.godotObject.isNil or obj.isNative: return # important to set it before so that ``unreference`` is aware obj.isFinalized = true - if (obj.isRef or not obj.linkedObject.isNil and obj.linkedObject.isRef) and + if (obj.isRef or not obj.linkedObject.isNil and obj.linkedObject.isRef) and obj.godotObject.unreference(): obj.deinit() @@ -708,16 +710,13 @@ proc toVariant*(s: string): Variant {.inline.} = proc fromVariant*(s: var string, val: Variant): ConversionResult = if val.getType() == VariantType.String: s = val.asString() - when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): - if val.getType() == VariantType.Nil: + elif val.getType() == VariantType.Nil: + when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): s = nil else: - result = ConversionResult.TypeError - else: - if val.getType() == VariantType.Nil: s = "" - else: - result = ConversionResult.TypeError + else: + result = ConversionResult.TypeError template arrTypeInfo(T) = result.variantType = VariantType.Array @@ -840,11 +839,6 @@ when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): N_LIB_EXPORT N_CDECL(void, NimMain)(void); N_NOINLINE(void, setStackBottom)(void* thestackbottom); """.} -else: - {.emit: """/*TYPESECTION*/ - N_LIB_EXPORT N_CDECL(void, NimMain)(void); - N_NOINLINE(void, nimGC_setStackBottom)(void* thestackbottom); - """.} var nativeLibHandle: pointer proc getNativeLibHandle*(): pointer = @@ -857,10 +851,16 @@ proc godot_nativescript_init(handle: pointer) {. nativeLibHandle = handle var stackBottom {.volatile.}: pointer + stackBottom = addr(stackBottom) {.emit: """ NimMain(); - nimGC_setStackBottom((void*)(&`stackBottom`)); """.} + when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): + {.emit: """ + setStackBottom((void*)(&`stackBottom`)); + """.} + else: + nimGC_setStackBottom(stackBottom) GC_fullCollect() GC_disable() @@ -896,9 +896,13 @@ proc registerFrameCallback*(cb: proc () {.closure.}) = proc godot_nativescript_frame() {.cdecl, exportc, dynlib.} = var stackBottom {.volatile.}: pointer - {.emit: """ - nimGC_setStackBottom((void*)(&`stackBottom`)); - """.} + stackBottom = addr(stackBottom) + when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): + {.emit: """ + setStackBottom((void*)(&`stackBottom`)); + """.} + else: + nimGC_setStackBottom(stackBottom) for cb in idleCallbacks: cb() GC_step(nimGcStepLengthUs, true, 0) diff --git a/godot/nim/nim.cfg b/godot/nim/nim.cfg index 1f12860..add9a4d 100644 --- a/godot/nim/nim.cfg +++ b/godot/nim/nim.cfg @@ -1,2 +1,2 @@ --path:"$projectdir/../" --d:userealtimeGC \ No newline at end of file +-d:useRealtimeGc \ No newline at end of file From 2f3f4034cfd8d532efea88d15b62e39af67419e2 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 18 Sep 2019 13:27:31 +0700 Subject: [PATCH 65/82] Fix newVariant for nil strings and older Nim --- godot.nimble | 2 +- godot/core/variants.nim | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index c5472c9..71cfda5 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.21" +version = "0.7.22" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/variants.nim b/godot/core/variants.nim index ce1d945..fcb2b04 100644 --- a/godot/core/variants.nim +++ b/godot/core/variants.nim @@ -73,6 +73,10 @@ proc newVariant*(r: cdouble): Variant {.inline.} = proc newVariant*(s: string): Variant {.inline.} = new(result, variantFinalizer) + when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): + if s.isNil: + initGodotVariant(result.godotVariant) + return var godotStr = s.toGodotString() initGodotVariant(result.godotVariant, godotStr) godotStr.deinit() From 7dd1b1ed5f0c2fedfc23b31ed7593c57515c8c66 Mon Sep 17 00:00:00 2001 From: Dwana Games Date: Thu, 19 Sep 2019 14:14:58 -0500 Subject: [PATCH 66/82] Add self to field initialization --- godot/nim/godotmacros.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index 90e9ea7..c0a23cc 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -455,7 +455,7 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = let initBody = newStmtList() for decl in obj.fields: if not decl.defaultValue.isNil and decl.defaultValue.kind != nnkEmpty: - initBody.add(newNimNode(nnkAsgn).add(decl.name, decl.defaultValue)) + initBody.add(newNimNode(nnkAsgn).add(newDotExpr(ident("self"), decl.name), decl.defaultValue)) let name = if not decl.isExported: decl.name else: postfix(decl.name, "*") recList.add(newIdentDefs(name, decl.typ)) From c2db807da4bbc68fb7a70d4feb77b1575e869e53 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Fri, 20 Sep 2019 09:20:50 +0700 Subject: [PATCH 67/82] Up version to 0.7.23 --- godot.nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index 71cfda5..1fdeeeb 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.22" +version = "0.7.23" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" From 1b8e7ccd983e26f0838696ca7c7fe4df2282ae3d Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 2 Oct 2019 15:26:41 +0700 Subject: [PATCH 68/82] Add variant conversion for Option[T] --- godot.nimble | 2 +- godot/nim/godotnim.nim | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/godot.nimble b/godot.nimble index 1fdeeeb..6b77ece 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.23" +version = "0.7.24" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index bba8b98..cf989dc 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -1,6 +1,6 @@ # Copyright 2018 Xored Software, Inc. -import tables, typetraits, macros, unicode, strutils, sets +import tables, typetraits, macros, unicode, strutils, sets, options import gdnativeapi import core/godotcoretypes, core/godotbase import core/vector2, core/rect2, @@ -788,6 +788,27 @@ proc fromVariant*[T: array](s: var T, val: Variant): ConversionResult = else: result = ConversionResult.TypeError +proc godotTypeInfo*[T](OptT: typedesc[Option[T]]): GodotTypeInfo = + when compiles(godotTypeInfo(T)): + result.variantType = godotTypeInfo(T) + else: + result.variantType = VariantType.Nil + +proc toVariant*[T](option: Option[T]): Variant = + if option.isSome(): + result = toVariant(option.unsafeGet()) + else: + result = newVariant() + +proc fromVariant*[T](option: var Option[T], val: Variant): ConversionResult = + if val.getType() == VariantType.Nil: + option = none(T) + else: + var v: T + result = fromVariant(v, val) + if result == ConversionResult.OK: + option = some(result) + proc godotTypeInfo*(T: typedesc[Table|TableRef|OrderedTable|OrderedTableRef]): GodotTypeInfo {.inline.} = result.variantType = VariantType.Dictionary From 78d3626fa36c5749e098fa32086c34a39a6ad81e Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 4 Dec 2019 23:58:13 +0700 Subject: [PATCH 69/82] Do not log error when casting fails This allows not to perform unnecessary 'of' check before casting, if cast failure is expected. --- godot.nimble | 2 +- godot/nim/godotnim.nim | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/godot.nimble b/godot.nimble index 6b77ece..1ad646b 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.24" +version = "0.7.25" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index cf989dc..4d577cc 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -332,9 +332,6 @@ proc `as`*[T: NimGodotObject](obj: NimGodotObject, t: typedesc[T]): T = elif not obj.linkedObject.isNil and system.`of`(obj.linkedObject, T): result = T(obj.linkedObject) else: - when not defined(release): - printError("Failed to cast object to " & - T.name & "\n" & getStackTrace()) result = nil proc `of`*[T1, T2: NimGodotObject](obj: T1, t: typedesc[T2]): bool {.inline.} = From d1b82d351c81243670694e6f79d584ac7b837106 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 23 Dec 2019 20:53:13 +0700 Subject: [PATCH 70/82] Fix unsigned int conversion to/from Variant --- godot.nimble | 2 +- godot/nim/godotnim.nim | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/godot.nimble b/godot.nimble index 1ad646b..7115536 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.25" +version = "0.7.26" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 4d577cc..7b0a832 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -604,7 +604,11 @@ proc fromVariant*[T: SomeSignedInt or SomeUnsignedInt]( else: uint64) intVal = when T is SomeSignedInt: val.asInt() else: val.asUint() - if intVal > high(T) or intVal < low(T): + const highT = when T is SomeSignedInt: high(T).int64 + else: high(T).uint64 + const lowT = when T is SomeSignedInt: low(T).int64 + else: low(T).uint64 + if intVal > highT or intVal < lowT: result = ConversionResult.RangeError else: self = T(intVal) From 157a90e4a0bd82a91f8ab34cd1154e0b9869ae48 Mon Sep 17 00:00:00 2001 From: zetashift Date: Wed, 5 Feb 2020 05:35:50 +0100 Subject: [PATCH 71/82] add gensym in hygienic template fix thanks to demotohiro (#55) Add gensym in hygienic template fix thanks to demotohiro --- godot/nim/godotmacros.nim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index c0a23cc..c4715c3 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -396,10 +396,9 @@ template registerGodotField(classNameLit, classNameIdent, propNameLit, getFunc: getFuncIdent ) mixin godotTypeInfo - static: - var typeInfo: GodotTypeInfo - when compiles(godotTypeInfo(propTypeIdent)): - typeInfo = godotTypeInfo(propTypeIdent) + const typeInfo = when compiles(godotTypeInfo(propTypeIdent)): + godotTypeInfo(propTypeIdent) + else: GodotTypeInfo() const hintStr = when hintStrLit != "NIM": hintStrLit else: @@ -455,7 +454,8 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} = let initBody = newStmtList() for decl in obj.fields: if not decl.defaultValue.isNil and decl.defaultValue.kind != nnkEmpty: - initBody.add(newNimNode(nnkAsgn).add(newDotExpr(ident("self"), decl.name), decl.defaultValue)) + initBody.add(newNimNode(nnkAsgn).add(newDotExpr(ident("self"), decl.name), + decl.defaultValue)) let name = if not decl.isExported: decl.name else: postfix(decl.name, "*") recList.add(newIdentDefs(name, decl.typ)) @@ -605,7 +605,7 @@ N_NOINLINE(void, setStackBottom)(void* thestackbottom); else: toGodotStyle(meth.name) let hasReturnValueBool = not (meth.returnType.isNil or meth.returnType.kind == nnkEmpty or - (meth.returnType.kind == nnkIdent and + (meth.returnType.kind == nnkIdent and meth.returnType.strVal == "void")) let hasReturnValue = if hasReturnValueBool: ident("true") else: ident("false") From a49fcbdac7da28bb9af40f1a12ff87ca656102ed Mon Sep 17 00:00:00 2001 From: Konstantin Zaitsev Date: Wed, 5 Feb 2020 10:30:04 +0700 Subject: [PATCH 72/82] Fix variant size for 32bit platform with memory alignment --- godot/internal/godotinternaltypes.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/godot/internal/godotinternaltypes.nim b/godot/internal/godotinternaltypes.nim index 8474af8..a2910c9 100644 --- a/godot/internal/godotinternaltypes.nim +++ b/godot/internal/godotinternaltypes.nim @@ -116,7 +116,8 @@ type expected*: VariantType GodotVariant* {.byref.} = object - data: array[4 + sizeof(int) div 4, float32] + data: array[2, int64] + data2: int type GodotMethodBind* = object From ed9ede5cb357022d18bd6fdb326c76aa3eb3b92d Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 5 Feb 2020 12:34:44 +0700 Subject: [PATCH 73/82] Up version to 0.7.27 --- godot.nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index 7115536..6d35312 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.26" +version = "0.7.27" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" From 031774f54f1ee88d9a88e8be0a255c3a590c58fd Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 3 Jun 2020 15:52:11 +0700 Subject: [PATCH 74/82] More efficient and GC-safe conversions in API generator --- godot.nimble | 2 +- godot/godotapigen.nim | 66 ++++++++++++++++++++++++++++++++------- godot/nim/godotmacros.nim | 6 +++- 3 files changed, 61 insertions(+), 13 deletions(-) diff --git a/godot.nimble b/godot.nimble index 6d35312..f511b3f 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.27" +version = "0.7.28" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index ca0dfaf..432814e 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -308,6 +308,13 @@ const standardTypes = toHashSet( "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray", "PoolVector2Array", "PoolVector3Array", "PoolColorArray"]) +const variantPrimitives = [ + "bool", "cint", "int", "uint8", "int8", "uint16", "int16", "uint32", "int32", + "uint64", "Error", + "int64", "float32", "cfloat", "float64", "GodotString", "Vector2", "Rect2", + "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform", + "Color", "RID"] + const smallIntTypes = toHashSet(["uint8", "int8", "uint16", "int16", "uint32", "int32", "cint", "int", "Error"]) const int64Types = toHashSet(["uint64", "int64"]) @@ -322,7 +329,7 @@ const wrapperTypes = union(arrayTypes, toHashSet(["NodePath", "Dictionary", "Variant"])) proc getInternalPtr(varName: PNode, typ: string): PNode = - assert(typ in wrapperTypes) + assert(typ in wrapperTypes or typ == "Object") result = newDotExpr(varName, ident("godot" & typ)) proc newNilCheck(ident, toAssign: PNode): PNode = @@ -479,7 +486,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], ident("+"), newDotExpr(ident(varargsName.get), ident("len")))) argsAlloc.add(newCall("godotAlloc", newCall("cint", infix( - newCall("sizeof", ident("Variant")), ident("*"), + newCall("sizeof", newPNode(nkPtrTy).addChain(ident("GodotVariant"))), ident("*"), newPNode(nkPar).addChain(argLenNode)))) ) else: @@ -493,6 +500,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], vars.add(newIdentDefs(argsName, newPNode(nkEmpty), argsAlloc)) let argConversions = newPNode(nkStmtList) + let destructors = newPNode(nkStmtList) for idx, arg in meth.args: var argName = if arg.kind == ArgKind.Bound: ident(boundArgName(idx)) else: ident(arg.name) @@ -503,13 +511,48 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], let argIdx = if arg.kind == ArgKind.VarArgs: ident("idx") else: newIntLit(idx) let isStandardType = arg.typ in standardTypes let isWrappedType = arg.typ in wrapperTypes - let convArg = if varargsName.isSome: - getInternalPtr(newCall("toVariant", argName), "Variant") - elif isWrappedType: getInternalPtr(argName, arg.typ) - elif isStandardType: newCall("unsafeAddr", argName) - elif arg.typ == "string": newCall("unsafeAddr", - ident("argToPassToGodot" & $idx)) - else: ident("argToPassToGodot" & $idx) # object + let convArg = + if varargsName.isSome: + let isAlreadyVariant = arg.typ == "Variant" + let variantIdent = if isAlreadyVariant: getInternalPtr(argName, "Variant") + else: ident("variant" & $idx) + if not isAlreadyVariant: + argConversions.add(newPNode(nkVarSection).addChain( + newIdentDefs(variantIdent, ident("GodotVariant"), newEmptyNode()) + )) + destructors.add( + newCall("deinit", variantIdent) + ) + if arg.typ in variantPrimitives: + argConversions.add( + newCall("initGodotVariant", variantIdent, argName) + ) + elif arg.typ in wrapperTypes or arg.typ == "Object": + argConversions.add( + newCall("initGodotVariant", variantIdent, getInternalPtr(argName, arg.typ)) + ) + elif arg.typ == "string": + let stringIdent = ident("variantString" & $idx) + argConversions.addChain( + newPNode(nkVarSection).addChain( + newIdentDefs(stringIdent, ident("GodotString"), newCall("toGodotString", argName)) + ) + ).addChain( + newCall("initGodotVariant", variantIdent, stringIdent) + ) + destructors.add(newCall("deinit", stringIdent)) + else: + raise newException(ValueError, + "Non-standard type $# for varargs params of method $# of type $#" % + [arg.typ, meth.godotName, meth.typ.godotName]) + + if isAlreadyVariant: variantIdent + else: newCall("addr", variantIdent) + elif isWrappedType: getInternalPtr(argName, arg.typ) + elif isStandardType: newCall("unsafeAddr", argName) + elif arg.typ == "string": newCall("unsafeAddr", + ident("argToPassToGodot" & $idx)) + else: ident("argToPassToGodot" & $idx) # object if not isStandardType and arg.kind == ArgKind.VarArgs: raise newException(ValueError, "Non-standard type $# for varargs params of method $# of type $#" % @@ -630,9 +673,10 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], if arg.typ == "string": body.add(newCall("deinit", ident("argToPassToGodot" & $idx))) - if meth.args.len > 0 and varargsName.isSome: - body.add(freeCall) if varargsName.isSome: + if meth.args.len > 0: + body.add(freeCall) + body.add(destructors) let errCheck = newIfStmt( infix(newDotExpr(ident("callError"), ident("error")), ident("!="), newDotExpr(ident("VariantCallErrorType"), ident("OK"))), diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index c4715c3..d6efa6d 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -272,8 +272,12 @@ macro invokeVarArgs(procIdent, objIdent; invocation = newNimNode(nnkCall).add(ident("procCall"), invocation) if hasReturnValue: + let resultVariant = genSym(nskLet, "ret") + branchBody.add( + newNimNode(nnkLetSection).add( + newIdentDefs(resultVariant, ident("Variant"), newCall("toVariant", invocation)))) let theCall = newNimNode(nnkBracketExpr).add(newNimNode(nnkDotExpr).add( - newCall("toVariant", invocation), ident("godotVariant"))) + resultVariant, ident("godotVariant"))) branchBody.add(getAst(initGodotVariantCall(ident("result"), theCall))) else: branchBody.add(invocation) From 87707a86b437371db4534884291d0e12c12036fa Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 3 Jun 2020 18:06:18 +0700 Subject: [PATCH 75/82] Remove Travis badge from README Need to fix the CI script. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 891a920..db27270 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Nim bindings for Godot Engine [![Build Status](https://travis-ci.org/pragmagic/godot-nim.svg?branch=master)](https://travis-ci.org/pragmagic/godot-nim) +# Nim bindings for Godot Engine Nim bindings for Godot 3.0 based on [GDNative](https://godotengine.org/article/dlscript-here). From 3f46e3c6481e9f18041f3b4b7d018635ae36b819 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Fri, 5 Jun 2020 16:53:34 +0700 Subject: [PATCH 76/82] Break reference cycle in NimGodotObject --- godot.nimble | 2 +- godot/nim/godotnim.nim | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/godot.nimble b/godot.nimble index f511b3f..817406d 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.7.28" +version = "0.8.0" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 7b0a832..7f3ed96 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -31,7 +31,7 @@ type ## The base type all Godot types inherit from. ## Manages lifecycle of the wrapped ``GodotObject``. godotObject: ptr GodotObject - linkedObject: NimGodotObject + linkedObjectPtr: pointer ## Wrapper around native object that is the container of the Nim "script" ## This is needed for `of` checks and `as` conversions to work as ## expected. For example, Nim type may inherit from ``Spatial``, but the @@ -39,6 +39,8 @@ type ## ``Particles`` is valid, but Nim type system is not aware of that. ## This works in both directions - for linked native object this ## reference points to Nim object. + ## This is stored as a raw pointer to avoid reference cycles and therefore + ## improve GC performance. isRef*: bool isFinalized: bool isNative: bool @@ -185,6 +187,9 @@ proc deinit*(obj: NimGodotObject) = obj.godotObject.deinit() obj.godotObject = nil +proc linkedObject(obj: NimGodotObject): NimGodotObject {.inline.} = + cast[NimGodotObject](obj.linkedObjectPtr) + proc nimGodotObjectFinalizer*[T: NimGodotObject](obj: T) = if obj.godotObject.isNil or obj.isNative: return # important to set it before so that ``unreference`` is aware @@ -465,14 +470,17 @@ proc setGodotObject*(nimObj: NimGodotObject, obj: ptr GodotObject) {.inline.} = proc setNativeObject*(nimObj: NimGodotObject, nativeObj: NimGodotObject) {.inline.} = ## Used from Godot constructor produced by ``gdobj`` macro. Do not call. - nimObj.linkedObject = nativeObj - nativeObj.linkedObject = nimObj + GC_ref(nativeObj) + nimObj.linkedObjectPtr = cast[pointer](nativeObj) + nativeObj.linkedObjectPtr = cast[pointer](nimObj) nativeObj.isNative = true proc removeGodotObject*(nimObj: NimGodotObject) {.inline.} = ## Used from Godot destructor produced by ``gdobj`` macro. Do not call. + GC_unref(nimObj.linkedObject) nimObj.godotObject = nil nimObj.linkedObject.godotObject = nil + nimObj.linkedObjectPtr = nil proc `==`*(self, other: NimGodotObject): bool {.inline.} = ## Compares objects by referential equality. From d3e5f91b403cb1cabc3d2f298b2c6ffc994493e4 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Fri, 14 Aug 2020 01:44:48 +0700 Subject: [PATCH 77/82] Fix wrapping methods with Array return types --- godot.nimble | 2 +- godot/godotapigen.nim | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index 817406d..a296063 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.8.0" +version = "0.8.1" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/godotapigen.nim b/godot/godotapigen.nim index 432814e..ccbcc6c 100644 --- a/godot/godotapigen.nim +++ b/godot/godotapigen.nim @@ -642,6 +642,8 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], body.add(newPNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("Godot" & returnType), ))) + if returnType != "NodePath": + body.add(newCall("initGodot" & returnType, retValIdent)) elif returnType in standardTypes: addrToAssign = newCall("addr", ident("result")) elif returnType == "string": From f25c3c7a5dbe2b6ac8e4a3407e5c03751658e401 Mon Sep 17 00:00:00 2001 From: ShalokShalom Date: Sun, 11 Oct 2020 23:17:11 +0200 Subject: [PATCH 78/82] Clarify version compability One guy in the chat just asked me, if this binding is for 3.0 only, or also for 3.2.3 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index db27270..62e28d3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Nim bindings for Godot Engine -Nim bindings for Godot 3.0 based on [GDNative](https://godotengine.org/article/dlscript-here). +Nim bindings for Godot 3 based on [GDNative](https://godotengine.org/article/dlscript-here). Documentation: https://pragmagic.github.io/godot-nim/ @@ -13,4 +13,4 @@ Documentation: https://pragmagic.github.io/godot-nim/ This project is licensed under the MIT license. Read [LICENSE](LICENSE) file for details. -Copyright (c) 2018 Xored Software, Inc. \ No newline at end of file +Copyright (c) 2018 Xored Software, Inc. From 388bea92053593646518946f6abc1001aea77702 Mon Sep 17 00:00:00 2001 From: Arun Dilipan Date: Mon, 23 Nov 2020 11:29:03 -0500 Subject: [PATCH 79/82] Added moveToward for vectors. --- godot/core/vector2.nim | 12 ++++++++++++ godot/core/vector3.nim | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/godot/core/vector2.nim b/godot/core/vector2.nim index 01c0312..390f1f6 100644 --- a/godot/core/vector2.nim +++ b/godot/core/vector2.nim @@ -5,6 +5,8 @@ import math, godotbase, hashes import internal/godotinternaltypes, internal/godotstrings import godotcoretypes, gdnativeapi +const EPSILON = 0.00001'f32 + {.push stackTrace: off.} proc vec2*(): Vector2 {.inline, noinit.} = @@ -199,4 +201,14 @@ proc clamped*(self: Vector2; length: float32): Vector2 {.noinit.} = result /= len result *= length +proc moveToward*(vFrom, to: Vector2, delta: float32): Vector2 = + let + vd = to - vFrom + vLen = vd.length + + if vLen <= delta or vLen < EPSILON: + result = to + else: + result = vFrom + (vd / vLen) * delta + {.pop.} # stackTrace: off diff --git a/godot/core/vector3.nim b/godot/core/vector3.nim index 16f2f04..ed2903a 100644 --- a/godot/core/vector3.nim +++ b/godot/core/vector3.nim @@ -3,6 +3,8 @@ import math, hashes import godotbase, godotcoretypes +const EPSILON = 0.00001'f32 + {.push stackTrace: off.} proc vec3*(): Vector3 {.inline.} = @@ -239,4 +241,14 @@ proc cubicInterpolate*(self, b, preA, postB: Vector3; (2.0 * p0 - 5.0 * p1 + 4 * p2 - p3) * t2 + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3) +proc moveToward*(vFrom, to: Vector3, delta: float32): Vector3 = + let + vd = to - vFrom + vLen = vd.length + + if vLen <= delta or vLen < EPSILON: + result = to + else: + result = vFrom + (vd / vLen) * delta + {.pop.} # stackTrace: off \ No newline at end of file From 00d8ac2691140edc610245fa56f28abea6572ec5 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 9 Mar 2021 01:57:51 -0700 Subject: [PATCH 80/82] Support nim case insensitivy in pragmas --- godot/nim/godotmacros.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/godot/nim/godotmacros.nim b/godot/nim/godotmacros.nim index d6efa6d..6b81f7e 100644 --- a/godot/nim/godotmacros.nim +++ b/godot/nim/godotmacros.nim @@ -94,7 +94,7 @@ proc removePragmaNode(statement: NimNode, var pragmas = if RoutineNodes.contains(statement.kind): statement.pragma() else: statement[1] for ident, val, i in pragmas(pragmas): - if ident == pname: + if ident.eqIdent(pname): pragmas.del(i) return val @@ -106,7 +106,7 @@ proc removePragma(statement: NimNode, pname: string): bool = var pragmas = if RoutineNodes.contains(statement.kind): statement.pragma() else: statement[1] for ident, val, i in pragmas(pragmas): - if ident == pname: + if ident.eqIdent(pname): pragmas.del(i) return true From 7eadb07820a424c14a9474113ad3c0ee019c7334 Mon Sep 17 00:00:00 2001 From: Joey Date: Mon, 3 May 2021 10:01:38 -0600 Subject: [PATCH 81/82] Move template below arrays import Fixes #81 Alternate workaround for https://github.com/nim-lang/Nim/issues/16462 without changing VariantType. --- godot/core/poolarrays.nim | 48 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/godot/core/poolarrays.nim b/godot/core/poolarrays.nim index eac4cf4..29fda96 100644 --- a/godot/core/poolarrays.nim +++ b/godot/core/poolarrays.nim @@ -35,6 +35,30 @@ template definePoolArrayBase(T, GodotT, DataT, fieldName, newProcName, (when type(item) is GodotString: ($item).hash() else: item.hash()) result = !$result +definePoolArrayBase(PoolByteArray, GodotPoolByteArray, uint8, + godotPoolByteArray, newPoolByteArray, + initGodotPoolByteArray) +definePoolArrayBase(PoolIntArray, GodotPoolIntArray, cint, + godotPoolIntArray, newPoolIntArray, + initGodotPoolIntArray) +definePoolArrayBase(PoolRealArray, GodotPoolRealArray, float32, + godotPoolRealArray, newPoolRealArray, + initGodotPoolRealArray) +definePoolArrayBase(PoolVector2Array, GodotPoolVector2Array, Vector2, + godotPoolVector2Array, newPoolVector2Array, + initGodotPoolVector2Array) +definePoolArrayBase(PoolVector3Array, GodotPoolVector3Array, Vector3, + godotPoolVector3Array, newPoolVector3Array, + initGodotPoolVector3Array) +definePoolArrayBase(PoolColorArray, GodotPoolColorArray, Color, + godotPoolColorArray, newPoolColorArray, + initGodotPoolColorArray) +definePoolArrayBase(PoolStringArray, GodotPoolStringArray, string, + godotPoolStringArray, newPoolStringArray, + initGodotPoolStringArray) + +import arrays + template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName; noData = false) = @@ -92,30 +116,6 @@ template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName; for pair in arr.fieldName.mpairs: yield (pair[0].int, pair[1]) -definePoolArrayBase(PoolByteArray, GodotPoolByteArray, uint8, - godotPoolByteArray, newPoolByteArray, - initGodotPoolByteArray) -definePoolArrayBase(PoolIntArray, GodotPoolIntArray, cint, - godotPoolIntArray, newPoolIntArray, - initGodotPoolIntArray) -definePoolArrayBase(PoolRealArray, GodotPoolRealArray, float32, - godotPoolRealArray, newPoolRealArray, - initGodotPoolRealArray) -definePoolArrayBase(PoolVector2Array, GodotPoolVector2Array, Vector2, - godotPoolVector2Array, newPoolVector2Array, - initGodotPoolVector2Array) -definePoolArrayBase(PoolVector3Array, GodotPoolVector3Array, Vector3, - godotPoolVector3Array, newPoolVector3Array, - initGodotPoolVector3Array) -definePoolArrayBase(PoolColorArray, GodotPoolColorArray, Color, - godotPoolColorArray, newPoolColorArray, - initGodotPoolColorArray) -definePoolArrayBase(PoolStringArray, GodotPoolStringArray, string, - godotPoolStringArray, newPoolStringArray, - initGodotPoolStringArray) - -import arrays - definePoolArray(PoolByteArray, GodotPoolByteArray, uint8, godotPoolByteArray, newPoolByteArray, initGodotPoolByteArray) From 4175dbb3e50d09341ae61cfa55907f40e9eb388b Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 3 May 2021 23:18:50 +0700 Subject: [PATCH 82/82] Bump version to 0.8.2 --- godot.nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot.nimble b/godot.nimble index a296063..d7ca12b 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.8.1" +version = "0.8.2" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT"