[Mono-list] MethodImpl(MethodImplOptions.InternalCall)

Robert Jordan robertj at gmx.net
Thu Dec 14 04:39:09 EST 2006


luke at quinane.id.au wrote:
> Hi All,
> 
> Is there any documentation on how parameters are marshalled for internals
> calls? Are all strings marshalled as MonoString*? What about other types
> such as delegates and structs?

The runtime's source contains hundreds of "samples", because it
uses a lot if icalls itself. Don't hesitate to look at them.

Icall parameters are not marshaled at all.

- Managed objects are represented as MonoObject*. Some distinguished
   types (strings, delegates) have a MonoFoo* pendant, but these
   are MonoObjects as well.

- Managed structs and primitive types have the same layout as
   unmanaged structs/primitive types.

   The only limitation is that structs should never be passed
   by value, because this is not implemented for all architectures.
   They must be declared using "ref SomeStruct foo" in managed code and
   "SomeStruct *foo" in the icall.

- Since delegates are objects, they are represented by a
   MonoObject* as well. It can by casted to a MonoDelegate*, though.


> p.s. In the embedding sample the teste.c file should include "#include
> <mono/mini/jit.h>" instead of "#include <mono/jit/jit.h>".

Nope. You should *not* include these files from inside the Mono
sources. Those include files are installed during "make install"
into $prefix/include/mono/ and there is no "mini" folder.

Robert



More information about the Mono-list mailing list