Macro @:autoBuild modifying class's parent

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro @:autoBuild modifying class's parent

David
Hi all,

Is it possible for autoBuild macros to change properties of a class
other than just the fields?

For example - can it change the super class? Say, in the code below -

class MacroClass {
    @:macro public static function build() : Array<Field> {
    }
}


@:autoBuild(SomeMacro.build()) class BaseMacro {
}

class MyClass extends BaseMacro {
}

So the macro function MacroClass.build will be called on MyClass. In
this MacroClass.build call, is there a way to modify MyClass so that
it doesn't extend from BaseMacro?

Regards,
David

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Macro @:autoBuild modifying class's parent

Heinz Hölzer-2
Is there a reason that you extend BaseMacro, or do you extend it only to
get the autoBuild macro called?

Am 24.10.2011 14:22, schrieb David:

> Hi all,
>
> Is it possible for autoBuild macros to change properties of a class
> other than just the fields?
>
> For example - can it change the super class? Say, in the code below -
>
> class MacroClass {
>      @:macro public static function build() : Array<Field>  {
>      }
> }
>
>
> @:autoBuild(SomeMacro.build()) class BaseMacro {
> }
>
> class MyClass extends BaseMacro {
> }
>
> So the macro function MacroClass.build will be called on MyClass. In
> this MacroClass.build call, is there a way to modify MyClass so that
> it doesn't extend from BaseMacro?
>
> Regards,
> David
>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Macro @:autoBuild modifying class's parent

David
It's only to get the macro called. I had also experimented with having
a macro function creating a new class from scratch but I had some
other problems with that. I've solved what I was doing another way but
I still find it interesting to know just how much a macro can change.

2011/10/24 Heinz Hölzer <[hidden email]>:

> Is there a reason that you extend BaseMacro, or do you extend it only to get
> the autoBuild macro called?
>
> Am 24.10.2011 14:22, schrieb David:
>>
>> Hi all,
>>
>> Is it possible for autoBuild macros to change properties of a class
>> other than just the fields?
>>
>> For example - can it change the super class? Say, in the code below -
>>
>> class MacroClass {
>>     @:macro public static function build() : Array<Field>  {
>>     }
>> }
>>
>>
>> @:autoBuild(SomeMacro.build()) class BaseMacro {
>> }
>>
>> class MyClass extends BaseMacro {
>> }
>>
>> So the macro function MacroClass.build will be called on MyClass. In
>> this MacroClass.build call, is there a way to modify MyClass so that
>> it doesn't extend from BaseMacro?
>>
>> Regards,
>> David
>>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org