basically the most important abstracts

This commit is contained in:
lemz1 2024-10-28 00:31:43 +01:00 committed by lemz
parent 9a1985369f
commit d0efde8a04
2 changed files with 38 additions and 5 deletions

View file

@ -589,7 +589,13 @@ class Project extends HXProject {
// This macro allows addition of new functionality to existing Flixel. -->
addHaxeMacro("addMetadata('@:build(funkin.util.macro.FlxMacro.buildFlxBasic())', 'flixel.FlxBasic')");
var abstracts:Array<String> = ['funkin.*', 'flixel.util.FlxColor', 'flixel.util.FlxTypedSignal'];
var abstracts:Array<String> = [
'funkin.*',
'flixel.*',
'haxe.ui.*',
'!flixel.graphics.frames.bmfont.BMFont',
'!flixel.addons.util.FlxSimplex'
];
addHaxeMacro("funkin.util.macro.PolymodMacro.buildPolymodAbstracts(['" + abstracts.join("', '") + "'])");
}

View file

@ -25,6 +25,19 @@ class PolymodMacro
return;
}
var sortedAbstractClasses:Array<String> = [];
for (abstractCls in abstractClasses)
{
if (abstractCls.startsWith('!'))
{
sortedAbstractClasses.insert(0, abstractCls);
}
else
{
sortedAbstractClasses.push(abstractCls);
}
}
var aliases:Map<String, String> = new Map<String, String>();
for (type in types)
@ -33,14 +46,27 @@ class PolymodMacro
{
case ModuleType.TAbstract(a):
var cls = a.get();
for (abstractCls in abstractClasses)
for (abstractCls in sortedAbstractClasses)
{
if (!cls.module.startsWith(abstractCls.replace('.*', ''))
&& cls.module + cls.name != abstractCls
&& cls.pack.join('.') + '.' + cls.name != abstractCls)
var negate:Bool = abstractCls.startsWith('!');
var name:String = abstractCls.replace('!', '').replace('.*', '');
if (!negate && !cls.module.startsWith(name) && cls.module + cls.name != name && cls.pack.join('.') + '.' + cls.name != name)
{
continue;
}
else if (negate)
{
if (cls.module.startsWith(name) || cls.module + cls.name == name || cls.pack.join('.') + '.' + cls.name == name)
{
break;
}
else
{
continue;
}
}
aliases.set('${cls.pack.join('.')}.${cls.name}', 'polymod.abstracts.${cls.pack.join('.')}.${cls.name}');
buildAbstract(cls);
break;
@ -177,6 +203,7 @@ class PolymodMacro
ret: (macro :Dynamic),
expr: macro
{
@:privateAccess
return ${Context.parse(newExprStr + '(' + funcArgNames.join(', ') + ')', Context.currentPos())};
},
}),