[Gtk-sharp-list] Gtk.Label set_Text()
Joe Scaduto
scooch@noggle.biz
Sun, 19 Oct 2003 12:05:54 -0400
On Sun, 2003-10-19 at 11:19, Jonathan Pryor wrote:
> Just as a follow up, where are you seeing "set_Text", anyway? Monodoc
> just shows "Text".
>
> For future reference, CIL has a formalized "name mangling" scheme, so
> that languages that don't have support for properties, events, and
> operator overloading can still invoke the underlying functions.
>
> A property declaration:
>
> int Property {
> get {return 1;}
> set {}
> }
>
> is renamed in the underling CIL to a "get_" or set_" prefix followed by
> the property name:
>
> int get_Property ();
> void set_Property (int value);
>
> However, in languages that support properties, you call the above
> functions using field-access syntax:
>
> obj.Property = 42; // calls set_Property (int);
> int n = obj.Property; // calls get_Property ();
>
> Events use "add_" and "remove_" prefixes; "add_" uses += syntax in C#,
> while "remove_" uses -= syntax in C#. Note that specifying add and
> remove blocks in the event is optional; if not present, a default event
> implementation is provided.
>
> event EventHandler FooEvent;
> event EventHandler BarEvent {
> add {/* do something */}
> remove {/* do something else */}
> }
> obj.FooEvent += new EventHandler (func);// calls add_FooEvent
> obj.FooEvent -= new EventHandler (func);// calls remove_FooEvent
>
> Operator overloading is mangled into "op_" + English description of
> operation, for example op_Add for operator+, op_Subtract for operator-,
> etc. More detail is provided in the ECMA standard documents.
>
> The only time you really need to worry about any of this is when
> programming in a language that doesn't have support for these features,
> for example Microsoft J#, which must directly call the property, event,
> and operator overloading functions (as it lacks support for those
> language features).
>
> - Jon
Jon,
The only way I know the property existed was because I ran the
TreeviewDemo.exe in the samples directory which came with the
gtk-sharp-0.11 source code. In there I saw 'set_Text' and in the next
column 'Void set_Text(String)'. Then I went to the 'gtk' dir which also
came with the gtk-sharp-0.11 source code and noticed a 'generated' dir
and in there found 'Label.cs' which neither approved or denied the
notation of 'Void set_Text(String)'...so this is when I email the
mailing list. This was my first time playing around with set and get in
this manner because I a newbie to C#. However, I greatly appreciate
your explaination....very helpful.
Joe