Use GDNative API struct

This commit is contained in:
Ruslan Mustakov 2017-10-04 23:41:15 +07:00
commit b62db02d8f
32 changed files with 2846 additions and 1535 deletions

View file

@ -1,107 +1,130 @@
# Copyright (c) 2017 Xored Software, Inc.
type
GodotArray* {.byref.} = object
data: array[sizeof(int), byte]
import godotinternaltypes, gdnativeapi, core.godotcoretypes
proc len*(self: GodotArray): cint {.
noSideEffect,
importc: "godot_array_size".}
proc len*(self: GodotArray): cint {.inline.} =
getGDNativeAPI().arraySize(self)
import hashes
import godotobjects, godotpoolarrays, godotvariants, godotstrings
proc initGodotArray*(dest: var GodotArray) {.
importc: "godot_array_new".}
proc initGodotArray*(dest: var GodotArray; pca: GodotPoolColorArray) {.
importc: "godot_array_new_pool_coloarray".}
proc initGodotArray*(dest: var GodotArray; pv3a: GodotPoolVector3Array) {.
importc: "godot_array_new_pool_vector3_array".}
proc initGodotArray*(dest: var GodotArray; pv2a: GodotPoolVector2Array) {.
importc: "godot_array_new_pool_vector2_array".}
proc initGodotArray*(dest: var GodotArray; psa: GodotPoolStringArray) {.
importc: "godot_array_new_pool_string_array".}
proc initGodotArray*(dest: var GodotArray; pra: GodotPoolRealArray) {.
importc: "godot_array_new_pool_real_array".}
proc initGodotArray*(dest: var GodotArray; pia: GodotPoolIntArray) {.
importc: "godot_array_new_pool_int_array".}
proc initGodotArray*(dest: var GodotArray; pba: GodotPoolByteArray) {.
importc: "godot_array_new_pool_byte_array".}
proc iniGodotArray*(dest: var GodotArray; src: GodotArray) {.
importc: "godot_array_new_copy".}
proc initGodotArray*(dest: var GodotArray) {.inline.} =
getGDNativeAPI().arrayNew(dest)
proc deinit*(self: var GodotArray) {.importc: "godot_array_destroy".}
proc initGodotArray*(dest: var GodotArray;
pca: GodotPoolColorArray) {.inline.} =
getGDNativeAPI().arrayNewPoolColorArray(dest, pca)
proc `[]=`*(self: var GodotArray; idx: cint;
value: GodotVariant) {.
noSideEffect,
importc: "godot_array_set".}
proc `[]`*(self: GodotArray; idx: cint): GodotVariant {.
noSideEffect,
importc: "godot_array_get".}
proc mget*(self: var GodotArray; idx: cint): ptr GodotVariant {.
importc: "godot_array_operator_index".}
proc initGodotArray*(dest: var GodotArray;
pv3a: GodotPoolVector3Array) {.inline.} =
getGDNativeAPI().arrayNewPoolVector3Array(dest, pv3a)
proc initGodotArray*(dest: var GodotArray;
pv2a: GodotPoolVector2Array) {.inline.} =
getGDNativeAPI().arrayNewPoolVector2Array(dest, pv2a)
proc initGodotArray*(dest: var GodotArray;
psa: GodotPoolStringArray) {.inline.} =
getGDNativeAPI().arrayNewPoolStringArray(dest, psa)
proc initGodotArray*(dest: var GodotArray;
pra: GodotPoolRealArray) {.inline.} =
getGDNativeAPI().arrayNewPoolRealArray(dest, pra)
proc initGodotArray*(dest: var GodotArray;
pia: GodotPoolIntArray) {.inline.} =
getGDNativeAPI().arrayNewPoolIntArray(dest, pia)
proc initGodotArray*(dest: var GodotArray;
pba: GodotPoolByteArray) {.inline.} =
getGDNativeAPI().arrayNewPoolByteArray(dest, pba)
proc initGodotArray*(dest: var GodotArray; src: GodotArray) {.inline.} =
getGDNativeAPI().arrayNewCopy(dest, src)
proc deinit*(self: var GodotArray) {.inline.} =
getGDNativeAPI().arrayDestroy(self)
proc `[]=`*(self: var GodotArray; idx: cint; value: GodotVariant) {.inline.} =
getGDNativeAPI().arraySet(self, idx, value)
proc `[]`*(self: GodotArray; idx: cint): GodotVariant {.inline.} =
getGDNativeAPI().arrayGet(self, idx)
proc mget*(self: var GodotArray; idx: cint): ptr GodotVariant {.inline.} =
getGDNativeAPI().arrayOperatorIndex(self, idx)
proc add*(self: var GodotArray; value: GodotVariant) {.inline.} =
getGDNativeAPI().arrayPushBack(self, value)
proc clear*(self: var GodotArray) {.inline.} =
getGDNativeAPI().arrayClear(self)
proc count*(self: GodotArray; value: GodotVariant): cint {.inline.} =
getGDNativeAPI().arrayCount(self, value)
proc isEmpty*(self: GodotArray): bool {.inline.} =
getGDNativeAPI().arrayEmpty(self)
proc erase*(self: var GodotArray; value: GodotVariant) {.inline.} =
getGDNativeAPI().arrayErase(self, value)
proc first*(self: GodotArray): GodotVariant {.inline.} =
getGDNativeAPI().arrayFront(self)
proc last*(self: GodotArray): GodotVariant {.inline.} =
getGDNativeAPI().arrayBack(self)
proc add*(self: var GodotArray; value: GodotVariant) {.
noSideEffect,
importc: "godot_array_append".}
proc clear*(self: var GodotArray) {.importc: "godot_array_clear".}
proc count*(self: GodotArray; value: GodotVariant): cint {.
noSideEffect,
importc: "godot_array_count".}
proc isEmpty*(self: GodotArray): bool {.
noSideEffect,
importc: "godot_array_empty".}
proc erase*(self: var GodotArray; value: GodotVariant) {.
importc: "godot_array_erase".}
proc first*(self: GodotArray): GodotVariant {.
noSideEffect,
importc: "godot_array_front".}
proc last*(self: GodotArray): GodotVariant {.
noSideEffect,
importc: "godot_array_back".}
proc find*(self: GodotArray; what: GodotVariant;
f: cint): cint {.
noSideEffect,
importc: "godot_array_find".}
proc findLast*(self: GodotArray; what: GodotVariant): cint {.
noSideEffect,
importc: "godot_array_find_last".}
proc contains*(self: GodotArray; value: GodotVariant): bool {.
noSideEffect,
importc: "godot_array_has".}
fromIdx: cint): cint {.inline.} =
getGDNativeAPI().arrayFind(self, what, fromIdx)
proc findLast*(self: GodotArray; what: GodotVariant): cint {.inline.} =
getGDNativeAPI().arrayFindLast(self, what)
proc contains*(self: GodotArray; value: GodotVariant): bool {.inline.} =
getGDNativeAPI().arrayHas(self, value)
proc godotHash*(self: GodotArray): cint {.inline.} =
getGDNativeAPI().arrayHash(self)
proc godotHash*(self: GodotArray): cint {.
noSideEffect,
importc: "godot_array_hash".}
proc hash*(self: GodotArray): Hash {.inline.} =
hash(godotHash(self))
proc insert*(self: var GodotArray; pos: cint;
value: GodotVariant) {.
importc: "godot_array_insert".}
proc reverse*(self: var GodotArray) {.importc: "godot_array_invert".}
proc popLast*(self: var GodotArray): GodotVariant {.
importc: "godot_array_pop_back".}
proc popFirst*(self: var GodotArray): GodotVariant {.
importc: "godot_array_pop_front".}
proc addLast*(self: var GodotArray; value: GodotVariant) {.
importc: "godot_array_push_back".}
proc addFirst*(self: var GodotArray; value: GodotVariant) {.
importc: "godot_array_push_front".}
value: GodotVariant): Error {.discardable, inline.} =
getGDNativeAPI().arrayInsert(self, pos, value)
proc reverse*(self: var GodotArray) {.inline.} =
getGDNativeAPI().arrayInvert(self)
proc popLast*(self: var GodotArray): GodotVariant {.inline.} =
getGDNativeAPI().arrayPopBack(self)
proc popFirst*(self: var GodotArray): GodotVariant {.inline.} =
getGDNativeAPI().arrayPopFront(self)
proc addLast*(self: var GodotArray; value: GodotVariant) {.inline.} =
getGDNativeAPI().arrayPushBack(self, value)
proc addFirst*(self: var GodotArray; value: GodotVariant) {.inline.} =
getGDNativeAPI().arrayPushFront(self, value)
proc delete*(self: var GodotArray; idx: cint) {.inline.} =
getGDNativeAPI().arrayRemove(self, idx)
proc setLen*(self: var GodotArray; size: cint) {.inline.} =
getGDNativeAPI().arrayResize(self, size)
proc delete*(self: var GodotArray; idx: cint) {.
importc: "godot_array_remove".}
proc setLen*(self: var GodotArray; size: cint) {.
importc: "godot_array_resize".}
proc rfind*(self: GodotArray; what: GodotVariant;
f: cint): cint {.
noSideEffect,
importc: "godot_array_rfind".}
proc sort*(self: var GodotArray) {.importc: "godot_array_sort".}
proc sortCustom*(self: var GodotArray; obj: var GodotObject;
funcName: GodotString) {.
importc: "godot_array_sort_custom".}
fromIdx: cint): cint {.inline.} =
getGDNativeAPI().arrayRFind(self, what, fromIdx)
proc sort*(self: var GodotArray) {.inline.} =
getGDNativeAPI().arraySort(self)
proc sortCustom*(self: var GodotArray; obj: ptr GodotObject;
funcName: GodotString) {.inline.} =
getGDNativeAPI().arraySortCustom(self, obj, funcName)
iterator items*(self: GodotArray): GodotVariant =
for i in 0..<self.len:

