[Mono-list] PInvoke Conventions
Miguel de Icaza
26 Jul 2001 17:47:03 -0400
> I think it is unlikely that you'll be able to do it *all* using only
> managed code. I think it would be easier to just bite the bullet and
> accept that there will be some unmanaged code. This code can be written
> in C (or perhap C++), and will get compiled to a platform-specific native
> code library.
> Once you accept that, then "stat" is no real problem, you just have
> to write some glue code in C that wraps up stat() and presents an
> interface that you can access using a platform-independent PInvoke.
After reading your message I am reconsidering bloating PInvoke and
going for a less high-tech solution.
For the tricky bits that need to interface to the system, we could
generate the code on the flight from a bunch of scripts that would map
the actual sizes, layouts and constants for the system.
So basically we could use an autoconf-like system to probe the system,
and generate the source code for a `Mono.System' assembly that would
abstract things out.
The script could then based on this information spit out all the
information we need. It would take care of structures, and would also
take care of mapping UNIX constants to C# constants.