diff --git a/.travis.yml b/.travis.yml index b0b27d4..d0b4bfa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,5 +49,6 @@ script: - set -e - mkdir godotapi - nim c -d:release -r godot/godotapigen.nim "$GODOT_BIN" godotapi - - nim c -d:useRealtimeGc --path:godot -c godotapi/godotall.nim + - nimble install -y + - nim c -d:useRealtimeGc -c godotapi/godotall.nim - nim c -d:release -r docs/docpublish.nim diff --git a/.vscode/settings.json b/.vscode/settings.json index 6960f9a..aa6f1c7 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 2018 Xored Software, Inc.\n\n", + "nim.licenseString": "# Copyright 2017 Xored Software, Inc.\n\n", "files.exclude": { "**/nimcache/**": true } diff --git a/LICENSE b/LICENSE index 07ecdb6..16a448a 100644 --- a/LICENSE +++ b/LICENSE @@ -2,7 +2,7 @@ godot-nim - Nim bindings for Godot Engine The MIT License -Copyright (c) 2018 Xored Software Inc. +Copyright (c) 2017 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 62e28d3..7c518a2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Nim bindings for Godot Engine +# 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 3 based on [GDNative](https://godotengine.org/article/dlscript-here). +Nim bindings for Godot 3.0 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. +Copyright (c) 2017 Xored Software, Inc. \ No newline at end of file diff --git a/docs/docbuild.nim b/docs/docbuild.nim index 477c45b..b48368d 100644 --- a/docs/docbuild.nim +++ b/docs/docbuild.nim @@ -1,4 +1,4 @@ -# Copyright 2018 Xored Software, Inc. +# Copyright 2017 Xored Software, Inc. import threadpool, os, osproc, strutils, sequtils, pegs @@ -71,7 +71,7 @@ proc fixupHrefs(file: string) = proc getGitHash(): string = result = execProcess("git rev-parse HEAD") - if result.len > 0: + if not result.isNil and result.len > 0: result = result.replace("\L", "").replace("\r", "") proc buildDocs*(outDir, godotNimDir, godotBin: string) = @@ -94,8 +94,7 @@ proc buildDocs*(outDir, godotNimDir, godotBin: string) = allNimFiles.add(file) for file in allNimFiles: spawn execOrFail( - "nim doc -d:useRealtimeGc --path:godot -o:" & - quoted(outName(outDirAbs, file)) & + "nim doc -o:" & quoted(outName(outDirAbs, file)) & " --git.url:" & quoted(gitHubUrl) & " --git.commit:" & quoted(gitCommit) & ' ' & quoted(file)) @@ -104,15 +103,14 @@ 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 -o:" & - quoted(outName(godotApiFolder, file)) & ' ' & quoted(file)) + spawn execOrFail("nim doc " & quoted(file)) sync() var gitHash: string withDir(godotBinAbs.parentDir()): gitHash = getGitHash() - if gitHash.len == 0: + if gitHash.isNil or gitHash.len == 0: raise newException(Exception, "Godot executable is not under Git repository") diff --git a/docs/docpublish.nim b/docs/docpublish.nim index e55974c..d682aec 100644 --- a/docs/docpublish.nim +++ b/docs/docpublish.nim @@ -1,4 +1,4 @@ -# Copyright 2018 Xored Software, Inc. +# Copyright 2017 Xored Software, Inc. import os, pegs, strutils import docbuild diff --git a/docs/index.rst b/docs/index.rst index e14d38d..bffe100 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -5,7 +5,6 @@ Nim bindings for Godot Engine :Author: Ruslan Mustakov :Version: |godotnimversion| :GitHub: `$GODOTNIM_GITHUB_URL <$GODOTNIM_GITHUB_URL>`_ -:License: MIT .. contents:: @@ -33,11 +32,25 @@ which adds features for editing GDScript and Godot resource files. Getting Started =============== -Getting Godot +Building Godot -------------- -The library requires Godot version 3.0, which you can get here: -https://godotengine.org/download +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 +`_. + Installing Nim ------------- @@ -50,7 +63,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 the existing stub: +The fastest way to set up a Godot-Nim project is to use an existing stub: .. code-block:: bash git clone --depth=1 https://github.com/pragmagic/godot-nim-stub.git myproject @@ -75,7 +88,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 ``nimlib.gdnlib`` to your Godot project folder. It is a +2. Copy ``project/nimlib.tres`` 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 d7ca12b..968dac3 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.8.2" +version = "0.6.9" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/core/aabb.nim b/godot/core/aabb.nim index 2d816da..5892081 100644 --- a/godot/core/aabb.nim +++ b/godot/core/aabb.nim @@ -1,9 +1,6 @@ -# Copyright (c) 2018 Xored Software, Inc. +# Copyright (c) 2017 Xored Software, Inc. -import hashes - -import vector3 -import internal/godotinternaltypes, internal/godotstrings +import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi proc initAABB*(pos, size: Vector3): AABB {.inline.} = @@ -12,9 +9,6 @@ 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) @@ -31,10 +25,10 @@ proc encloses*(self, other: AABB): bool {.inline.} = getGDNativeAPI().aabbEncloses(self, other) proc merge*(self, other: AABB): AABB {.inline.} = - getGDNativeAPI().aabbMerge(self, other).toAABB() + getGDNativeAPI().aabbMerge(self, other) proc intersection*(self, other: AABB): AABB {.inline.} = - getGDNativeAPI().aabbIntersection(self, other).toAABB() + getGDNativeAPI().aabbIntersection(self, other) proc intersectsPlane*(self: AABB; plane: Plane): bool {.inline.} = getGDNativeAPI().aabbIntersectsPlane(self, plane) @@ -46,10 +40,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).toVector3() + getGDNativeAPI().aabbGetSupport(self, dir) proc getLongestAxis*(self: AABB): Vector3 {.inline.} = - getGDNativeAPI().aabbGetLongestAxis(self).toVector3() + getGDNativeAPI().aabbGetLongestAxis(self) proc getLongestAxisIndex*(self: AABB): cint {.inline.} = getGDNativeAPI().aabbGetLongestAxisIndex(self) @@ -58,7 +52,7 @@ proc getLongestAxisSize*(self: AABB): float32 {.inline.} = getGDNativeAPI().aabbGetLongestAxisSize(self) proc getShortestAxis*(self: AABB): Vector3 {.inline.} = - getGDNativeAPI().aabbGetShortestAxis(self).toVector3() + getGDNativeAPI().aabbGetShortestAxis(self) proc getShortestAxisIndex*(self: AABB): cint {.inline.} = getGDNativeAPI().aabbGetShortestAxisIndex(self) @@ -67,13 +61,13 @@ proc getShortestAxisSize*(self: AABB): float32 {.inline.} = getGDNativeAPI().aabbGetShortestAxisSize(self) proc expand*(self: AABB; toPoint: Vector3): AABB {.inline.} = - getGDNativeAPI().aabbExpand(self, toPoint).toAABB() + getGDNativeAPI().aabbExpand(self, toPoint) proc grow*(self: AABB; by: float32): AABB {.inline.} = - getGDNativeAPI().aabbGrow(self, by).toAABB() + getGDNativeAPI().aabbGrow(self, by) proc getEndpoint*(self: AABB; idx: cint): Vector3 {.inline.} = - getGDNativeAPI().aabbGetEndpoint(self, idx).toVector3() + getGDNativeAPI().aabbGetEndpoint(self, idx) proc `==`*(a, b: AABB): bool {.inline.} = getGDNativeAPI().aabbOperatorEqual(a, b) diff --git a/godot/core/arrays.nim b/godot/core/arrays.nim index fcbafb2..414ac99 100644 --- a/godot/core/arrays.nim +++ b/godot/core/arrays.nim @@ -1,7 +1,7 @@ -# Copyright 2018 Xored Software, Inc. +# Copyright 2017 Xored Software, Inc. import hashes -import internal/godotinternaltypes, internal/godotarrays +import internal.godotinternaltypes, internal.godotarrays type Array* = ref object @@ -62,16 +62,16 @@ proc newArray*(pba: PoolByteArray): Array {.inline.} = new(result, arrayFinalizer) initGodotArray(result.godotArray, pba.godotPoolByteArray[]) -proc `[]=`*(self: Array; idx: int; value: Variant) {.inline.} = +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: Array; value: Variant) {.inline.} = +proc add*(self: var Array; value: Variant) {.inline.} = self.godotArray.add(value.godotVariant[]) -proc clear*(self: Array) {.inline.} = +proc clear*(self: var 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: Array; value: Variant) {.inline.} = +proc erase*(self: var 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: Array; pos: int; value: Variant) {.inline.} = +proc insert*(self: var Array; pos: int; value: Variant) {.inline.} = self.godotArray.insert(pos.cint, value.godotVariant[]) -proc reverse*(self: Array) {.inline.} = +proc reverse*(self: var Array) {.inline.} = self.godotArray.reverse() -proc popLast*(self: Array): Variant {.inline.} = +proc popLast*(self: var Array): Variant {.inline.} = newVariant(self.godotArray.popLast()) -proc popFirst*(self: Array): Variant {.inline.} = +proc popFirst*(self: var Array): Variant {.inline.} = newVariant(self.godotArray.popFirst()) -proc addLast*(self: Array; value: Variant) {.inline.} = +proc addLast*(self: var Array; value: Variant) {.inline.} = self.godotArray.addLast(value.godotVariant[]) -proc addFirst*(self: Array; value: Variant) {.inline.} = +proc addFirst*(self: var Array; value: Variant) {.inline.} = self.godotArray.addFirst(value.godotVariant[]) -proc delete*(self: Array; idx: int) {.inline.} = +proc delete*(self: var Array; idx: int) {.inline.} = self.godotArray.delete(idx.cint) -proc setLen*(self: Array; size: int) {.inline.} = +proc setLen*(self: var 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: Array) {.inline.} = +proc sort*(self: var Array) {.inline.} = self.godotArray.sort() iterator items*(self: Array): Variant = diff --git a/godot/core/basis.nim b/godot/core/basis.nim index 704f666..6f7e9d9 100644 --- a/godot/core/basis.nim +++ b/godot/core/basis.nim @@ -1,12 +1,9 @@ -# Copyright (c) 2018 Xored Software, Inc. - -import math, hashes +# Copyright (c) 2017 Xored Software, Inc. +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 @@ -202,9 +199,6 @@ 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] @@ -455,5 +449,3 @@ 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/colors.nim b/godot/core/colors.nim index 8e01b7a..dedb1a2 100644 --- a/godot/core/colors.nim +++ b/godot/core/colors.nim @@ -1,6 +1,4 @@ -# Copyright (c) 2018 Xored Software, Inc. - -import hashes +# Copyright (c) 2017 Xored Software, Inc. import godotcoretypes, gdnativeapi @@ -35,9 +33,6 @@ 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] @@ -64,16 +59,16 @@ proc gray*(self: Color): float32 {.inline.} = getGDNativeAPI().colorGray(self) proc inverted*(self: Color): Color {.inline.} = - getGDNativeAPI().colorInverted(self).toColor() + getGDNativeAPI().colorInverted(self) proc contrasted*(self: Color): Color {.inline.} = - getGDNativeAPI().colorContrasted(self).toColor() + getGDNativeAPI().colorContrasted(self) proc lerp*(self: Color; b: Color; t: float32): Color {.inline.} = - getGDNativeAPI().colorLinearInterpolate(self, b, t).toColor() + getGDNativeAPI().colorLinearInterpolate(self, b, t) proc blend*(self: Color; over: Color): Color {.inline.} = - getGDNativeAPI().colorBlend(self, over).toColor() + 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 3aea17a..5445d27 100644 --- a/godot/core/dictionaries.nim +++ b/godot/core/dictionaries.nim @@ -1,8 +1,8 @@ -# Copyright 2018 Xored Software, Inc. +# Copyright 2017 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 @@ -30,12 +30,9 @@ proc len*(self: Dictionary): int {.inline.} = proc isEmpty*(self: Dictionary): bool {.inline.} = self.godotDictionary.isEmpty() -proc clear*(self: Dictionary) {.inline.} = +proc clear*(self: var Dictionary) {.inline.} = self.godotDictionary.clear() -proc hash*(self: Dictionary): Hash {.inline.} = - hash(self.godotDictionary.godotHash()) - import variants, arrays proc newVariant*(dict: Dictionary): Variant {.inline.} = @@ -43,7 +40,7 @@ proc newVariant*(dict: Dictionary): Variant {.inline.} = initGodotVariant(result.godotVariant[], dict.godotDictionary) proc asDictionary*(self: Variant): Dictionary {.inline.} = - newDictionary(self.godotVariant[].asGodotDictionary()) + newDictionary(self.godotVariant[].asGodotDictionary) proc contains*(self: Dictionary; key: Variant): bool {.inline.}= self.godotDictionary.contains(key.godotVariant[]) @@ -51,9 +48,12 @@ proc contains*(self: Dictionary; key: Variant): bool {.inline.}= proc contains*(self: Dictionary; keys: Array): bool {.inline.} = self.godotDictionary.contains(keys.godotArray[]) -proc del*(self: Dictionary; key: Variant) {.inline.} = +proc del*(self: var 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()) @@ -71,7 +71,7 @@ proc `[]`*(self: Dictionary; keyStr: string): Variant {.inline.} = godotStr.deinit() godotVariant.deinit() -proc `[]=`*(self: Dictionary; key, value: Variant) {.inline.} = +proc `[]=`*(self: var Dictionary; key, value: Variant) {.inline.} = self.godotDictionary[key.godotVariant[]] = value.godotVariant[] proc `==`*(self, other: Dictionary): bool {.inline.} = diff --git a/godot/core/godotbase.nim b/godot/core/godotbase.nim index 7b5b804..0f410b8 100644 --- a/godot/core/godotbase.nim +++ b/godot/core/godotbase.nim @@ -1,64 +1,30 @@ -# Copyright (c) 2018 Xored Software, Inc. +# Copyright (c) 2017 Xored Software, Inc. -import math, godotinternal +import math # math helpers -{.push stackTrace: off.} const EPSILON = 0.00001'f32 -proc isEqualApprox*(a, b: float32): bool {.inline, noinit.} = +proc isEqualApprox*(a, b: float32): bool {.inline.} = abs(a - b) < EPSILON -proc isEqualApprox*(a, b: float64): bool {.inline, noinit.} = +proc isEqualApprox*(a, b: float64): bool {.inline.} = abs(a - b) < EPSILON -proc sign*(a: float32): float32 {.inline, noinit.} = +proc sign*(a: float32): float32 {.inline.} = if a < 0: -1.0'f32 else: 1.0'f32 -proc sign*(a: float64): float64 {.inline, noinit.} = +proc sign*(a: float64): float64 {.inline.} = if a < 0: -1.0'f64 else: 1.0'f64 -proc stepify*(value, step: float64): float64 {.inline, noinit.} = +proc stepify*(value, step: float64): float64 = if step != 0'f64: floor(value / step + 0.5'f64) * step else: value -proc stepify*(value, step: float32): float32 {.inline, noinit.} = +proc stepify*(value, step: float32): float32 = if step != 0'f32: floor(value / step + 0.5'f32) * step else: value - -when (NimMajor, NimMinor, NimPatch) < (0, 20, 4): - # Newer Nim has these procs in system module - - 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 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 instInfo = instantiationInfo() - godotPrintError(cstring($error), cstring"", cstring(instInfo.filename), instInfo.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/godotcoretypes.nim b/godot/core/godotcoretypes.nim index c4c4b71..cc5da9e 100644 --- a/godot/core/godotcoretypes.nim +++ b/godot/core/godotcoretypes.nim @@ -1,4 +1,4 @@ -# Copyright 2018 Xored Software, Inc. +# Copyright 2017 Xored Software, Inc. type Color* {.byref.} = object diff --git a/godot/core/nodepaths.nim b/godot/core/nodepaths.nim index bf690d7..537d93e 100644 --- a/godot/core/nodepaths.nim +++ b/godot/core/nodepaths.nim @@ -1,9 +1,7 @@ -# Copyright 2018 Xored Software, Inc. +# Copyright 2017 Xored Software, Inc. -import hashes - -import internal/godotinternaltypes, internal/godotnodepaths, - internal/godotstrings +import internal.godotinternaltypes, internal.godotnodepaths, + internal.godotstrings type NodePath* = ref object @@ -34,9 +32,6 @@ 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 2d15c79..99dd652 100644 --- a/godot/core/planes.nim +++ b/godot/core/planes.nim @@ -1,10 +1,8 @@ -# Copyright (c) 2018 Xored Software, Inc. - -import hashes +# Copyright (c) 2017 Xored Software, Inc. import vector3 -import internal/godotinternaltypes, internal/godotstrings +import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi proc initPlane*(a, b, c, d: float32): Plane {.inline.} = @@ -22,17 +20,14 @@ 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).toPlane() + getGDNativeAPI().planeNormalized(self) proc center*(self: Plane): Vector3 {.inline.} = - getGDNativeAPI().planeCenter(self).toVector3() + getGDNativeAPI().planeCenter(self) proc getAnyPoint*(self: Plane): Vector3 {.inline.} = - getGDNativeAPI().planeGetAnyPoint(self).toVector3() + getGDNativeAPI().planeGetAnyPoint(self) proc isPointOver*(self: Plane; point: Vector3): bool {.inline.} = getGDNativeAPI().planeIsPointOver(self, point) @@ -45,7 +40,7 @@ proc contains*(self: Plane; point: Vector3; getGDNativeAPI().planeHasPoint(self, point, epsilon) proc project*(self: Plane; point: Vector3): Vector3 {.inline.} = - getGDNativeAPI().planeProject(self, point).toVector3() + getGDNativeAPI().planeProject(self, point) proc intersect3*(self: Plane; dest: var Vector3; b, c: Plane): bool {.inline.} = @@ -60,7 +55,7 @@ proc intersectsSegment*(self: Plane; dest: var Vector3; getGDNativeAPI().planeIntersectsSegment(self, dest, segmentBegin, segmentEnd) proc `-`*(self: Plane): Plane {.inline.} = - getGDNativeAPI().planeOperatorNeg(self).toPlane() + 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 29fda96..dd3f544 100644 --- a/godot/core/poolarrays.nim +++ b/godot/core/poolarrays.nim @@ -1,11 +1,8 @@ -# Copyright 2018 Xored Software, Inc. - -import hashes +# Copyright 2017 Xored Software, Inc. import godotcoretypes -import internal/godotinternaltypes, internal/godotpoolarrays, - internal/godotstrings -import vector2, vector3, colors +import internal.godotinternaltypes, internal.godotpoolarrays, + internal.godotstrings template definePoolArrayBase(T, GodotT, DataT, fieldName, newProcName, initProcName) = @@ -29,11 +26,48 @@ 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) = + + proc newProcName*(arr: Array): T {.inline.} = + new(result, poolArrayFinalizer) + initProcName(result.fieldName, arr.godotArray[]) + + proc add*(self: var T; arr: T) {.inline.} = + self.fieldName.add(arr.fieldName) + + proc delete*(self: var T; idx: int) {.inline.} = + self.fieldName.delete(idx.cint) + + proc reverse*(self: var T) {.inline.} = + self.fieldName.reverse() + + proc setLen*(self: var 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.} = + self.fieldName.add(data) + + proc insert*(self: var T; idx: int; data: DataT): Error {.inline.} = + self.fieldName.insert(idx.cint, data) + + proc `[]=`*(self: var T; idx: int; data: DataT) {.inline.} = + self.fieldName[idx.cint] = data + + proc `[]`*(self: T; idx: int): DataT {.inline.} = + self.fieldName[idx.cint] + + iterator items*(arr: T): DataT = + for i in 0..= 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) - - proc insert*(self: T; idx: int; data: DataT): Error {.inline.} = - self.fieldName.insert(idx.cint, data) - - proc `[]=`*(self: T; idx: int; data: DataT) {.inline.} = - self.fieldName[idx.cint] = data - - proc `[]`*(self: T; idx: int): DataT {.inline.} = - self.fieldName[idx.cint] - - iterator items*(arr: T): DataT = - for item in arr.fieldName.items: - yield item - - iterator pairs*(arr: T): tuple[key: int, val: DataT] = - for pair in arr.fieldName.pairs: - yield (pair[0].int, pair[1]) - - iterator mitems*(arr: T): var DataT = - for item in arr.fieldName.mitems: - yield item - - iterator mpairs*(arr: T): tuple[key: int, val: var DataT] = - for pair in arr.fieldName.mpairs: - yield (pair[0].int, pair[1]) - definePoolArray(PoolByteArray, GodotPoolByteArray, uint8, godotPoolByteArray, newPoolByteArray, initGodotPoolByteArray) definePoolArray(PoolIntArray, GodotPoolIntArray, cint, godotPoolIntArray, newPoolIntArray, initGodotPoolIntArray) -definePoolArray(PoolRealArray, GodotPoolRealArray, float32, +definePoolArray(PoolRealArray, GodotPoolRealArray, float64, godotPoolRealArray, newPoolRealArray, initGodotPoolRealArray) definePoolArray(PoolVector2Array, GodotPoolVector2Array, Vector2, @@ -138,17 +115,17 @@ definePoolArray(PoolStringArray, GodotPoolStringArray, string, godotPoolStringArray, newPoolStringArray, initGodotPoolStringArray, true) -proc add*(self: PoolStringArray; data: string) = +proc add*(self: var PoolStringArray; data: string) = var s = data.toGodotString() self.godotPoolStringArray.add(s) s.deinit() -proc insert*(self: PoolStringArray; idx: int; data: string): Error = +proc insert*(self: var PoolStringArray; idx: int; data: string): Error = var s = data.toGodotString() result = self.godotPoolStringArray.insert(idx.cint, s) s.deinit() -proc `[]=`*(self: PoolStringArray; idx: int; data: string) = +proc `[]=`*(self: var PoolStringArray; idx: int; data: string) = var s = data.toGodotString() self.godotPoolStringArray[idx.cint] = s s.deinit() diff --git a/godot/core/quats.nim b/godot/core/quats.nim index db88b10..ea8cad4 100644 --- a/godot/core/quats.nim +++ b/godot/core/quats.nim @@ -1,8 +1,6 @@ -# Copyright (c) 2018 Xored Software, Inc. +# Copyright (c) 2017 Xored Software, Inc. -import hashes - -import internal/godotinternaltypes, internal/godotstrings +import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi proc initQuat*(x, y, z, w: float32): Quat {.inline.} = @@ -19,9 +17,6 @@ proc initQuat*(axis: Vector3; angle: float32): Quat {.inline.} = proc `$`*(self: Quat): string {.inline.} = $getGDNativeAPI().quatAsString(self) -proc hash*(self: Quat): Hash {.inline.} = - !$(self.x.hash() !& self.y.hash() !& self.z.hash() !& self.w.hash()) - proc length*(self: Quat): float32 {.inline.} = getGDNativeAPI().quatLength(self) @@ -29,50 +24,50 @@ proc lengthSquared*(self: Quat): float32 {.inline.} = getGDNativeAPI().quatLengthSquared(self) proc normalized*(self: Quat): Quat {.inline.} = - getGDNativeAPI().quatNormalized(self).toQuat() + getGDNativeAPI().quatNormalized(self) proc isNormalized*(self: Quat): bool {.inline.} = getGDNativeAPI().quatIsNormalized(self) proc inverse*(self: Quat): Quat {.inline.} = - getGDNativeAPI().quatInverse(self).toQuat() + 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).toVector3() + getGDNativeAPI().quatXform(self, v) proc slerp*(self: Quat; b: Quat; t: float32): Quat {.inline.} = - getGDNativeAPI().quatSlerp(self, b, t).toQuat() + getGDNativeAPI().quatSlerp(self, b, t) proc slerpni*(self: Quat; b: Quat; t: float32): Quat {.inline.} = - getGDNativeAPI().quatSlerpni(self, b, t).toQuat() + getGDNativeAPI().quatSlerpni(self, b, t) proc cubicSlerp*(self, b, preA, postB: Quat; t: float32): Quat {.inline.} = - getGDNativeAPI().quatCubicSlerp(self, b, preA, postB, t).toQuat() + getGDNativeAPI().quatCubicSlerp(self, b, preA, postB, t) proc `*`*(a: Quat, b: float32): Quat {.inline.} = - getGDNativeAPI().quatOperatorMultiply(a, b).toQuat() + getGDNativeAPI().quatOperatorMultiply(a, b) proc `*=`*(a: var Quat, b: float32) {.inline.} = a = a * b proc `+`*(a, b: Quat): Quat {.inline.} = - getGDNativeAPI().quatOperatorAdd(a, b).toQuat() + getGDNativeAPI().quatOperatorAdd(a, b) proc `+=`*(a: var Quat, b: Quat) {.inline.} = a = a + b proc `-`*(a, b: Quat): Quat {.inline.} = - getGDNativeAPI().quatOperatorSubtract(a, b).toQuat() + getGDNativeAPI().quatOperatorSubtract(a, b) proc `-=`* (a: var Quat, b: Quat) {.inline.} = a = a - b proc `/`*(self: Quat; b: float32): Quat {.inline.} = - getGDNativeAPI().quatOperatorDivide(self, b).toQuat() + getGDNativeAPI().quatOperatorDivide(self, b) proc `/=`*(self: var Quat, b: float32) {.inline.} = self = self / b @@ -81,4 +76,4 @@ proc `==`*(a, b: Quat): bool {.inline.} = getGDNativeAPI().quatOperatorEqual(a, b) proc `-`*(self: Quat): Quat {.inline.} = - getGDNativeAPI().quatOperatorNeg(self).toQuat() + getGDNativeAPI().quatOperatorNeg(self) diff --git a/godot/core/rect2.nim b/godot/core/rect2.nim index 19b8cbf..ad813a9 100644 --- a/godot/core/rect2.nim +++ b/godot/core/rect2.nim @@ -1,153 +1,44 @@ -# Copyright (c) 2018 Xored Software, Inc. - -import hashes +# Copyright (c) 2017 Xored Software, Inc. import vector2 -import internal/godotinternaltypes, internal/godotstrings +import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi -{.push stackTrace: off.} - -proc initRect2*(): Rect2 {.inline, noinit.} = - Rect2() - -proc initRect2*(pos, size: Vector2): Rect2 {.inline, noinit.} = +proc initRect2*(pos, size: Vector2): Rect2 {.inline.} = Rect2(position: pos, size: size) -proc initRect2*(x, y, sizeX, sizeY: float32): Rect2 {.inline, noinit.} = +proc initRect2*(x, y, sizeX, sizeY: float32): Rect2 {.inline.} = Rect2(position: vec2(x, y), size: vec2(sizeX, sizeY)) -proc `$`*(self: Rect2): string {.inline, noinit.} = +proc `$`*(self: Rect2): string {.inline.} = $getGDNativeAPI().rect2AsString(self) -proc hash*(self: Rect2): Hash {.inline, noinit.} = - !$(self.position.hash() !& self.size.hash()) +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) - - 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 +proc `==`*(a, b: Rect2): bool {.inline.} = + getGDNativeAPI().rect2OperatorEqual(a, b) diff --git a/godot/core/rids.nim b/godot/core/rids.nim index a64137d..a113f60 100644 --- a/godot/core/rids.nim +++ b/godot/core/rids.nim @@ -1,8 +1,6 @@ -# Copyright (c) 2018 Xored Software, Inc. +# Copyright (c) 2017 Xored Software, Inc. -import hashes - -import godotcoretypes, internal/godotinternaltypes, gdnativeapi +import godotcoretypes, internal.godotinternaltypes, gdnativeapi proc initRID*(): RID {.inline.} = getGDNativeAPI().ridNew(result) @@ -16,9 +14,6 @@ proc id*(self: RID): uint32 {.inline.} = proc `$`*(self: RID): string {.inline.} = $self.id -proc hash*(self: RID): Hash {.inline.} = - self.id.hash() - proc `==`*(a, b: RID): bool {.inline.} = getGDNativeAPI().ridOperatorEqual(a, b) diff --git a/godot/core/transform2d.nim b/godot/core/transform2d.nim index a8db09e..922b24b 100644 --- a/godot/core/transform2d.nim +++ b/godot/core/transform2d.nim @@ -1,8 +1,6 @@ -# Copyright (c) 2018 Xored Software, Inc. +# Copyright (c) 2017 Xored Software, Inc. -import hashes, vector2 - -import internal/godotinternaltypes, internal/godotstrings +import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi proc initTransform2D*(): Transform2D {.inline.} = @@ -17,63 +15,60 @@ proc initTransform2D*(xAxis, yAxis, origin: Vector2): Transform2D {.inline.} = proc `$`*(self: Transform2D): string {.inline.} = $getGDNativeAPI().transform2DAsString(self) -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).toTransform2D() + getGDNativeAPI().transform2DInverse(self) proc affineInverse*(self: Transform2D): Transform2D {.inline.} = - getGDNativeAPI().transform2DAffineInverse(self).toTransform2D() + getGDNativeAPI().transform2DAffineInverse(self) proc rotation*(self: Transform2D): float32 {.inline.} = getGDNativeAPI().transform2DGetRotation(self) proc origin*(self: Transform2D): Vector2 {.inline.} = - getGDNativeAPI().transform2DGetOrigin(self).toVector2() + getGDNativeAPI().transform2DGetOrigin(self) proc scale*(self: Transform2D): Vector2 {.inline.} = - getGDNativeAPI().transform2DGetScale(self).toVector2() + getGDNativeAPI().transform2DGetScale(self) proc orthonormalized*(self: Transform2D): Transform2D {.inline.} = - getGDNativeAPI().transform2DOrthonormalized(self).toTransform2D() + getGDNativeAPI().transform2DOrthonormalized(self) proc rotated*(self: Transform2D; phi: float32): Transform2D {.inline.} = - getGDNativeAPI().transform2DRotated(self, phi).toTransform2D() + getGDNativeAPI().transform2DRotated(self, phi) proc scaled*(self: Transform2D; scale: Vector2): Transform2D {.inline.} = - getGDNativeAPI().transform2DScaled(self, scale).toTransform2D() + getGDNativeAPI().transform2DScaled(self, scale) proc translated*(self: Transform2D; offset: Vector2): Transform2D {.inline.} = - getGDNativeAPI().transform2DTranslated(self, offset).toTransform2D() + getGDNativeAPI().transform2DTranslated(self, offset) proc xformVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = - getGDNativeAPI().transform2DXformVector2(self, v).toVector2() + getGDNativeAPI().transform2DXformVector2(self, v) proc xformInvVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = - getGDNativeAPI().transform2DXformInvVector2(self, v).toVector2() + getGDNativeAPI().transform2DXformInvVector2(self, v) proc basisXformVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = - getGDNativeAPI().transform2DBasisXformVector2(self, v).toVector2() + getGDNativeAPI().transform2DBasisXformVector2(self, v) proc basisXformInvVector2*(self: Transform2D; v: Vector2): Vector2 {.inline.} = - getGDNativeAPI().transform2DBasisXformInvVector2(self, v).toVector2() + getGDNativeAPI().transform2DBasisXformInvVector2(self, v) proc xformRect2*(self: Transform2D; rect: Rect2): Rect2 {.inline.} = - getGDNativeAPI().transform2DXformRect2(self, rect).toRect2() + getGDNativeAPI().transform2DXformRect2(self, rect) proc xformInvRect2*(self: Transform2D; rect: Rect2): Rect2 {.inline.} = - getGDNativeAPI().transform2DXformInvRect2(self, rect).toRect2() + getGDNativeAPI().transform2DXformInvRect2(self, rect) proc interpolateWith*(self, m: Transform2D; c: float32): Transform2D {.inline.} = - getGDNativeAPI().transform2DInterpolateWith(self, m, c).toTransform2D() + 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).toTransform2D() + 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 501f743..fe43ccb 100644 --- a/godot/core/transforms.nim +++ b/godot/core/transforms.nim @@ -1,10 +1,8 @@ -# Copyright (c) 2018 Xored Software, Inc. +# Copyright (c) 2017 Xored Software, Inc. -import hashes - -import internal/godotinternaltypes, internal/godotstrings +import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi -import basis, vector3 +import basis proc initTransform*(): Transform {.inline.} = result.basis = initBasis() @@ -23,54 +21,51 @@ proc initTransform*(basis: Basis, origin: Vector3): Transform {.inline.} = proc `$`*(self: Transform): string {.inline.} = $getGDNativeAPI().transformAsString(self) -proc hash*(self: Transform): Hash {.inline.} = - !$(self.basis.hash() !& self.origin.hash()) - proc inverse*(self: Transform): Transform {.inline.} = - getGDNativeAPI().transformInverse(self).toTransform() + getGDNativeAPI().transformInverse(self) proc affineInverse*(self: Transform): Transform {.inline.} = - getGDNativeAPI().transformAffineInverse(self).toTransform() + getGDNativeAPI().transformAffineInverse(self) proc orthonormalized*(self: Transform): Transform {.inline.} = - getGDNativeAPI().transformOrthonormalized(self).toTransform() + getGDNativeAPI().transformOrthonormalized(self) proc rotated*(self: Transform; axis: Vector3; phi: float32): Transform {.inline.} = - getGDNativeAPI().transformRotated(self, axis, phi).toTransform() + getGDNativeAPI().transformRotated(self, axis, phi) proc scaled*(self: Transform; scale: Vector3): Transform {.inline.} = - getGDNativeAPI().transformScaled(self, scale).toTransform() + getGDNativeAPI().transformScaled(self, scale) proc translated*(self: Transform; offset: Vector3): Transform {.inline.} = - getGDNativeAPI().transformTranslated(self, offset).toTransform() + getGDNativeAPI().transformTranslated(self, offset) proc lookingAt*(self: Transform; target, up: Vector3): Transform {.inline.} = - getGDNativeAPI().transformLookingAt(self, target, up).toTransform() + getGDNativeAPI().transformLookingAt(self, target, up) proc xformPlane*(self: Transform; plane: Plane): Plane {.inline.} = - getGDNativeAPI().transformXformPlane(self, plane).toPlane() + getGDNativeAPI().transformXformPlane(self, plane) proc xformInvPlane*(self: Transform; plane: Plane): Plane {.inline.} = - getGDNativeAPI().transformXformInvPlane(self, plane).toPlane() + getGDNativeAPI().transformXformInvPlane(self, plane) proc xformVector3*(self: Transform; v: Vector3): Vector3 {.inline.} = - getGDNativeAPI().transformXformVector3(self, v).toVector3() + getGDNativeAPI().transformXformVector3(self, v) proc xformInvVector3*(self: Transform; v: Vector3): Vector3 {.inline.} = - getGDNativeAPI().transformXformInvVector3(self, v).toVector3() + getGDNativeAPI().transformXformInvVector3(self, v) proc xformAABB*(self: Transform; rect: AABB): AABB {.inline.} = - getGDNativeAPI().transformXformAABB(self, rect).toAABB() + getGDNativeAPI().transformXformAABB(self, rect) proc xformInvAABB*(self: Transform; rect: AABB): AABB {.inline.} = - getGDNativeAPI().transformXformInvAABB(self, rect).toAABB() + getGDNativeAPI().transformXformInvAABB(self, rect) proc `==`*(self: Transform; b: Transform): bool {.inline.} = getGDNativeAPI().transformOperatorEqual(self, b) proc `*`*(self, other: Transform): Transform {.inline.} = - getGDNativeAPI().transformOperatorMultiply(self, other).toTransform() + 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 fcb2b04..55284a1 100644 --- a/godot/core/variants.nim +++ b/godot/core/variants.nim @@ -1,9 +1,8 @@ -import tables, hashes +import tables import godotcoretypes -import internal/godotinternaltypes, internal/godotvariants, - internal/godotstrings, internal/godotdictionaries, - internal/godotarrays +import internal.godotinternaltypes, internal.godotvariants, + internal.godotstrings type Variant* = ref object @@ -73,13 +72,12 @@ 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() + if s.isNil: + initGodotVariant(result.godotVariant) + else: + var godotStr = s.toGodotString() + initGodotVariant(result.godotVariant, godotStr) + godotStr.deinit() import basis, nodepaths import planes, quats, rect2, aabb, rids @@ -142,7 +140,11 @@ proc newVariant*(obj: ptr GodotObject): Variant {.inline.} = new(result, variantFinalizer) initGodotVariant(result.godotVariant, obj) -import poolarrays +import arrays, poolarrays + +proc newVariant*(arr: Array): Variant {.inline.} = + new(result, variantFinalizer) + initGodotVariant(result.godotVariant, arr.godotArray[]) proc newVariant*(pba: PoolByteArray): Variant {.inline.} = new(result, variantFinalizer) @@ -175,119 +177,81 @@ proc newVariant*(pca: PoolColorArray): Variant {.inline.} = proc asBool*(self: Variant): bool {.inline.} = self.godotVariant.asBool() -proc asUInt*(self: Variant): uint64 {.inline.} = +proc asUInt*(self: Variant): uint64 = self.godotVariant.asUInt() -proc asInt*(self: Variant): int64 {.inline.} = +proc asInt*(self: Variant): int64 = self.godotVariant.asInt() -proc asReal*(self: Variant): cdouble {.inline.} = +proc asReal*(self: Variant): cdouble = self.godotVariant.asReal() -proc asString*(self: Variant): string {.inline.} = +proc asString*(self: Variant): string = $self -proc asVector2*(self: Variant): Vector2 {.inline.} = +proc asVector2*(self: Variant): Vector2 = self.godotVariant.asVector2() -proc asRect2*(self: Variant): Rect2 {.inline.} = +proc asRect2*(self: Variant): Rect2 = self.godotVariant.asRect2() -proc asVector3*(self: Variant): Vector3 {.inline.} = +proc asVector3*(self: Variant): Vector3 = self.godotVariant.asVector3() -proc asTransform2D*(self: Variant): Transform2D {.inline.} = +proc asTransform2D*(self: Variant): Transform2D = self.godotVariant.asTransform2D() -proc asPlane*(self: Variant): Plane {.inline.} = +proc asPlane*(self: Variant): Plane = self.godotVariant.asPlane() -proc asQuat*(self: Variant): Quat {.inline.} = +proc asQuat*(self: Variant): Quat = self.godotVariant.asQuat() -proc asAABB*(self: Variant): AABB {.inline.} = +proc asAABB*(self: Variant): AABB = self.godotVariant.asAABB() -proc asBasis*(self: Variant): Basis {.inline.} = +proc asBasis*(self: Variant): Basis = self.godotVariant.asBasis() -proc asTransform*(self: Variant): Transform {.inline.} = +proc asTransform*(self: Variant): Transform = self.godotVariant.asTransform() -proc asColor*(self: Variant): Color {.inline.} = +proc asColor*(self: Variant): Color = self.godotVariant.asColor() -proc asNodePath*(self: Variant): NodePath {.inline.} = +proc asNodePath*(self: Variant): NodePath = result = newNodePath(self.godotVariant.asNodePath()) -proc asRID*(self: Variant): RID {.inline.} = +proc asRID*(self: Variant): RID = self.godotVariant.asRID() -proc asGodotObject*(self: Variant): ptr GodotObject {.inline.} = +proc asGodotObject*(self: Variant): ptr GodotObject = self.godotVariant.asGodotObject() -proc asPoolByteArray*(self: Variant): PoolByteArray {.inline.} = +proc asArray*(self: Variant): Array = + newArray(self.godotVariant.asGodotArray()) + +proc asPoolByteArray*(self: Variant): PoolByteArray = newPoolByteArray(self.godotVariant.asGodotPoolByteArray()) -proc asPoolIntArray*(self: Variant): PoolIntArray {.inline.} = +proc asPoolIntArray*(self: Variant): PoolIntArray = newPoolIntArray(self.godotVariant.asGodotPoolIntArray()) -proc asPoolRealArray*(self: Variant): PoolRealArray {.inline.} = +proc asPoolRealArray*(self: Variant): PoolRealArray = newPoolRealArray(self.godotVariant.asGodotPoolRealArray()) -proc asPoolStringArray*(self: Variant): PoolStringArray {.inline.} = +proc asPoolStringArray*(self: Variant): PoolStringArray = newPoolStringArray(self.godotVariant.asGodotPoolStringArray()) -proc asPoolVector2Array*(self: Variant): PoolVector2Array {.inline.} = +proc asPoolVector2Array*(self: Variant): PoolVector2Array = newPoolVector2Array(self.godotVariant.asGodotPoolVector2Array()) -proc asPoolVector3Array*(self: Variant): PoolVector3Array {.inline.} = +proc asPoolVector3Array*(self: Variant): PoolVector3Array = newPoolVector3Array(self.godotVariant.asGodotPoolVector3Array()) -proc asPoolColorArray*(self: Variant): PoolColorArray {.inline.} = +proc asPoolColorArray*(self: Variant): PoolColorArray = newPoolColorArray(self.godotVariant.asGodotPoolColorArray()) -proc hash*(self: Variant): Hash = - proc objectHash(obj: ptr GodotObject): Hash = - if not obj.isNil: cast[int](obj).hash() else: 0.hash() - result = case self.getType(): - of VariantType.Nil: Hash(0) - of VariantType.Bool: self.asBool().hash() - of VariantType.Int: self.asInt().hash() - of VariantType.Real: self.asReal().hash() - of VariantType.String: self.asString().hash() - of VariantType.Vector2: self.asVector2().hash() - of VariantType.Rect2: self.asRect2().hash() - of VariantType.Vector3: self.asVector3().hash() - of VariantType.Transform2D: self.asTransform2D().hash() - of VariantType.Plane: self.asPlane().hash() - of VariantType.Quat: self.asQuat().hash() - of VariantType.AABB: self.asAABB().hash() - of VariantType.Basis: self.asBasis().hash() - of VariantType.Transform: self.asTransform().hash() - of VariantType.Color: self.asColor().hash() - of VariantType.NodePath: self.asNodePath().hash() - of VariantType.RID: self.asRID().hash() - of VariantType.Object: self.asGodotObject().objectHash() - of VariantType.Dictionary: hash(self.godotVariant.asGodotDictionary().godotHash()) - of VariantType.Array: hash(self.godotVariant.asGodotArray().godotHash()) - of VariantType.PoolByteArray: self.asPoolByteArray().hash() - of VariantType.PoolIntArray: self.asPoolIntArray().hash() - of VariantType.PoolRealArray: self.asPoolRealArray().hash() - of VariantType.PoolStringArray: self.asPoolStringArray().hash() - of VariantType.PoolVector2Array: self.asPoolVector2Array().hash() - of VariantType.PoolVector3Array: self.asPoolVector3Array().hash() - of VariantType.PoolColorArray: self.asPoolColorArray().hash() - -import arrays - -proc newVariant*(arr: Array): Variant {.inline.} = - new(result, variantFinalizer) - initGodotVariant(result.godotVariant, arr.godotArray[]) - -proc asArray*(self: Variant): Array {.inline.} = - newArray(self.godotVariant.asGodotArray()) - proc hasMethod*(self: Variant; meth: string): bool = var s = meth.toGodotString() result = self.godotVariant.hasMethod(s) diff --git a/godot/core/vector2.nim b/godot/core/vector2.nim index 390f1f6..9eca64d 100644 --- a/godot/core/vector2.nim +++ b/godot/core/vector2.nim @@ -1,214 +1,122 @@ -# Copyright (c) 2018 Xored Software, Inc. +# Copyright (c) 2017 Xored Software, Inc. -import math, godotbase, hashes - -import internal/godotinternaltypes, internal/godotstrings +import internal.godotinternaltypes, internal.godotstrings import godotcoretypes, gdnativeapi -const EPSILON = 0.00001'f32 - -{.push stackTrace: off.} - -proc vec2*(): Vector2 {.inline, noinit.} = - Vector2() - -proc vec2*(x, y: float32): Vector2 {.inline, noinit.} = +proc vec2*(x, y: float32): Vector2 {.inline.} = Vector2(x: x, y: y) -proc `$`*(self: Vector2): string {.inline, noinit.} = +proc `$`*(self: Vector2): string {.inline.} = $getGDNativeAPI().vector2AsString(self) -proc hash*(self: Vector2): Hash {.inline, noinit.} = - !$(self.x.hash() !& self.y.hash()) +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 `/`*(self, other: Vector2): Vector2 {.inline, noinit.} = - Vector2(x: self.x / other.x, y: self.y / other.y) - -proc `/=`*(self: var Vector2, other: Vector2) {.inline, noinit.} = - self.x /= other.x - self.y /= other.y - -proc `/`*(self: Vector2; scalar: float32): Vector2 {.inline, noinit.} = - Vector2(x: self.x / scalar, y: self.y / scalar) - -proc `/=`*(self: var Vector2; scalar: float32) {.inline, noinit.} = - self = self / scalar - -proc `==`*(self, other: Vector2): bool {.inline, noinit.} = - self.x == other.x and self.y == other.y - -proc `<`*(self, other: Vector2): bool {.inline, noinit.} = - if self.x == other.x: - self.y < other.y - else: - self.x < other.x - -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 lerp*(self, b: Vector2; t: float32): Vector2 {.inline.} = + getGDNativeAPI().vector2LinearInterpolate(self, b, t) proc cubicInterpolate*(self, b, preA, postB: Vector2; - t: float32): Vector2 {.noinit.} = - let p0 = preA - let p1 = self - let p2 = b - let p3 = postB + t: float32): Vector2 {.inline.} = + getGDNativeAPI().vector2CubicInterpolate(self, b, preA, postB, t) - let t2 = t * t - let t3 = t2 * t +proc rotated*(self: Vector2; phi: float32): Vector2 {.inline.} = + getGDNativeAPI().vector2Rotated(self, phi) - 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 tangent*(self: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Tangent(self) -proc setRotation*(self: var Vector2, radians: float32) {.inline, noinit.} = - self.x = cos(radians) - self.y = sin(radians) +proc floor*(self: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Floor(self) -proc rotated*(self: Vector2; phi: float32): Vector2 {.inline, noinit.} = - result.setRotation(phi) - result *= self.length() +proc snapped*(self: Vector2; by: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Snapped(self, by) -proc tangent*(self: Vector2): Vector2 {.inline, noinit.} = - Vector2(x: self.y, y: -self.x) +proc aspect*(self: Vector2): float32 {.inline.} = + getGDNativeAPI().vector2Aspect(self) -proc snapped*(self: Vector2; by: Vector2): Vector2 {.inline, noinit.} = - Vector2(x: stepify(self.x, by.x), y: stepify(self.y, by.y)) +proc dot*(a, b: Vector2): float32 {.inline.} = + getGDNativeAPI().vector2Dot(a, b) -proc aspect*(self: Vector2): float32 {.inline, noinit.} = - self.x / self.y +proc slide*(self, n: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Slide(self, n) -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 bounce*(self, n: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Bounce(self, 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 reflect*(self, n: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Reflect(self, n) -proc bounce*(self, n: Vector2): Vector2 {.inline, noinit.} = - -self.reflect(n) +proc abs*(self: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2Abs(self) -proc abs*(self: Vector2): Vector2 {.inline, noinit.} = - Vector2(x: abs(self.x), y: abs(self.y)) +proc clamped*(self: Vector2; length: float32): Vector2 {.inline.} = + getGDNativeAPI().vector2Clamped(self, length) -proc clamped*(self: Vector2; length: float32): Vector2 {.noinit.} = - let len = self.length() - result = self - if len > 0 and length < len: - result /= len - result *= length +proc `+`*(self, other: Vector2): Vector2 {.inline.} = + getGDNativeAPI().vector2OperatorAdd(self, other) -proc moveToward*(vFrom, to: Vector2, delta: float32): Vector2 = - let - vd = to - vFrom - vLen = vd.length +proc `+=`*(self: var Vector2, other: Vector2) {.inline.} = + self += other - if vLen <= delta or vLen < EPSILON: - result = to - else: - result = vFrom + (vd / vLen) * delta +proc `-`*(self, other: Vector2): Vector2 = + getGDNativeAPI().vector2OperatorSubtract(self, other) -{.pop.} # stackTrace: off +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.} = + self = self / scalar + +proc `==`*(self, other: Vector2): bool {.inline.} = + getGDNativeAPI().vector2OperatorEqual(self, other) + +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 ed2903a..ded30ce 100644 --- a/godot/core/vector3.nim +++ b/godot/core/vector3.nim @@ -1,12 +1,8 @@ -# Copyright (c) 2018 Xored Software, Inc. +# Copyright (c) 2017 Xored Software, Inc. -import math, hashes +import math import godotbase, godotcoretypes -const EPSILON = 0.00001'f32 - -{.push stackTrace: off.} - proc vec3*(): Vector3 {.inline.} = Vector3() @@ -23,9 +19,6 @@ proc `$`*(self: Vector3): string {.inline.} = result.add($self.z) result.add(')') -proc hash*(self: Vector3): Hash {.inline, noinit.} = - !$(self.x.hash() !& self.y.hash() !& self.z.hash()) - proc `+`*(a, b: Vector3): Vector3 {.inline.} = result.x = a.x + b.x result.y = a.y + b.y @@ -240,15 +233,3 @@ 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) - -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 diff --git a/godot/gdnativeapi.nim b/godot/gdnativeapi.nim index bb05425..2d6d98b 100644 --- a/godot/gdnativeapi.nim +++ b/godot/gdnativeapi.nim @@ -1,38 +1,8 @@ -# Copyright 2018 Xored Software, Inc. +# Copyright 2017 Xored Software, Inc. -import internal/godotinternaltypes, core/godotcoretypes, macros +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, @@ -123,14 +93,14 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} colorGray: proc (self: Color): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorInverted: proc (self: Color): ColorData + colorInverted: proc (self: Color): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorContrasted: proc (self: Color): ColorData + colorContrasted: proc (self: Color): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorLinearInterpolate: proc (self, other: Color, t: float32): ColorData + colorLinearInterpolate: proc (self, other: Color, t: float32): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorBlend: proc (self, other: Color): ColorData + 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.} @@ -144,7 +114,7 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2AsString: proc (self: Vector2): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Normalized: proc (self: Vector2): Vector2Data + vector2Normalized: proc (self: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2Length: proc (self: Vector2): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -163,57 +133,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): Vector2Data + vector2LinearInterpolate: proc (self, b: Vector2, t: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2CubicInterpolate: proc (self, b, preA, postB: Vector2, - t: float32): Vector2Data + t: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Rotated: proc (self: Vector2, phi: float32): Vector2Data + vector2Rotated: proc (self: Vector2, phi: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Tangent: proc (self: Vector2): Vector2Data + vector2Tangent: proc (self: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Floor: proc (self: Vector2): Vector2Data + vector2Floor: proc (self: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Snapped: proc (self, by: Vector2): Vector2Data + 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): Vector2Data + vector2Slide: proc (self, n: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Bounce: proc (self, n: Vector2): Vector2Data + vector2Bounce: proc (self, n: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Reflect: proc (self, n: Vector2): Vector2Data + vector2Reflect: proc (self, n: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Abs: proc (self: Vector2): Vector2Data + vector2Abs: proc (self: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Clamped: proc (self: Vector2, length: float32): Vector2Data + vector2Clamped: proc (self: Vector2, length: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorAdd: proc (self, other: Vector2): Vector2Data + vector2OperatorAdd: proc (self, other: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorSubtract: proc (self, other: Vector2): Vector2Data + vector2OperatorSubtract: proc (self, other: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorMultiplyVector: proc (self, other: Vector2): Vector2Data + vector2OperatorMultiplyVector: proc (self, other: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorMultiplyScalar: proc (self: Vector2, scalar: float32): Vector2Data + vector2OperatorMultiplyScalar: proc (self: Vector2, scalar: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorDivideVector: proc (self, other: Vector2): Vector2Data + vector2OperatorDivideVector: proc (self, other: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorDivideScalar: proc (self: Vector2, scalar: float32): Vector2Data + 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): Vector2Data + vector2OperatorNeg: proc (self: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2SetX: pointer vector2SetY: pointer @@ -248,33 +218,33 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} quatLengthSquared: proc (self: Quat): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatNormalized: proc (self: Quat): QuatData + 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): QuatData + 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): Vector3Data + quatXform: proc (self: Quat, v: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSlerp: proc (self, other: Quat, t: float32): QuatData + quatSlerp: proc (self, other: Quat, t: float32): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSlerpni: proc (self, other: Quat, t: float32): QuatData + quatSlerpni: proc (self, other: Quat, t: float32): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatCubicSlerp: proc (self, other, preA, postB: Quat, t: float32): QuatData + quatCubicSlerp: proc (self, other, preA, postB: Quat, t: float32): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorMultiply: proc (self: Quat, b: float32): QuatData + quatOperatorMultiply: proc (self: Quat, b: float32): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorAdd: proc (self, other: Quat): QuatData + quatOperatorAdd: proc (self, other: Quat): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorSubtract: proc (self, other: Quat): QuatData + quatOperatorSubtract: proc (self, other: Quat): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorDivide: proc (self: Quat, divider: float32): QuatData + 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): QuatData + quatOperatorNeg: proc (self: Quat): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} # Basis API @@ -377,10 +347,8 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolByteArrayResize: proc (self: var GodotPoolByteArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayRead: proc (self: GodotPoolByteArray): ptr GodotPoolByteArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayWrite: proc (self: var GodotPoolByteArray): ptr GodotPoolByteArrayWriteAccess - {.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 @@ -416,10 +384,8 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolIntArrayResize: proc (self: var GodotPoolIntArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayRead: proc (self: GodotPoolIntArray): ptr GodotPoolIntArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayWrite: proc (self: var GodotPoolIntArray): ptr GodotPoolIntArrayWriteAccess - {.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 @@ -457,10 +423,8 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolRealArrayResize: proc (self: var GodotPoolRealArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayRead: proc (self: GodotPoolRealArray): ptr GodotPoolRealArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayWrite: proc (self: var GodotPoolRealArray): ptr GodotPoolRealArrayWriteAccess - {.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.} @@ -507,10 +471,8 @@ type poolStringArrayResize: proc (self: var GodotPoolStringArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayRead: proc (self: GodotPoolStringArray): ptr GodotPoolStringArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayWrite: proc (self: var GodotPoolStringArray): ptr GodotPoolStringArrayWriteAccess - {.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.} @@ -557,14 +519,12 @@ type poolVector2ArrayResize: proc (self: var GodotPoolVector2Array, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayRead: proc (self: GodotPoolVector2Array): ptr GodotPoolVector2ArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayWrite: proc (self: var GodotPoolVector2Array): ptr GodotPoolVector2ArrayWriteAccess - {.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): Vector2Data + poolVector2ArrayGet: proc (self: GodotPoolVector2Array, idx: cint): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolVector2ArraySize: proc (self: GodotPoolVector2Array): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -606,14 +566,12 @@ type poolVector3ArrayResize: proc (self: var GodotPoolVector3Array, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayRead: proc (self: GodotPoolVector3Array): ptr GodotPoolVector3ArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayWrite: proc (self: var GodotPoolVector3Array): ptr GodotPoolVector3ArrayWriteAccess - {.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): Vector3Data + poolVector3ArrayGet: proc (self: GodotPoolVector3Array, idx: cint): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolVector3ArraySize: proc (self: GodotPoolVector3Array): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -651,14 +609,12 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolColorArrayResize: proc (self: var GodotPoolColorArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayRead: proc (self: GodotPoolColorArray): ptr GodotPoolColorArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayWrite: proc (self: var GodotPoolColorArray): ptr GodotPoolColorArrayWriteAccess - {.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): ColorData + poolColorArrayGet: proc (self: GodotPoolColorArray, idx: cint): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolColorArraySize: proc (self: GodotPoolColorArray): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -666,133 +622,51 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - # Pool Array Read/Write Access API + # Pool Array Read Access API - poolByteArrayReadAccessCopy: proc (self: ptr GodotPoolByteArrayReadAccess): ptr GodotPoolByteArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayReadAccessPtr: proc (self: ptr GodotPoolByteArrayReadAccess): ptr byte - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayReadAccessOperatorAssign: proc (self, other: ptr GodotPoolByteArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayReadAccessDestroy: proc (self: ptr GodotPoolByteArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + 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 - poolIntArrayReadAccessCopy: proc (self: ptr GodotPoolIntArrayReadAccess): ptr GodotPoolIntArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayReadAccessPtr: proc (self: ptr GodotPoolIntArrayReadAccess): ptr cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayReadAccessOperatorAssign: proc (self, other: ptr GodotPoolIntArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayReadAccessDestroy: proc (self: ptr GodotPoolIntArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolRealArrayReadAccessCopy: proc (self: ptr GodotPoolRealArrayReadAccess): ptr GodotPoolRealArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayReadAccessPtr: proc (self: ptr GodotPoolRealArrayReadAccess): ptr float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayReadAccessOperatorAssign: proc (self, other: ptr GodotPoolRealArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayReadAccessDestroy: proc (self: ptr GodotPoolRealArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolStringArrayReadAccessCopy: proc (self: ptr GodotPoolStringArrayReadAccess): ptr GodotPoolStringArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayReadAccessPtr: proc (self: ptr GodotPoolStringArrayReadAccess): ptr GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayReadAccessOperatorAssign: proc (self, other: ptr GodotPoolStringArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayReadAccessDestroy: proc (self: ptr GodotPoolStringArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolVector2ArrayReadAccessCopy: proc (self: ptr GodotPoolVector2ArrayReadAccess): ptr GodotPoolVector2ArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayReadAccessPtr: proc (self: ptr GodotPoolVector2ArrayReadAccess): ptr Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayReadAccessOperatorAssign: proc (self, other: ptr GodotPoolVector2ArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayReadAccessDestroy: proc (self: ptr GodotPoolVector2ArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolVector3ArrayReadAccessCopy: proc (self: ptr GodotPoolVector3ArrayReadAccess): ptr GodotPoolVector3ArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayReadAccessPtr: proc (self: ptr GodotPoolVector3ArrayReadAccess): ptr Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayReadAccessOperatorAssign: proc (self, other: ptr GodotPoolVector3ArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayReadAccessDestroy: proc (self: ptr GodotPoolVector3ArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolColorArrayReadAccessCopy: proc (self: ptr GodotPoolColorArrayReadAccess): ptr GodotPoolColorArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayReadAccessPtr: proc (self: ptr GodotPoolColorArrayReadAccess): ptr Color - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayReadAccessOperatorAssign: proc (self, other: ptr GodotPoolColorArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayReadAccessDestroy: proc (self: ptr GodotPoolColorArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolByteArrayWriteAccessCopy: proc (self: ptr GodotPoolByteArrayWriteAccess): ptr GodotPoolByteArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayWriteAccessPtr: proc (self: ptr GodotPoolByteArrayWriteAccess): ptr byte - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayWriteAccessOperatorAssign: proc (self, other: ptr GodotPoolByteArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayWriteAccessDestroy: proc (self: ptr GodotPoolByteArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolIntArrayWriteAccessCopy: proc (self: ptr GodotPoolIntArrayWriteAccess): ptr GodotPoolIntArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayWriteAccessPtr: proc (self: ptr GodotPoolIntArrayWriteAccess): ptr cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayWriteAccessOperatorAssign: proc (self, other: ptr GodotPoolIntArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayWriteAccessDestroy: proc (self: ptr GodotPoolIntArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolRealArrayWriteAccessCopy: proc (self: ptr GodotPoolRealArrayWriteAccess): ptr GodotPoolRealArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayWriteAccessPtr: proc (self: ptr GodotPoolRealArrayWriteAccess): ptr float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayWriteAccessOperatorAssign: proc (self, other: ptr GodotPoolRealArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayWriteAccessDestroy: proc (self: ptr GodotPoolRealArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolStringArrayWriteAccessCopy: proc (self: ptr GodotPoolStringArrayWriteAccess): ptr GodotPoolStringArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayWriteAccessPtr: proc (self: ptr GodotPoolStringArrayWriteAccess): ptr GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayWriteAccessOperatorAssign: proc (self, other: ptr GodotPoolStringArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayWriteAccessDestroy: proc (self: ptr GodotPoolStringArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolVector2ArrayWriteAccessCopy: proc (self: ptr GodotPoolVector2ArrayWriteAccess): ptr GodotPoolVector2ArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayWriteAccessPtr: proc (self: ptr GodotPoolVector2ArrayWriteAccess): ptr Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayWriteAccessOperatorAssign: proc (self, other: ptr GodotPoolVector2ArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayWriteAccessDestroy: proc (self: ptr GodotPoolVector2ArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolVector3ArrayWriteAccessCopy: proc (self: ptr GodotPoolVector3ArrayWriteAccess): ptr GodotPoolVector3ArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayWriteAccessPtr: proc (self: ptr GodotPoolVector3ArrayWriteAccess): ptr Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayWriteAccessOperatorAssign: proc (self, other: ptr GodotPoolVector3ArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayWriteAccessDestroy: proc (self: ptr GodotPoolVector3ArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolColorArrayWriteAccessCopy: proc (self: ptr GodotPoolColorArrayWriteAccess): ptr GodotPoolColorArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayWriteAccessPtr: proc (self: ptr GodotPoolColorArrayWriteAccess): ptr Color - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayWriteAccessOperatorAssign: proc (self, other: ptr GodotPoolColorArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayWriteAccessDestroy: proc (self: ptr GodotPoolColorArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + 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) @@ -967,11 +841,11 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeAsString: proc (self: Plane): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeNormalized: proc (self: Plane): PlaneData + planeNormalized: proc (self: Plane): Plane {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeCenter: proc (self: Plane): Vector3Data + planeCenter: proc (self: Plane): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeGetAnyPoint: proc (self: Plane): Vector3Data + planeGetAnyPoint: proc (self: Plane): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeIsPointOver: proc (self: Plane, point: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -979,7 +853,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): Vector3Data + 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.} @@ -990,13 +864,13 @@ type segmentBegin, segmentEnd: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeOperatorNeg: proc (self: Plane): PlaneData + 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): Vector3Data + planeGetNormal: proc (self: Plane): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeGetD: proc (self: Plane): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1019,21 +893,21 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2HasNoArea: proc (self: Rect2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Clip: proc (self, other: Rect2): Rect2Data + rect2Clip: proc (self, other: Rect2): Rect2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Merge: proc (self, other: Rect2): Rect2Data + 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): Rect2Data + rect2Grow: proc (self: Rect2, by: float32): Rect2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Expand: proc (self: Rect2, to: Vector2): Rect2Data + 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): Vector2Data + rect2GetPosition: proc (self: Rect2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2GetSize: proc (self: Rect2): Vector2Data + rect2GetSize: proc (self: Rect2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2SetPosition: proc (self: var Rect2, pos: Vector2) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1043,11 +917,11 @@ type # AABB API aabbNew: proc (dest: var AABB, pos, size: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetPosition: proc (self: AABB): Vector3Data + aabbGetPosition: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbSetPosition: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetSize: proc (self: AABB): Vector3Data + aabbGetSize: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbSetSize: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1063,9 +937,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): AABBData + aabbMerge: proc (self, other: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbIntersection: proc (self, other: AABB): AABBData + aabbIntersection: proc (self, other: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbIntersectsPlane: proc (self: AABB, plane: Plane): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1074,9 +948,9 @@ type locks: 0.} aabbHasPoint: proc (self: AABB, point: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetSupport: proc (self: AABB, dir: Vector3): Vector3Data + aabbGetSupport: proc (self: AABB, dir: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetLongestAxis: proc (self: AABB): Vector3Data + aabbGetLongestAxis: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbGetLongestAxisIndex: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], @@ -1084,7 +958,7 @@ type aabbGetLongestAxisSize: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetShortestAxis: proc (self: AABB): Vector3Data + aabbGetShortestAxis: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbGetShortestAxisIndex: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], @@ -1092,11 +966,11 @@ type aabbGetShortestAxisSize: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbExpand: proc (self: AABB, toPoint: Vector3): AABBData + aabbExpand: proc (self: AABB, toPoint: Vector3): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGrow: proc (self: AABB, by: float32): AABBData + aabbGrow: proc (self: AABB, by: float32): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetEndpoint: proc (self: AABB, idx: cint): Vector3Data + aabbGetEndpoint: proc (self: AABB, idx: cint): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbOperatorEqual: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1120,36 +994,36 @@ type locks: 0.} transformNew: proc (dest: var Transform, basis: Basis, origin: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformGetBasis: proc (self: Transform): BasisData + 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): Vector3Data + 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): TransformData + transformInverse: proc (self: Transform): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformAffineInverse: proc (self: Transform): TransformData + transformAffineInverse: proc (self: Transform): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformOrthonormalized: proc (self: Transform): TransformData + transformOrthonormalized: proc (self: Transform): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformRotated: proc (self: Transform, axis: Vector3, - phi: float32): TransformData + phi: float32): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformScaled: proc (self: Transform, scale: Vector3): TransformData + transformScaled: proc (self: Transform, scale: Vector3): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformTranslated: proc (self: Transform, offset: Vector3): TransformData + transformTranslated: proc (self: Transform, offset: Vector3): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformLookingAt: proc (self: Transform, target, up: Vector3): TransformData + transformLookingAt: proc (self: Transform, target, up: Vector3): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformPlane: proc (self: Transform, plane: Plane): PlaneData + transformXformPlane: proc (self: Transform, plane: Plane): Plane {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvPlane: proc (self: Transform, plane: Plane): PlaneData + transformXformInvPlane: proc (self: Transform, plane: Plane): Plane {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformNewIdentity: proc (dest: var Transform) @@ -1157,18 +1031,18 @@ type transformOperatorEqual: proc (self, other: Transform): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformOperatorMultiply: proc (self, other: Transform): TransformData + transformOperatorMultiply: proc (self, other: Transform): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformVector3: proc (self: Transform, v: Vector3): Vector3Data + transformXformVector3: proc (self: Transform, v: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvVector3: proc (self: Transform, v: Vector3): Vector3Data + transformXformInvVector3: proc (self: Transform, v: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformAABB: proc (self: Transform, v: AABB): AABBData + transformXformAABB: proc (self: Transform, v: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvAABB: proc (self: Transform, v: AABB): AABBData + transformXformInvAABB: proc (self: Transform, v: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1181,58 +1055,58 @@ type locks: 0.} transform2DAsString: proc (self: Transform2D): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DInverse: proc (self: Transform2D): Transform2DData + transform2DInverse: proc (self: Transform2D): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DAffineInverse: proc (self: Transform2D): Transform2DData + 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): Vector2Data + transform2DGetOrigin: proc (self: Transform2D): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DGetScale: proc (self: Transform2D): Vector2Data + transform2DGetScale: proc (self: Transform2D): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DOrthonormalized: proc (self: Transform2D): Transform2DData + transform2DOrthonormalized: proc (self: Transform2D): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DRotated: proc (self: Transform2D, phi: float32): Transform2DData + transform2DRotated: proc (self: Transform2D, phi: float32): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DScaled: proc (self: Transform2D, scale: Vector2): Transform2DData + transform2DScaled: proc (self: Transform2D, scale: Vector2): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DTranslated: proc (self: Transform2D, offset: Vector2): Transform2DData + transform2DTranslated: proc (self: Transform2D, offset: Vector2): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformVector2: proc (self: Transform2D, v: Vector2): Vector2Data + transform2DXformVector2: proc (self: Transform2D, v: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformInvVector2: proc (self: Transform2D, v: Vector2): Vector2Data + transform2DXformInvVector2: proc (self: Transform2D, v: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DBasisXformVector2: proc (self: Transform2D, v: Vector2): Vector2Data + transform2DBasisXformVector2: proc (self: Transform2D, v: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DBasisXformInvVector2: proc (self: Transform2D, - v: Vector2): Vector2Data + v: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DInterpolateWith: proc (self, other: Transform2D, - t: float32): Transform2DData + 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): Transform2DData + 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): Rect2Data + transform2DXformRect2: proc (self: Transform2D, v: Rect2): Rect2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformInvRect2: proc (self: Transform2D, v: Rect2): Rect2Data + transform2DXformInvRect2: proc (self: Transform2D, v: Rect2): Rect2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1321,25 +1195,25 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsString: proc (self: GodotVariant): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsVector2: proc (self: GodotVariant): Vector2Data + variantAsVector2: proc (self: GodotVariant): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsRect2: proc (self: GodotVariant): Rect2Data + variantAsRect2: proc (self: GodotVariant): Rect2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsVector3: proc (self: GodotVariant): Vector3Data + variantAsVector3: proc (self: GodotVariant): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsTransform2D: proc (self: GodotVariant): Transform2DData + variantAsTransform2D: proc (self: GodotVariant): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsPlane: proc (self: GodotVariant): PlaneData + variantAsPlane: proc (self: GodotVariant): Plane {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsQuat: proc (self: GodotVariant): QuatData + variantAsQuat: proc (self: GodotVariant): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsAABB: proc (self: GodotVariant): AABBData + variantAsAABB: proc (self: GodotVariant): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsBasis: proc (self: GodotVariant): BasisData + variantAsBasis: proc (self: GodotVariant): Basis {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsTransform: proc (self: GodotVariant): TransformData + variantAsTransform: proc (self: GodotVariant): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsColor: proc (self: GodotVariant): ColorData + variantAsColor: proc (self: GodotVariant): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsNodePath: proc (self: GodotVariant): GodotNodePath {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1391,21 +1265,18 @@ 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.} - stringNewWithWideString: pointer + 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 stringOperatorIndexConst: pointer - stringWideStr: proc (self: GodotString): ptr cwchar_t - {.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 @@ -1414,9 +1285,6 @@ 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 @@ -1508,14 +1376,11 @@ type stringErase: pointer stringAscii: pointer stringAsciiExtended: pointer - stringUtf8: proc (self: GodotString): GodotCharString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} + stringUtf8: pointer stringParseUtf8: pointer stringParseUtf8WithLen: 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.} + stringCharsToUtf8: pointer + stringCharsToUtf8WithLen: pointer stringHash: pointer stringHash64: pointer stringHashChars: pointer @@ -1587,7 +1452,6 @@ 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 @@ -1641,14 +1505,14 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} colorGray*: proc (self: Color): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorInverted*: proc (self: Color): ColorData + colorInverted*: proc (self: Color): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorContrasted*: proc (self: Color): ColorData + colorContrasted*: proc (self: Color): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorLinearInterpolate*: proc (self, other: Color, t: float32): ColorData + colorLinearInterpolate*: proc (self, other: Color, t: float32): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - colorBlend*: proc (self, other: Color): ColorData + 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.} @@ -1662,7 +1526,7 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2AsString*: proc (self: Vector2): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Normalized*: proc (self: Vector2): Vector2Data + vector2Normalized*: proc (self: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2Length*: proc (self: Vector2): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -1681,57 +1545,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): Vector2Data + vector2LinearInterpolate*: proc (self, b: Vector2, t: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} vector2CubicInterpolate*: proc (self, b, preA, postB: Vector2, - t: float32): Vector2Data + t: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Rotated*: proc (self: Vector2, phi: float32): Vector2Data + vector2Rotated*: proc (self: Vector2, phi: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Tangent*: proc (self: Vector2): Vector2Data + vector2Tangent*: proc (self: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Floor*: proc (self: Vector2): Vector2Data + vector2Floor*: proc (self: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Snapped*: proc (self, by: Vector2): Vector2Data + 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): Vector2Data + vector2Slide*: proc (self, n: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Bounce*: proc (self, n: Vector2): Vector2Data + vector2Bounce*: proc (self, n: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Reflect*: proc (self, n: Vector2): Vector2Data + vector2Reflect*: proc (self, n: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Abs*: proc (self: Vector2): Vector2Data + vector2Abs*: proc (self: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2Clamped*: proc (self: Vector2, length: float32): Vector2Data + vector2Clamped*: proc (self: Vector2, length: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorAdd*: proc (self, other: Vector2): Vector2Data + vector2OperatorAdd*: proc (self, other: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorSubtract*: proc (self, other: Vector2): Vector2Data + vector2OperatorSubtract*: proc (self, other: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorMultiplyVector*: proc (self, other: Vector2): Vector2Data + vector2OperatorMultiplyVector*: proc (self, other: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorMultiplyScalar*: proc (self: Vector2, scalar: float32): Vector2Data + vector2OperatorMultiplyScalar*: proc (self: Vector2, scalar: float32): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorDivideVector*: proc (self, other: Vector2): Vector2Data + vector2OperatorDivideVector*: proc (self, other: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - vector2OperatorDivideScalar*: proc (self: Vector2, scalar: float32): Vector2Data + 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): Vector2Data + vector2OperatorNeg*: proc (self: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} # Quat API @@ -1762,33 +1626,33 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} quatLengthSquared*: proc (self: Quat): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatNormalized*: proc (self: Quat): QuatData + 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): QuatData + 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): Vector3Data + quatXform*: proc (self: Quat, v: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSlerp*: proc (self, other: Quat, t: float32): QuatData + quatSlerp*: proc (self, other: Quat, t: float32): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatSlerpni*: proc (self, other: Quat, t: float32): QuatData + quatSlerpni*: proc (self, other: Quat, t: float32): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatCubicSlerp*: proc (self, other, preA, postB: Quat, t: float32): QuatData + quatCubicSlerp*: proc (self, other, preA, postB: Quat, t: float32): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorMultiply*: proc (self: Quat, b: float32): QuatData + quatOperatorMultiply*: proc (self: Quat, b: float32): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorAdd*: proc (self, other: Quat): QuatData + quatOperatorAdd*: proc (self, other: Quat): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorSubtract*: proc (self, other: Quat): QuatData + quatOperatorSubtract*: proc (self, other: Quat): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - quatOperatorDivide*: proc (self: Quat, divider: float32): QuatData + 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): QuatData + quatOperatorNeg*: proc (self: Quat): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} # PoolByteArray API @@ -1820,10 +1684,6 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolByteArrayResize*: proc (self: var GodotPoolByteArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayRead*: proc (self: GodotPoolByteArray): ptr GodotPoolByteArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayWrite*: proc (self: var GodotPoolByteArray): ptr GodotPoolByteArrayWriteAccess - {.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 @@ -1859,10 +1719,6 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolIntArrayResize*: proc (self: var GodotPoolIntArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayRead*: proc (self: GodotPoolIntArray): ptr GodotPoolIntArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayWrite*: proc (self: var GodotPoolIntArray): ptr GodotPoolIntArrayWriteAccess - {.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 @@ -1899,10 +1755,6 @@ type 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*: proc (self: GodotPoolRealArray): ptr GodotPoolRealArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayWrite*: proc (self: var GodotPoolRealArray): ptr GodotPoolRealArrayWriteAccess {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolRealArraySet*: proc (self: var GodotPoolRealArray, idx: cint, data: float32) @@ -1950,10 +1802,6 @@ type poolStringArrayResize*: proc (self: var GodotPoolStringArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayRead*: proc (self: GodotPoolStringArray): ptr GodotPoolStringArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayWrite*: proc (self: var GodotPoolStringArray): ptr GodotPoolStringArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolStringArraySet*: proc (self: var GodotPoolStringArray, idx: cint, data: GodotString) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2000,14 +1848,10 @@ type poolVector2ArrayResize*: proc (self: var GodotPoolVector2Array, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayRead*: proc (self: GodotPoolVector2Array): ptr GodotPoolVector2ArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayWrite*: proc (self: var GodotPoolVector2Array): ptr GodotPoolVector2ArrayWriteAccess - {.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): Vector2Data + poolVector2ArrayGet*: proc (self: GodotPoolVector2Array, idx: cint): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolVector2ArraySize*: proc (self: GodotPoolVector2Array): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2049,14 +1893,10 @@ type poolVector3ArrayResize*: proc (self: var GodotPoolVector3Array, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayRead*: proc (self: GodotPoolVector3Array): ptr GodotPoolVector3ArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayWrite*: proc (self: var GodotPoolVector3Array): ptr GodotPoolVector3ArrayWriteAccess - {.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): Vector3Data + poolVector3ArrayGet*: proc (self: GodotPoolVector3Array, idx: cint): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolVector3ArraySize*: proc (self: GodotPoolVector3Array): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2094,14 +1934,10 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolColorArrayResize*: proc (self: var GodotPoolColorArray, size: cint) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayRead*: proc (self: GodotPoolColorArray): ptr GodotPoolColorArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayWrite*: proc (self: var GodotPoolColorArray): ptr GodotPoolColorArrayWriteAccess - {.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): ColorData + poolColorArrayGet*: proc (self: GodotPoolColorArray, idx: cint): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} poolColorArraySize*: proc (self: GodotPoolColorArray): cint {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2109,134 +1945,6 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - # Pool Array Read/Write Access API - - poolByteArrayReadAccessCopy*: proc (self: ptr GodotPoolByteArrayReadAccess): ptr GodotPoolByteArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayReadAccessPtr*: proc (self: ptr GodotPoolByteArrayReadAccess): ptr byte - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayReadAccessOperatorAssign*: proc (self, other: ptr GodotPoolByteArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayReadAccessDestroy*: proc (self: ptr GodotPoolByteArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolIntArrayReadAccessCopy*: proc (self: ptr GodotPoolIntArrayReadAccess): ptr GodotPoolIntArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayReadAccessPtr*: proc (self: ptr GodotPoolIntArrayReadAccess): ptr cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayReadAccessOperatorAssign*: proc (self, other: ptr GodotPoolIntArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayReadAccessDestroy*: proc (self: ptr GodotPoolIntArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolRealArrayReadAccessCopy*: proc (self: ptr GodotPoolRealArrayReadAccess): ptr GodotPoolRealArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayReadAccessPtr*: proc (self: ptr GodotPoolRealArrayReadAccess): ptr float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayReadAccessOperatorAssign*: proc (self, other: ptr GodotPoolRealArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayReadAccessDestroy*: proc (self: ptr GodotPoolRealArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolStringArrayReadAccessCopy*: proc (self: ptr GodotPoolStringArrayReadAccess): ptr GodotPoolStringArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayReadAccessPtr*: proc (self: ptr GodotPoolStringArrayReadAccess): ptr GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayReadAccessOperatorAssign*: proc (self, other: ptr GodotPoolStringArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayReadAccessDestroy*: proc (self: ptr GodotPoolStringArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolVector2ArrayReadAccessCopy*: proc (self: ptr GodotPoolVector2ArrayReadAccess): ptr GodotPoolVector2ArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayReadAccessPtr*: proc (self: ptr GodotPoolVector2ArrayReadAccess): ptr Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayReadAccessOperatorAssign*: proc (self, other: ptr GodotPoolVector2ArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayReadAccessDestroy*: proc (self: ptr GodotPoolVector2ArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolVector3ArrayReadAccessCopy*: proc (self: ptr GodotPoolVector3ArrayReadAccess): ptr GodotPoolVector3ArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayReadAccessPtr*: proc (self: ptr GodotPoolVector3ArrayReadAccess): ptr Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayReadAccessOperatorAssign*: proc (self, other: ptr GodotPoolVector3ArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayReadAccessDestroy*: proc (self: ptr GodotPoolVector3ArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolColorArrayReadAccessCopy*: proc (self: ptr GodotPoolColorArrayReadAccess): ptr GodotPoolColorArrayReadAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayReadAccessPtr*: proc (self: ptr GodotPoolColorArrayReadAccess): ptr Color - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayReadAccessOperatorAssign*: proc (self, other: ptr GodotPoolColorArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayReadAccessDestroy*: proc (self: ptr GodotPoolColorArrayReadAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolByteArrayWriteAccessCopy*: proc (self: ptr GodotPoolByteArrayWriteAccess): ptr GodotPoolByteArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayWriteAccessPtr*: proc (self: ptr GodotPoolByteArrayWriteAccess): ptr byte - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayWriteAccessOperatorAssign*: proc (self, other: ptr GodotPoolByteArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolByteArrayWriteAccessDestroy*: proc (self: ptr GodotPoolByteArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolIntArrayWriteAccessCopy*: proc (self: ptr GodotPoolIntArrayWriteAccess): ptr GodotPoolIntArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayWriteAccessPtr*: proc (self: ptr GodotPoolIntArrayWriteAccess): ptr cint - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayWriteAccessOperatorAssign*: proc (self, other: ptr GodotPoolIntArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolIntArrayWriteAccessDestroy*: proc (self: ptr GodotPoolIntArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolRealArrayWriteAccessCopy*: proc (self: ptr GodotPoolRealArrayWriteAccess): ptr GodotPoolRealArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayWriteAccessPtr*: proc (self: ptr GodotPoolRealArrayWriteAccess): ptr float32 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayWriteAccessOperatorAssign*: proc (self, other: ptr GodotPoolRealArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolRealArrayWriteAccessDestroy*: proc (self: ptr GodotPoolRealArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolStringArrayWriteAccessCopy*: proc (self: ptr GodotPoolStringArrayWriteAccess): ptr GodotPoolStringArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayWriteAccessPtr*: proc (self: ptr GodotPoolStringArrayWriteAccess): ptr GodotString - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayWriteAccessOperatorAssign*: proc (self, other: ptr GodotPoolStringArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolStringArrayWriteAccessDestroy*: proc (self: ptr GodotPoolStringArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolVector2ArrayWriteAccessCopy*: proc (self: ptr GodotPoolVector2ArrayWriteAccess): ptr GodotPoolVector2ArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayWriteAccessPtr*: proc (self: ptr GodotPoolVector2ArrayWriteAccess): ptr Vector2 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayWriteAccessOperatorAssign*: proc (self, other: ptr GodotPoolVector2ArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector2ArrayWriteAccessDestroy*: proc (self: ptr GodotPoolVector2ArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolVector3ArrayWriteAccessCopy*: proc (self: ptr GodotPoolVector3ArrayWriteAccess): ptr GodotPoolVector3ArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayWriteAccessPtr*: proc (self: ptr GodotPoolVector3ArrayWriteAccess): ptr Vector3 - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayWriteAccessOperatorAssign*: proc (self, other: ptr GodotPoolVector3ArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolVector3ArrayWriteAccessDestroy*: proc (self: ptr GodotPoolVector3ArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - - poolColorArrayWriteAccessCopy*: proc (self: ptr GodotPoolColorArrayWriteAccess): ptr GodotPoolColorArrayWriteAccess - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayWriteAccessPtr*: proc (self: ptr GodotPoolColorArrayWriteAccess): ptr Color - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayWriteAccessOperatorAssign*: proc (self, other: ptr GodotPoolColorArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - poolColorArrayWriteAccessDestroy*: proc (self: ptr GodotPoolColorArrayWriteAccess) - {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - # Array API arrayNew*: proc (dest: var GodotArray) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2408,11 +2116,11 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeAsString*: proc (self: Plane): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeNormalized*: proc (self: Plane): PlaneData + planeNormalized*: proc (self: Plane): Plane {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeCenter*: proc (self: Plane): Vector3Data + planeCenter*: proc (self: Plane): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeGetAnyPoint*: proc (self: Plane): Vector3Data + planeGetAnyPoint*: proc (self: Plane): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeIsPointOver*: proc (self: Plane, point: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2420,7 +2128,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): Vector3Data + 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.} @@ -2431,13 +2139,13 @@ type segmentBegin, segmentEnd: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - planeOperatorNeg*: proc (self: Plane): PlaneData + 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): Vector3Data + planeGetNormal*: proc (self: Plane): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} planeGetD*: proc (self: Plane): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2460,21 +2168,21 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2HasNoArea*: proc (self: Rect2): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Clip*: proc (self, other: Rect2): Rect2Data + rect2Clip*: proc (self, other: Rect2): Rect2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Merge*: proc (self, other: Rect2): Rect2Data + 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): Rect2Data + rect2Grow*: proc (self: Rect2, by: float32): Rect2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2Expand*: proc (self: Rect2, to: Vector2): Rect2Data + 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): Vector2Data + rect2GetPosition*: proc (self: Rect2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - rect2GetSize*: proc (self: Rect2): Vector2Data + rect2GetSize*: proc (self: Rect2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} rect2SetPosition*: proc (self: var Rect2, pos: Vector2) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2484,11 +2192,11 @@ type # AABB API aabbNew*: proc (dest: var AABB, pos, size: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetPosition*: proc (self: AABB): Vector3Data + aabbGetPosition*: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbSetPosition*: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetSize*: proc (self: AABB): Vector3Data + aabbGetSize*: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbSetSize*: proc (self: var AABB, pos: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2504,9 +2212,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): AABBData + aabbMerge*: proc (self, other: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbIntersection*: proc (self, other: AABB): AABBData + aabbIntersection*: proc (self, other: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbIntersectsPlane*: proc (self: AABB, plane: Plane): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2515,9 +2223,9 @@ type locks: 0.} aabbHasPoint*: proc (self: AABB, point: Vector3): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetSupport*: proc (self: AABB, dir: Vector3): Vector3Data + aabbGetSupport*: proc (self: AABB, dir: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetLongestAxis*: proc (self: AABB): Vector3Data + aabbGetLongestAxis*: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbGetLongestAxisIndex*: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], @@ -2525,7 +2233,7 @@ type aabbGetLongestAxisSize*: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetShortestAxis*: proc (self: AABB): Vector3Data + aabbGetShortestAxis*: proc (self: AABB): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbGetShortestAxisIndex*: proc (self: AABB): cint {.noconv, raises: [], gcsafe, tags: [], @@ -2533,11 +2241,11 @@ type aabbGetShortestAxisSize*: proc (self: AABB): float32 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbExpand*: proc (self: AABB, toPoint: Vector3): AABBData + aabbExpand*: proc (self: AABB, toPoint: Vector3): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGrow*: proc (self: AABB, by: float32): AABBData + aabbGrow*: proc (self: AABB, by: float32): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - aabbGetEndpoint*: proc (self: AABB, idx: cint): Vector3Data + aabbGetEndpoint*: proc (self: AABB, idx: cint): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} aabbOperatorEqual*: proc (self, other: AABB): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2561,36 +2269,36 @@ type locks: 0.} transformNew*: proc (dest: var Transform, basis: Basis, origin: Vector3) {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformGetBasis*: proc (self: Transform): BasisData + 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): Vector3Data + 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): TransformData + transformInverse*: proc (self: Transform): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformAffineInverse*: proc (self: Transform): TransformData + transformAffineInverse*: proc (self: Transform): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformOrthonormalized*: proc (self: Transform): TransformData + transformOrthonormalized*: proc (self: Transform): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformRotated*: proc (self: Transform, axis: Vector3, - phi: float32): TransformData + phi: float32): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformScaled*: proc (self: Transform, scale: Vector3): TransformData + transformScaled*: proc (self: Transform, scale: Vector3): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformTranslated*: proc (self: Transform, offset: Vector3): TransformData + transformTranslated*: proc (self: Transform, offset: Vector3): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformLookingAt*: proc (self: Transform, target, up: Vector3): TransformData + transformLookingAt*: proc (self: Transform, target, up: Vector3): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformPlane*: proc (self: Transform, plane: Plane): PlaneData + transformXformPlane*: proc (self: Transform, plane: Plane): Plane {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvPlane*: proc (self: Transform, plane: Plane): PlaneData + transformXformInvPlane*: proc (self: Transform, plane: Plane): Plane {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transformNewIdentity*: proc (dest: var Transform) @@ -2598,18 +2306,18 @@ type transformOperatorEqual*: proc (self, other: Transform): bool {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformOperatorMultiply*: proc (self, other: Transform): TransformData + transformOperatorMultiply*: proc (self, other: Transform): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformVector3*: proc (self: Transform, v: Vector3): Vector3Data + transformXformVector3*: proc (self: Transform, v: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvVector3*: proc (self: Transform, v: Vector3): Vector3Data + transformXformInvVector3*: proc (self: Transform, v: Vector3): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformAABB*: proc (self: Transform, v: AABB): AABBData + transformXformAABB*: proc (self: Transform, v: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transformXformInvAABB*: proc (self: Transform, v: AABB): AABBData + transformXformInvAABB*: proc (self: Transform, v: AABB): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2622,58 +2330,58 @@ type locks: 0.} transform2DAsString*: proc (self: Transform2D): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DInverse*: proc (self: Transform2D): Transform2DData + transform2DInverse*: proc (self: Transform2D): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DAffineInverse*: proc (self: Transform2D): Transform2DData + 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): Vector2Data + transform2DGetOrigin*: proc (self: Transform2D): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DGetScale*: proc (self: Transform2D): Vector2Data + transform2DGetScale*: proc (self: Transform2D): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DOrthonormalized*: proc (self: Transform2D): Transform2DData + transform2DOrthonormalized*: proc (self: Transform2D): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DRotated*: proc (self: Transform2D, phi: float32): Transform2DData + transform2DRotated*: proc (self: Transform2D, phi: float32): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DScaled*: proc (self: Transform2D, scale: Vector2): Transform2DData + transform2DScaled*: proc (self: Transform2D, scale: Vector2): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DTranslated*: proc (self: Transform2D, offset: Vector2): Transform2DData + transform2DTranslated*: proc (self: Transform2D, offset: Vector2): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformVector2*: proc (self: Transform2D, v: Vector2): Vector2Data + transform2DXformVector2*: proc (self: Transform2D, v: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformInvVector2*: proc (self: Transform2D, v: Vector2): Vector2Data + transform2DXformInvVector2*: proc (self: Transform2D, v: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DBasisXformVector2*: proc (self: Transform2D, v: Vector2): Vector2Data + transform2DBasisXformVector2*: proc (self: Transform2D, v: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DBasisXformInvVector2*: proc (self: Transform2D, - v: Vector2): Vector2Data + v: Vector2): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} transform2DInterpolateWith*: proc (self, other: Transform2D, - t: float32): Transform2DData + 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): Transform2DData + 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): Rect2Data + transform2DXformRect2*: proc (self: Transform2D, v: Rect2): Rect2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - transform2DXformInvRect2*: proc (self: Transform2D, v: Rect2): Rect2Data + transform2DXformInvRect2*: proc (self: Transform2D, v: Rect2): Rect2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2762,25 +2470,25 @@ type {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsString*: proc (self: GodotVariant): GodotString {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsVector2*: proc (self: GodotVariant): Vector2Data + variantAsVector2*: proc (self: GodotVariant): Vector2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsRect2*: proc (self: GodotVariant): Rect2Data + variantAsRect2*: proc (self: GodotVariant): Rect2 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsVector3*: proc (self: GodotVariant): Vector3Data + variantAsVector3*: proc (self: GodotVariant): Vector3 {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsTransform2D*: proc (self: GodotVariant): Transform2DData + variantAsTransform2D*: proc (self: GodotVariant): Transform2D {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsPlane*: proc (self: GodotVariant): PlaneData + variantAsPlane*: proc (self: GodotVariant): Plane {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsQuat*: proc (self: GodotVariant): QuatData + variantAsQuat*: proc (self: GodotVariant): Quat {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsAABB*: proc (self: GodotVariant): AABBData + variantAsAABB*: proc (self: GodotVariant): AABB {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsBasis*: proc (self: GodotVariant): BasisData + variantAsBasis*: proc (self: GodotVariant): Basis {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsTransform*: proc (self: GodotVariant): TransformData + variantAsTransform*: proc (self: GodotVariant): Transform {.noconv, raises: [], gcsafe, tags: [], locks: 0.} - variantAsColor*: proc (self: GodotVariant): ColorData + variantAsColor*: proc (self: GodotVariant): Color {.noconv, raises: [], gcsafe, tags: [], locks: 0.} variantAsNodePath*: proc (self: GodotVariant): GodotNodePath {.noconv, raises: [], gcsafe, tags: [], locks: 0.} @@ -2832,18 +2540,14 @@ 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.} - stringWideStr*: proc (self: GodotString): ptr cwchar_t - {.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 @@ -2854,12 +2558,6 @@ 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) @@ -2928,38 +2626,6 @@ 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: @@ -2972,8 +2638,7 @@ var gdNativeAPI: GDNativeAPI proc getGDNativeAPI*(): ptr GDNativeAPI {.inline.} = addr gdNativeAPI -proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOptions, - foundCoreApi: var bool, foundNativeScriptApi: var bool) = +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: @@ -2981,7 +2646,7 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt case typ: of GDNativeCore: let coreApi = cast[ptr GDNativeCoreAPI1](apiStruct) - if coreApi[].version.major == 1 and coreApi[].version.minor == 0: + if coreApi[].version.major == 1: assign(gdNativeApi, coreApi[]): # Color API colorNewRGBA @@ -3084,8 +2749,6 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt poolByteArrayPushBack poolByteArrayRemove poolByteArrayResize - poolByteArrayRead - poolByteArrayWrite poolByteArraySet poolByteArrayGet poolByteArraySize @@ -3102,8 +2765,6 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt poolIntArrayPushBack poolIntArrayRemove poolIntArrayResize - poolIntArrayRead - poolIntArrayWrite poolIntArraySet poolIntArrayGet poolIntArraySize @@ -3120,8 +2781,6 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt poolRealArrayPushBack poolRealArrayRemove poolRealArrayResize - poolRealArrayRead - poolRealArrayWrite poolRealArraySet poolRealArrayGet poolRealArraySize @@ -3138,8 +2797,6 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt poolStringArrayPushBack poolStringArrayRemove poolStringArrayResize - poolStringArrayRead - poolStringArrayWrite poolStringArraySet poolStringArrayGet poolStringArraySize @@ -3157,8 +2814,6 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt poolVector2ArrayPushBack poolVector2ArrayRemove poolVector2ArrayResize - poolVector2ArrayRead - poolVector2ArrayWrite poolVector2ArraySet poolVector2ArrayGet poolVector2ArraySize @@ -3175,8 +2830,6 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt poolVector3ArrayPushBack poolVector3ArrayRemove poolVector3ArrayResize - poolVector3ArrayRead - poolVector3ArrayWrite poolVector3ArraySet poolVector3ArrayGet poolVector3ArraySize @@ -3193,8 +2846,6 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt poolColorArrayPushBack poolColorArrayRemove poolColorArrayResize - poolColorArrayRead - poolColorArrayWrite poolColorArraySet poolColorArrayGet poolColorArraySize @@ -3240,78 +2891,6 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt arrayBSearchCustom arrayDestroy - # Pool Array Read/Write Access API - - poolByteArrayReadAccessCopy - poolByteArrayReadAccessPtr - poolByteArrayReadAccessOperatorAssign - poolByteArrayReadAccessDestroy - - poolIntArrayReadAccessCopy - poolIntArrayReadAccessPtr - poolIntArrayReadAccessOperatorAssign - poolIntArrayReadAccessDestroy - - poolRealArrayReadAccessCopy - poolRealArrayReadAccessPtr - poolRealArrayReadAccessOperatorAssign - poolRealArrayReadAccessDestroy - - poolStringArrayReadAccessCopy - poolStringArrayReadAccessPtr - poolStringArrayReadAccessOperatorAssign - poolStringArrayReadAccessDestroy - - poolVector2ArrayReadAccessCopy - poolVector2ArrayReadAccessPtr - poolVector2ArrayReadAccessOperatorAssign - poolVector2ArrayReadAccessDestroy - - poolVector3ArrayReadAccessCopy - poolVector3ArrayReadAccessPtr - poolVector3ArrayReadAccessOperatorAssign - poolVector3ArrayReadAccessDestroy - - poolColorArrayReadAccessCopy - poolColorArrayReadAccessPtr - poolColorArrayReadAccessOperatorAssign - poolColorArrayReadAccessDestroy - - poolByteArrayWriteAccessCopy - poolByteArrayWriteAccessPtr - poolByteArrayWriteAccessOperatorAssign - poolByteArrayWriteAccessDestroy - - poolIntArrayWriteAccessCopy - poolIntArrayWriteAccessPtr - poolIntArrayWriteAccessOperatorAssign - poolIntArrayWriteAccessDestroy - - poolRealArrayWriteAccessCopy - poolRealArrayWriteAccessPtr - poolRealArrayWriteAccessOperatorAssign - poolRealArrayWriteAccessDestroy - - poolStringArrayWriteAccessCopy - poolStringArrayWriteAccessPtr - poolStringArrayWriteAccessOperatorAssign - poolStringArrayWriteAccessDestroy - - poolVector2ArrayWriteAccessCopy - poolVector2ArrayWriteAccessPtr - poolVector2ArrayWriteAccessOperatorAssign - poolVector2ArrayWriteAccessDestroy - - poolVector3ArrayWriteAccessCopy - poolVector3ArrayWriteAccessPtr - poolVector3ArrayWriteAccessOperatorAssign - poolVector3ArrayWriteAccessDestroy - - poolColorArrayWriteAccessCopy - poolColorArrayWriteAccessPtr - poolColorArrayWriteAccessOperatorAssign - poolColorArrayWriteAccessDestroy - # Dictionary API dictionaryNew dictionaryNewCopy @@ -3540,21 +3119,15 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt variantDestroy # String API - charStringLength - charStringGetData - charStringDestroy - stringNew stringNewCopy - stringWideStr + stringNewData + stringGetData stringOperatorEqual stringOperatorLess stringOperatorPlus stringLength stringDestroy - stringUtf8 - stringCharsToUtf8 - stringCharsToUtf8WithLen # Misc API objectDestroy @@ -3572,14 +3145,15 @@ proc setGDNativeAPIInternal(apiStruct: pointer, initOptions: ptr GDNativeInitOpt printWarning print - foundCoreApi = true for i in 0.cuint..= (0, 19, 0): - import compiler/lineinfos - -when (NimMajor, NimMinor, NimPatch) >= (0, 19, 0): - var gic = newIdentCache() - - proc getIdent(ident: string): PIdent = - getIdent(gic, ident) +import compiler / [ast, renderer, idents, astalgo] proc ident(ident: string): PNode = - result = PNode(kind: nkIdent, ident: getIdent(ident)) - -proc newPNode(kind: TNodeKind): PNode = - 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) + result = newNode(nkIdent) + result.ident = getIdent(ident) proc addChain(node: PNode, others: varargs[PNode]): PNode {.discardable.} = for other in others: @@ -34,37 +15,37 @@ proc addChain(node: PNode, others: varargs[PNode]): PNode {.discardable.} = proc newIdentDefs(name, typ: PNode, defaultVal: PNode = nil): PNode = - result = newPNode(nkIdentDefs) + result = newNode(nkIdentDefs) result.add(name) result.add(typ) if defaultVal.isNil: - result.add(newPNode(nkEmpty)) + result.add(newNode(nkEmpty)) else: result.add(defaultVal) -proc newProc(name: PNode, params: openArray[PNode], body = newPNode(nkEmpty), +proc newProc(name: PNode, params: openArray[PNode], body = newNode(nkEmpty), procType = nkProcDef): PNode = - result = newPNode(procType) + result = newNode(procType) result.add(name) - result.add(newPNode(nkEmpty)) - result.add(newPNode(nkEmpty)) - let formalParams = newPNode(nkFormalParams) + result.add(newNode(nkEmpty)) + result.add(newNode(nkEmpty)) + let formalParams = newNode(nkFormalParams) for param in params: formalParams.add(param) result.add(formalParams) - result.add(newPNode(nkEmpty)) - result.add(newPNode(nkEmpty)) + result.add(newNode(nkEmpty)) + result.add(newNode(nkEmpty)) result.add(body) proc newIfStmt(condition, body: PNode): PNode = - result = newPNode(nkIfStmt) - let branch = newPNode(nkElifBranch) + result = newNode(nkIfStmt) + let branch = newNode(nkElifBranch) result.add(branch) branch.add(condition) branch.add(body) proc newCall(theProc: PNode, args: varargs[PNode]): PNode = - result = newPNode(nkCall) + result = newNode(nkCall) result.add(theProc) for arg in args: result.add(arg) @@ -73,66 +54,66 @@ proc newCall(theProc: string, args: varargs[PNode]): PNode = newCall(ident(theProc), args) proc newStrLit(s: string): PNode = - result = newPNode(nkStrLit) + result = newNode(nkStrLit) result.strVal = s proc newRStrLit(s: string): PNode = - result = newPNode(nkRStrLit) + result = newNode(nkRStrLit) result.strVal = s proc newCStringLit(s: string): PNode = - newPNode(nkCallStrLit).addChain(ident("cstring"), newRStrLit(s)) + newNode(nkCallStrLit).addChain(ident("cstring"), newRStrLit(s)) proc newIntLit(val: BiggestInt): PNode = - result = newPNode(nkIntLit) + result = newNode(nkIntLit) result.intVal = val proc newInt64Lit(val: BiggestInt): PNode = - result = newPNode(nkInt64Lit) + result = newNode(nkInt64Lit) result.intVal = val proc newFloatLit(val: BiggestFloat): PNode = - result = newPNode(nkFloatLit) + result = newNode(nkFloatLit) result.floatVal = val proc newFloat64Lit(val: BiggestFloat): PNode = - result = newPNode(nkFloat64Lit) + result = newNode(nkFloat64Lit) result.floatVal = val proc newNilLit(): PNode = - result = newPNode(nkNilLit) + result = newNode(nkNilLit) proc newDotExpr(left, right: PNode): PNode = - result = newPNode(nkDotExpr) + result = newNode(nkDotExpr) result.add(left) result.add(right) proc newCommand(left, right: PNode): PNode = - result = newPNode(nkCommand) + result = newNode(nkCommand) result.add(left) result.add(right) proc infix(left, op, right: PNode): PNode = - result = newPNode(nkInfix) + result = newNode(nkInfix) result.add(op) result.add(left) result.add(right) proc postfix(left: PNode, op: string): PNode = - result = newPNode(nkPostfix) + result = newNode(nkPostfix) result.add(ident(op)) result.add(left) proc prefix(op: string, right: PNode): PNode = - result = newPNode(nkPrefix) + result = newNode(nkPrefix) result.add(ident(op)) result.add(right) proc newBracketExpr(first, bracket: PNode): PNode = - newPNode(nkBracketExpr).addChain(first, bracket) + newNode(nkBracketExpr).addChain(first, bracket) proc newEmptyNode(): PNode = - newPNode(nkEmpty) + newNode(nkEmpty) type GodotType = ref object name: string @@ -158,19 +139,19 @@ proc findCommonRoot(typeRegistry: Table[string, GodotType], var idx = 0 while true: - var curType = none(string) + var curType: string var allEqual = true for chain in chains: if idx >= chain.len: allEqual = false break - if curType.isNone: - curType = some(chain[idx]) - elif curType.get != chain[idx]: + if curType.isNil: + curType = chain[idx] + elif curType != chain[idx]: allEqual = false break if allEqual: - result = curType.get + result = curType else: break inc idx @@ -225,42 +206,42 @@ proc toNimStyle(name: string): string = proc newRefTypeNode(typeSection: PNode, typ, base, doc: string, isExported = true) = - let typeDef = newPNode(nkTypeDef) + let typeDef = newNode(nkTypeDef) typeSection.add(typeDef) if isExported: typeDef.add(postfix(ident(typ), "*")) else: typeDef.add(ident(typ)) - typeDef.add(newPNode(nkEmpty)) # generic - let objTy = newPNode(nkObjectTy) - let refTy = newPNode(nkRefTy) + typeDef.add(newNode(nkEmpty)) # generic + let objTy = newNode(nkObjectTy) + let refTy = newNode(nkRefTy) refTy.add(objTy) typeDef.add(refTy) - objTy.add(newPNode(nkEmpty)) - let inherit = newPNode(nkOfInherit) + objTy.add(newNode(nkEmpty)) + let inherit = newNode(nkOfInherit) inherit.add(ident(base)) objTy.add(inherit) - if doc.len > 0: - let recList = newPNode(nkRecList) - let docNode = newPNode(nkCommentStmt) + if not doc.isNil: + let recList = newNode(nkRecList) + let docNode = newNode(nkCommentStmt) docNode.comment = doc recList.add(docNode) objTy.add(recList) else: - objTy.add(newPNode(nkEmpty)) + objTy.add(newNode(nkEmpty)) proc makeConstSection(constObj: JsonNode): PNode = if constObj.len == 0: - return newPNode(nkEmpty) + return newNode(nkEmpty) - result = newPNode(nkConstSection) + result = newNode(nkConstSection) for field, val in constObj: - let def = newPNode(nkConstDef) + let def = newNode(nkConstDef) def.add(postfix(ident(field), "*")) - def.add(newPNode(nkEmpty)) # infer type + def.add(newNode(nkEmpty)) # infer type var valNode: PNode if val.kind == JInt: valNode = newInt64Lit(val.num) @@ -270,7 +251,7 @@ proc makeConstSection(constObj: JsonNode): PNode = elif val.kind == JBool: valNode = ident($val.bval) elif val.kind == JString: - valNode = newPNode(nkStrLit) + valNode = newNode(nkStrLit) valNode.strVal = val.str else: raise newException(ValueError, "Unexpected constant kind: " & $val.kind) @@ -278,63 +259,46 @@ proc makeConstSection(constObj: JsonNode): PNode = result.add(def) type - ArgKind = enum - Normal, - VarArgs - Bound - - MethodArg = object - name: string - typ: string - defaultVal: JsonNode - kind: ArgKind - + MethodArg = tuple[name, typ: string, defaultVal: JsonNode, isVarargs: bool] MethodInfo = ref object name: PNode godotName: string typ: GodotType args: seq[MethodArg] - returnType: Option[string] + returnType: string isVirtual: bool isBase: bool isDiscardable: bool -const standardTypes = toHashSet( +const standardTypes = toSet( ["bool", "cint", "int", "uint8", "int8", "uint16", "int16", "uint32", "int32", - "uint64", "Error", + "uint64", "int64", "float32", "cfloat", "float64", "GodotString", "Vector2", "Rect2", "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform", "Color", "RID", "NodePath", "Dictionary", "Variant", "Array", "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"]) +const smallIntTypes = toSet(["uint8", "int8", "uint16", "int16", "uint32", + "int32", "cint", "int", "Error"]) +const int64Types = toSet(["uint64", "int64"]) const intTypes = union(smallIntTypes, int64Types) -const float64Types = toHashSet(["float64", "cdouble"]) -const float32Types = toHashSet(["float32", "cfloat"]) +const float64Types = toSet(["float64", "cdouble"]) +const float32Types = toSet(["float32", "cfloat"]) const floatTypes = union(float64Types, float32Types) -const arrayTypes = toHashSet(["Array", "PoolByteArray", +const arrayTypes = toSet(["Array", "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray", "PoolVector2Array", "PoolVector3Array", "PoolColorArray"]) const wrapperTypes = union(arrayTypes, - toHashSet(["NodePath", "Dictionary", "Variant"])) + toSet(["NodePath", "Dictionary", "Variant"])) proc getInternalPtr(varName: PNode, typ: string): PNode = - assert(typ in wrapperTypes or typ == "Object") + assert(typ in wrapperTypes) result = newDotExpr(varName, ident("godot" & typ)) proc newNilCheck(ident, toAssign: PNode): PNode = newIfStmt(newCall("isNil", ident), - newPNode(nkAsgn).addChain(ident).addChain( + newNode(nkAsgn).addChain(ident).addChain( toAssign ) ) @@ -345,7 +309,6 @@ 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: @@ -362,15 +325,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'): @@ -379,58 +342,23 @@ proc makeDefaultValue(arg: MethodArg): PNode = result = newCall("initRect2", parts) elif arg.defaultVal.str == "[Object:null]": result = newNilLit() - 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 - elif arg.typ == "Dictionary": - result = newCall("newDictionary") - else: - failed = true - - if failed: + elif arg.typ != "Transform" and arg.typ != "Transform2D" and + arg.typ != "Variant" and arg.typ notin arrayTypes: # TODO raise newException( ValueError, - "Cannot build default value from \"$#\" ($#) - please report this at https://github.com/pragmagic/godot-nim/issues" % + "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 if not withImplementation: - body = newPNode(nkEmpty) + body = newNode(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 = newPNode(nkStmtList).addChain( - newPNode(nkDiscardStmt).addChain(newPNode(nkEmpty))) + body = newNode(nkStmtList).addChain( + newNode(nkDiscardStmt).addChain(newNode(nkEmpty))) else: let methGodotName = if meth.godotName.startsWith('_'): "underscore" & meth.godotName[1..^1] @@ -441,12 +369,12 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], if methodBindName[0].isUpperAscii(): methodBindName[0] = methodBindName[0].toLowerAscii() if methodBindName notin methodBindRegistry: - let methodBindDecl = newPNode(nkVarSection).addChain( + let methodBindDecl = newNode(nkVarSection).addChain( newIdentDefs( - newPNode(nkPragmaExpr).addChain( + newNode(nkPragmaExpr).addChain( ident(methodBindName)).addChain( - newPNode(nkPragma).addChain(ident("threadvar"))), - newPNode(nkPtrTy).addChain(ident("GodotMethodBind")) + newNode(nkPragma).addChain(ident("threadvar"))), + newNode(nkPtrTy).addChain(ident("GodotMethodBind")) )) tree.add(methodBindDecl) methodBindRegistry.incl(methodBindName) @@ -455,138 +383,94 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], newCall("getMethod", newCStringLit(meth.typ.godotName), newCStringLit(meth.godotName)) ) - let vars = newPNode(nkVarSection) - var varargsName = none(string) + let vars = newNode(nkVarSection) + var varargsName: string var isVarargs: bool var staticArgsLen: int var argLenNode = newIntLit(0) let argsName = ident("argsToPassToGodot") if meth.args.len > 0: - for idx, arg in meth.args: - if arg.kind == ArgKind.VarArgs: - varargsName = some(arg.name) + for arg in meth.args: + if arg.isVarargs: + varargsName = arg.name isVarargs = true vars.add(newIdentDefs(ident("callError"), ident("VariantCallError"))) - elif arg.kind == ArgKind.Bound: - let argName = boundArgName(idx) - vars.add(newIdentDefs( - ident(argName), newPNode(nkEmpty), arg.makeDefaultValue())) - - let argsAlloc = newPNode(nkCast).addChain( - newPNode(nkPtrTy).addChain( - newPNode(nkBracketExpr).addChain( + break + let argsAlloc = newNode(nkCast).addChain( + newNode(nkPtrTy).addChain( + newNode(nkBracketExpr).addChain( ident("array"), ident("MAX_ARG_COUNT"), - if isVarargs: newPNode(nkPtrTy).addChain(ident("GodotVariant")) + if isVarargs: newNode(nkPtrTy).addChain(ident("GodotVariant")) else: ident("pointer")))) - staticArgsLen = if varargsName.isNone: meth.args.len + staticArgsLen = if varargsName.isNil: meth.args.len else: meth.args.len - 1 - if varargsName.isSome: + if not varargsName.isNil: argLenNode = newCall("cint", infix(newIntLit(staticArgsLen), ident("+"), - newDotExpr(ident(varargsName.get), ident("len")))) + newDotExpr(ident(varargsName), ident("len")))) argsAlloc.add(newCall("godotAlloc", newCall("cint", infix( - newCall("sizeof", newPNode(nkPtrTy).addChain(ident("GodotVariant"))), ident("*"), - newPNode(nkPar).addChain(argLenNode)))) + newCall("sizeof", ident("Variant")), ident("*"), + newNode(nkPar).addChain(argLenNode)))) ) else: argLenNode = newCall("cint", newIntLit(staticArgsLen)) vars.add(newIdentDefs( ident("argsStatic"), - newPNode(nkBracketExpr).addChain( + newNode(nkBracketExpr).addChain( ident("array"), newIntLit(staticArgsLen), ident("pointer")), - newPNode(nkEmpty))) + newNode(nkEmpty))) argsAlloc.add(newCommand(ident("addr"), ident("argsStatic"))) - vars.add(newIdentDefs(argsName, newPNode(nkEmpty), argsAlloc)) + vars.add(newIdentDefs(argsName, newNode(nkEmpty), argsAlloc)) - let argConversions = newPNode(nkStmtList) - let destructors = newPNode(nkStmtList) + let argConversions = newNode(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 = newPNode(nkBracketExpr).addChain( - ident(varargsName.get), + var argName = ident(arg.name) + if arg.isVarargs: + argName = newNode(nkBracketExpr).addChain( + ident(varargsName), infix(ident("idx"), ident("-"), newIntLit(staticArgsLen))) - let argIdx = if arg.kind == ArgKind.VarArgs: ident("idx") else: newIntLit(idx) + let argIdx = if arg.isVarargs: ident("idx") else: newIntLit(idx) let isStandardType = arg.typ in standardTypes let isWrappedType = arg.typ in wrapperTypes - 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: + let convArg = if not varargsName.isNil: + 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 + if not isStandardType and arg.isVarargs: 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.isNone: + if not isStandardType and varargsName.isNil: if arg.typ == "string": - argConversions.add(newPNode(nkVarSection).addChain( + argConversions.add(newNode(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(newPNode(nkElse).addChain(newNilLit())) - argConversions.add(newPNode(nkLetSection).addChain( - newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(), objVal))) - let argAsgn = newPNode(nkAsgn).addChain( - newPNode(nkBracketExpr).addChain( - newPNode(nkBracketExpr).addChain(argsName), argIdx), + argConversions.add(newNode(nkLetSection).addChain( + newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(), + newDotExpr(argName, ident("godotObject"))))) + let argAsgn = newNode(nkAsgn).addChain( + newNode(nkBracketExpr).addChain( + newNode(nkBracketExpr).addChain(argsName), argIdx), convArg ) - if arg.kind != ArgKind.VarArgs: + if not arg.isVarargs: argConversions.add( argAsgn ) else: - argConversions.add(newPNode(nkVarSection).addChain( - newIdentDefs(ident("idx"), newPNode(nkEmpty), + argConversions.add(newNode(nkVarSection).addChain( + newIdentDefs(ident("idx"), newNode(nkEmpty), newIntLit(staticArgsLen)))) - let argLoop = newPNode(nkWhileStmt) + let argLoop = newNode(nkWhileStmt) argConversions.add(argLoop) argLoop.add(infix(ident("idx"), ident("<"), argLenNode) ) - argLoop.add(newPNode(nkStmtList).addChain( + argLoop.add(newNode(nkStmtList).addChain( argAsgn, newCommand(ident("inc"), ident("idx")))) @@ -595,26 +479,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: newPNode(nkNilLit), + if meth.args.len > 0: argsName else: newNode(nkNilLit), argLenNode, if not isVarargs: ident(retName) else: ident("callError") ) if not isVarargs: theCall.sons.delete(3) let freeCall = newCall("godotFree", argsName) - body = newPNode(nkStmtList) + body = newNode(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(newPNode(nkLetSection).addChain(newIdentDefs( - ident("self"), newPNode(nkEmpty), varName + body.add(newNode(nkLetSection).addChain(newIdentDefs( + ident("self"), newNode(nkEmpty), varName ))) body.add(nilCheck) body.add(vars) body.add(argConversions) if not isVarargs: - let retPtrDecl = newPNode(nkVarSection).addChain( + let retPtrDecl = newNode(nkVarSection).addChain( newIdentDefs(ident(retName), ident("pointer"), newEmptyNode()) ) body.add(retPtrDecl) @@ -624,135 +508,126 @@ 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 meth.returnType.isSome and not isVarargs: - let returnType = meth.returnType.get + if not meth.returnType.isNil and not isVarargs: var addrToAssign = newCall("addr", retValIdent) - if returnType in smallIntTypes: + if meth.returnType in smallIntTypes: isConversionRet = true - body.add(newPNode(nkVarSection).addChain(newIdentDefs( + body.add(newNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("int64"), ))) - elif returnType in float32Types: + elif meth.returnType in float32Types: isConversionRet = true - body.add(newPNode(nkVarSection).addChain(newIdentDefs( + body.add(newNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("float64"), ))) - elif returnType in wrapperTypes: + elif meth.returnType in wrapperTypes: isWrapperRet = true - body.add(newPNode(nkVarSection).addChain(newIdentDefs( - retValIdent, ident("Godot" & returnType), + body.add(newNode(nkVarSection).addChain(newIdentDefs( + retValIdent, ident("Godot" & meth.returnType), ))) - if returnType != "NodePath": - body.add(newCall("initGodot" & returnType, retValIdent)) - elif returnType in standardTypes: + elif meth.returnType in standardTypes: addrToAssign = newCall("addr", ident("result")) - elif returnType == "string": + elif meth.returnType == "string": isStringRet = true - body.add(newPNode(nkVarSection).addChain(newIdentDefs( + body.add(newNode(nkVarSection).addChain(newIdentDefs( retValIdent, ident("GodotString"), ))) - elif returnType != "void": + elif meth.returnType != "void": isObjRet = true - body.add(newPNode(nkVarSection).addChain(newIdentDefs( - retValIdent, newPNode(nkPtrTy).addChain(ident("GodotObject")), + body.add(newNode(nkVarSection).addChain(newIdentDefs( + retValIdent, newNode(nkPtrTy).addChain(ident("GodotObject")), ))) - body.add(newPNode(nkAsgn).addChain(ident(retName), addrToAssign)) + body.add(newNode(nkAsgn).addChain(ident(retName), addrToAssign)) if not isVarargs: body.add(theCall) else: - if meth.returnType.isSome: + if not meth.returnType.isNil: isVariantRet = true - let callStmt = newPNode(nkLetSection).addChain( + let callStmt = newNode(nkLetSection).addChain( newIdentDefs( - newPNode(nkPragmaExpr).addChain( - ident(retName), newPNode(nkPragma).addChain(ident("used"))), - newPNode(nkEmpty), theCall)) + newNode(nkPragmaExpr).addChain( + ident(retName), newNode(nkPragma).addChain(ident("used"))), + newNode(nkEmpty), theCall)) body.add(callStmt) - if varargsName.isNone: + if varargsName.isNil: for idx, arg in meth.args: if arg.typ == "string": body.add(newCall("deinit", ident("argToPassToGodot" & $idx))) - if varargsName.isSome: - if meth.args.len > 0: - body.add(freeCall) - body.add(destructors) + if meth.args.len > 0 and not varargsName.isNil: + body.add(freeCall) + if not varargsName.isNil: let errCheck = newIfStmt( infix(newDotExpr(ident("callError"), ident("error")), ident("!="), newDotExpr(ident("VariantCallErrorType"), ident("OK"))), - newPNode(nkRaiseStmt).addChain( + newNode(nkRaiseStmt).addChain( newCall("newCallError", ident("callError"))) ) body.add(errCheck) if isVariantRet: - let convErrDef = newPNode(nkLetSection).addChain( - newIdentDefs(ident("convErr"), newPNode(nkEmpty), + let convErrDef = newNode(nkLetSection).addChain( + newIdentDefs(ident("convErr"), newNode(nkEmpty), newCall("fromVariant", ident("result"), newCall("newVariant", retValIdent)))) let convCheck = newIfStmt( infix(ident("convErr"), ident("!="), newDotExpr(ident("ConversionResult"), ident("OK"))), - newPNode(nkRaiseStmt).addChain( + newNode(nkRaiseStmt).addChain( newCall("newConversionError", ident("convErr"))) ) body.add(convErrDef) body.add(convCheck) if isStringRet: - body.add(newPNode(nkAsgn).addChain( + body.add(newNode(nkAsgn).addChain( ident("result"), prefix("$", retValIdent))) body.add(newCall("deinit", retValIdent)) elif isConversionRet: - body.add(newPNode(nkAsgn).addChain( + body.add(newNode(nkAsgn).addChain( ident("result"), - newCall(meth.returnType.get, retValIdent))) + newCall(meth.returnType, retValIdent))) elif isWrapperRet: - body.add(newPNode(nkAsgn).addChain( + body.add(newNode(nkAsgn).addChain( ident("result"), - newCall("new" & meth.returnType.get, retValIdent))) + newCall("new" & meth.returnType, retValIdent))) elif isObjRet: - body.add(newPNode(nkAsgn).addChain(ident("result"), + body.add(newNode(nkAsgn).addChain(ident("result"), newCall(newBracketExpr(ident("asNimGodotObject"), - newCall("type", ident("result"))), - retValIdent, ident("false"), ident("true")))) + newCall("type", ident("result"))), retValIdent))) elif isStringRet: - body.add(newPNode(nkAsgn).addChain(ident("result"), + body.add(newNode(nkAsgn).addChain(ident("result"), newCall("$", retValIdent))) let procType = if meth.isVirtual: nkMethodDef else: nkProcDef var params = newSeqOfCap[PNode](meth.args.len + 2) - if meth.returnType.isSome: - params.add(ident(meth.returnType.get)) + if not meth.returnType.isNil: + params.add(ident(meth.returnType)) else: - params.add(newPNode(nkEmpty)) + params.add(newNode(nkEmpty)) if not meth.typ.isSingleton: params.add(newIdentDefs(ident("self"), ident(toNimType(meth.typ.name)))) for arg in meth.args: - case arg.kind: - of ArgKind.Normal: + if arg.isVarargs: + params.add(newIdentDefs(ident(arg.name), + newNode(nkBracketExpr).addChain(ident("varargs"), ident(arg.typ)))) + else: let defaultValue = arg.makeDefaultValue() params.add(newIdentDefs(ident(arg.name), ident(arg.typ), defaultValue)) - of ArgKind.VarArgs: - params.add(newIdentDefs(ident(arg.name), - newPNode(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) if not withImplementation: - let pragma = newPNode(nkPragma) + let pragma = newNode(nkPragma) pragma.add(ident("gcsafe")) - pragma.add(newPNode(nkExprColonExpr).addChain(ident("locks"), + pragma.add(newNode(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 pragma.add(ident("base")) - if meth.isDiscardable and meth.returnType.isSome: + if meth.isDiscardable and not meth.returnType.isNil: pragma.add(ident("discardable")) procDecl.sons[4] = pragma tree.add(procDecl) @@ -761,8 +636,45 @@ 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 = +proc makeProperty(types: Table[string, GodotType], tree: PNode, + methodBindRegistry: var HashSet[string], + typ: GodotType, + propertyObj: JsonNode, withImplementation: bool) = + let getterNameStr = toNimStyle(propertyObj["name"].str) + let getterName = ident(toNimStyle(propertyObj["name"].str)) + let setterName = newNode(nkAccQuoted).addChain(ident(getterNameStr & "=")) + + let nimType = toNimType(types, propertyObj["type"].str) + let getterInfo = MethodInfo( + name: getterName, + typ: typ, + godotName: propertyObj["getter"].str, + args: @[], + returnType: nimType + ) + let setterInfo = MethodInfo( + name: setterName, + typ: typ, + godotName: propertyObj["setter"].str, + args: @[("val", nimType, JsonNode(nil), false)] + ) + generateMethod(tree, methodBindRegistry, getterInfo, withImplementation) + generateMethod(tree, methodBindRegistry, setterInfo, withImplementation) + +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 + + 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"] var isBase = methodObj["is_virtual"].bval if methodObj["is_virtual"].bval: @@ -778,16 +690,14 @@ proc getMethodInfo(methodObj: JsonNode, types: Table[string, GodotType], 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)) + args.add((toNimStyle(arg["name"].str), typ, + defaultVal, false)) if methodObj["has_varargs"].bval: - args.add(MethodArg(name: "variantArgs", typ: "Variant", kind: ArgKind.VarArgs)) + args.add(("variantArgs", "Variant", JsonNode(nil), true)) let godotName = methodObj["name"].str var nimName = toNimStyle(godotName) @@ -796,11 +706,8 @@ proc getMethodInfo(methodObj: JsonNode, types: Table[string, GodotType], if meth["name"].str == '_' & godotName: nimName = nimName & "Impl" - let returnType = if methodObj["return_type"].str != "void": - some(toNimType(types, methodObj["return_type"].str)) - else: none(string) - const discardableMethods = toHashSet(["emit_signal"]) - result = MethodInfo( + const discardableMethods = toSet(["emit_signal"]) + let methodInfo = MethodInfo( name: ident(nimName), typ: typ, godotName: methodObj["name"].str, @@ -812,71 +719,6 @@ proc getMethodInfo(methodObj: JsonNode, types: Table[string, GodotType], 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, 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 = newPNode(nkAccQuoted).addChain(ident(getterNameStr & "=")) - - let getter = findMethod(obj, propertyObj["getter"].str) - let nimType = if getter.isNil: toNimType(types, propertyObj["type"].str) - else: getMethodInfo(getter, types, typ).returnType.get("void") - let getterInfo = MethodInfo( - name: getterName, - typ: typ, - godotName: propertyObj["getter"].str, - args: newSeq[MethodArg](), - returnType: some(nimType) - ) - let setterInfo = MethodInfo( - name: setterName, - typ: typ, - godotName: propertyObj["setter"].str, - 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) - -proc makeMethod(types: Table[string, GodotType], tree: PNode, - methodBindRegistry: var HashSet[string], - typ: GodotType, methodObj: JsonNode, - withImplementation: bool) = - 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: - 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) - generateMethod(tree, methodBindRegistry, methodInfo, withImplementation) proc addAttributeToDoc(doc: var string, propName, propValue: string) = @@ -909,15 +751,15 @@ proc typeNameToModuleName(name: string): string = proc newRegisterClassNode(typ: GodotType): PNode = newCall("registerClass", ident(typ.name), - newStrLit(typ.godotName), + newCStringLit(typ.godotName), ident("true") # isNative ) proc genSingletonDecl(typ: string): PNode = - result = newPNode(nkVarSection) + result = newNode(nkVarSection) let name = singletonName(typ) - let threadvar = newPNode(nkPragma).addChain(ident("threadvar")) - result.add(newIdentDefs(newPNode(nkPragmaExpr).addChain(name, threadvar), + let threadvar = newNode(nkPragma).addChain(ident("threadvar")) + result.add(newIdentDefs(newNode(nkPragmaExpr).addChain(name, threadvar), ident(typ))) proc shouldExport(typ: GodotType, types: Table[string, GodotType]): bool = @@ -934,9 +776,9 @@ proc sortByDerivedCount(types: Table[string, GodotType]): seq[GodotType] = proc genTypeFile(types: Table[string, GodotType], targetDir: string) = let sortedTypes = sortByDerivedCount(types) - let godotApiTypesTree = newPNode(nkStmtList) - godotApiTypesTree.add(newPNode(nkImportStmt).addChain(ident("godot"))) - let typeSection = newPNode(nkTypeSection) + let godotApiTypesTree = newNode(nkStmtList) + godotApiTypesTree.add(newNode(nkImportStmt).addChain(ident("godot"))) + let typeSection = newNode(nkTypeSection) godotApiTypesTree.add(typeSection) for typ in sortedTypes: @@ -947,7 +789,7 @@ proc genTypeFile(types: Table[string, GodotType], targetDir: string) = if not typ.shouldExport(types): continue let regNode = newCall("registerClass", ident(typ.name), - newStrLit(typ.godotName), + newCStringLit(typ.godotName), ident("true") # isNative ) godotApiTypesTree.add(regNode) @@ -958,10 +800,10 @@ proc genSingletonWithDerived(tree: PNode, typ: GodotType, types: Table[string, GodotType]) = let sortedTypes = sortByDerivedCount(types) - var parents = initHashSet[string]() + var parents = initSet[string]() parents.incl(typ.name) - let typeDecl = newPNode(nkTypeSection) + let typeDecl = newNode(nkTypeSection) tree.add(typeDecl) proc genDecl(typ: GodotType) = newRefTypeNode(typeDecl, typ.name, typ.baseName, typ.doc, @@ -990,7 +832,7 @@ proc genApi*(targetDir: string, apiJsonFile: string) = let className = godotClassName.replace("_", "") var baseClassName = obj["base_class"].str baseClassName = toNimType(baseClassName.replace("_", "")) - if baseClassName.len == 0: + if baseClassName.isNil or baseClassName.len == 0: baseClassName = "NimGodotObject" var doc = "" for attr in classAttributes: @@ -1011,17 +853,17 @@ proc genApi*(targetDir: string, apiJsonFile: string) = for typ in types.values(): let moduleName = typeNameToModuleName(typ.name) echo "Generating ", moduleName, ".nim..." - let tree = newPNode(nkStmtList) - let importStmt = newPNode(nkImportStmt) + let tree = newNode(nkStmtList) + let importStmt = newNode(nkImportStmt) importStmt.add(ident("godot")) importStmt.add(ident("godottypes")) importStmt.add(ident("godotinternal")) tree.add(importStmt) - let exportStmt = newPNode(nkExportStmt) + let exportStmt = newNode(nkExportStmt) exportStmt.add(ident("godottypes")) tree.add(exportStmt) - var methodBindRegsitry = initHashSet[string]() + var methodBindRegsitry = initSet[string]() let obj = typ.jsonNode if typ.baseName != "NimGodotObject": let baseModule = typeNameToModuleName(typ.baseName) @@ -1053,18 +895,16 @@ proc genApi*(targetDir: string, apiJsonFile: string) = # first, generate declarations only for ease of # human readability of the file - if not typ.isSingleton: - for property in obj["properties"]: - makeProperty(types, tree, methodBindRegsitry, typ, property, - obj, withImplementation = false) + 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) - if not typ.isSingleton: - for property in obj["properties"]: - makeProperty(types, tree, methodBindRegsitry, typ, - property, obj, withImplementation = true) + 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) @@ -1082,6 +922,7 @@ when isMainModule: import os const usage = """Tool for wrapping Godot API into Nim + godotapigen [godot binary path] [target directory]""" proc main() = @@ -1112,4 +953,4 @@ when isMainModule: genApi(targetDir, jsonFile) - main() \ No newline at end of file + main() diff --git a/godot/godotinternal.nim b/godot/godotinternal.nim index 207d76f..90903a7 100644 --- a/godot/godotinternal.nim +++ b/godot/godotinternal.nim @@ -1,8 +1,8 @@ -# Copyright 2018 Xored Software, Inc. +# Copyright 2017 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, @@ -93,11 +93,6 @@ 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/backwardcompat.inc.nim b/godot/internal/backwardcompat.inc.nim deleted file mode 100644 index 9d31844..0000000 --- a/godot/internal/backwardcompat.inc.nim +++ /dev/null @@ -1,19 +0,0 @@ -# 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/godotarrays.nim b/godot/internal/godotarrays.nim index c7e451d..32bcefa 100644 --- a/godot/internal/godotarrays.nim +++ b/godot/internal/godotarrays.nim @@ -1,6 +1,6 @@ -# Copyright (c) 2018 Xored Software, Inc. +# Copyright (c) 2017 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/godotdictionaries.nim b/godot/internal/godotdictionaries.nim index 447647a..7c61b76 100644 --- a/godot/internal/godotdictionaries.nim +++ b/godot/internal/godotdictionaries.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Xored Software, Inc. +# Copyright (c) 2017 Xored Software, Inc. import godotinternaltypes, gdnativeapi diff --git a/godot/internal/godotinternaltypes.nim b/godot/internal/godotinternaltypes.nim index a2910c9..508c39e 100644 --- a/godot/internal/godotinternaltypes.nim +++ b/godot/internal/godotinternaltypes.nim @@ -1,4 +1,4 @@ -# Copyright 2018 Xored Software, Inc. +# Copyright 2017 Xored Software, Inc. const MAX_ARG_COUNT* = 256 @@ -16,61 +16,22 @@ type GodotPoolByteArray* {.byref.} = object data: array[sizeof(int), byte] - GodotPoolByteArrayReadAccess* {.byref.} = object - data: array[1, byte] - GodotPoolByteArrayWriteAccess* {.byref.} = object - data: array[1, byte] - GodotPoolIntArray* {.byref.} = object data: array[sizeof(int), byte] - GodotPoolIntArrayReadAccess* {.byref.} = object - data: array[1, byte] - GodotPoolIntArrayWriteAccess* {.byref.} = object - data: array[1, byte] - GodotPoolRealArray* {.byref.} = object data: array[sizeof(int), byte] - GodotPoolRealArrayReadAccess* {.byref.} = object - data: array[1, byte] - GodotPoolRealArrayWriteAccess* {.byref.} = object - data: array[1, byte] - GodotPoolStringArray* {.byref.} = object data: array[sizeof(int), byte] - GodotPoolStringArrayReadAccess* {.byref.} = object - data: array[1, byte] - GodotPoolStringArrayWriteAccess* {.byref.} = object - data: array[1, byte] - GodotPoolVector2Array* {.byref.} = object data: array[sizeof(int), byte] - GodotPoolVector2ArrayReadAccess* {.byref.} = object - data: array[1, byte] - GodotPoolVector2ArrayWriteAccess* {.byref.} = object - data: array[1, byte] - GodotPoolVector3Array* {.byref.} = object data: array[sizeof(int), byte] - GodotPoolVector3ArrayReadAccess* {.byref.} = object - data: array[1, byte] - GodotPoolVector3ArrayWriteAccess* {.byref.} = object - data: array[1, byte] - GodotPoolColorArray* {.byref.} = object data: array[sizeof(int), byte] - GodotPoolColorArrayReadAccess* {.byref.} = object - data: array[1, byte] - GodotPoolColorArrayWriteAccess* {.byref.} = object - data: array[1, byte] GodotString* {.byref.} = object data: array[sizeof(int), byte] - cwchar_t* {.importc: "wchar_t", nodecl.} = object - - GodotCharString* {.byref.} = object - data: array[sizeof(int), byte] - VariantType* {.size: sizeof(cint), pure.} = enum Nil, ## atomic types Bool, @@ -116,8 +77,7 @@ type expected*: VariantType GodotVariant* {.byref.} = object - data: array[2, int64] - data2: int + data: array[4 + sizeof(int) div 4, float32] type GodotMethodBind* = object @@ -308,6 +268,3 @@ 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/godotnodepaths.nim b/godot/internal/godotnodepaths.nim index b4578c0..11a0280 100644 --- a/godot/internal/godotnodepaths.nim +++ b/godot/internal/godotnodepaths.nim @@ -1,4 +1,4 @@ -# Copyright 2018 Xored Software, Inc. +# Copyright 2017 Xored Software, Inc. import godotinternaltypes, gdnativeapi diff --git a/godot/internal/godotpoolarrays.nim b/godot/internal/godotpoolarrays.nim index 119848f..e655adb 100644 --- a/godot/internal/godotpoolarrays.nim +++ b/godot/internal/godotpoolarrays.nim @@ -1,15 +1,13 @@ -# Copyright (c) 2018 Xored Software, Inc. +# Copyright (c) 2017 Xored Software, Inc. import godotinternaltypes, gdnativeapi -import core/godotcoretypes +import core.godotcoretypes template genPoolArrayAPI(ArrayT, initIdent, DataT, newProc, newCopyProc, newWithArrayProc, appendProc, appendArrayProc, insertProc, invertProc, pushBackProc, removeProc, resizeProc, setProc, getProc, sizeProc, - destroyProc, readProc, writeProc, - readAccessPtrProc, writeAccessPtrProc, - readAccessDestroyProc, writeAccessDestroyProc) = + destroyProc) = proc initIdent*(dest: var ArrayT) {.inline.} = getGDNativeAPI().newProc(dest) @@ -45,74 +43,18 @@ template genPoolArrayAPI(ArrayT, initIdent, DataT, getGDNativeAPI().setProc(self, idx, data) proc `[]`*(self: ArrayT; idx: cint): DataT {.inline.} = - 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 + getGDNativeAPI().getProc(self, idx) proc len*(self: ArrayT): cint {.inline.} = getGDNativeAPI().sizeProc(self) - iterator items*(self: ArrayT): DataT = - let readAccess = getGDNativeAPI().readProc(self) - let readPtr = getGDNativeAPI().readAccessPtrProc(readAccess) - for i in 0.cint..= ownLen: - let instInfo = instantiationInfo() - getGDNativeAPI().printError( - cstring"Invalid subarray begin index", cstring"subarray", instInfo.filename, instInfo.line.cint) - return - if actualIdxTo < 0 or actualIdxTo >= ownLen: - let instInfo = instantiationInfo() - getGDNativeAPI().printError( - cstring"Invalid subarray end index", cstring"subarray", instInfo.filename, instInfo.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) + iterator pairs*(arr: ArrayT): tuple[key: cint, val: DataT] = + for i in 0.cint..`_ or by using ## `load `_ or any other way ## that you can find in `Godot API `_. - let typeDef = parseType(ast) + let typeDef = parseType(definition, callsite()) result = genType(typeDef) + +{.push warning[Deprecated]: on.} diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index 7f3ed96..0eccb6b 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -1,14 +1,14 @@ -# Copyright 2018 Xored Software, Inc. +# Copyright 2017 Xored Software, Inc. -import tables, typetraits, macros, unicode, strutils, sets, options +import tables, typetraits, macros, asyncdispatch 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 +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`` @@ -31,7 +31,7 @@ type ## The base type all Godot types inherit from. ## Manages lifecycle of the wrapped ``GodotObject``. godotObject: ptr GodotObject - linkedObjectPtr: pointer + linkedObject: NimGodotObject ## 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,8 +39,6 @@ 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 @@ -91,71 +89,40 @@ type ## values. ## See documentation of ``GodotPropertyHint`` for description of formats. - FNV1Hash = uint32 - -include "internal/backwardcompat.inc.nim" - proc isFinalized*(obj: NimGodotObject): bool {.inline.} = obj.isFinalized -var classRegistry {.threadvar.}: TableRef[FNV1Hash, ObjectInfo] -var classRegistryStatic* {.compileTime.}: TableRef[FNV1Hash, ObjectInfo] +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 ## and macros static: - classRegistryStatic = newTable[FNV1Hash, ObjectInfo]() + classRegistryStatic = newTable[cstring, 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)) and 0xFFFFFFFF'u32).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() @@ -173,13 +140,6 @@ 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. @@ -187,15 +147,12 @@ 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 obj.isFinalized = true - if (obj.isRef or not obj.linkedObject.isNil and obj.linkedObject.isRef) and - obj.godotObject.unreference(): + if obj.isRef and obj.godotObject.unreference() or + not obj.linkedObject.isNil: obj.deinit() macro baseNativeType(T: typedesc): cstring = @@ -209,7 +166,7 @@ macro baseNativeType(T: typedesc): cstring = if typeName == "NimGodotObject": break t = getType(t[1][1]) - if baseT.len == 0: + if baseT.isNil: result = newNilLit() else: let rStr = newNimNode(nnkRStrLit) @@ -234,12 +191,12 @@ macro isResource(T: typedesc): bool = result = if inherits(getType(T), "Resource"): ident("true") else: ident("false") -template registerClass*(T: typedesc; godotClassName: string or cstring, +template registerClass*(T: typedesc; godotClassName: cstring, native: bool) = ## Registers the specified Godot type. ## Used by ``gdobj`` macro and `godotapigen `_. if classRegistry.isNil: - classRegistry = newTable[FNV1Hash, ObjectInfo]() + classRegistry = newTable[cstring, ObjectInfo]() let constructor = proc(): NimGodotObject = var t: T new(t, nimGodotObjectFinalizer[T]) @@ -253,22 +210,14 @@ template registerClass*(T: typedesc; godotClassName: string or cstring, isNative: native, isRef: isRef ) - classRegistry[fnv1Hash($godotClassName)] = objInfo + classRegistry[godotClassName] = objInfo static: let objInfoStatic = ObjectInfo( baseNativeClass: base, isNative: native, isRef: isRef, ) - 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) + classRegistryStatic[godotClassName] = objInfoStatic when isRef: static: refClasses.add(T.name) @@ -277,10 +226,10 @@ template registerClass*(T: typedesc; godotClassName: string or cstring, nativeClasses.add(T.name) proc newNimGodotObject[T: NimGodotObject]( - godotObject: ptr GodotObject, godotClassName: GodotString, noRef: bool): T = + godotObject: ptr GodotObject, godotClassName: cstring, noRef: bool): T = assert(not classRegistry.isNil) assert(not godotObject.isNil) - let objInfo = classRegistry.getOrDefault(fnv1Hash(godotClassName)) + let objInfo = classRegistry.getOrDefault(godotClassName) if objInfo.constructor.isNil: printError("Nim constructor not found for class " & $godotClassName) else: @@ -291,7 +240,7 @@ proc newNimGodotObject[T: NimGodotObject]( result.godotObject.reference() proc asNimGodotObject*[T: NimGodotObject]( - godotObject: ptr GodotObject, forceNativeObject, 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. @@ -303,11 +252,8 @@ proc asNimGodotObject*[T: NimGodotObject]( # Could be data from other bindings result = nil if result.isNil: - var classNameStr = godotObject.getClassNameRaw() result = newNimGodotObject[T]( - godotObject, classNameStr, - forceNativeObject or noRef) - deinit(classNameStr) + godotObject, cstring(godotObject.getClassName()), forceNativeObject) proc newVariant*(obj: NimGodotObject): Variant {.inline.} = newVariant(obj.godotObject) @@ -332,35 +278,45 @@ 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 system.`of`(obj, T): + if obj of T: result = T(obj) - elif not obj.linkedObject.isNil and system.`of`(obj.linkedObject, T): + elif not obj.linkedObject.isNil and obj.linkedObject of 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.} = +proc `of`*[T: NimGodotObject](obj: NimGodotObject, + t: typedesc[T]): bool {.inline.} = ## Godot-specific inheritance check. - not obj.isNil and (system.`of`(obj, T2) or system.`of`(obj.linkedObject, T2)) + not obj.isNil and (system.`of`(obj, T) or system.`of`(obj.linkedObject, T)) proc newRStrLit(s: string): NimNode {.compileTime.} = result = newNimNode(nnkRStrLit) result.strVal = s -macro toGodotName(T: typedesc): untyped = +static: + import strutils + +macro toGodotName(T: typedesc): string = + var godotName: string if T is GodotString or T is string: - newStrLitNode"String" + godotName = "String" elif T is SomeFloat: - newStrLitNode"float" + godotName = "float" elif T is SomeUnsignedInt or T is SomeSignedInt: - newStrLitNode"int" - else: - let nameStr = ((T.getType()[1][1].strVal).split(':')[0]) - case nameStr: - of "File", "Directory", "Thread", "Mutex", "Semaphore": - newStrLitNode("_" & nameStr) - else: - newStrLitNode(nameStr) + godotName = "int" + if godotName.isNil: + let nameStr: string = (($T.getType()[1][1].symbol).split(':')[0]) + godotName = case nameStr: + of "File", "Directory", "Thread", "Mutex", "Semaphore": + "_" & nameStr + else: + nameStr + + result = newLit(godotName) macro asCString(s: static[string]): cstring = result = newNimNode(nnkCallStrLit).add( @@ -419,18 +375,11 @@ proc newOwnObj[T: NimGodotObject](name: cstring): T = proc gdnew*[T: NimGodotObject](): T = ## Instantiates new object of type ``T``. - const godotName = toGodotName(T) - const cGodotName = asCString(godotName) - const objInfo = classRegistryStatic[fnv1Hash(godotName)] - when objInfo.isNative: - let godotObject = getClassConstructor(cGodotName)() - new(result, nimGodotObjectFinalizer[T]) - result.godotObject = godotObject - when objInfo.isRef: - godotObject.initRef() - result.isRef = true - else: - result = newOwnObj[T](cGodotName) + const godotName = asCString(toGodotName(T)) + const objInfo = classRegistryStatic[godotName] + result = when objInfo.isNative: + asNimGodotObject[T](getClassConstructor(godotName)()) + else: newOwnObj[T](godotName) proc newCallError*(err: VariantCallError): ref CallError = ## Instantiates ``CallError`` from Godot ``err``. @@ -470,17 +419,14 @@ 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. - GC_ref(nativeObj) - nimObj.linkedObjectPtr = cast[pointer](nativeObj) - nativeObj.linkedObjectPtr = cast[pointer](nimObj) + 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. - 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. @@ -523,7 +469,7 @@ proc toVariant*(self: Variant): Variant {.inline.} = if self.isNil: newVariant() else: - newVariant(self) + self proc fromVariant*(self: var Variant, val: Variant): ConversionResult {.inline.} = @@ -612,11 +558,7 @@ proc fromVariant*[T: SomeSignedInt or SomeUnsignedInt]( else: uint64) intVal = when T is SomeSignedInt: val.asInt() else: val.asUint() - 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: + if intVal > high(T) or intVal < low(T): result = ConversionResult.RangeError else: self = T(intVal) @@ -720,10 +662,7 @@ proc fromVariant*(s: var string, val: Variant): ConversionResult = if val.getType() == VariantType.String: s = val.asString() elif val.getType() == VariantType.Nil: - when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): - s = nil - else: - s = "" + s = nil else: result = ConversionResult.TypeError @@ -797,31 +736,10 @@ 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.} = +proc godotTypeInfo*(T: typedesc[Table|TableRef]): GodotTypeInfo {.inline.} = result.variantType = VariantType.Dictionary -proc toVariant*[T: Table or TableRef or OrderedTable or OrderedTableRef](t: T): Variant = +proc toVariant*[T: Table or TableRef](t: T): Variant = when t is ref: if t.isNil: return newVariant() @@ -831,7 +749,7 @@ proc toVariant*[T: Table or TableRef or OrderedTable or OrderedTableRef](t: T): dict[toVariant(k)] = toVariant(v) result = newVariant(dict) -proc fromVariant*[T: Table or TableRef or OrderedTable or OrderedTableRef](t: var T, +proc fromVariant*[T: Table or TableRef](t: var T, val: Variant): ConversionResult = if val.getType() == VariantType.Nil: when t is ref: @@ -841,12 +759,8 @@ proc fromVariant*[T: Table or TableRef or OrderedTable or OrderedTableRef](t: va mixin fromVariant when t is Table: t = initTable[type(t.keys()), type(t.values())]() - 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())]() + t = newTable[type(t.keys()), type(t.values())]() for k, v in dict: var nimKey: type(t.keys()) var nimVal: type(t.values()) @@ -864,11 +778,10 @@ proc fromVariant*[T: Table or TableRef or OrderedTable or OrderedTableRef](t: va else: result = ConversionResult.TypeError -when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): - {.emit: """/*TYPESECTION*/ - N_LIB_EXPORT N_CDECL(void, NimMain)(void); - N_NOINLINE(void, setStackBottom)(void* thestackbottom); - """.} +{.emit: """/*TYPESECTION*/ +void NimMain(void); +N_NOINLINE(void, setStackBottom)(void* thestackbottom); +""".} var nativeLibHandle: pointer proc getNativeLibHandle*(): pointer = @@ -881,16 +794,10 @@ proc godot_nativescript_init(handle: pointer) {. nativeLibHandle = handle var stackBottom {.volatile.}: pointer - stackBottom = addr(stackBottom) {.emit: """ NimMain(); + setStackBottom((void*)(&`stackBottom`)); """.} - when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): - {.emit: """ - setStackBottom((void*)(&`stackBottom`)); - """.} - else: - nimGC_setStackBottom(stackBottom) GC_fullCollect() GC_disable() @@ -901,40 +808,18 @@ proc godot_gdnative_init(options: ptr GDNativeInitOptions) {. proc godot_gdnative_terminate(options: ptr GDNativeTerminateOptions) {. cdecl, exportc, dynlib.} = - if not options[].inEditor or not compileOption("threads"): - deallocHeap(runFinalizers = not options[].inEditor, allowGcAfterwards = false) + 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) - -{.push stackTrace: off.} - proc godot_nativescript_frame() {.cdecl, exportc, dynlib.} = var stackBottom {.volatile.}: pointer - stackBottom = addr(stackBottom) - when (NimMajor, NimMinor, NimPatch) < (0, 19, 0): - {.emit: """ - setStackBottom((void*)(&`stackBottom`)); - """.} - else: - nimGC_setStackBottom(stackBottom) - for cb in idleCallbacks: - cb() + {.emit: """ + setStackBottom((void*)(&`stackBottom`)); + """.} + for _ in 1..10: + if not asyncdispatch.hasPendingOperations(): + break + poll(0) GC_step(nimGcStepLengthUs, true, 0) when not defined(release): @@ -945,7 +830,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. If you see this warning when running the editor and you don't actually use threads, ignore it." + 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() @@ -953,5 +838,3 @@ proc godot_nativescript_thread_enter() {.cdecl, exportc, dynlib.} = proc godot_nativescript_thread_exit() {.cdecl, exportc, dynlib.} = when compileOption("threads"): teardownForeignThreadGc() - -{.pop.} # stackTrace: off diff --git a/godot/nim/nim.cfg b/godot/nim/nim.cfg index add9a4d..f1fb6a7 100644 --- a/godot/nim/nim.cfg +++ b/godot/nim/nim.cfg @@ -1,2 +1 @@ ---path:"$projectdir/../" --d:useRealtimeGc \ No newline at end of file +--path:"$projectdir/../" \ No newline at end of file