View file

@ -1,48 +1,56 @@
# Copyright (c) 2017 Xored Software, Inc.
type
GodotDictionary* {.byref.} = object
data: array[sizeof(int), byte]
import godotinternaltypes, gdnativeapi
import godotarrays, godotvariants, godotstrings
proc initGodotDictionary*(dest: var GodotDictionary) {.inline.} =
getGDNativeAPI().dictionaryNew(dest)
proc initGodotDictionary*(dest: var GodotDictionary; src: GodotDictionary) {.
importc: "godot_dictionary_new_copy".}
proc initGodotDictionary*(dest: var GodotDictionary;
src: GodotDictionary) {.inline.} =
getGDNativeAPI().dictionaryNewCopy(dest, src)
proc deinit*(self: var GodotDictionary) {.
importc: "godot_dictionary_destroy".}
proc deinit*(self: var GodotDictionary) {.inline.} =
getGDNativeAPI().dictionaryDestroy(self)
proc initGodotDictionary*(dest: var GodotDictionary) {.
importc: "godot_dictionary_new".}
proc len*(self: GodotDictionary): cint {.inline.} =
getGDNativeAPI().dictionarySize(self)
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 isEmpty*(self: GodotDictionary): bool {.inline.} =
getGDNativeAPI().dictionaryEmpty(self)
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 clear*(self: var GodotDictionary) {.inline.} =
getGDNativeAPI().dictionaryClear(self)
proc `==`*(self, other: GodotDictionary): bool {.
importc: "godot_dictionary_operator_equal".}
proc contains*(self: GodotDictionary; key: GodotVariant): bool {.inline.} =
getGDNativeAPI().dictionaryHas(self, key)
proc toJson*(self: GodotDictionary): GodotString {.
importc: "godot_dictionary_to_json".}
proc contains*(self: GodotDictionary; keys: GodotArray): bool {.inline.} =
getGDNativeAPI().dictionaryHasAll(self, keys)
proc del*(self: var GodotDictionary; key: GodotVariant) {.inline.} =
getGDNativeAPI().dictionaryErase(self, key)
proc godotHash*(self: GodotDictionary): cint {.inline.} =
getGDNativeAPI().dictionaryHash(self, )
proc keys*(self: GodotDictionary): GodotArray {.inline.} =
getGDNativeAPI().dictionaryKeys(self)
proc values*(self: GodotDictionary): GodotArray {.inline.} =
getGDNativeAPI().dictionaryValues(self)
proc `[]`*(self: GodotDictionary; key: GodotVariant): GodotVariant {.inline.} =
getGDNativeAPI().dictionaryGet(self, key)
proc `[]=`*(self: var GodotDictionary; key, value: GodotVariant) {.inline.} =
getGDNativeAPI().dictionarySet(self, key, value)
proc mget*(self: var GodotDictionary;
key: GodotVariant): ptr GodotVariant {.inline.} =
getGDNativeAPI().dictionaryOperatorIndex(self, key)
proc `==`*(self, other: GodotDictionary): bool {.inline.} =
getGDNativeAPI().dictionaryOperatorEqual(self, other)
proc toJson*(self: GodotDictionary): GodotString {.inline.} =
getGDNativeAPI().dictionaryToJson(self)

