Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var meta = null;
- if (Context.getLocalClass().get().meta.has(":composite") == true) {
- meta = Context.getLocalClass().get().meta.extract(":composite");
- } else if (Context.getLocalClass().get().meta.has("composite") == true) {
- meta = Context.getLocalClass().get().meta.extract("composite");
- }
- if (meta != null) {
- var m = null;
- for (t in meta) {
- if (t.name == "composite" || t.name == ":composite") {
- m = t;
- break;
- }
- }
- var currentRegisterCompositeFn = MacroHelpers.getFunction(fields, "registerComposite");
- if (currentRegisterCompositeFn != null) {
- for (p in m.params) {
- var s = ExprTools.toString(p);
- // probably a better way to do this
- if (s.indexOf("Event") != -1) {
- MacroHelpers.appendLine(currentRegisterCompositeFn, Context.parseInlineString('_internalEventsClass = ${ExprTools.toString(p)}', pos));
- } else if (s.indexOf("Builder") != -1) {
- MacroHelpers.appendLine(currentRegisterCompositeFn, Context.parseInlineString('_compositeBuilderClass = ${ExprTools.toString(p)}', pos));
- } else if (s.indexOf("Layout") != -1) {
- MacroHelpers.appendLine(currentRegisterCompositeFn, Context.parseInlineString('_defaultLayoutClass = ${ExprTools.toString(p)}', pos));
- }
- }
- } else {
- var code:String = "";
- code += "function() {\n";
- code += "super.registerComposite();\n";
- for (p in m.params) {
- var s = ExprTools.toString(p);
- // probably a better way to do this
- if (s.indexOf("Event") != -1) {
- code += '_internalEventsClass = ${ExprTools.toString(p)};\n';
- } else if (s.indexOf("Builder") != -1) {
- code += '_compositeBuilderClass = ${ExprTools.toString(p)};\n';
- } else if (s.indexOf("Layout") != -1) {
- code += '_defaultLayoutClass = ${ExprTools.toString(p)};\n';
- }
- }
- code += "}";
- var access:Array<Access> = [APrivate, AOverride];
- MacroHelpers.addFunction("registerComposite", Context.parseInlineString(code, pos), access, fields, pos);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement