[Mono-list] PInvoke:TNG

Fergus Henderson fjh@cs.mu.oz.au
Fri, 27 Jul 2001 12:46:12 +1000


On 27-Jul-2001, Rhys Weatherley <rweather@zip.com.au> wrote:
> Fergus Henderson wrote:
> 
> > The syntax is quite elegant, but you're pushing a lot of the complexity into
> > the VM engine.
> >
> > How exactly is the VM engine supposed to handle the [PosixType] custom attribute?
> > Is it supposed to have a hard-coded list of types and their layouts,
> 
> That's the assumption, yes, and it _is_ a drawback of this
> approach.  Any other approach will need something equally
> yucky.  Something somewhere needs to know how what the
> real underlying type is.  Either the VM does it, or we #ifdef
> the C# library to compile differently for platforms with
> different type sizes.

The other approach is to write wrappers in C.
Then you don't need any #ifdefs.

The wrappers would convert variable-sized C types (e.g. `int')
to fixed-size C types e.g. `int64_t', so that they can be
acessed using Pinvoke in a portable fashion.

The advantage of this approach is that it doesn't rely on extensions
(like [PosixType]) in the VM.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.