Avoid using godot_get_stack_bottom

It's not reliable on Android.
This commit is contained in:
Ruslan Mustakov 2017-08-23 13:29:32 +07:00
commit fda800fd26
2 changed files with 6 additions and 5 deletions

View file

@ -239,9 +239,6 @@ type ClassConstructor = proc (): ptr GodotObject {.noconv.}
proc getClassConstructor*(className: cstring): ClassConstructor {.
importc: "godot_get_class_constructor".}
proc godotStackBottom*(): pointer {.
importc: "godot_get_stack_bottom".}
proc deinit*(o: ptr GodotObject) {.
importc: "godot_object_destroy".}

View file

@ -780,10 +780,10 @@ proc godot_nativescript_init(handle: pointer) {.
cdecl, exportc, dynlib.} =
nativeLibHandle = handle
let stackBottom = godotStackBottom()
var stackBottom {.volatile.}: pointer
{.emit: """
NimMain();
setStackBottom(`stackBottom`);
setStackBottom((void*)(&`stackBottom`));
""".}
GC_fullCollect()
GC_disable()
@ -798,6 +798,10 @@ proc godot_gdnative_terminate(options: ptr GodotNativeTerminateOptions) {.
const nimGcStepLengthUs {.intdefine.} = 2000
proc godot_nativescript_frame() {.cdecl, exportc, dynlib.} =
var stackBottom {.volatile.}: pointer
{.emit: """
setStackBottom((void*)(&`stackBottom`));
""".}
if asyncdispatch.hasPendingOperations():
poll(0)
GC_step(nimGcStepLengthUs, true, 0)