[Mono-list] managed code thunks for unmanaged functions?

Dietmar Maurer dietmar@ximian.com
18 Oct 2002 08:42:54 +0200


I am a bit unsure how to handle this. The dbp is passed as a ref
parameter, and I don't know if MS PInvoke automatically creates
delegates for that case - someone need to test that on MS. But the
structures in db.h are quite complex and automatically creating up to 50
delegates in a single PInvoke call is IMO no good solution anyways.

A simpler solution would be to write some C glue, functions which takes
the DB pointer as argument and calls the appropriate function.

But maybe someone knows a better solution?

- Dietmar

On Fri, 2002-10-18 at 06:56, Michael Poole wrote:
> I would like to write a C# PInvoke binding for the Sleepycat Berkeley
> Database library.  Part of the API is a structure similar to this:
> 
>   typedef struct __db DB;
>   struct __db {
>     int (*func)(DB *db, int arg);
>   };
>   int DB_create(DB **dbp);
> 
> DB_create() allocates and initializes the structure, writes it into
> *dbp, and sets several function pointers inside the structure.  The
> preferred way to perform operations on the database is to make calls
> using the function pointers kept in the DB struct.
> 
> However, Mono does not seem to create wrappers for those function
> pointers.  Has anyone started on this?  Would it just reuse
> mono_create_trampoline() in some reasonably straightforward way?
> 
> -- Michael
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list