From 631cb58ba703de097b2e062ac7e9531c93b6c5c3 Mon Sep 17 00:00:00 2001 From: George Corney Date: Mon, 27 Sep 2021 15:23:05 +0100 Subject: [PATCH] Disable tests while I seek a cleaner solution --- test/unit/app.c | 3 + test/unit/haxe-bin/HaxeLib.h | 4 -- .../haxe-bin/src/__HaxeCBridgeBindings__.cpp | 72 ------------------- test/unit/src/Main.hx | 2 + 4 files changed, 5 insertions(+), 76 deletions(-) diff --git a/test/unit/app.c b/test/unit/app.c index 7493856..a8a2b02 100644 --- a/test/unit/app.c +++ b/test/unit/app.c @@ -160,6 +160,8 @@ int main(void) { // can we pass NULL for an object? HaxeLib_checkNull(NULL, 0); + /* + Disabled tests until we can have a cleaner solution for (int i = 0; i < 100; i++) { // run many times to try to catch GC issues // test returning Array int arrayLength = 0; @@ -181,6 +183,7 @@ int main(void) { assert(arrayLength == 3); logf("array char* (%d) [%s, %s, %s]", arrayLength, array[0], array[1], array[2]); } + */ // sleep one second and verify the haxe thread event loop continued to run log("sleeping 1s to let the haxe thread event loop run"); diff --git a/test/unit/haxe-bin/HaxeLib.h b/test/unit/haxe-bin/HaxeLib.h index 2838910..5663561 100644 --- a/test/unit/haxe-bin/HaxeLib.h +++ b/test/unit/haxe-bin/HaxeLib.h @@ -129,10 +129,6 @@ extern "C" { MessagePayload HaxeLib_externStruct(MessagePayload v, MessagePayload* vStar); - int* HaxeLib_getHaxeArray(int* length); - - int64_t* HaxeLib_getHaxeArrayStr(int* length); - /** * Test the GC behavior, runs on haxe main thread */ diff --git a/test/unit/haxe-bin/src/__HaxeCBridgeBindings__.cpp b/test/unit/haxe-bin/src/__HaxeCBridgeBindings__.cpp index bf6442e..974057f 100644 --- a/test/unit/haxe-bin/src/__HaxeCBridgeBindings__.cpp +++ b/test/unit/haxe-bin/src/__HaxeCBridgeBindings__.cpp @@ -548,78 +548,6 @@ MessagePayload HaxeLib_externStruct(MessagePayload a0, MessagePayload* a1) { return data.ret; } -HXCPP_EXTERN_CLASS_ATTRIBUTES -int* HaxeLib_getHaxeArray(int* a0) { - if (HaxeCBridgeInternal::isHaxeMainThread()) { - return test::HxPublicApi_obj::getHaxeArray(a0); - } - struct Data { - struct {int* a0;} args; - HxSemaphore lock; - int* ret; - }; - struct Callback { - static void run(void* p) { - // executed within the haxe main thread - Data* data = (Data*) p; - try { - data->ret = test::HxPublicApi_obj::getHaxeArray(data->args.a0); - data->lock.Set(); - } catch(Dynamic runtimeException) { - data->lock.Set(); - throw runtimeException; - } - } - }; - - #ifdef HXCPP_DEBUG - assert(HaxeCBridgeInternal::threadRunning && "haxe thread not running, use HaxeLib_initializeHaxeThread() to activate the haxe thread"); - #endif - - Data data = { {a0} }; - - // queue a callback to execute getHaxeArray() on the main thread and wait until execution completes - HaxeCBridgeInternal::runInMainThread(Callback::run, &data); - data.lock.Wait(); - return data.ret; -} - -HXCPP_EXTERN_CLASS_ATTRIBUTES -int64_t* HaxeLib_getHaxeArrayStr(int* a0) { - if (HaxeCBridgeInternal::isHaxeMainThread()) { - return test::HxPublicApi_obj::getHaxeArrayStr(a0); - } - struct Data { - struct {int* a0;} args; - HxSemaphore lock; - int64_t* ret; - }; - struct Callback { - static void run(void* p) { - // executed within the haxe main thread - Data* data = (Data*) p; - try { - data->ret = test::HxPublicApi_obj::getHaxeArrayStr(data->args.a0); - data->lock.Set(); - } catch(Dynamic runtimeException) { - data->lock.Set(); - throw runtimeException; - } - } - }; - - #ifdef HXCPP_DEBUG - assert(HaxeCBridgeInternal::threadRunning && "haxe thread not running, use HaxeLib_initializeHaxeThread() to activate the haxe thread"); - #endif - - Data data = { {a0} }; - - // queue a callback to execute getHaxeArrayStr() on the main thread and wait until execution completes - HaxeCBridgeInternal::runInMainThread(Callback::run, &data); - data.lock.Wait(); - return data.ret; -} - HXCPP_EXTERN_CLASS_ATTRIBUTES void HaxeLib_allocateABunchOfData() { if (HaxeCBridgeInternal::isHaxeMainThread()) { diff --git a/test/unit/src/Main.hx b/test/unit/src/Main.hx index 91e80d0..50819c3 100644 --- a/test/unit/src/Main.hx +++ b/test/unit/src/Main.hx @@ -203,6 +203,7 @@ class PublicCApi { return v; } + /* static public function getHaxeArray(length: Star) { var array = [1,2,3,4,5]; HaxeCBridge.retainHaxeObject(array); // @! this isn't ideal, retain should happen automatically @@ -229,6 +230,7 @@ class PublicCApi { return cpp.Pointer.ofArray(nativeArray); } + */ /** Test the GC behavior, runs on haxe main thread **/ static public function allocateABunchOfData(): Void {