From f5769045fc136706ec09ead8a63e0ec7e32c4285 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Fri, 28 Jul 2017 00:28:17 +0700 Subject: [PATCH] No destructors --- godot/apigen/apigen.nim | 75 +-- godot/core/arrays.nim | 216 +++++---- godot/core/basis.nim | 2 +- godot/core/{color.nim => colors.nim} | 31 +- godot/core/dictionaries.nim | 93 ++++ godot/core/dictionary.nim | 89 ---- godot/core/godotbase.nim | 114 ++--- godot/core/nodepath.nim | 51 --- godot/core/nodepaths.nim | 69 +++ godot/core/{plane.nim => planes.nim} | 5 +- godot/core/poolarray.nim | 430 ------------------ godot/core/poolarrays.nim | 126 +++++ godot/core/{quat.nim => quats.nim} | 31 +- godot/core/rect2.nim | 7 +- godot/core/rect3.nim | 8 +- godot/core/{rid.nim => rids.nim} | 2 + godot/core/transform2d.nim | 10 +- godot/core/{transform.nim => transforms.nim} | 7 +- godot/core/variant.nim | 269 ----------- godot/core/variants.nim | 251 ++++++++++ godot/core/vector2.nim | 7 +- godot/core/vector3.nim | 2 +- godot/godot.nim | 17 +- .../{core/godotcore.nim => godotinternal.nim} | 58 ++- godot/internal/godotarrays.nim | 115 +++++ godot/internal/godotdictionaries.nim | 48 ++ godot/internal/godotinternaltypes.nim | 8 + godot/internal/godotnodepaths.nim | 32 ++ godot/internal/godotpoolarrays.nim | 376 +++++++++++++++ .../strings.nim => internal/godotstrings.nim} | 20 - godot/internal/godotvariants.nim | 190 ++++++++ godot/nim/godotmacros.nim | 56 +-- godot/nim/godotnim.nim | 100 ++-- godot/nimruntime.nim | 2 +- 34 files changed, 1701 insertions(+), 1216 deletions(-) rename godot/core/{color.nim => colors.nim} (68%) create mode 100644 godot/core/dictionaries.nim delete mode 100644 godot/core/dictionary.nim delete mode 100644 godot/core/nodepath.nim create mode 100644 godot/core/nodepaths.nim rename godot/core/{plane.nim => planes.nim} (97%) delete mode 100644 godot/core/poolarray.nim create mode 100644 godot/core/poolarrays.nim rename godot/core/{quat.nim => quats.nim} (75%) rename godot/core/{rid.nim => rids.nim} (93%) rename godot/core/{transform.nim => transforms.nim} (94%) delete mode 100644 godot/core/variant.nim create mode 100644 godot/core/variants.nim rename godot/{core/godotcore.nim => godotinternal.nim} (84%) create mode 100644 godot/internal/godotarrays.nim create mode 100644 godot/internal/godotdictionaries.nim create mode 100644 godot/internal/godotinternaltypes.nim create mode 100644 godot/internal/godotnodepaths.nim create mode 100644 godot/internal/godotpoolarrays.nim rename godot/{core/strings.nim => internal/godotstrings.nim} (76%) create mode 100644 godot/internal/godotvariants.nim diff --git a/godot/apigen/apigen.nim b/godot/apigen/apigen.nim index 85f00a1..4b9ec5b 100644 --- a/godot/apigen/apigen.nim +++ b/godot/apigen/apigen.nim @@ -104,12 +104,6 @@ proc postfix(left: PNode, op: string): PNode = result.add(ident(op)) result.add(left) -proc newExprColonExpr(key, value: PNode): PNode = - newNode(nkExprColonExpr).addChain(key, value) - -proc pragma(key: PNode, value: PNode): PNode = - newNode(nkPragma).addChain(key, value) - proc newBracketExpr(first, bracket: PNode): PNode = newNode(nkBracketExpr).addChain(first, bracket) @@ -263,9 +257,9 @@ const standardTypes = toSet( "uint64", "int64", "float32", "cfloat", "float64", "GodotString", "Vector2", "Rect2", "Vector3", "Transform2D", "Plane", "Quat", "Rect3", "Basis", "Transform", - "Color", "NodePath", "RID", "Dictionary", "Array", "PoolByteArray", - "PoolIntArray", "PoolRealArray", "PoolStringArray", "PoolVector2Array", - "PoolVector3Array", "PoolColorArray", "Variant"]) + "Color", "RID", "NodePath", "Dictionary", "Variant", "Array", + "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray", + "PoolVector2Array", "PoolVector3Array", "PoolColorArray"]) const smallIntTypes = toSet(["uint8", "int8", "uint16", "int16", "uint32", "int32", "cint", "int", "Error"]) @@ -277,6 +271,12 @@ const floatTypes = union(float64Types, float32Types) const arrayTypes = toSet(["Array", "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray", "PoolVector2Array", "PoolVector3Array", "PoolColorArray"]) +const wrapperTypes = union(arrayTypes, + toSet(["NodePath", "Dictionary", "Variant"])) + +proc getInternalPtr(varName: PNode, typ: string): PNode = + assert(typ in wrapperTypes) + result = newDotExpr(varName, ident("godot" & typ)) proc newNilCheck(ident, toAssign: PNode): PNode = newIfStmt(newCall("isNil", ident), @@ -301,7 +301,7 @@ proc makeDefaultValue(arg: MethodArg): PNode = result = newFloatLit(parseFloat(arg.defaultVal.str)) elif arg.defaultVal.str == "Null": if arg.typ == "Variant": - result = newCall("variant") + result = newCall("newVariant") else: result = newNilLit() elif arg.typ == "Color": @@ -376,7 +376,8 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], newNode(nkPtrTy).addChain( newNode(nkBracketExpr).addChain( ident("array"), ident("MAX_ARG_COUNT"), - if isVarargs: ident("Variant") else: ident("pointer")))) + if isVarargs: newNode(nkPtrTy).addChain(ident("GodotVariant")) + else: ident("pointer")))) staticArgsLen = if varargsName.isNil: args.len else: args.len - 1 if not varargsName.isNil: @@ -407,7 +408,10 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], newInfix(ident("idx"), ident("-"), newIntLit(staticArgsLen))) let argIdx = if arg.isVarargs: ident("idx") else: newIntLit(idx) let isStandardType = arg.typ in standardTypes - let convArg = if not varargsName.isNil: newCall("toGodot", argName) + let isWrappedType = arg.typ in wrapperTypes + let convArg = if not varargsName.isNil: + getInternalPtr(newCall("toGodot", argName), "Variant") + elif isWrappedType: getInternalPtr(argName, arg.typ) elif isStandardType: newCall("unsafeAddr", argName) elif arg.typ == "string": newCall("unsafeAddr", ident("argToPassToGodot" & $idx)) @@ -418,7 +422,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], [arg.typ, godotMethodName, typ.godotName]) if not isStandardType and varargsName.isNil: if arg.typ == "string": - argConversions.add(newNode(nkLetSection).addChain( + argConversions.add(newNode(nkVarSection).addChain( newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(), newCall("toGodotString", argName)))) else: @@ -465,11 +469,6 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], body.add(newNode(nkLetSection).addChain(newIdentDefs( ident("self"), newNode(nkEmpty), varName ))) - if not varargsName.isNil: - body.add( - pragma(ident("push"), newExprColonExpr( - newBracketExpr(ident("warning"), ident("Destructor")), - ident("off")))) body.add(nilCheck) body.add(vars) body.add(argConversions) @@ -482,9 +481,10 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], var isConversionRet: bool var isObjRet: bool var isStringRet: bool + var isWrapperRet: bool let retValIdent = if not isVarargs: ident("ptrCallVal") else: ident(retName) - if not returnType.isNil and varargsName.isNil: - var addrToAssign = newCall("addr", ident("ptrCallVal")) + if not returnType.isNil and not isVarargs: + var addrToAssign = newCall("addr", retValIdent) if returnType in smallIntTypes: isConversionRet = true body.add(newNode(nkVarSection).addChain(newIdentDefs( @@ -495,6 +495,11 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], body.add(newNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("float64"), ))) + elif returnType in wrapperTypes: + isWrapperRet = true + body.add(newNode(nkVarSection).addChain(newIdentDefs( + retValIdent, ident("Godot" & returnType), + ))) elif returnType in standardTypes: addrToAssign = newCall("addr", ident("result")) elif returnType == "string": @@ -520,9 +525,12 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], ident(retName), newNode(nkPragma).addChain(ident("used"))), newNode(nkEmpty), theCall)) body.add(callStmt) - # if not returnType.isNil and not varargsName.isNil: - # body.add(newCall("fromGodot", ident("result"), ident(retName))) - # body.add(newCall("deinit", ident(retName))) + + if varargsName.isNil: + for idx, arg in args: + if arg.typ == "string": + body.add(newCall("deinit", ident("argToPassToGodot" & $idx))) + if args.len > 0 and not varargsName.isNil: body.add(freeCall) if not varargsName.isNil: @@ -536,7 +544,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], if isVariantRet: let convErrDef = newNode(nkLetSection).addChain( newIdentDefs(ident("convErr"), newNode(nkEmpty), - newCall("fromGodot", ident("result"), retValIdent))) + newCall("fromGodot", ident("result"), newCall("newVariant", retValIdent)))) let convCheck = newIfStmt( newInfix(ident("convErr"), ident("!="), newDotExpr(ident("ConversionResult"), ident("OK"))), @@ -545,12 +553,16 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], ) body.add(convErrDef) body.add(convCheck) - if not isVarargs and (isVariantRet or isStringRet): - # varargs use call with "let" so destructor is invoked + if isStringRet: body.add(newCall("deinit", retValIdent)) elif isConversionRet: - body.add(newNode(nkAsgn).addChain(ident("result"), - newCall(returnType, retValIdent))) + body.add(newNode(nkAsgn).addChain( + ident("result"), + newCall(returnType, retValIdent))) + elif isWrapperRet: + body.add(newNode(nkAsgn).addChain( + ident("result"), + newCall("new" & returnType, retValIdent))) elif isObjRet: body.add(newNode(nkAsgn).addChain(ident("result"), newCall(newBracketExpr(ident("asNimGodotObject"), @@ -558,11 +570,6 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], elif isStringRet: body.add(newNode(nkAsgn).addChain(ident("result"), newCall("$", retValIdent))) - if not varargsName.isNil: - body.add( - pragma(ident("push"), newExprColonExpr( - newBracketExpr(ident("warning"), ident("Destructor")), - ident("on")))) let procType = if isVirtual: nkMethodDef else: nkProcDef @@ -770,7 +777,7 @@ proc genApi*(targetDir: string, apiJsonFile: string) = let importStmt = newNode(nkImportStmt) importStmt.add(ident("godot")) importStmt.add(ident("godottypes")) - importStmt.add(newDotExpr(ident("core"), ident("godotcore"))) + importStmt.add(ident("godotinternal")) tree.add(importStmt) let exportStmt = newNode(nkExportStmt) exportStmt.add(ident("godottypes")) diff --git a/godot/core/arrays.nim b/godot/core/arrays.nim index fcc065b..7f07a86 100644 --- a/godot/core/arrays.nim +++ b/godot/core/arrays.nim @@ -1,135 +1,127 @@ -# Copyright (c) 2017 Xored Software, Inc. +# Copyright 2017 Xored Software, Inc. import hashes -import godotbase, poolarray, variant, strings +import "../internal/godotinternaltypes.nim", "../internal/godotarrays.nim" -proc initArray(dest: var Array) {. - importc: "godot_array_new".} -proc initArray(dest: var Array; pca: PoolColorArray) {. - importc: "godot_array_new_pool_coloarray".} -proc initArray(dest: var Array; pv3a: PoolVector3Array) {. - importc: "godot_array_new_pool_vector3_array".} -proc initArray(dest: var Array; pv2a: PoolVector2Array) {. - importc: "godot_array_new_pool_vector2_array".} -proc initArray(dest: var Array; psa: PoolStringArray) {. - importc: "godot_array_new_pool_string_array".} -proc initArray(dest: var Array; pra: PoolRealArray) {. - importc: "godot_array_new_pool_real_array".} -proc initArray(dest: var Array; pia: PoolIntArray) {. - importc: "godot_array_new_pool_int_array".} -proc initArray(dest: var Array; pba: PoolByteArray) {. - importc: "godot_array_new_pool_byte_array".} +import godotbase, poolarrays -proc initArray*(): Array {.inline.} = - initArray(result) +proc arrayFinalizer(arr: Array) = + arr.godotArray[].deinit() -proc initArray*(pca: PoolColorArray): Array {.inline.} = - initArray(result, pca) +proc newArray*(): Array {.inline.} = + new(result, arrayFinalizer) + initGodotArray(result.godotArray[]) -proc initArray*(pv3a: PoolVector3Array): Array {.inline.} = - initArray(result, pv3a) +proc newArray*(arr: GodotArray): Array {.inline.} = + new(result, arrayFinalizer) + result.godotArray[] = arr -proc initArray*(pv2a: PoolVector2Array): Array {.inline.} = - initArray(result, pv2a) +proc newArray*(pca: PoolColorArray): Array {.inline.} = + new(result, arrayFinalizer) + initGodotArray(result.godotArray[], pca.godotPoolColorArray[]) -proc initArray*(psa: PoolStringArray): Array {.inline.} = - initArray(result, psa) +proc newArray*(pv3a: PoolVector3Array): Array {.inline.} = + new(result, arrayFinalizer) + initGodotArray(result.godotArray[], pv3a.godotPoolVector3Array[]) -proc initArray*(pra: PoolRealArray): Array {.inline.} = - initArray(result, pra) +proc newArray*(pv2a: PoolVector2Array): Array {.inline.} = + new(result, arrayFinalizer) + initGodotArray(result.godotArray[], pv2a.godotPoolVector2Array[]) -proc initArray*(pia: PoolIntArray): Array {.inline.} = - initArray(result, pia) +proc newArray*(psa: PoolStringArray): Array {.inline.} = + new(result, arrayFinalizer) + initGodotArray(result.godotArray[], psa.godotPoolStringArray[]) -proc initArray*(pba: PoolByteArray): Array {.inline.} = - initArray(result, pba) +proc newArray*(pra: PoolRealArray): Array {.inline.} = + new(result, arrayFinalizer) + initGodotArray(result.godotArray[], pra.godotPoolRealArray[]) -proc `[]=`*(self: var Array; idx: cint; - value: Variant) {. - noSideEffect, - importc: "godot_array_set".} -proc `[]`*(self: Array; idx: cint): Variant {. - noSideEffect, - importc: "godot_array_get".} -proc mget*(self: var Array; idx: cint): ptr Variant {. - importc: "godot_array_operator_index".} +proc newArray*(pia: PoolIntArray): Array {.inline.} = + new(result, arrayFinalizer) + initGodotArray(result.godotArray[], pia.godotPoolIntArray[]) -proc add*(self: var Array; value: Variant) {. - noSideEffect, - importc: "godot_array_append".} -proc clear*(self: var Array) {.importc: "godot_array_clear".} -proc count*(self: Array; value: Variant): cint {. - noSideEffect, - importc: "godot_array_count".} -proc isEmpty*(self: Array): bool {. - noSideEffect, - importc: "godot_array_empty".} -proc erase*(self: var Array; value: Variant) {. - importc: "godot_array_erase".} -proc first*(self: Array): Variant {. - noSideEffect, - importc: "godot_array_front".} -proc last*(self: Array): Variant {. - noSideEffect, - importc: "godot_array_back".} -proc find*(self: Array; what: Variant; - f: cint): cint {. - noSideEffect, - importc: "godot_array_find".} -proc findLast*(self: Array; what: Variant): cint {. - noSideEffect, - importc: "godot_array_find_last".} -proc contains*(self: Array; value: Variant): bool {. - noSideEffect, - importc: "godot_array_has".} +proc newArray*(pba: PoolByteArray): Array {.inline.} = + new(result, arrayFinalizer) + initGodotArray(result.godotArray[], pba.godotPoolByteArray[]) + +import variants + +proc `[]=`*(self: var 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.} = + self.godotArray[].add(value.godotVariant[]) + +proc clear*(self: var Array) {.inline.} = + self.godotArray[].clear() + +proc count*(self: Array; value: Variant): int {.inline.} = + self.godotArray[].count(value.godotVariant[]).int + +proc isEmpty*(self: Array): bool {.inline.} = + self.godotArray[].isEmpty() + +proc erase*(self: var Array; value: Variant) {.inline.} = + self.godotArray[].erase(value.godotVariant[]) + +proc first*(self: Array): Variant {.inline.} = + newVariant(self.godotArray[].first()) + +proc last*(self: Array): Variant {.inline.} = + newVariant(self.godotArray[].last()) + +proc find*(self: Array; what: Variant; f: int): int {.inline.} = + self.godotArray[].find(what.godotVariant[], f.cint).int + +proc findLast*(self: Array; what: Variant): int {.inline.} = + self.godotArray[].findLast(what.godotVariant[]).int + +proc contains*(self: Array; value: Variant): bool {.inline.} = + self.godotArray[].contains(value.godotVariant[]) -proc godotHash*(self: Array): cint {. - noSideEffect, - importc: "godot_array_hash".} proc hash*(self: Array): Hash {.inline.} = - hash(godotHash(self)) + hash(self.godotArray[].godotHash()) -proc insert*(self: var Array; pos: cint; - value: Variant) {. - importc: "godot_array_insert".} -proc reverse*(self: var Array) {.importc: "godot_array_invert".} -proc popLast*(self: var Array): Variant {. - importc: "godot_array_pop_back".} -proc popFirst*(self: var Array): Variant {. - importc: "godot_array_pop_front".} -proc addLast*(self: var Array; value: Variant) {. - importc: "godot_array_push_back".} -proc addFirst*(self: var Array; value: Variant) {. - importc: "godot_array_push_front".} +proc insert*(self: var Array; pos: int; value: Variant) {.inline.} = + self.godotArray[].insert(pos.cint, value.godotVariant[]) -proc delete*(self: var Array; idx: cint) {. - importc: "godot_array_remove".} -proc setLen*(self: var Array; size: cint) {. - importc: "godot_array_resize".} -proc rfind*(self: Array; what: Variant; - f: cint): cint {. - noSideEffect, - importc: "godot_array_rfind".} -proc len*(self: Array): cint {. - noSideEffect, - importc: "godot_array_size".} -proc sort*(self: var Array) {.importc: "godot_array_sort".} -proc sortCustom*(self: var Array; obj: var GodotObject; - funcName: GodotString) {. - importc: "godot_array_sort_custom".} +proc reverse*(self: var Array) {.inline.} = + self.godotArray[].reverse() -iterator items*(arr: Array): Variant = +proc popLast*(self: var Array): Variant {.inline.} = + newVariant(self.godotArray[].popLast()) + +proc popFirst*(self: var Array): Variant {.inline.} = + newVariant(self.godotArray[].popFirst()) + +proc addLast*(self: var Array; value: Variant) {.inline.} = + self.godotArray[].addLast(value.godotVariant[]) + +proc addFirst*(self: var Array; value: Variant) {.inline.} = + self.godotArray[].addFirst(value.godotVariant[]) + +proc delete*(self: var Array; idx: int) {.inline.} = + self.godotArray[].delete(idx.cint) + +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 len*(self: Array): int {.inline.} = + self.godotArray[].len.int + +proc sort*(self: var Array) {.inline.} = + self.godotArray[].sort() + +iterator items*(arr: Array): Variant {.inline.} = for i in 0.. 2 and result[^2] == 'S' and result[^1] == 'W': + # There are physics type not known by ClassDB + result = result[0..result.len-3] diff --git a/godot/internal/godotarrays.nim b/godot/internal/godotarrays.nim new file mode 100644 index 0000000..c74a9ff --- /dev/null +++ b/godot/internal/godotarrays.nim @@ -0,0 +1,115 @@ +# Copyright (c) 2017 Xored Software, Inc. + +import hashes +import godotinternaltypes, 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 deinit*(self: var GodotArray) {.importc: "godot_array_destroy".} + +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 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".} + +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".} + +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 len*(self: GodotArray): cint {. + noSideEffect, + importc: "godot_array_size".} +proc sort*(self: var GodotArray) {.importc: "godot_array_sort".} +proc sortCustom*(self: var GodotArray; obj: var GodotObject; + funcName: GodotString) {. + importc: "godot_array_sort_custom".} + +iterator items*(arr: GodotArray): GodotVariant = + for i in 0..