hxcpp icon indicating copy to clipboard operation
hxcpp copied to clipboard

[cppia] Replacing functions in main source through cppia causes crash

Open kevansevans opened this issue 4 years ago • 1 comments

Haxe 4.1.1 and Windows 10. I was recommended on the forum to come here.

Main program code

class ToolCore 
{
	public static var replaceable_func:Void -> Void;
	
	public function new() 
	{
		replaceable_func = null_action_safety;

		Host.runFile("./plugins/tools/TestTool.cppia"); //<- Crash happens here.
	}
	
	public static function null_action_safety():Void {
		trace("Function has not been replaced");
	}
	
}

cppia code

class TestTool {
	static public function main() {
		ToolCore.replaceable_func = () -> {trace("herpa derp"); };
	}
}

I get the error Unknown function : __hxcpp_mutex_create(0) and nothing else. Everything compiles correctly, and I have the scriptable flag enabled. In order to accomplish the replacement so the source doesn't complain, I'm treating ToolCore as a haxelib, which I believe is an intended function.

kevansevans avatar Jun 01 '20 17:06 kevansevans

So I tried to reproduce this, but it seem to work. Generally, the "unknown function" looks like a mismatch between the haxe and hxcpp versions. Perhaps this is working after an update?

hughsando avatar Dec 08 '20 14:12 hughsando