[Mono-osx] NObjective and Inheritance
Eugeny Grishul
eugeny.grishul at gmail.com
Mon Feb 9 09:39:07 EST 2009
Hi,
Thanks for deep code review =)
Weaver pros and cons:
1) without inheritance proxy assemblies will be about 60M due to duplicated
methods
2) it will be used for Objective-C property accessors for same goal
Cons:
1) code produced by weaver is not verifiable. By spec CLI itself does not
allow for value type inheritance:
8.9.7.
...
3. A value type does not inherit; rather the base type specified in the
class definition defines the
base type of the boxed type.
4. The base type of a boxed type shall not have any fields.
8.9.10.
In their unboxed form value types do not inherit from any type. Boxed value
types shall inherit directly from
System.ValueType unless they are enumerations, in which case, they shall
inherit from System.Enum. Boxed
value types shall be sealed.
My approach is a violation of the spec. If you run "peverify" on the
assembly with one value type inheriting from another, it will tell you as
much =) If mono won't support value-type inheritace in future it will be bug
in ther JIT coz CLR implementation actually ALLOWS it.
2) Current Mono VES implementation have a bug related ot value type
inheritance and to workaround it don't allow objc proxies to be boxed.
Following code will crash JIT:
public void ButtonPressed( NSButton sender )
{
Console.WriteLine( "Pressed {0}", sender );
...
...
And workaround:
public void ButtonPressed( NSButton sender )
{
Console.WriteLine( "Pressed {0}", sender.ToString() );
...
...
About NObjectiveAST - it works like NRefactory and able to parse and save
AST tree to file. But if you want to extend interoping abilities of
resulting code then you should modify HeaderAnalyzer (
http://code.google.com/p/nobjective/source/browse/trunk/ProxyGenerator/HeaderAnalyzer.cs
) which is not part of NObjectiveAST. The goal of mine bridge is Objective-C
interop so I'll not plan to add support for automatical P/Invoke
generation.. My friend's dimpoma thesis is related with automatical P/Invoke
generation (he will use NObjectiveAST and test his work on creating Qt
bindings with full code coverage) and may be after 5 months of his work we
will see brialliant project..or not =) Anyway you can make patch and help to
improve project =)
WBR,
Eugeny Grishul
Martin Smith-8 wrote:
>
> Hello,
>
> I was looking at the NObjective source code, and noticed that that
> basically
> all the proxies are generated as structs. The compiled assembly then gets
> passed to a code weaver which fills in the Objective-C class inheritance
> structure. The code weaver basically uses Mono.Cecil to make structs
> support
> inheritance.
>
> I guess this works, but the thing I'm wondering is: is it safe te rely on
> the fact that the mono runtime can actually support inheritance for value
> types? Is this something that's supposed to be supported by the CLI but
> just isnt supported by C#? I'm assuming that there would be some serious
> issues if all the proxies weren't the same size (i.e. with only an IntPtr
> as
> the instance data).
>
> At any rate, cheers Eugeny. You've created a pretty impressive layer
> here.
> Have you thought about extending NObjectiveAST to suport interoping some
> of
> the C-based functions (for example, NSMakeRect, or the CGContext*
> methods).
>
> Thanks again Eugeny for such great code!
> Martin
>
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
>
>
--
View this message in context: http://www.nabble.com/NObjective-and-Inheritance-tp21882576p21914042.html
Sent from the Mono - OSX mailing list archive at Nabble.com.
More information about the Mono-osx
mailing list