Bladeren bron

[cpp] Allow setting callback for cppia script load (#12051)

* [cpp] Allow setting callback for cppia script load

Debugger clients may want to do some work if a script is loaded, e.g.
adding breakpoints.

* [cpp] Bump api level to 500
tobil4sk 3 maanden geleden
bovenliggende
commit
cfd3d275b8
2 gewijzigde bestanden met toevoegingen van 12 en 1 verwijderingen
  1. 1 1
      src/compiler/compiler.ml
  2. 11 0
      std/cpp/vm/Debugger.hx

+ 1 - 1
src/compiler/compiler.ml

@@ -134,7 +134,7 @@ module Setup = struct
 				add_std "php";
 				"php"
 			| Cpp ->
-				Common.define_value com Define.HxcppApiLevel "430";
+				Common.define_value com Define.HxcppApiLevel "500";
 				add_std "cpp";
 				if Common.defined com Define.Cppia then
 					actx.classes <- (Path.parse_path "cpp.cppia.HostClasses" ) :: actx.classes;

+ 11 - 0
std/cpp/vm/Debugger.hx

@@ -321,6 +321,17 @@ class Debugger {
 			THREAD_NOT_STOPPED);
 	}
 
+	#if scriptable
+	/**
+		Sets the callback to run whenever a new CPPIA script is loaded.
+
+		This can be helpful for adding breakpoints to a script.
+	**/
+	public static function setOnScriptLoadedFunction(callback:Void->Void):Void {
+		untyped __global__.__hxcpp_dbg_setOnScriptLoadedFunction(callback);
+	}
+	#end
+
 	// The hxcpp runtime calls back through these functions to create Haxe
 	// objects as needed, which allows the C++ implementation code to create
 	// Haxe objects without having to actually know the structure of those