View file

@ -0,0 +1,262 @@
# Copyright 2017 Xored Software, Inc.
const MAX_ARG_COUNT* = 256
type
GodotArray* {.byref.} = object
data: array[sizeof(int), byte]
GodotDictionary* {.byref.} = object
data: array[sizeof(int), byte]
GodotNodePath* {.byref.} = object
data: array[sizeof(int), byte]
GodotObject* = object
GodotPoolByteArray* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolIntArray* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolRealArray* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolStringArray* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolVector2Array* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolVector3Array* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolColorArray* {.byref.} = object
data: array[sizeof(int), byte]
GodotString* {.byref.} = object
data: array[sizeof(int), byte]
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
GodotVariant* {.byref.} = object
data: array[4 + sizeof(int) div 4, float32]
type GodotMethodBind* = object
type
GodotNativeInitOptions* = object
inEditor*: bool
coreApiHash*: uint64
editorApiHash*: uint64
noApiHash*: uint64
gdNativeLibrary*: ptr GodotObject
gdNativeAPIStruct*: pointer
activeLibraryPath*: ptr GodotString
GodotNativeTerminateOptions* = object
inEditor*: bool
GodotMethodRPCMode* {.size: sizeof(cint), pure.} = enum
Disabled,
Remote,
Sync,
Master,
Slave
GodotMethodAttributes* = object
rpcMode*: GodotMethodRPCMode
GodotPropertyHint* {.size: sizeof(cint), pure.} = enum
None, ## no hint provided.
Range, ## hint_text = "min,max,step,slider; // slider is optional"
ExpRange, ## hint_text = "min,max,step", exponential edit
Enum, ## hint_text= "val1,val2,val3,etc"
ExpEasing, ## exponential easing funciton (Math::ease)
Length, ## hint_text= "length" (as integer)
SpriteFrame,
KeyAccel, ## hint_text= "length" (as integer)
Flags, ## hint_text= "flag1,flag2,etc" (as bit flags)
Layers2DRender,
Layers2DPhysics,
Layers3DRender,
Layers3DPhysics,
File, ## a file path must be passed, hint_text (optionally)
## is a filter "*.png,*.wav,*.doc,"
Dir, ## a directort path must be passed
GlobalFile, ## a file path must be passed, hint_text (optionally) is a
## filter "*.png,*.wav,*.doc,"
GlobalDir, ## a directort path must be passed
ResourceType, ## a resource object type
MultilineText, ## used for string properties that can contain multiple lines
ColorNoAlpha, ## used for ignoring alpha component when editing a color
ImageCompressLossy,
ImageCompressLossless,
ObjectId,
TypeString, ## a type string, the hint is the base type to choose
NodePathToEditedNode, ## so something else can provide this
## (used in scripts)
MethodOfVariantType, ## a method of a type
MethodOfBaseType, ## a method of a base type
MethodOfInstance, ## a method of an instance
MethodOfScript, ## a method of a script & base
PropertyOfVariantType, ## a property of a type
PropertyOfBaseType, ## a property of a base type
PropertyOfInstance, ## a property of an instance
PropertyOfScript, ## a property of a script & base
PropertyHintMax
const
GODOT_PROPERTY_USAGE_STORAGE_VALUE = 1.cint
GODOT_PROPERTY_USAGE_EDITOR_VALUE = 2.cint
GODOT_PROPERTY_USAGE_NETWORK_VALUE = 4.cint
GODOT_PROPERTY_USAGE_EDITOR_HELPER_VALUE = 8.cint
GODOT_PROPERTY_USAGE_CHECKABLE_VALUE = 16.cint
GODOT_PROPERTY_USAGE_CHECKED_VALUE = 32.cint
GODOT_PROPERTY_USAGE_INTERNATIONALIZED_VALUE = 64.cint
GODOT_PROPERTY_USAGE_GROUP_VALUE = 128.cint
GODOT_PROPERTY_USAGE_CATEGORY_VALUE = 256.cint
GODOT_PROPERTY_USAGE_STORE_IF_NONZERO_VALUE = 512.cint
GODOT_PROPERTY_USAGE_STORE_IF_NONONE_VALUE = 1024.cint
GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE_VALUE = 2048.cint
GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED_VALUE = 4096.cint
GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE_VALUE = 8192.cint
GODOT_PROPERTY_USAGE_STORE_IF_NULL_VALUE = 16384.cint
GODOT_PROPERTY_USAGE_ANIMATE_AS_TRIGGER_VALUE = 32768.cint
GODOT_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED_VALUE = 65536.cint
GODOT_PROPERTY_USAGE_DEFAULT_VALUE: cint =
GODOT_PROPERTY_USAGE_STORAGE_VALUE or GODOT_PROPERTY_USAGE_EDITOR_VALUE or
GODOT_PROPERTY_USAGE_NETWORK_VALUE
GODOT_PROPERTY_USAGE_DEFAULT_INTL_VALUE: cint =
GODOT_PROPERTY_USAGE_STORAGE_VALUE or
GODOT_PROPERTY_USAGE_EDITOR_VALUE or GODOT_PROPERTY_USAGE_NETWORK_VALUE or
GODOT_PROPERTY_USAGE_INTERNATIONALIZED_VALUE
GODOT_PROPERTY_USAGE_NOEDITOR_VALUE: cint =
GODOT_PROPERTY_USAGE_STORAGE_VALUE or GODOT_PROPERTY_USAGE_NETWORK_VALUE
type
GodotPropertyUsage* {.size: sizeof(cint), pure.} = enum
Storage = GODOT_PROPERTY_USAGE_STORAGE_VALUE
Editor = GODOT_PROPERTY_USAGE_EDITOR_VALUE
Network = GODOT_PROPERTY_USAGE_NETWORK_VALUE
NoEditor = GODOT_PROPERTY_USAGE_NOEDITOR_VALUE
Default = GODOT_PROPERTY_USAGE_DEFAULT_VALUE
EditorHelper = GODOT_PROPERTY_USAGE_EDITOR_HELPER_VALUE
Checkable = GODOT_PROPERTY_USAGE_CHECKABLE_VALUE
## used for editing global variables
Checked = GODOT_PROPERTY_USAGE_CHECKED_VALUE
## used for editing global variables
Internationalized = GODOT_PROPERTY_USAGE_INTERNATIONALIZED_VALUE
## hint for internationalized strings
DefaultIntl = GODOT_PROPERTY_USAGE_DEFAULT_INTL_VALUE
Group = GODOT_PROPERTY_USAGE_GROUP_VALUE
## used for grouping props in the editor
Category = GODOT_PROPERTY_USAGE_CATEGORY_VALUE
NonZero = GODOT_PROPERTY_USAGE_STORE_IF_NONZERO_VALUE
## only store if nonzero
NonOne = GODOT_PROPERTY_USAGE_STORE_IF_NONONE_VALUE
## only store if false
NoInstanceState = GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE_VALUE
RestartIfChanged = GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED_VALUE
ScriptVariable = GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE_VALUE
StoreIfNull = GODOT_PROPERTY_USAGE_STORE_IF_NULL_VALUE
AnimateAsTrigger = GODOT_PROPERTY_USAGE_ANIMATE_AS_TRIGGER_VALUE
UpdateAllIfModified = GODOT_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED_VALUE
GodotPropertyAttributes* {.bycopy.} = object
rsetType*: GodotMethodRPCMode
typ*: cint
hint*: GodotPropertyHint
hintString*: GodotString
usage*: cint
defaultValue*: GodotVariant
GodotInstanceCreateFunc* {.bycopy.} = object
createFunc*:
proc (obj: ptr GodotObject; methodData: pointer): pointer {.noconv.}
## returns user data
methodData*: pointer
freeFunc*: proc (a2: pointer) {.noconv.}
GodotInstanceDestroyFunc* {.bycopy.} = object
destroyFunc*:
proc (obj: ptr GodotObject; methodData: pointer;
userData: pointer) {.noconv.}
methodData*: pointer
freeFunc*: proc (a2: pointer) {.noconv.}
GodotInstanceMethod* {.bycopy.} = object
meth*:
proc (obj: ptr GodotObject; methodData: pointer;
userData: pointer; numArgs: cint;
args: var array[MAX_ARG_COUNT, ptr GodotVariant]):
GodotVariant {.noconv.}
methodData*: pointer
freeFunc*: proc (a2: pointer) {.noconv.}
GodotPropertySetFunc* {.bycopy.} = object
setFunc*: proc (obj: ptr GodotObject; methodData: pointer;
userData: pointer; value: GodotVariant) {.noconv.}
methodData*: pointer
freeFunc*: proc (a2: pointer) {.noconv.}
GodotPropertyGetFunc* {.bycopy.} = object
getFunc*: proc (obj: ptr GodotObject; methodData: pointer;
userData: pointer): GodotVariant {.noconv.}
methodData*: pointer
freeFunc*: proc (a2: pointer) {.noconv.}
GodotSignalArgument* {.bycopy.} = object
name*: GodotString
typ*: cint
hint*: GodotPropertyHint
hintString*: GodotString
usage*: cint
defaultValue*: GodotVariant
GodotSignal* = object
name*: GodotString
numArgs*: cint
args*: ptr GodotSignalArgument
numDefaultArgs*: cint
defaultArgs*: ptr GodotVariant
GodotClassConstructor* = proc (): ptr GodotObject {.noconv.}

