Don't run embedBytes() if embedByteArray() is also running. (#1871)

* Don't run `embedBytes()` if `embedByteArray()` is also running.

Both functions insert a constructor, and one class can't have two constructors, much less call `super()` with two different signatures.

I can only assume a bug in Haxe that prevented this from being an issue until now, and that Haxe 5 is fixing the bug.

* Check for `@:autoBuild` only after checking for embed data.

If we ever decide to handle the case of the embed functions being called for non-classes (meaning `getLocalClass()` would return null), we'd handle it in `embedData()`. Therefore `embedData()` should happen first.
This commit is contained in:
player-03
2024-12-06 16:14:58 -05:00
committed by GitHub
parent 5905e7cc6f
commit d6e20eb987

View File

@@ -31,6 +31,16 @@ class AssetsMacro
var fields = embedData(":file");
if (fields == null) return null;
for (autoBuild in Context.getLocalClass().get().meta.extract(":autoBuild"))
{
switch (autoBuild.params[0])
{
case macro lime._internal.macros.AssetsMacro.embedByteArray():
return null;
default:
}
}
var superCall = Context.defined("html5") ? macro super(bytes.b.buffer)
: Context.defined("hl") ? macro super(bytes.b, bytes.length)
: macro super(bytes.length, bytes.b);