From eebd5ce72e807f168c44c5c9b7ff2869b0cbe2e8 Mon Sep 17 00:00:00 2001 From: Ian Harrigan Date: Thu, 8 Feb 2024 21:33:43 +0100 Subject: [PATCH] allow component macros to also work with abstracts --- haxe/ui/macros/helpers/ClassBuilder.hx | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/haxe/ui/macros/helpers/ClassBuilder.hx b/haxe/ui/macros/helpers/ClassBuilder.hx index 2053ef28c..91fdb3a98 100644 --- a/haxe/ui/macros/helpers/ClassBuilder.hx +++ b/haxe/ui/macros/helpers/ClassBuilder.hx @@ -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 _: } @@ -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 _: } @@ -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 _: } @@ -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;