View file

@ -1,32 +1,40 @@
# Copyright 2017 Xored Software, Inc.
import godotstrings
import godotinternaltypes, gdnativeapi
type
GodotNodePath* {.byref.} = object
data: array[sizeof(int), byte]
proc initGodotNodePath*(dest: var GodotNodePath; s: GodotString) {.inline.} =
getGDNativeAPI().nodePathNew(dest, s)
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 initGodotNodePath*(dest: var GodotNodePath;
src: GodotNodePath) {.inline.} =
getGDNativeAPI().nodePathNewCopy(dest, src)
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 deinit*(self: var GodotNodePath) {.inline.} =
getGDNativeAPI().nodePathDestroy(self)
proc `==`*(a, b: GodotNodePath): bool {.
noSideEffect, importc: "godot_node_path_operator_equal".}
proc toGodotString*(self: GodotNodePath): GodotString {.inline.} =
getGDNativeAPI().nodePathAsString(self)
proc isAbsolute*(self: GodotNodePath): bool {.inline.} =
getGDNativeAPI().nodePathIsAbsolute(self)
proc nameCount*(self: GodotNodePath): cint {.inline.} =
getGDNativeAPI().nodePathGetNameCount(self)
proc getName*(self: GodotNodePath; idx: cint): GodotString {.inline.} =
getGDNativeAPI().nodePathGetName(self, idx)
proc subnameCount*(self: GodotNodePath): cint {.inline.} =
getGDNativeAPI().nodePathGetSubnameCount(self)
proc getSubname*(self: GodotNodePath; idx: cint): GodotString {.inline.} =
getGDNativeAPI().nodePathGetSubname(self, idx)
proc property*(self: GodotNodePath): GodotString {.inline.} =
getGDNativeAPI().nodePathGetProperty(self)
proc isEmpty*(self: GodotNodePath): bool {.inline.} =
getGDNativeAPI().nodePathIsEmpty(self)
proc `==`*(a, b: GodotNodePath): bool {.inline.} =
getGDNativeAPI().nodePathOperatorEqual(a, b)

