Add thread enter/exit callbacks
This commit is contained in:
parent
291e14a32a
commit
3a6acbbe92
3 changed files with 21 additions and 1 deletions
|
|
@ -285,6 +285,10 @@ proc print*(message: string) {.inline.} =
|
|||
let s = message.toGodotString()
|
||||
godotPrint(s)
|
||||
|
||||
proc print*(message: cstring) {.inline.} =
|
||||
let s = message.toGodotString()
|
||||
godotPrint(s)
|
||||
|
||||
template printWarning*(warn: typed) =
|
||||
let (filename, line) = instantiationInfo()
|
||||
godotPrintWarning(cstring($warn), nil, cstring(filename), line.cint)
|
||||
|
|
|
|||
|
|
@ -56,3 +56,7 @@ proc `$`*(self: GodotString): string =
|
|||
proc toGodotString*(s: string): GodotString {.inline.} =
|
||||
## Converts the Nim string into ``GodotString``
|
||||
initGodotString(result, unsafeAddr s[0], cint(s.len + 1))
|
||||
|
||||
proc toGodotString*(s: cstring): GodotString {.inline.} =
|
||||
## Converts the cstring into ``GodotString``
|
||||
initGodotString(result, s, cint(s.len + 1))
|
||||
|
|
|
|||
|
|
@ -554,4 +554,16 @@ proc godot_gdnative_init(options: ptr GodotNativeInitOptions) {.
|
|||
|
||||
proc godot_gdnative_terminate(options: ptr GodotNativeTerminateOptions) {.
|
||||
cdecl, exportc, dynlib.} =
|
||||
deallocHeap()
|
||||
deallocHeap(runFinalizers = true, allowGcAfterwards = false)
|
||||
|
||||
proc godot_nativescript_thread_enter() {.
|
||||
cdecl, exportc, dynlib.} =
|
||||
when compileOption("threads"):
|
||||
setupForeignThreadGc()
|
||||
else:
|
||||
print(cstring"A foreign thread is created, but app is compiled without --threads:on. Bad things will happen if Nim code is invoked from this thread.")
|
||||
|
||||
proc godot_nativescript_thread_exit() {.
|
||||
cdecl, exportc, dynlib.} =
|
||||
when compileOption("threads"):
|
||||
teardownForeignThreadGc()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue