[nem-en] += Macro and delegates

Kamil Skalski kamil.skalski at gmail.com
Thu Dec 7 23:40:34 CET 2006


If the original expression expanded into call of add_ method and the
macro was += then I guess you can safely assume that:

match (original) {
  | <[ $e += $method ]> =>
}

will give you  event reference in $e  and method reference in $method

On 12/7/06, Andrey Khropov <andrey.khropov at gmail.com> wrote:
>
> Hello,
>
> I have a question about how "+=" macro is transformed to event handler
> attachment :
>
> We have TExpr.MacroEnvelope(original,the_macro,expanded)
>
> original:
> ----------------------------------------------------------------
> this.button1.Click += System.EventHandler (this.button1_Click)
> ----------------------------------------------------------------
>
> expanded:
> ----------------------------------------------------------------
> mutable _N_cached_obj4611 = this.button1;
> _N_cached_obj4611.add_Click(System.EventHandler(this.button1_Click));
> ----------------------------------------------------------------
>
> So I have a question how can I detect such a case (among all "+="s)
> because I need to generate System.CodeDom.CodeAttachEventStatement in my
> CodeDomParser in this case.
>
> Should I just try to parse *original* like that:
>
> ----------------------------------------------------------------
> match(original)
> {
>         | <[ $( e1 : ?* ) += $delegate ]> =>  ...
>         ...
> }
> ----------------------------------------------------------------?
>
> How should I detect that lhs of this expression is an event?
>
> *(?) means 'what to insert here?'
>
>
> --
> AKhropov
>
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>


-- 
Kamil Skalski
http://nazgul.omega.pl



More information about the devel-en mailing list