View file

@ -1,4 +0,0 @@
# Copyright 2017 Xored Software, Inc.
type
GodotObject* = object

View file

@ -1,374 +1,169 @@
# Copyright (c) 2017 Xored Software, Inc.
type
GodotPoolByteArray* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolIntArray* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolRealArray* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolStringArray* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolVector2Array* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolVector3Array* {.byref.} = object
data: array[sizeof(int), byte]
GodotPoolColorArray* {.byref.} = object
data: array[sizeof(int), byte]
import godotinternaltypes, gdnativeapi
import core.godotcoretypes
import godotstrings, godotarrays
import core.godotbase, core.colors, core.vector2, core.vector3
template genPoolArrayAPI(ArrayT, initIdent, DataT,
newProc, newCopyProc, newWithArrayProc, appendProc,
appendArrayProc, insertProc, invertProc, pushBackProc,
removeProc, resizeProc, setProc, getProc, sizeProc,
destroyProc) =
proc initIdent*(dest: var ArrayT) {.inline.} =
getGDNativeAPI().newProc(dest)
# byte
proc initIdent*(dest: var ArrayT; src: ArrayT) {.inline.} =
getGDNativeAPI().newCopyProc(dest, src)
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 initIdent*(dest: var ArrayT; arr: GodotArray) {.inline.} =
getGDNativeAPI().newWithArrayProc(dest, arr)
proc deinit*(self: var GodotPoolByteArray) {.
importc: "godot_pool_byte_array_destroy".}
proc deinit*(self: var ArrayT) {.inline.} =
getGDNativeAPI().destroyProc(self)
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 add*(self: var ArrayT; data: DataT) {.inline.} =
getGDNativeAPI().pushBackProc(self, data)
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 add*(self: var ArrayT; arr: ArrayT) {.inline.} =
getGDNativeAPI().appendArrayProc(self, arr)
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".}
proc insert*(self: var ArrayT; idx: cint;
data: DataT): Error {.inline.} =
getGDNativeAPI().insertProc(self, idx, data)
iterator items*(arr: GodotPoolByteArray): byte =
for i in 0..<arr.len:
yield arr[i]
proc delete*(self: var ArrayT; idx: cint) {.inline.} =
getGDNativeAPI().removeProc(self, idx)
iterator pairs*(arr: GodotPoolByteArray): tuple[key: cint, val: byte] =
for i in 0..<arr.len:
yield (i, arr[i])
proc reverse*(self: var ArrayT) {.inline.} =
getGDNativeAPI().invertProc(self)
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 setLen*(self: var ArrayT; size: cint) {.inline.} =
getGDNativeAPI().resizeProc(self, size)
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 `[]=`*(self: var ArrayT; idx: cint; data: DataT) {.inline.} =
getGDNativeAPI().setProc(self, idx, data)
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".}
proc `[]`*(self: ArrayT; idx: cint): DataT {.inline.} =
getGDNativeAPI().getProc(self, idx)
iterator items*(arr: GodotPoolIntArray): cint =
for i in 0..<arr.len:
yield arr[i]
proc len*(self: ArrayT): cint {.inline.} =
getGDNativeAPI().sizeProc(self)
iterator pairs*(arr: GodotPoolIntArray): tuple[key: cint, val: cint] =
for i in 0..<arr.len:
yield (i, arr[i])
iterator items*(arr: ArrayT): DataT =
for i in 0..<arr.len:
yield arr[i]
# Real
iterator pairs*(arr: ArrayT): tuple[key: cint, val: DataT] =
for i in 0..<arr.len:
yield (i, arr[i])
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".}
genPoolArrayAPI(GodotPoolByteArray, initGodotPoolByteArray, byte,
poolByteArrayNew,
poolByteArrayNewCopy,
poolByteArrayNewWithArray,
poolByteArrayAppend,
poolByteArrayAppendArray,
poolByteArrayInsert,
poolByteArrayInvert,
poolByteArrayPushBack,
poolByteArrayRemove,
poolByteArrayResize,
poolByteArraySet,
poolByteArrayGet,
poolByteArraySize,
poolByteArrayDestroy)
proc deinit*(self: var GodotPoolRealArray) {.
importc: "godot_pool_real_array_destroy".}
genPoolArrayAPI(GodotPoolIntArray, initGodotPoolIntArray, cint,
poolIntArrayNew,
poolIntArrayNewCopy,
poolIntArrayNewWithArray,
poolIntArrayAppend,
poolIntArrayAppendArray,
poolIntArrayInsert,
poolIntArrayInvert,
poolIntArrayPushBack,
poolIntArrayRemove,
poolIntArrayResize,
poolIntArraySet,
poolIntArrayGet,
poolIntArraySize,
poolIntArrayDestroy)
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".}
genPoolArrayAPI(GodotPoolRealArray, initGodotPoolRealArray, float32,
poolRealArrayNew,
poolRealArrayNewCopy,
poolRealArrayNewWithArray,
poolRealArrayAppend,
poolRealArrayAppendArray,
poolRealArrayInsert,
poolRealArrayInvert,
poolRealArrayPushBack,
poolRealArrayRemove,
poolRealArrayResize,
poolRealArraySet,
poolRealArrayGet,
poolRealArraySize,
poolRealArrayDestroy)
iterator items*(arr: GodotPoolRealArray): float32 =
for i in 0..<arr.len:
yield arr[i]
genPoolArrayAPI(GodotPoolStringArray, initGodotPoolStringArray, GodotString,
poolStringArrayNew,
poolStringArrayNewCopy,
poolStringArrayNewWithArray,
poolStringArrayAppend,
poolStringArrayAppendArray,
poolStringArrayInsert,
poolStringArrayInvert,
poolStringArrayPushBack,
poolStringArrayRemove,
poolStringArrayResize,
poolStringArraySet,
poolStringArrayGet,
poolStringArraySize,
poolStringArrayDestroy)
iterator pairs*(arr: GodotPoolRealArray): tuple[key: cint, val: float32] =
for i in 0..<arr.len:
yield (i, arr[i])
genPoolArrayAPI(GodotPoolVector2Array, initGodotPoolVector2Array, Vector2,
poolVector2ArrayNew,
poolVector2ArrayNewCopy,
poolVector2ArrayNewWithArray,
poolVector2ArrayAppend,
poolVector2ArrayAppendArray,
poolVector2ArrayInsert,
poolVector2ArrayInvert,
poolVector2ArrayPushBack,
poolVector2ArrayRemove,
poolVector2ArrayResize,
poolVector2ArraySet,
poolVector2ArrayGet,
poolVector2ArraySize,
poolVector2ArrayDestroy)
# String
genPoolArrayAPI(GodotPoolVector3Array, initGodotPoolVector3Array, Vector3,
poolVector3ArrayNew,
poolVector3ArrayNewCopy,
poolVector3ArrayNewWithArray,
poolVector3ArrayAppend,
poolVector3ArrayAppendArray,
poolVector3ArrayInsert,
poolVector3ArrayInvert,
poolVector3ArrayPushBack,
poolVector3ArrayRemove,
poolVector3ArrayResize,
poolVector3ArraySet,
poolVector3ArrayGet,
poolVector3ArraySize,
poolVector3ArrayDestroy)
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])
genPoolArrayAPI(GodotPoolColorArray, initGodotPoolColorArray, Color,
poolColorArrayNew,
poolColorArrayNewCopy,
poolColorArrayNewWithArray,
poolColorArrayAppend,
poolColorArrayAppendArray,
poolColorArrayInsert,
poolColorArrayInvert,
poolColorArrayPushBack,
poolColorArrayRemove,
poolColorArrayResize,
poolColorArraySet,
poolColorArrayGet,
poolColorArraySize,
poolColorArrayDestroy)

