forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
15
Kha/Backends/Kinc-hxcpp/khacpp/test/extern-use/Build.xml
Normal file
15
Kha/Backends/Kinc-hxcpp/khacpp/test/extern-use/Build.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<xml>
|
||||
<files id="myfiles">
|
||||
<compilerflag value="-I${HXCPP}/include"/>
|
||||
<compilerflag value="-I../extern-lib/gen-externs/include"/>
|
||||
<file name="Main.cpp" />
|
||||
</files>
|
||||
|
||||
<target id="default" tool="linker" toolid="exe" output="ExternUse">
|
||||
<files id="myfiles"/>
|
||||
|
||||
<libpath name="../extern-lib/gen-externs" />
|
||||
<lib base="liboutput" />
|
||||
</target>
|
||||
|
||||
</xml>
|
73
Kha/Backends/Kinc-hxcpp/khacpp/test/extern-use/Main.cpp
Normal file
73
Kha/Backends/Kinc-hxcpp/khacpp/test/extern-use/Main.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <hx/Native.h>
|
||||
#include <api/HaxeObject.h>
|
||||
#include <api/HaxeApi.h>
|
||||
|
||||
|
||||
struct MyStruct
|
||||
{
|
||||
hx::Ref<api::HaxeObject *> haxeRef;
|
||||
};
|
||||
|
||||
extern void __hxcpp_collect(bool inMajor);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MyStruct *myStruct = new MyStruct();
|
||||
|
||||
|
||||
const char *err = hx::Init();
|
||||
if (err)
|
||||
{
|
||||
printf("Could not initialize library: %s\n", err);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
hx::NativeAttach autoAttach;
|
||||
|
||||
api::HaxeObject *obj = api::HaxeApi::createBase();
|
||||
obj->setName("child");
|
||||
|
||||
myStruct->haxeRef = obj;
|
||||
obj->setName("Name");
|
||||
|
||||
api::HaxeObject *child = obj->createChild();
|
||||
}
|
||||
|
||||
{
|
||||
hx::NativeAttach autoAttach;
|
||||
__hxcpp_collect(true);
|
||||
}
|
||||
|
||||
{
|
||||
hx::NativeAttach autoAttach;
|
||||
if (myStruct->haxeRef->getName()!="Name")
|
||||
{
|
||||
printf("Could not get value back (%s)\n", myStruct->haxeRef->getName().c_str() );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
hx::NativeAttach autoAttach0;
|
||||
hx::NativeAttach autoAttach1;
|
||||
hx::NativeAttach autoAttach2;
|
||||
hx::NativeAttach autoAttach3;
|
||||
if (hx::GcGetThreadAttachedCount()!=4)
|
||||
{
|
||||
printf("Bad attach count\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (hx::GcGetThreadAttachedCount()!=0)
|
||||
{
|
||||
printf("Bad clear attach count\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("all good\n");
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user