ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: Mixins for Introspection
Date Mon, 02 Oct 2006 10:40:16 GMT
On 10/2/06, Jan.Materne@rzf.fin-nrw.de <Jan.Materne@rzf.fin-nrw.de> wrote:
>
> >> void antMixin(RegexMixin x) {
> >>   this.regexParams = x;
> >> }
> >
> >That would be *fantastic* Peter!!!


It would be nice to have. I have no
code but suspect that IH would hit new Complexity Limits.

>
> >Overlap in attr/elem between the main type and the mixins
> >would be silently ignored (maybe a warning a warn or debug
> >level only), the main type taking precedence;


Hard to know what is the best approach -whine or ignore?

but overlap in
> >attr/elem between the mixins would be an error (ambiguous).


Yes.

You could also pass the value to both: the task and the mixin.


Mmm.. I do not think so - too much scope for bugs.


public class MyMixin /* extends PC/some baseclass? */ {


PC I think, to get location,and loging -  just Object should work as well.


    private String foo;
>     public void setFoo(String f) { foo=f; }
> }
>
> public class MyTask extends Task /* maybe each ProjectComponent */ {
>     MyMixin mixin;
>     public void antMixin(MyMixin in) {
>         mixin = in;
>     }
>     String foo;
>     public void setFoo(String f) { foo=f; }
> }
>
> <mytask foo="bar"/>
> -->  MyTask.foo       = "bar"
> -->  MyTask.mixin.foo = "bar"
>
>
> Another possibility would be setting the back reference automatically
>
> public class MyMixin {
>     Task caller;
>     public void setTask(Task c) { caller=c; }
> }


Or
public void setContaining(ProjectComponent pc) ;


Declation of mixin:

I would rather have annotations:

public class MyTask {
   @AntMixin
   private RegexParams regexParams;
}

but that will not happen
so:
   void antMixin(RegexParams ..)

will have to do for the moment.
Note that antMixin will always be called, even if the no attributes or
nested elements
are set

alternatively other naming convenetions could be used:

  private RegexParams  antMixinRegexParams;

or

  RegexParams getAntMixinXXX()
(where XXX is ignored by IH, but can ge used to have multiple mixins).

or
  Object[] getAntMixins()


Peter

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message