View file

@ -1,35 +1,38 @@
# Copyright (c) 2017 Xored Software, Inc.
type
GodotString* {.byref.} = object
data: array[sizeof(int), byte]
import godotinternaltypes, gdnativeapi
proc initGodotString(dest: var GodotString) {.inline, raises: [].} =
getGDNativeAPI().stringNew(dest)
proc initGodotString(dest: var GodotString) {.
importc: "godot_string_new".}
proc initGodotString(dest: var GodotString; contents: cstring;
size: cint) {.
importc: "godot_string_new_data".}
size: cint) {.inline.} =
## Initializes ``dest`` from UTF-8 ``contents``
getGDNativeAPI().stringNewData(dest, contents, size)
proc getData(self: GodotString; dest: cstring;
size: var cint) {.
noSideEffect
importc: "godot_string_get_data".}
size: var cint) {.inline.} =
## Converts ``self`` into UTF-8 encoding, putting the result into ``dest``.
getGDNativeAPI().stringGetData(self, dest, size)
proc len*(self: GodotString): cint {.inline.} =
## Returns the length of string in bytes if it is represented as UTF-8.
getData(self, nil, result)
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 cstring*(self: GodotString): cstring {.inline.} =
getGDNativeAPI().stringCStr(self)
proc deinit*(self: var GodotString) {.importc: "godot_string_destroy".}
proc `==`*(self, b: GodotString): bool {.inline.} =
getGDNativeAPI().stringOperatorEqual(self, b)
proc `<`*(self, b: GodotString): bool {.inline.} =
getGDNativeAPI().stringOperatorLess(self, b)
proc `&`*(self, b: GodotString): GodotString {.inline.} =
getGDNativeAPI().stringOperatorPlus(self, b)
proc deinit*(self: var GodotString) {.inline.} =
getGDNativeAPI().stringDestroy(self)
proc `$`*(self: GodotString): string =
## Converts the ``GodotString`` into Nim string

