Is there any way to get the generated cpp name/namespace of a class? (For hxcpp externs.)

Say you have a class called ExampleClass, in a package called example, ie: import example.ExampleClass;. The generated output when calling it would look like this: ::example::ExampleClass_obj.

Is there any way to get the value of this generated output as a string during compilation (perhaps using macros / reflection)?

This is so that I can call classes using hxcpp externs by just passing in the class Haxe class name itself (ExampleClass) and having the extern function convert it to the cpp syntax and then calling it with untyped __cpp__() and ::example::ExampleClass_obj, ect.

What are you trying to achieve?
If you call with __cpp__ on ::example::ExampleClass_obj it’s the same as directly using haxe code on ExampleClass.

I think the rule is pretty simple:

"::" + packages.join("::") + "::" + className + "_obj"

I don’t remember seeing any exceptions to that.

1 Like