Skip to content

Commit

Permalink
allow component macros to also work with abstracts
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Feb 8, 2024
1 parent 55f6448 commit eebd5ce
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions haxe/ui/macros/helpers/ClassBuilder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,30 @@ class ClassBuilder {
break;
}
}
case TAbstract(t, _):
switch (t.get().type) {
case TInst(t, _):
while (t != null) {
for (i in t.get().interfaces) {
var interfaceName:String = i.t.toString();
if (interfaceName == interfaceRequired) {
has = true;
break;
}
}

if (has == false) {
if (t.get().superClass != null) {
t = t.get().superClass.t;
} else {
t = null;
}
} else {
break;
}
}
case _:
}
case _:
}

Expand All @@ -325,6 +349,18 @@ class ClassBuilder {
break;
}
}
case TAbstract(t, _):
switch (t.get().type) {
case TInst(t, _):
for (i in t.get().interfaces) {
var interfaceName:String = i.t.toString();
if (interfaceName == interfaceRequired) {
has = true;
break;
}
}
case _:
}
case _:
}

Expand Down Expand Up @@ -354,6 +390,26 @@ class ClassBuilder {
}
}
}
case TAbstract(t, _):
switch (t.get().type) {
case TInst(t, _):
if (t.toString() == classRequired) {
has = true;
} else {
while (t != null) {
if (t.get().superClass != null) {
t = t.get().superClass.t;
if (t.toString() == classRequired) {
has = true;
break;
}
} else {
t = null;
}
}
}
case _:
}
case _:
}

Expand All @@ -366,6 +422,12 @@ class ClassBuilder {
switch (type) {
case TInst(t, _):
superClass = t.get().superClass;
case TAbstract(t, _):
switch (t.get().type) {
case TInst(t, _):
superClass = t.get().superClass;
case _:
}
case _:
}
return superClass;
Expand Down

0 comments on commit eebd5ce

Please sign in to comment.