View file

@ -1,197 +1,216 @@
# 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
import core.godotcoretypes, godotinternaltypes, gdnativeapi
VariantCallErrorType* {.size: sizeof(cint), pure.} = enum
OK,
InvalidMethod,
InvalidArgument,
TooManyArguments,
TooFewArguments,
InstanceIsNull
proc getType*(p: GodotVariant): VariantType {.inline.} =
getGDNativeAPI().variantGetType(p)
VariantCallError* = object
error*: VariantCallErrorType
argument*: cint
expected*: VariantType
proc initGodotVariant*(dest: var GodotVariant) {.inline.} =
getGDNativeAPI().variantNewNil(dest)
GodotVariant* {.byref.} = object
data: array[4 + sizeof(int) div 4, float32]
proc initGodotVariant*(dest: var GodotVariant, src: GodotVariant) {.inline.} =
getGDNativeAPI().variantNewCopy(dest, src)
import godotobjects, godotarrays, godotpoolarrays,
godotstrings, godotnodepaths, godotdictionaries
proc initGodotVariant*(dest: var GodotVariant; b: bool) {.inline.} =
getGDNativeAPI().variantNewBool(dest, b)
import core.vector2, core.rect2,
core.vector3, core.transform2d, core.planes,
core.quats, core.rect3, core.basis,
core.transforms, core.colors, core.rids,
core.rect2
proc initGodotVariant*(dest: var GodotVariant; i: uint64) {.inline.} =
getGDNativeAPI().variantNewUInt(dest, i)
proc getType*(p: GodotVariant): VariantType {.
importc: "godot_variant_get_type".}
proc initGodotVariant*(dest: var GodotVariant; i: int64) {.inline.} =
getGDNativeAPI().variantNewInt(dest, i)
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 initGodotVariant*(dest: var GodotVariant; r: cdouble) {.inline.} =
getGDNativeAPI().variantNewReal(dest, r)
proc deinit*(v: var GodotVariant) {.importc: "godot_variant_destroy".}
proc initGodotVariant*(dest: var GodotVariant; s: GodotString) {.inline.} =
getGDNativeAPI().variantNewString(dest, s)
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 initGodotVariant*(dest: var GodotVariant; v2: Vector2) {.inline.} =
getGDNativeAPI().variantNewVector2(dest, v2)
proc call*(self: GodotVariant; meth: GodotString;
args: var array[128, GodotVariant]; argCount: cint;
error: var VariantCallError): GodotVariant {.
importc: "godot_variant_call".}
proc initGodotVariant*(dest: var GodotVariant; rect2: Rect2) {.inline.} =
getGDNativeAPI().variantNewRect2(dest, rect2)
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".}
proc initGodotVariant*(dest: var GodotVariant; v3: Vector3) {.inline.} =
getGDNativeAPI().variantNewVector3(dest, v3)
proc initGodotVariant*(dest: var GodotVariant; t2d: Transform2D) {.inline.} =
getGDNativeAPI().variantNewTransform2D(dest, t2d)
proc initGodotVariant*(dest: var GodotVariant; plane: Plane) {.inline.} =
getGDNativeAPI().variantNewPlane(dest, plane)
proc initGodotVariant*(dest: var GodotVariant; quat: Quat) {.inline.} =
getGDNativeAPI().variantNewQuat(dest, quat)
proc initGodotVariant*(dest: var GodotVariant; rect3: Rect3) {.inline.} =
getGDNativeAPI().variantNewRect3(dest, rect3)
proc initGodotVariant*(dest: var GodotVariant; basis: Basis) {.inline.} =
getGDNativeAPI().variantNewBasis(dest, basis)
proc initGodotVariant*(dest: var GodotVariant; trans: Transform) {.inline.} =
getGDNativeAPI().variantNewTransform(dest, trans)
proc initGodotVariant*(dest: var GodotVariant; color: Color) {.inline.} =
getGDNativeAPI().variantNewColor(dest, color)
proc initGodotVariant*(dest: var GodotVariant;
nodePath: GodotNodePath) {.inline.} =
getGDNativeAPI().variantNewNodePath(dest, nodePath)
proc initGodotVariant*(dest: var GodotVariant; rid: RID) {.inline.} =
getGDNativeAPI().variantNewRID(dest, rid)
proc initGodotVariant*(dest: var GodotVariant;
obj: ptr GodotObject) {.inline.} =
getGDNativeAPI().variantNewObject(dest, obj)
proc initGodotVariant*(dest: var GodotVariant; arr: GodotArray) {.inline.} =
getGDNativeAPI().variantNewArray(dest, arr)
proc initGodotVariant*(dest: var GodotVariant;
pba: GodotPoolByteArray) {.inline.} =
getGDNativeAPI().variantNewPoolByteArray(dest, pba)
proc initGodotVariant*(dest: var GodotVariant;
pia: GodotPoolIntArray) {.inline.} =
getGDNativeAPI().variantNewPoolIntArray(dest, pia)
proc initGodotVariant*(dest: var GodotVariant;
pra: GodotPoolRealArray) {.inline.} =
getGDNativeAPI().variantNewPoolRealArray(dest, pra)
proc initGodotVariant*(dest: var GodotVariant;
psa: GodotPoolStringArray) {.inline.} =
getGDNativeAPI().variantNewPoolStringArray(dest, psa)
proc initGodotVariant*(dest: var GodotVariant;
pv2a: GodotPoolVector2Array) {.inline.} =
getGDNativeAPI().variantNewPoolVector2Array(dest, pv2a)
proc initGodotVariant*(dest: var GodotVariant;
pv3a: GodotPoolVector3Array) {.inline.} =
getGDNativeAPI().variantNewPoolVector3Array(dest, pv3a)
proc initGodotVariant*(dest: var GodotVariant;
pca: GodotPoolColorArray) {.inline.} =
getGDNativeAPI().variantNewPoolColorArray(dest, pca)
proc initGodotVariant*(dest: var GodotVariant;
dict: GodotDictionary) {.inline.} =
getGDNativeAPI().variantNewDictionary(dest, dict)
proc deinit*(v: var GodotVariant) {.inline.} =
getGDNativeAPI().variantDestroy(v)
proc asBool*(self: GodotVariant): bool {.inline.} =
getGDNativeAPI().variantAsBool(self)
proc asUInt*(self: GodotVariant): uint64 {.inline.} =
getGDNativeAPI().variantAsUInt(self)
proc asInt*(self: GodotVariant): int64 {.inline.} =
getGDNativeAPI().variantAsInt(self)
proc asReal*(self: GodotVariant): cdouble {.inline.} =
getGDNativeAPI().variantAsReal(self)
proc asGodotString*(self: GodotVariant): GodotString {.inline.} =
getGDNativeAPI().variantAsString(self)
proc asVector2*(self: GodotVariant): Vector2 {.inline.} =
getGDNativeAPI().variantAsVector2(self)
proc asRect2*(self: GodotVariant): Rect2 {.inline.} =
getGDNativeAPI().variantAsRect2(self)
proc asVector3*(self: GodotVariant): Vector3 {.inline.} =
getGDNativeAPI().variantAsVector3(self)
proc asTransform2D*(self: GodotVariant): Transform2D {.inline.} =
getGDNativeAPI().variantAsTransform2D(self)
proc asPlane*(self: GodotVariant): Plane {.inline.} =
getGDNativeAPI().variantAsPlane(self)
proc asQuat*(self: GodotVariant): Quat {.inline.} =
getGDNativeAPI().variantAsQuat(self)
proc asRect3*(self: GodotVariant): Rect3 {.inline.} =
getGDNativeAPI().variantAsRect3(self)
proc asBasis*(self: GodotVariant): Basis {.inline.} =
getGDNativeAPI().variantAsBasis(self)
proc asTransform*(self: GodotVariant): Transform {.inline.} =
getGDNativeAPI().variantAsTransform(self)
proc asColor*(self: GodotVariant): Color {.inline.} =
getGDNativeAPI().variantAsColor(self)
proc asNodePath*(self: GodotVariant): GodotNodePath {.inline.} =
getGDNativeAPI().variantAsNodePath(self)
proc asRID*(self: GodotVariant): RID {.inline.} =
getGDNativeAPI().variantAsRID(self)
proc asGodotObject*(self: GodotVariant): ptr GodotObject {.inline.} =
getGDNativeAPI().variantAsObject(self)
proc asGodotArray*(self: GodotVariant): GodotArray {.inline.} =
getGDNativeAPI().variantAsArray(self)
proc asGodotPoolByteArray*(self: GodotVariant): GodotPoolByteArray {.inline.} =
getGDNativeAPI().variantAsPoolByteArray(self)
proc asGodotPoolIntArray*(self: GodotVariant): GodotPoolIntArray {.inline.} =
getGDNativeAPI().variantAsPoolIntArray(self)
proc asGodotPoolRealArray*(self: GodotVariant): GodotPoolRealArray {.inline.} =
getGDNativeAPI().variantAsPoolRealArray(self)
proc asGodotPoolStringArray*(self: GodotVariant): GodotPoolStringArray
{.inline.} =
getGDNativeAPI().variantAsPoolStringArray(self)
proc asGodotPoolVector2Array*(self: GodotVariant): GodotPoolVector2Array
{.inline.} =
getGDNativeAPI().variantAsPoolVector2Array(self)
proc asGodotPoolVector3Array*(self: GodotVariant): GodotPoolVector3Array
{.inline.} =
getGDNativeAPI().variantAsPoolVector3Array(self)
proc asGodotPoolColorArray*(self: GodotVariant): GodotPoolColorArray
{.inline.} =
getGDNativeAPI().variantAsPoolColorArray(self)
proc asGodotDictionary*(self: GodotVariant): GodotDictionary {.inline.} =
getGDNativeAPI().variantAsDictionary(self)
proc call*(self: var GodotVariant; meth: GodotString;
args: ptr array[256, ptr GodotVariant]; argCount: cint;
error: var VariantCallError): GodotVariant {.inline.} =
getGDNativeAPI().variantCall(self, meth, args, argCount, error)
proc hasMethod*(self: GodotVariant; meth: GodotString): bool {.inline.} =
getGDNativeAPI().variantHasMethod(self, meth)
proc `==`*(self, other: GodotVariant): bool {.inline.} =
getGDNativeAPI().variantOperatorEqual(self, other)
proc `<`*(self, other: GodotVariant): bool {.inline.} =
getGDNativeAPI().variantOperatorLess(self, other)
proc hashCompare*(self, other: GodotVariant): bool {.inline.} =
getGDNativeAPI().variantHashCompare(self, other)
proc booleanize*(self: GodotVariant): bool {.inline.} =
getGDNativeAPI().variantBooleanize(self)
import godotstrings
proc `$`*(self: GodotVariant): string =
var s = self.asGodotString()
result = $s