0

I'm trying to do this:

var player:Player = new Player();  // class Player extends PlayerCore

var playerCore:PlayerCore = cast (player, PlayerCore);
var playerStr:String = Serializer.run(playerCore);

which compiles, but gives runtime error:

compile_server.command: line 3:  4267 Bus error: 10           ../bin/Server/Main

Cast works, it fails on serializer line. Except that Std.is(playerCore, PlayerCore) and Std.is(playerCore, Player) are both true, I don't know if it is expected result or not. Is this Haxe / hxcpp bug or am I doing something wrong?

Or alternatively, I need to convert object of type Player to it's parent type PlayerCore ("strip it off" the Player type features) and then serialize it. Is there a way to do this properly, or do I need to create new object and copy all the parameters manually?

Haxe 3.2.1, hxcpp 3.2.180, mac target

wildfireheart
  • 373
  • 2
  • 4
  • 13
  • There doesn't seem to be anything illegit in your code as you describe it. This code http://try.haxe.org/#9Eac9 works fine in cpp on my ubuntu machine. The error is probably caused by something in your PlayerCore and/or Player implementations. – Cambiata Dec 19 '15 at 10:16
  • 1
    If you have recursion going on in your code, setting Serializer.USE_CACHE = true before doing any actual serializing might help. http://api.haxe.org/haxe/Serializer.html#USE_CACHE – Cambiata Dec 19 '15 at 10:18

0 Answers0