Changes to work with dot net namespaces


In D a package cannot be a name space. This is not the case with dot net though eg:
using System;
using System.Windows.Forms;
To allow this a slight change must be made:
--- module-old.c 2009-05-24 22:19:58.000000000 +1200
+++ module.c 2009-05-25 18:35:56.550000000 +1200
@@ -1023,11 +1023,14 @@
+#if TARGET_NET //dot net needs modules and packages with same name
    if (p->isModule())
    {   p->error("module and package have the same name");
    parent = p;
    dst = ((Package *)p)->symtab;
The old way was to use nested classes for the sub namespaces but that plan wasnt going to work. Dot net supports nested classes aswell so this would conflict. I have attached new imports as a replacement untill a tool to automatically generate this is done. It no longer uses nested classes as sub name spaces. (The class defined within Control is an actual subclass)
There needs to be a pragma to define the assembly file for the classes and fields. The old class mscorlib hack removed. Also many assemblys require version and publickeytoken in the generated IL.
In the generated il it will usually say Foo.Bar::func where Foo is the d-language module and Bar is the class but Foo needs to be changed from just the module to the full length package.package.module.
When an object is passed as a parameter simple types like string are allowed as just: (string). Complex types are passed like (Foo) but it should be ([assembly]all.name.spaces.Foo)
Nested classes are named in the IL outer.nested but it should be outer/nested
I have also attached a simple example of code to show a form with 1 button on it. It has the fixed il with it so you can compare the differences.

file attachments


tim_m89 wrote May 25, 2009 at 2:53 PM

To compile that dnetform-fixed.il I provided you need to add the word 'class' on lines 41 and 59 just inside the parenthesis at the begining before the square brackets. (mono's ilasm didnt require this for some reason)

cristiv wrote Jun 20, 2009 at 2:45 AM

I have applied the fix.

cristiv wrote Sep 20, 2009 at 4:43 PM

Can we close this one?

wrote Apr 27, 2010 at 10:07 AM

wrote Feb 14, 2013 at 12:52 AM