Update for latest Godot
This commit is contained in:
parent
bf5bd54356
commit
a1c378301a
6 changed files with 31 additions and 26 deletions
|
|
@ -1,4 +1,4 @@
|
|||
version = "0.6.5"
|
||||
version = "0.6.6"
|
||||
author = "Xored Software, Inc."
|
||||
description = "Godot Engine bindings"
|
||||
license = "MIT"
|
||||
|
|
|
|||
|
|
@ -9,10 +9,6 @@ type
|
|||
GDNativeExtPluginScript,
|
||||
GDNativeExtNativeARVR
|
||||
|
||||
GDNativeAPIVersion = object
|
||||
major: cuint
|
||||
minor: cuint
|
||||
|
||||
GDNativeAPIHeader = object
|
||||
typ: cuint
|
||||
version: GDNativeAPIVersion
|
||||
|
|
@ -1271,8 +1267,6 @@ type
|
|||
stringGetData: proc (self: GodotString, dest: cstring, size: var cint)
|
||||
{.noconv, raises: [], gcsafe, tags: [], locks: 0.}
|
||||
stringOperatorIndex: pointer
|
||||
stringCStr: proc (self: GodotString): cstring
|
||||
{.noconv, raises: [], gcsafe, tags: [], locks: 0.}
|
||||
stringOperatorIndexConst: pointer
|
||||
stringUTF16Str: pointer
|
||||
stringOperatorEqual: proc (self, other: GodotString): bool
|
||||
|
|
@ -1450,7 +1444,10 @@ type
|
|||
{.noconv, raises: [], gcsafe, tags: [], locks: 0.}
|
||||
getClassConstructor: proc (className: cstring): GodotClassConstructor
|
||||
{.noconv, raises: [], gcsafe, tags: [], locks: 0.}
|
||||
|
||||
registerNativeCallType: proc (callType: cstring,
|
||||
cb: proc (procHandle: pointer,
|
||||
args: ptr GodotArray): GodotVariant
|
||||
{.noconv.}) {.noconv.}
|
||||
alloc: proc (bytes: cint): pointer
|
||||
{.noconv, raises: [], gcsafe, tags: [], locks: 0.}
|
||||
realloc: proc (p: pointer, bytes: cint): pointer
|
||||
|
|
@ -2535,8 +2532,6 @@ type
|
|||
{.noconv, raises: [], gcsafe, tags: [], locks: 0.}
|
||||
stringGetData*: proc (self: GodotString, dest: cstring, size: var cint)
|
||||
{.noconv, raises: [], gcsafe, tags: [], locks: 0.}
|
||||
stringCStr*: proc (self: GodotString): cstring
|
||||
{.noconv, raises: [], gcsafe, tags: [], locks: 0.}
|
||||
stringOperatorEqual*: proc (self, other: GodotString): bool
|
||||
{.noconv, raises: [], gcsafe, tags: [], locks: 0.}
|
||||
stringOperatorLess*: proc (self, other: GodotString): bool
|
||||
|
|
@ -2627,7 +2622,7 @@ var gdNativeAPI: GDNativeAPI
|
|||
proc getGDNativeAPI*(): ptr GDNativeAPI {.inline.} =
|
||||
addr gdNativeAPI
|
||||
|
||||
proc setGDNativeAPI*(apiStruct: pointer) {.inline.} =
|
||||
proc setGDNativeAPI*(apiStruct: pointer, initOptions: ptr GDNativeInitOptions) =
|
||||
let header = cast[ptr GDNativeAPIHeader](apiStruct)
|
||||
|
||||
if header.typ >= ord(low(GDNativeAPIType)).cuint and header.typ <= ord(high(GDNativeAPIType)).cuint:
|
||||
|
|
@ -3110,7 +3105,6 @@ proc setGDNativeAPI*(apiStruct: pointer) {.inline.} =
|
|||
stringNewCopy
|
||||
stringNewData
|
||||
stringGetData
|
||||
stringCStr
|
||||
stringOperatorEqual
|
||||
stringOperatorLess
|
||||
stringOperatorPlus
|
||||
|
|
@ -3134,7 +3128,11 @@ proc setGDNativeAPI*(apiStruct: pointer) {.inline.} =
|
|||
print
|
||||
|
||||
for i in 0.cuint..<coreApi.numExtensions:
|
||||
setGDNativeAPI(coreApi.extensions[][i.int])
|
||||
setGDNativeAPI(coreApi.extensions[][i.int], initOptions)
|
||||
else:
|
||||
let want = GDNativeAPIVersion(major: 1, minor: 0)
|
||||
initOptions[].reportVersionMismatch(
|
||||
initOptions[].gdNativeLibrary, cstring"Core", want, coreApi[].version)
|
||||
of GDNativeExtNativeScript:
|
||||
let nativeScriptApi = cast[ptr GDNativeNativeScriptAPI1](apiStruct)
|
||||
if nativeScriptApi[].version.major == 1:
|
||||
|
|
@ -3145,10 +3143,15 @@ proc setGDNativeAPI*(apiStruct: pointer) {.inline.} =
|
|||
nativeScriptRegisterProperty
|
||||
nativeScriptRegisterSignal
|
||||
nativeScriptGetUserdata
|
||||
else:
|
||||
let want = GDNativeAPIVersion(major: 1, minor: 0)
|
||||
initOptions[].reportVersionMismatch(
|
||||
initOptions[].gdNativeLibrary, cstring"NativeScript",
|
||||
want, nativeScriptApi[].version)
|
||||
|
||||
of GDNativeExtPluginScript, GDNativeExtNativeARVR:
|
||||
# Not used
|
||||
discard
|
||||
|
||||
if not header.next.isNil:
|
||||
setGDNativeAPI(header.next)
|
||||
setGDNativeAPI(header.next, initOptions)
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ proc nativeScriptRegisterClass*(libHandle: pointer; name, base: cstring;
|
|||
createFunc: GodotInstanceCreateFunc;
|
||||
destroyFunc: GodotInstanceDestroyFunc)
|
||||
{.inline.} =
|
||||
let api = getGDNativeAPI()
|
||||
api.nativeScriptRegisterClass(
|
||||
getGDNativeAPI().nativeScriptRegisterClass(
|
||||
libHandle, name, base, createFunc, destroyFunc)
|
||||
|
||||
proc nativeScriptRegisterToolClass*(libHandle: pointer; name, base: cstring;
|
||||
|
|
@ -73,8 +72,7 @@ proc deinit*(o: ptr GodotObject) {.inline.} =
|
|||
|
||||
proc godotPrintError*(description, function, file: cstring;
|
||||
line: cint) {.inline.} =
|
||||
let api = getGDNativeAPI()
|
||||
api.printError(description, function, file, line)
|
||||
getGDNativeAPI().printError(description, function, file, line)
|
||||
|
||||
proc godotPrintWarning*(description, function, file: cstring;
|
||||
line: cint) {.inline.} =
|
||||
|
|
|
|||
|
|
@ -82,16 +82,23 @@ type
|
|||
type GodotMethodBind* = object
|
||||
|
||||
type
|
||||
GodotNativeInitOptions* = object
|
||||
GDNativeAPIVersion* = object
|
||||
major*: cuint
|
||||
minor*: cuint
|
||||
|
||||
GDNativeInitOptions* = object
|
||||
inEditor*: bool
|
||||
coreApiHash*: uint64
|
||||
editorApiHash*: uint64
|
||||
noApiHash*: uint64
|
||||
reportVersionMismatch*: proc (library: ptr GodotObject, extension: cstring,
|
||||
want: GDNativeAPIVersion, have: GDNativeAPIVersion) {.noconv.}
|
||||
reportLoadingError*: proc (library: ptr GodotObject, what: cstring) {.noconv.}
|
||||
gdNativeLibrary*: ptr GodotObject
|
||||
gdNativeAPIStruct*: pointer
|
||||
activeLibraryPath*: ptr GodotString
|
||||
|
||||
GodotNativeTerminateOptions* = object
|
||||
GDNativeTerminateOptions* = object
|
||||
inEditor*: bool
|
||||
|
||||
GodotMethodRPCMode* {.size: sizeof(cint), pure.} = enum
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ 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 {.inline.} =
|
||||
getGDNativeAPI().stringCStr(self)
|
||||
|
||||
proc `==`*(self, b: GodotString): bool {.inline.} =
|
||||
getGDNativeAPI().stringOperatorEqual(self, b)
|
||||
|
||||
|
|
|
|||
|
|
@ -801,12 +801,12 @@ proc godot_nativescript_init(handle: pointer) {.
|
|||
GC_fullCollect()
|
||||
GC_disable()
|
||||
|
||||
proc godot_gdnative_init(options: ptr GodotNativeInitOptions) {.
|
||||
proc godot_gdnative_init(options: ptr GDNativeInitOptions) {.
|
||||
cdecl, exportc, dynlib.} =
|
||||
gdNativeLibraryObj = options.gdNativeLibrary
|
||||
setGDNativeAPI(options.gdNativeAPIStruct)
|
||||
setGDNativeAPI(options.gdNativeAPIStruct, options)
|
||||
|
||||
proc godot_gdnative_terminate(options: ptr GodotNativeTerminateOptions) {.
|
||||
proc godot_gdnative_terminate(options: ptr GDNativeTerminateOptions) {.
|
||||
cdecl, exportc, dynlib.} =
|
||||
deallocHeap(runFinalizers = not options[].inEditor, allowGcAfterwards = false)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue