removed export system

This commit is contained in:
2024-03-12 21:47:49 +01:00
parent 72654b1036
commit fdcb81b565
12 changed files with 2 additions and 404 deletions

View File

@@ -1,79 +0,0 @@
package macros;
import haxe.macro.Context;
import haxe.macro.Expr;
using Lambda;
class Exporter {
macro public static function buildExport():Array<haxe.macro.Expr.Field> {
var fields = Context.getBuildFields();
var getExp = [];
for (field in fields) {
if (field.meta == null)
continue;
var s = "";
for (meta in field.meta) {
if (meta.name == "export") {
switch (meta.params[0].expr) {
case EConst(CString(s1)):
s = s1;
default:
Context.error("Invalid export name", meta.pos);
}
}
}
if (s == "")
continue;
switch (field.kind) {
case FFun(f):
var funName = field.name;
switch (f.ret) {
case TPath(p):
switch (p.name) {
case "Int":
getExp.push(macro $v{s} => (i:Int) -> lib.exporter.Response.ValueType.Int(this.$funName()));
case "Float":
getExp.push(macro $v{s} => (i:Int) -> lib.exporter.Response.ValueType.Float(this.$funName()));
case "Bool":
getExp.push(macro $v{s} => (i:Int) -> lib.exporter.Response.ValueType.Bool(this.$funName()));
case "String":
getExp.push(macro $v{s} => (i:Int) -> lib.exporter.Response.ValueType.String(this.$funName()));
default:
Context.error("Only Int, Float, Bool and String can be exported", field.pos);
}
default:
Context.error("Only functions returning a type can be exported", field.pos);
}
default:
Context.error("Only functions can be exported", field.pos);
}
}
var exportField:Field = {
name: "export",
pos: Context.currentPos(),
kind: FFun({
args: [],
ret: TPath({name: "ExportConfig", pack: []}),
expr: macro {
return {
getDelegates: $a{getExp},
};
}
}),
access: [APublic],
doc: null,
meta: [],
};
fields.push(exportField);
return fields;
}
}