HeapsIO / hxbit

Haxe Binary serialization and network synchronization library
155 stars 30 forks source link

JS: makeAlive Std.Instance check incorrect. #18

Closed Coderah closed 7 years ago

Coderah commented 7 years ago

This code NetworkHost:544 will always return false due to the way createEmptyInstance works in the JS implementation at Serializer.hx:473

       public static function createEmptyInstance<T>( cl : Class<T> ) : T untyped {
        __js__("function empty() {}; empty.prototype = cl.prototype");
        return __js__("new empty()");
    }

I'm not sure the best approach to fixing this, I'll likely do a hacky fix for the time being, potentially more of a Haxe JS implementation issue than hxbit?

ncannasse commented 7 years ago

Yes it's more an haxe issue. Please open an one there that tells that using Type.createEmptyInstance + Std.instance doesn't work in JS.

dadon commented 7 years ago

This will work for JS target for NetworkHost:544 var n:NetworkSerializable = cast o;