Skip to content

Commit

Permalink
Don't run embedBytes() if embedByteArray() is also running. (#1871)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
player-03 authored Dec 6, 2024
1 parent 5905e7c commit d6e20eb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lime/_internal/macros/AssetsMacro.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d6e20eb

Please sign in to comment.