HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.17k stars 656 forks source link

[cppia] Classes that use Float32 cannot be overridden correctly #8502

Closed waneck closed 5 years ago

waneck commented 5 years ago

The following gist https://gist.github.com/waneck/4dbe2e8a59128a5228c26f0f17106894

produces the following result:

Main.hx:5: loading cppia
Test2.hx:5: doTest cppia,1.01985010851924e-316
Test.hx:7: doTest,0

While the following would be expected:

Main.hx:5: loading cppia
Test2.hx:5: doTest cppia,15
Test.hx:7: doTest,15

This seems to happen because in the scriptable object definition, the following is set:

    void doTest( float _hx_float ) {
    if (__scriptVTable[1] ) {
        hx::CppiaCtx *__ctx = hx::CppiaCtx::getCurrent();
        hx::AutoStack __as(__ctx);
        __ctx->pushObject(this);
        __ctx->pushObject(_hx_float);
         __ctx->runVoid(__scriptVTable[1] );
    }  else  Test_obj::doTest(_hx_float);}

While I believe it should have been ctx->pushFloat instead

waneck commented 5 years ago

Also very weirdly - running this code without the -debug flag in the cppia compilation makes the runtime fail with Error : Error reading file Bad class type, line 26, char 9