COMMUNITY

Generating xml with native field names and after build macro transformations

haxe-xml

(Bary Levi) #1

I’m doing some transformations with a build macro, and renaming some fields with the @:native metadata. For example

@:native("AnotherName")
@:expose
class SomeClass {}

The generated JS output has this class named AnotherName rather than SomeClass. But it is represented in the generated xml as

<class path="SomeClass" params="" file="SomeClass.hx">
    <meta>
        <m n=":native"><e>"AnotherName"</e></m>
        <m n=":expose"/>
    </meta>
</class>

While I need

<class path="AnotherName" params="" file="SomeClass.hx">
</class>

Is there a way to do this?


(Valentin Lemière) #2

@:native changes the generated name, but the class (or field) still has its original name, which you use in your haxe code.
That’s why the xml reflect this, it’s mainly used for documentation, where you want the haxe name.

You’ll have to either check for the presence of the meta in your application using the xml,
or do a preprocess step with either custom code or something like xslt.