This project is read-only.
2
Vote

Changes to work with dot net namespaces

description

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 @@
    else
 
    {
 
    assert(p->isPackage());
 
+#if TARGET_NET //dot net needs modules and packages with same name
 
+#else
 
    if (p->isModule())
 
    {   p->error("module and package have the same name");
 
        fatal();
 
        break;
 
    }
 
+#endif
 
    }
 
    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

comments

tim_m89 wrote May 25, 2009 at 3: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 3:45 AM

I have applied the fix.

cristiv wrote Sep 20, 2009 at 5:43 PM

Can we close this one?

wrote Apr 27, 2010 at 11:07 AM

wrote Feb 14, 2013 at 1:52 AM