[Mono-list] Multiplatform DllImport?

Rhys Weatherley rweather@zip.com.au
Sat, 24 Nov 2001 11:38:10 +1000


Miguel de Icaza wrote:

> > [DllImportMap("winsock.dll", "*-sunos-*", "libsocket.so")]
> > [DllImportMap("winsock.dll", "std-shared-object", "libc.so")]
> > class SocketOps
> > {
> >     [DllImport("winsock.dll")]
> >     public int listen(int fd, int backlog);
> > }
>
> Oh!  This is a really sweet idea!

Yep.  It works very nicely, and leverages the existing
autoconf system for naming hosts.  Check out the function
"ILPInvokeResolveModule" in "image/link.c" within
the Portable.NET sources for the exact algorithmic
details.  Feel free to rip off that code. :-)

> > So as not to introduce too much embrace and extend,
> > I made the attribute "floating".  That is, it can be in
> > any namespace.  This allows a "private" class to be
> > put into the importing assembly called something like
> > "MyNamespace.DllImportMapAttribute".  This will
> > not pollute the global namespace, and so third party
> > programmers will not come to rely upon it by accident.
>
> This is nice, and also, it can always be just an internal attribute as
> well.

I meant "internal".  I get confused sometimes - declaring
a class as "internal" in C# causes it to get marked as
"private" in the metadata.

Cheers,

Rhys.