No destructors
This commit is contained in:
parent
2fd1efcc4e
commit
f5769045fc
34 changed files with 1701 additions and 1216 deletions
115
godot/internal/godotarrays.nim
Normal file
115
godot/internal/godotarrays.nim
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
import hashes
|
||||
import godotinternaltypes, godotpoolarrays, godotvariants, godotstrings
|
||||
|
||||
proc initGodotArray*(dest: var GodotArray) {.
|
||||
importc: "godot_array_new".}
|
||||
proc initGodotArray*(dest: var GodotArray; pca: GodotPoolColorArray) {.
|
||||
importc: "godot_array_new_pool_coloarray".}
|
||||
proc initGodotArray*(dest: var GodotArray; pv3a: GodotPoolVector3Array) {.
|
||||
importc: "godot_array_new_pool_vector3_array".}
|
||||
proc initGodotArray*(dest: var GodotArray; pv2a: GodotPoolVector2Array) {.
|
||||
importc: "godot_array_new_pool_vector2_array".}
|
||||
proc initGodotArray*(dest: var GodotArray; psa: GodotPoolStringArray) {.
|
||||
importc: "godot_array_new_pool_string_array".}
|
||||
proc initGodotArray*(dest: var GodotArray; pra: GodotPoolRealArray) {.
|
||||
importc: "godot_array_new_pool_real_array".}
|
||||
proc initGodotArray*(dest: var GodotArray; pia: GodotPoolIntArray) {.
|
||||
importc: "godot_array_new_pool_int_array".}
|
||||
proc initGodotArray*(dest: var GodotArray; pba: GodotPoolByteArray) {.
|
||||
importc: "godot_array_new_pool_byte_array".}
|
||||
proc iniGodotArray*(dest: var GodotArray; src: GodotArray) {.
|
||||
importc: "godot_array_new_copy".}
|
||||
|
||||
proc deinit*(self: var GodotArray) {.importc: "godot_array_destroy".}
|
||||
|
||||
proc `[]=`*(self: var GodotArray; idx: cint;
|
||||
value: GodotVariant) {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_set".}
|
||||
proc `[]`*(self: GodotArray; idx: cint): GodotVariant {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_get".}
|
||||
proc mget*(self: var GodotArray; idx: cint): ptr GodotVariant {.
|
||||
importc: "godot_array_operator_index".}
|
||||
|
||||
proc add*(self: var GodotArray; value: GodotVariant) {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_append".}
|
||||
proc clear*(self: var GodotArray) {.importc: "godot_array_clear".}
|
||||
proc count*(self: GodotArray; value: GodotVariant): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_count".}
|
||||
proc isEmpty*(self: GodotArray): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_empty".}
|
||||
proc erase*(self: var GodotArray; value: GodotVariant) {.
|
||||
importc: "godot_array_erase".}
|
||||
proc first*(self: GodotArray): GodotVariant {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_front".}
|
||||
proc last*(self: GodotArray): GodotVariant {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_back".}
|
||||
proc find*(self: GodotArray; what: GodotVariant;
|
||||
f: cint): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_find".}
|
||||
proc findLast*(self: GodotArray; what: GodotVariant): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_find_last".}
|
||||
proc contains*(self: GodotArray; value: GodotVariant): bool {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_has".}
|
||||
|
||||
proc godotHash*(self: GodotArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_hash".}
|
||||
proc hash*(self: GodotArray): Hash {.inline.} =
|
||||
hash(godotHash(self))
|
||||
|
||||
proc insert*(self: var GodotArray; pos: cint;
|
||||
value: GodotVariant) {.
|
||||
importc: "godot_array_insert".}
|
||||
proc reverse*(self: var GodotArray) {.importc: "godot_array_invert".}
|
||||
proc popLast*(self: var GodotArray): GodotVariant {.
|
||||
importc: "godot_array_pop_back".}
|
||||
proc popFirst*(self: var GodotArray): GodotVariant {.
|
||||
importc: "godot_array_pop_front".}
|
||||
proc addLast*(self: var GodotArray; value: GodotVariant) {.
|
||||
importc: "godot_array_push_back".}
|
||||
proc addFirst*(self: var GodotArray; value: GodotVariant) {.
|
||||
importc: "godot_array_push_front".}
|
||||
|
||||
proc delete*(self: var GodotArray; idx: cint) {.
|
||||
importc: "godot_array_remove".}
|
||||
proc setLen*(self: var GodotArray; size: cint) {.
|
||||
importc: "godot_array_resize".}
|
||||
proc rfind*(self: GodotArray; what: GodotVariant;
|
||||
f: cint): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_rfind".}
|
||||
proc len*(self: GodotArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_array_size".}
|
||||
proc sort*(self: var GodotArray) {.importc: "godot_array_sort".}
|
||||
proc sortCustom*(self: var GodotArray; obj: var GodotObject;
|
||||
funcName: GodotString) {.
|
||||
importc: "godot_array_sort_custom".}
|
||||
|
||||
iterator items*(arr: GodotArray): GodotVariant =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator mitems*(arr: var GodotArray): var GodotVariant =
|
||||
for i in 0..<arr.len:
|
||||
yield arr.mget(i)[]
|
||||
|
||||
iterator pairs*(arr: GodotArray): tuple[key: cint, val: GodotVariant] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
iterator mpairs*(arr: var GodotArray): tuple[key: cint, val: var GodotVariant] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr.mget(i)[])
|
||||
48
godot/internal/godotdictionaries.nim
Normal file
48
godot/internal/godotdictionaries.nim
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
type
|
||||
GodotDictionary* {.byref.} = object
|
||||
p: pointer
|
||||
|
||||
import godotinternaltypes, godotarrays, godotvariants, godotstrings
|
||||
|
||||
proc initGodotDictionary*(dest: var GodotDictionary; src: GodotDictionary) {.
|
||||
importc: "godot_dictionary_new_copy".}
|
||||
|
||||
proc deinit*(self: var GodotDictionary) {.
|
||||
importc: "godot_dictionary_destroy".}
|
||||
|
||||
proc initGodotDictionary*(dest: var GodotDictionary) {.
|
||||
importc: "godot_dictionary_new".}
|
||||
|
||||
proc len*(self: GodotDictionary): cint {.
|
||||
importc: "godot_dictionary_size".}
|
||||
proc isEmpty*(self: GodotDictionary): bool {.
|
||||
importc: "godot_dictionary_empty".}
|
||||
proc clear*(self: var GodotDictionary) {.
|
||||
importc: "godot_dictionary_clear".}
|
||||
proc contains*(self: GodotDictionary; key: GodotVariant): bool {.
|
||||
importc: "godot_dictionary_has".}
|
||||
proc contains*(self: GodotDictionary; keys: GodotArray): bool {.
|
||||
importc: "godot_dictionary_has_all".}
|
||||
proc del*(self: var GodotDictionary; key: GodotVariant) {.
|
||||
importc: "godot_dictionary_erase".}
|
||||
|
||||
proc godotHash*(self: GodotDictionary): cint {.
|
||||
importc: "godot_dictionary_hash".}
|
||||
proc keys*(self: GodotDictionary): GodotArray {.
|
||||
importc: "godot_dictionary_keys".}
|
||||
proc values*(self: GodotDictionary): GodotArray {.
|
||||
importc: "godot_dictionary_values".}
|
||||
proc `[]`*(self: GodotDictionary; key: GodotVariant): GodotVariant {.
|
||||
importc: "godot_dictionary_get".}
|
||||
proc `[]=`*(self: var GodotDictionary; key, value: GodotVariant) {.
|
||||
importc: "godot_dictionary_set".}
|
||||
proc mget*(self: var GodotDictionary; key: GodotVariant): ptr GodotVariant {.
|
||||
importc: "godot_dictionary_operator_index".}
|
||||
|
||||
proc `==`*(self, other: GodotDictionary): bool {.
|
||||
importc: "godot_dictionary_operator_equal".}
|
||||
|
||||
proc toJson*(self: GodotDictionary): GodotString {.
|
||||
importc: "godot_dictionary_to_json".}
|
||||
8
godot/internal/godotinternaltypes.nim
Normal file
8
godot/internal/godotinternaltypes.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Copyright 2017 Xored Software, Inc.
|
||||
|
||||
type
|
||||
GodotObject* = object
|
||||
GodotArray* {.byref.} = object
|
||||
p: pointer
|
||||
GodotVariant* {.byref.} = object
|
||||
data: array[24, byte]
|
||||
32
godot/internal/godotnodepaths.nim
Normal file
32
godot/internal/godotnodepaths.nim
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# Copyright 2017 Xored Software, Inc.
|
||||
|
||||
import godotstrings
|
||||
|
||||
type
|
||||
GodotNodePath* {.byref.} = object
|
||||
p: pointer
|
||||
|
||||
proc initGodotNodePath*(dest: var GodotNodePath; s: GodotString) {.
|
||||
importc: "godot_node_path_new".}
|
||||
proc deinit*(self: var GodotNodePath) {.
|
||||
importc: "godot_node_path_destroy".}
|
||||
proc toGodotString*(self: GodotNodePath): GodotString {.
|
||||
importc: "godot_node_path_as_string".}
|
||||
|
||||
proc isAbsolute*(self: GodotNodePath): bool {.
|
||||
noSideEffect, importc: "godot_node_path_is_absolute".}
|
||||
proc nameCount*(self: GodotNodePath): cint {.
|
||||
noSideEffect, importc: "godot_node_path_get_name_count".}
|
||||
proc getName*(self: GodotNodePath; idx: cint): GodotString {.
|
||||
noSideEffect, importc: "godot_node_path_get_name".}
|
||||
proc subnameCount*(self: GodotNodePath): cint {.
|
||||
noSideEffect, importc: "godot_node_path_get_subname_count".}
|
||||
proc getSubname*(self: GodotNodePath; idx: cint): GodotString {.
|
||||
noSideEffect, importc: "godot_node_path_get_subname".}
|
||||
proc property*(self: GodotNodePath): GodotString {.
|
||||
noSideEffect, importc: "godot_node_path_get_property".}
|
||||
proc isEmpty*(self: GodotNodePath): bool {.
|
||||
noSideEffect, importc: "godot_node_path_is_empty".}
|
||||
|
||||
proc `==`*(a, b: GodotNodePath): bool {.
|
||||
noSideEffect, importc: "godot_node_path_operator_equal".}
|
||||
376
godot/internal/godotpoolarrays.nim
Normal file
376
godot/internal/godotpoolarrays.nim
Normal file
|
|
@ -0,0 +1,376 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
|
||||
import godotinternaltypes, godotstrings
|
||||
import "../core/godotbase.nim", "../core/colors.nim",
|
||||
"../core/vector2.nim", "../core/vector3.nim"
|
||||
|
||||
type
|
||||
GodotPoolByteArray* {.byref.} = object
|
||||
p: pointer
|
||||
GodotPoolIntArray* {.byref.} = object
|
||||
p: pointer
|
||||
GodotPoolRealArray* {.byref.} = object
|
||||
p: pointer
|
||||
GodotPoolStringArray* {.byref.} = object
|
||||
p: pointer
|
||||
GodotPoolVector2Array* {.byref.} = object
|
||||
p: pointer
|
||||
GodotPoolVector3Array* {.byref.} = object
|
||||
p: pointer
|
||||
GodotPoolColorArray* {.byref.} = object
|
||||
p: pointer
|
||||
|
||||
# byte
|
||||
|
||||
proc initGodotPoolByteArray*(dest: var GodotPoolByteArray) {.
|
||||
importc: "godot_pool_byte_array_new".}
|
||||
proc initGodotPoolByteArray*(dest: var GodotPoolByteArray;
|
||||
src: GodotPoolByteArray) {.
|
||||
importc: "godot_pool_byte_array_new_copy".}
|
||||
proc initGodotPoolByteArray*(dest: var GodotPoolByteArray; arr: GodotArray) {.
|
||||
importc: "godot_pool_byte_array_new_with_array".}
|
||||
|
||||
proc deinit*(self: var GodotPoolByteArray) {.
|
||||
importc: "godot_pool_byte_array_destroy".}
|
||||
|
||||
proc add*(self: var GodotPoolByteArray;
|
||||
data: uint8) {.
|
||||
importc: "godot_pool_byte_array_append".}
|
||||
proc addFirst*(self: var GodotPoolByteArray, data: uint8) {.
|
||||
importc: "godot_pool_byte_array_push_back".}
|
||||
proc add*(self: var GodotPoolByteArray;
|
||||
arr: GodotPoolByteArray) {.
|
||||
importc: "godot_pool_byte_array_append_array".}
|
||||
proc insert*(self: var GodotPoolByteArray; idx: cint;
|
||||
data: uint8): Error {.
|
||||
importc: "godot_pool_byte_array_insert".}
|
||||
proc delete*(self: var GodotPoolByteArray; idx: cint) {.
|
||||
importc: "godot_pool_byte_array_remove".}
|
||||
|
||||
proc reverse*(self: var GodotPoolByteArray) {.
|
||||
importc: "godot_pool_byte_array_invert".}
|
||||
proc setLen*(self: var GodotPoolByteArray; size: cint) {.
|
||||
importc: "godot_pool_byte_array_resize".}
|
||||
|
||||
proc `[]=`*(self: var GodotPoolByteArray; idx: cint; data: uint8) {.
|
||||
importc: "godot_pool_byte_array_set".}
|
||||
proc `[]`*(self: GodotPoolByteArray; idx: cint): uint8 {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_byte_array_get".}
|
||||
proc len*(self: GodotPoolByteArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_byte_array_size".}
|
||||
|
||||
iterator items*(arr: GodotPoolByteArray): byte =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: GodotPoolByteArray): tuple[key: cint, val: byte] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
proc initGodotPoolIntArray*(dest: var GodotPoolIntArray) {.
|
||||
importc: "godot_pool_int_array_new".}
|
||||
proc initGodotPoolIntArray*(dest: var GodotPoolIntArray;
|
||||
src: GodotPoolIntArray) {.
|
||||
importc: "godot_pool_int_array_new_copy".}
|
||||
proc initGodotPoolIntArray*(dest: var GodotPoolIntArray;
|
||||
arr: GodotArray) {.
|
||||
importc: "godot_pool_int_array_new_with_array".}
|
||||
proc deinit*(self: var GodotPoolIntArray) {.
|
||||
importc: "godot_pool_int_array_destroy".}
|
||||
|
||||
proc add*(self: var GodotPoolIntArray; data: cint) {.
|
||||
importc: "godot_pool_int_array_append".}
|
||||
proc addFirst*(self: var GodotPoolIntArray; data: cint) {.
|
||||
importc: "godot_pool_int_array_push_back".}
|
||||
proc add*(self: var GodotPoolIntArray; arr: GodotPoolIntArray) {.
|
||||
importc: "godot_pool_int_array_append_array".}
|
||||
proc insert*(self: var GodotPoolIntArray; idx: cint;
|
||||
data: cint): Error {.
|
||||
importc: "godot_pool_int_array_insert".}
|
||||
proc delete*(self: var GodotPoolIntArray; idx: cint) {.
|
||||
importc: "godot_pool_int_array_remove".}
|
||||
proc reverse*(self: var GodotPoolIntArray) {.
|
||||
importc: "godot_pool_int_array_invert".}
|
||||
|
||||
proc setLen*(self: var GodotPoolIntArray; size: cint) {.
|
||||
importc: "godot_pool_int_array_resize".}
|
||||
proc `[]=`*(self: var GodotPoolIntArray; idx: cint; data: cint) {.
|
||||
importc: "godot_pool_int_array_set".}
|
||||
proc `[]`*(self: GodotPoolIntArray; idx: cint): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_int_array_get".}
|
||||
proc len*(self: GodotPoolIntArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_int_array_size".}
|
||||
|
||||
iterator items*(arr: GodotPoolIntArray): cint =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: GodotPoolIntArray): tuple[key: cint, val: cint] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
# Real
|
||||
|
||||
proc initGodotPoolRealArray*(dest: var GodotPoolRealArray) {.
|
||||
importc: "godot_pool_real_array_new".}
|
||||
proc initGodotPoolRealArray*(dest: var GodotPoolRealArray;
|
||||
src: GodotPoolRealArray) {.
|
||||
importc: "godot_pool_real_array_new_copy".}
|
||||
proc initGodotPoolRealArray*(dest: var GodotPoolRealArray; arr: GodotArray) {.
|
||||
importc: "godot_pool_real_array_new_with_array".}
|
||||
|
||||
proc deinit*(self: var GodotPoolRealArray) {.
|
||||
importc: "godot_pool_real_array_destroy".}
|
||||
|
||||
proc add*(self: var GodotPoolRealArray; data: float32) {.
|
||||
importc: "godot_pool_real_array_append".}
|
||||
proc addFirst*(self: var GodotPoolRealArray; data: float32) {.
|
||||
importc: "godot_pool_real_array_push_back".}
|
||||
proc add*(self: var GodotPoolRealArray; arr: GodotPoolRealArray) {.
|
||||
importc: "godot_pool_real_array_append_array".}
|
||||
proc insert*(self: var GodotPoolRealArray;
|
||||
idx: cint; data: float32): Error {.
|
||||
importc: "godot_pool_real_array_insert".}
|
||||
proc delete*(self: var GodotPoolRealArray; idx: cint) {.
|
||||
importc: "godot_pool_real_array_remove".}
|
||||
proc reverse*(self: var GodotPoolRealArray) {.
|
||||
importc: "godot_pool_real_array_invert".}
|
||||
proc setLen*(self: var GodotPoolRealArray; size: cint) {.
|
||||
importc: "godot_pool_real_array_resize".}
|
||||
proc `[]=`*(self: var GodotPoolRealArray; idx: cint; data: float32) {.
|
||||
importc: "godot_pool_real_array_set".}
|
||||
proc `[]`*(self: GodotPoolRealArray; idx: cint): float32 {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_real_array_get".}
|
||||
proc len*(self: GodotPoolRealArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_real_array_size".}
|
||||
|
||||
iterator items*(arr: GodotPoolRealArray): float32 =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: GodotPoolRealArray): tuple[key: cint, val: float32] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
# String
|
||||
|
||||
proc initGodotPoolStringArray*(dest: var GodotPoolStringArray) {.
|
||||
importc: "godot_pool_string_array_new".}
|
||||
proc initGodotPoolStringArray*(dest: var GodotPoolStringArray;
|
||||
src: GodotPoolStringArray) {.
|
||||
importc: "godot_pool_string_array_new_copy".}
|
||||
proc initGodotPoolStringArray*(dest: var GodotPoolStringArray; arr: GodotArray) {.
|
||||
importc: "godot_pool_string_array_new_with_array".}
|
||||
|
||||
proc deinit*(self: var GodotPoolStringArray) {.
|
||||
importc: "godot_pool_string_array_destroy".}
|
||||
|
||||
proc initGodotPoolStringArray*(): GodotPoolStringArray {.inline.} =
|
||||
initGodotPoolStringArray(result)
|
||||
|
||||
proc initGodotPoolStringArray*(arr: GodotArray): GodotPoolStringArray {.inline.} =
|
||||
initGodotPoolStringArray(result, arr)
|
||||
|
||||
proc add*(self: var GodotPoolStringArray; data: GodotString) {.
|
||||
importc: "godot_pool_string_array_append".}
|
||||
proc addFirst*(self: var GodotPoolStringArray; data: GodotString) {.
|
||||
importc: "godot_pool_string_array_push_back".}
|
||||
proc add*(self: var GodotPoolStringArray; arr: GodotPoolStringArray) {.
|
||||
importc: "godot_pool_string_array_append_array".}
|
||||
proc insert*(self: var GodotPoolStringArray;
|
||||
idx: cint; data: GodotString): Error {.
|
||||
importc: "godot_pool_string_array_insert".}
|
||||
proc delete*(self: var GodotPoolStringArray; idx: cint) {.
|
||||
importc: "godot_pool_string_array_remove".}
|
||||
proc reverse*(self: var GodotPoolStringArray) {.
|
||||
importc: "godot_pool_string_array_invert".}
|
||||
proc setLen*(self: var GodotPoolStringArray; size: cint) {.
|
||||
importc: "godot_pool_string_array_resize".}
|
||||
proc `[]=`*(self: var GodotPoolStringArray; idx: cint;
|
||||
data: GodotString) {.
|
||||
importc: "godot_pool_string_array_set".}
|
||||
proc `[]`*(self: GodotPoolStringArray; idx: cint): GodotString {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_string_array_get".}
|
||||
proc len*(self: GodotPoolStringArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_string_array_size".}
|
||||
|
||||
iterator items*(arr: GodotPoolStringArray): GodotString =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: GodotPoolStringArray): tuple[key: cint, val: GodotString] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
# Vector2
|
||||
|
||||
proc initGodotPoolVector2Array*(dest: var GodotPoolVector2Array) {.
|
||||
importc: "godot_pool_vector2_array_new".}
|
||||
proc initGodotPoolVector2Array*(dest: var GodotPoolVector2Array;
|
||||
src: GodotPoolVector2Array) {.
|
||||
importc: "godot_pool_vector2_array_new_copy".}
|
||||
proc initGodotPoolVector2Array*(dest: var GodotPoolVector2Array;
|
||||
arr: GodotArray) {.
|
||||
importc: "godot_pool_vector2_array_new_with_array".}
|
||||
|
||||
proc deinit*(self: var GodotPoolVector2Array) {.
|
||||
importc: "godot_pool_vector2_array_destroy".}
|
||||
|
||||
proc initGodotPoolVector2Array*(): GodotPoolVector2Array {.inline.} =
|
||||
initGodotPoolVector2Array(result)
|
||||
|
||||
proc initGodotPoolVector2Array*(arr: GodotArray): GodotPoolVector2Array {.inline.} =
|
||||
initGodotPoolVector2Array(result, arr)
|
||||
|
||||
proc add*(self: var GodotPoolVector2Array; data: Vector2) {.
|
||||
importc: "godot_pool_vector2_array_append".}
|
||||
proc addFirst*(self: var GodotPoolVector2Array; data: Vector2) {.
|
||||
importc: "godot_pool_vector2_array_push_back".}
|
||||
proc add*(self: var GodotPoolVector2Array;
|
||||
arr: GodotPoolVector2Array) {.
|
||||
importc: "godot_pool_vector2_array_append_array".}
|
||||
proc insert*(self: var GodotPoolVector2Array;
|
||||
idx: cint; data: Vector2): Error {.
|
||||
importc: "godot_pool_vector2_array_insert".}
|
||||
proc delete*(self: var GodotPoolVector2Array; idx: cint) {.
|
||||
importc: "godot_pool_vector2_array_remove".}
|
||||
proc reverse*(self: var GodotPoolVector2Array) {.
|
||||
importc: "godot_pool_vector2_array_invert".}
|
||||
proc setLen*(self: var GodotPoolVector2Array; size: cint) {.
|
||||
importc: "godot_pool_vector2_array_resize".}
|
||||
proc `[]=`*(self: var GodotPoolVector2Array; idx: cint;
|
||||
data: Vector2) {.
|
||||
importc: "godot_pool_vector2_array_set".}
|
||||
proc `[]`*(self: GodotPoolVector2Array; idx: cint): Vector2 {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_vector2_array_get".}
|
||||
proc len*(self: GodotPoolVector2Array): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_vector2_array_size".}
|
||||
|
||||
iterator items*(arr: GodotPoolVector2Array): Vector2 =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: GodotPoolVector2Array): tuple[key: cint, val: Vector2] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
# Vector3
|
||||
|
||||
proc initGodotPoolVector3Array*(dest: var GodotPoolVector3Array) {.
|
||||
importc: "godot_pool_vector3_array_new".}
|
||||
proc initGodotPoolVector3Array*(dest: var GodotPoolVector3Array;
|
||||
src: GodotPoolVector3Array) {.
|
||||
importc: "godot_pool_vector3_array_new_copy".}
|
||||
proc initGodotPoolVector3Array*(dest: var GodotPoolVector3Array;
|
||||
arr: GodotArray) {.
|
||||
importc: "godot_pool_vector3_array_new_with_array".}
|
||||
|
||||
proc deinit*(self: var GodotPoolVector3Array) {.
|
||||
importc: "godot_pool_vector3_array_destroy".}
|
||||
|
||||
proc initGodotPoolVector3Array*(): GodotPoolVector3Array {.inline.} =
|
||||
initGodotPoolVector3Array(result)
|
||||
|
||||
proc initGodotPoolVector3Array*(arr: GodotArray):
|
||||
GodotPoolVector3Array {.inline.} =
|
||||
initGodotPoolVector3Array(result, arr)
|
||||
|
||||
proc add*(self: var GodotPoolVector3Array;
|
||||
data: Vector3) {.
|
||||
importc: "godot_pool_vector3_array_append".}
|
||||
proc addFirst*(self: var GodotPoolVector3Array;
|
||||
data: Vector3) {.
|
||||
importc: "godot_pool_vector3_array_push_back".}
|
||||
proc add*(self: var GodotPoolVector3Array;
|
||||
arr: GodotPoolVector3Array) {.
|
||||
importc: "godot_pool_vector3_array_append_array".}
|
||||
proc insert*(self: var GodotPoolVector3Array;
|
||||
idx: cint; data: Vector3): Error {.
|
||||
importc: "godot_pool_vector3_array_insert".}
|
||||
proc delete*(self: var GodotPoolVector3Array; idx: cint) {.
|
||||
importc: "godot_pool_vector3_array_remove".}
|
||||
proc reverse*(self: var GodotPoolVector3Array) {.
|
||||
importc: "godot_pool_vector3_array_invert".}
|
||||
proc setLen*(self: var GodotPoolVector3Array; size: cint) {.
|
||||
importc: "godot_pool_vector3_array_resize".}
|
||||
proc `[]=`*(self: var GodotPoolVector3Array;
|
||||
idx: cint; data: Vector3) {.
|
||||
importc: "godot_pool_vector3_array_set".}
|
||||
proc `[]`*(self: GodotPoolVector3Array;
|
||||
idx: cint): Vector3 {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_vector3_array_get".}
|
||||
proc len*(self: GodotPoolVector3Array): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_vector3_array_size".}
|
||||
|
||||
iterator items*(arr: GodotPoolVector3Array): Vector3 =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: GodotPoolVector3Array): tuple[key: cint, val: Vector3] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
|
||||
# Color
|
||||
|
||||
proc initGodotPoolColorArray*(dest: var GodotPoolColorArray) {.
|
||||
importc: "godot_pool_color_array_new".}
|
||||
proc initGodotPoolColorArray*(dest: var GodotPoolColorArray;
|
||||
src: GodotPoolColorArray) {.
|
||||
importc: "godot_pool_color_array_new_copy".}
|
||||
proc initGodotPoolColorArray*(dest: var GodotPoolColorArray; arr: GodotArray) {.
|
||||
importc: "godot_pool_color_array_new_with_array".}
|
||||
|
||||
proc deinit*(self: var GodotPoolColorArray) {.
|
||||
importc: "godot_pool_color_array_destroy".}
|
||||
|
||||
proc initGodotPoolColorArray*(): GodotPoolColorArray {.inline.} =
|
||||
initGodotPoolColorArray(result)
|
||||
|
||||
proc initGodotPoolColorArray*(arr: GodotArray): GodotPoolColorArray {.inline.} =
|
||||
initGodotPoolColorArray(result, arr)
|
||||
|
||||
proc add*(self: var GodotPoolColorArray; data: Color) {.
|
||||
importc: "godot_pool_color_array_append".}
|
||||
proc addFirst*(self: var GodotPoolColorArray; data: Color) {.
|
||||
importc: "godot_pool_color_array_push_back".}
|
||||
proc add*(self: var GodotPoolColorArray; arr: GodotPoolColorArray) {.
|
||||
importc: "godot_pool_color_array_append_array".}
|
||||
proc insert*(self: var GodotPoolColorArray;
|
||||
idx: cint; data: Color): Error {.
|
||||
importc: "godot_pool_color_array_insert".}
|
||||
proc delete*(self: var GodotPoolColorArray; idx: cint) {.
|
||||
importc: "godot_pool_color_array_remove".}
|
||||
proc reverse*(self: var GodotPoolColorArray) {.
|
||||
importc: "godot_pool_color_array_invert".}
|
||||
proc setLen*(self: var GodotPoolColorArray; size: cint) {.
|
||||
importc: "godot_pool_color_array_resize".}
|
||||
proc `[]=`*(self: var GodotPoolColorArray; idx: cint;
|
||||
data: Color) {.
|
||||
importc: "godot_pool_color_array_set".}
|
||||
proc `[]`*(self: GodotPoolColorArray; idx: cint): Color {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_color_array_get".}
|
||||
proc len*(self: GodotPoolColorArray): cint {.
|
||||
noSideEffect,
|
||||
importc: "godot_pool_color_array_size".}
|
||||
|
||||
iterator items*(arr: GodotPoolColorArray): Color =
|
||||
for i in 0..<arr.len:
|
||||
yield arr[i]
|
||||
|
||||
iterator pairs*(arr: GodotPoolColorArray): tuple[key: cint, val: Color] =
|
||||
for i in 0..<arr.len:
|
||||
yield (i, arr[i])
|
||||
54
godot/internal/godotstrings.nim
Normal file
54
godot/internal/godotstrings.nim
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# Copyright (c) 2017 Xored Software, Inc.
|
||||
|
||||
type
|
||||
GodotString* {.byref.} = object
|
||||
p: pointer
|
||||
|
||||
proc initGodotString(dest: var GodotString) {.
|
||||
importc: "godot_string_new".}
|
||||
proc initGodotString(dest: var GodotString; contents: cstring;
|
||||
size: cint) {.
|
||||
importc: "godot_string_new_data".}
|
||||
## Initializes ``dest`` from UTF-8 ``contents``
|
||||
proc getData(self: GodotString; dest: cstring;
|
||||
size: var cint) {.
|
||||
noSideEffect
|
||||
importc: "godot_string_get_data".}
|
||||
## Converts ``self`` into UTF-8 encoding, putting the result into ``dest``.
|
||||
|
||||
proc len*(self: GodotString): cint {.inline.} =
|
||||
## Returns the length of string in bytes if it is represented as UTF-8.
|
||||
getData(self, nil, result)
|
||||
|
||||
proc cstring*(self: GodotString): cstring {.
|
||||
importc: "godot_string_c_str".}
|
||||
proc `==`*(self, b: GodotString): bool {.
|
||||
importc: "godot_string_operator_equal".}
|
||||
proc `<`*(self, b: GodotString): bool {.
|
||||
importc: "godot_string_operator_less".}
|
||||
proc `&`*(self, b: GodotString): GodotString {.
|
||||
importc: "godot_string_operator_plus".}
|
||||
|
||||
proc deinit*(self: var GodotString) {.importc: "godot_string_destroy".}
|
||||
|
||||
proc `$`*(self: GodotString): string =
|
||||
## Converts the ``GodotString`` into Nim string
|
||||
var length = self.len
|
||||
result = newStringOfCap(length)
|
||||
getData(self, addr result[0], length)
|
||||
result.setLen(length)
|
||||
assert(result[length] == '\0')
|
||||
|
||||
proc toGodotString*(s: string): GodotString {.inline.} =
|
||||
## Converts the Nim string into ``GodotString``
|
||||
if s.isNil:
|
||||
initGodotString(result)
|
||||
else:
|
||||
initGodotString(result, unsafeAddr s[0], cint(s.len + 1))
|
||||
|
||||
proc toGodotString*(s: cstring): GodotString {.inline.} =
|
||||
## Converts the cstring into ``GodotString``
|
||||
if s.isNil:
|
||||
initGodotString(result)
|
||||
else:
|
||||
initGodotString(result, s, cint(s.len + 1))
|
||||
190
godot/internal/godotvariants.nim
Normal file
190
godot/internal/godotvariants.nim
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
# Copyright 2017 Xored Software, Inc.
|
||||
|
||||
type
|
||||
VariantType* {.size: sizeof(cint), pure.} = enum
|
||||
Nil, ## atomic types
|
||||
Bool,
|
||||
Int,
|
||||
Real,
|
||||
String,
|
||||
# math types
|
||||
Vector2, ## 5
|
||||
Rect2,
|
||||
Vector3,
|
||||
Transform2D,
|
||||
Plane,
|
||||
Quat, ## 10
|
||||
Rect3,
|
||||
Basis,
|
||||
Transform, ## misc types
|
||||
Color,
|
||||
NodePath, ## 15
|
||||
RID,
|
||||
Object,
|
||||
Dictionary,
|
||||
Array, ## 20
|
||||
# arrays
|
||||
PoolByteArray,
|
||||
PoolIntArray,
|
||||
PoolRealArray,
|
||||
PoolStringArray,
|
||||
PoolVector2Array, ## 25
|
||||
PoolVector3Array,
|
||||
PoolColorArray
|
||||
|
||||
VariantCallErrorType* {.size: sizeof(cint), pure.} = enum
|
||||
OK,
|
||||
InvalidMethod,
|
||||
InvalidArgument,
|
||||
TooManyArguments,
|
||||
TooFewArguments,
|
||||
InstanceIsNull
|
||||
|
||||
VariantCallError* = object
|
||||
error*: VariantCallErrorType
|
||||
argument*: cint
|
||||
expected*: VariantType
|
||||
|
||||
import godotinternaltypes, godotpoolarrays, godotstrings, godotnodepaths,
|
||||
godotdictionaries
|
||||
|
||||
import "../core/vector2.nim", "../core/rect2.nim",
|
||||
"../core/vector3.nim", "../core/transform2d.nim", "../core/planes.nim",
|
||||
"../core/quats.nim", "../core/rect3.nim", "../core/basis.nim",
|
||||
"../core/transforms.nim", "../core/colors.nim", "../core/rids.nim",
|
||||
"../core/rect2.nim"
|
||||
|
||||
proc getType*(p: GodotVariant): VariantType {.
|
||||
importc: "godot_variant_get_type".}
|
||||
|
||||
proc initGodotVariant*(dest: var GodotVariant) {.
|
||||
importc: "godot_variant_new_nil".}
|
||||
proc initGodotVariant*(dest: var GodotVariant, src: GodotVariant) {.
|
||||
importc: "godot_variant_new_copy".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; b: bool) {.
|
||||
importc: "godot_variant_new_bool".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; i: uint64) {.
|
||||
importc: "godot_variant_new_uint".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; i: int64) {.
|
||||
importc: "godot_variant_new_int".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; r: cdouble) {.
|
||||
importc: "godot_variant_new_real".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; s: GodotString) {.
|
||||
importc: "godot_variant_new_string".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; v2: Vector2) {.
|
||||
importc: "godot_variant_new_vector2".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; rect2: Rect2) {.
|
||||
importc: "godot_variant_new_rect2".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; v3: Vector3) {.
|
||||
importc: "godot_variant_new_vector3".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; t2d: Transform2D) {.
|
||||
importc: "godot_variant_new_transform2d".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; plane: Plane) {.
|
||||
importc: "godot_variant_new_plane".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; quat: Quat) {.
|
||||
importc: "godot_variant_new_quat".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; rect3: Rect3) {.
|
||||
importc: "godot_variant_new_rect3".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; basis: Basis) {.
|
||||
importc: "godot_variant_new_basis".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; trans: Transform) {.
|
||||
importc: "godot_variant_new_transform".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; color: Color) {.
|
||||
importc: "godot_variant_new_color".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; nodePath: GodotNodePath) {.
|
||||
importc: "godot_variant_new_node_path".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; rid: RID) {.
|
||||
importc: "godot_variant_new_rid".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; obj: ptr GodotObject) {.
|
||||
importc: "godot_variant_new_object".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; arr: GodotArray) {.
|
||||
importc: "godot_variant_new_array".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; pba: GodotPoolByteArray) {.
|
||||
importc: "godot_variant_new_pool_byte_array".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; pia: GodotPoolIntArray) {.
|
||||
importc: "godot_variant_new_pool_int_array".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; pra: GodotPoolRealArray) {.
|
||||
importc: "godot_variant_new_pool_real_array".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; psa: GodotPoolStringArray) {.
|
||||
importc: "godot_variant_new_pool_string_array".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; pv2a: GodotPoolVector2Array) {.
|
||||
importc: "godot_variant_new_pool_vector2_array".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; pv3a: GodotPoolVector3Array) {.
|
||||
importc: "godot_variant_new_pool_vector3_array".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; pca: GodotPoolColorArray) {.
|
||||
importc: "godot_variant_new_pool_color_array".}
|
||||
proc initGodotVariant*(dest: var GodotVariant; dict: GodotDictionary) {.
|
||||
importc: "godot_variant_new_dictionary".}
|
||||
|
||||
proc deinit*(v: var GodotVariant) {.importc: "godot_variant_destroy".}
|
||||
|
||||
proc asBool*(self: GodotVariant): bool {.
|
||||
importc: "godot_variant_as_bool".}
|
||||
proc asUInt*(self: GodotVariant): uint64 {.
|
||||
importc: "godot_variant_as_uint".}
|
||||
proc asInt*(self: GodotVariant): int64 {.
|
||||
importc: "godot_variant_as_int".}
|
||||
proc asReal*(self: GodotVariant): cdouble {.
|
||||
importc: "godot_variant_as_real".}
|
||||
proc asGodotString*(self: GodotVariant): GodotString {.
|
||||
importc: "godot_variant_as_string".}
|
||||
proc asVector2*(self: GodotVariant): Vector2 {.
|
||||
importc: "godot_variant_as_vector2".}
|
||||
proc asRect2*(self: GodotVariant): Rect2 {.
|
||||
importc: "godot_variant_as_rect2".}
|
||||
proc asVector3*(self: GodotVariant): Vector3 {.
|
||||
importc: "godot_variant_as_vector3".}
|
||||
proc asTransform2D*(self: GodotVariant): Transform2D {.
|
||||
importc: "godot_variant_as_transform2d".}
|
||||
proc asPlane*(self: GodotVariant): Plane {.
|
||||
importc: "godot_variant_as_plane".}
|
||||
proc asQuat*(self: GodotVariant): Quat {.
|
||||
importc: "godot_variant_as_quat".}
|
||||
proc asRect3*(self: GodotVariant): Rect3 {.
|
||||
importc: "godot_variant_as_rect3".}
|
||||
proc asBasis*(self: GodotVariant): Basis {.
|
||||
importc: "godot_variant_as_basis".}
|
||||
proc asTransform*(self: GodotVariant): Transform {.
|
||||
importc: "godot_variant_as_transform".}
|
||||
proc asColor*(self: GodotVariant): Color {.
|
||||
importc: "godot_variant_as_color".}
|
||||
proc asNodePath*(self: GodotVariant): GodotNodePath {.
|
||||
importc: "godot_variant_as_node_path".}
|
||||
proc asRID*(self: GodotVariant): RID {.
|
||||
importc: "godot_variant_as_rid".}
|
||||
proc asGodotObject*(self: GodotVariant): ptr GodotObject {.
|
||||
importc: "godot_variant_as_object".}
|
||||
proc asGodotArray*(self: GodotVariant): GodotArray {.
|
||||
importc: "godot_variant_as_array".}
|
||||
proc asGodotPoolByteArray*(self: GodotVariant): GodotPoolByteArray {.
|
||||
importc: "godot_variant_as_pool_byte_array".}
|
||||
proc asGodotPoolIntArray*(self: GodotVariant): GodotPoolIntArray {.
|
||||
importc: "godot_variant_as_pool_int_array".}
|
||||
proc asGodotPoolRealArray*(self: GodotVariant): GodotPoolRealArray {.
|
||||
importc: "godot_variant_as_pool_real_array".}
|
||||
proc asGodotPoolStringArray*(self: GodotVariant): GodotPoolStringArray {.
|
||||
importc: "godot_variant_as_pool_string_array".}
|
||||
proc asGodotPoolVector2Array*(self: GodotVariant): GodotPoolVector2Array {.
|
||||
importc: "godot_variant_as_pool_vector2_array".}
|
||||
proc asGodotPoolVector3Array*(self: GodotVariant): GodotPoolVector3Array {.
|
||||
importc: "godot_variant_as_pool_vector3_array".}
|
||||
proc asGodotPoolColorArray*(self: GodotVariant): GodotPoolColorArray {.
|
||||
importc: "godot_variant_as_pool_color_array".}
|
||||
proc asGodotDictionary*(self: GodotVariant): GodotDictionary {.
|
||||
importc: "godot_variant_as_dictionary".}
|
||||
|
||||
proc call*(self: GodotVariant; meth: GodotString;
|
||||
args: var array[128, GodotVariant]; argCount: cint;
|
||||
error: var VariantCallError): GodotVariant {.
|
||||
importc: "godot_variant_call".}
|
||||
|
||||
proc hasMethod*(self: GodotVariant; meth: GodotString): bool {.
|
||||
importc: "godot_variant_has_method".}
|
||||
proc `==`*(self, other: GodotVariant): bool {.
|
||||
importc: "godot_variant_operator_equal".}
|
||||
proc `<`*(self, other: GodotVariant): bool {.
|
||||
importc: "godot_variant_operator_less".}
|
||||
proc hashCompare*(self, other: GodotVariant): bool {.
|
||||
importc: "godot_variant_hash_compare".}
|
||||
proc booleanize*(self: GodotVariant; isValid: var bool): bool {.
|
||||
importc: "godot_variant_booleanize".}
|
||||
Loading…
Add table
Add a link
Reference in a new issue