5 The Common Language Infrastructure allows for methods to be
6 implemented in unmanaged code. Unlike the Platform Invocation
7 services which provide marshalling and unmarshalling of data
8 from managed to unmanaged and viceversa the Internal calls do
9 not perform any kind of marshalling.
13 The following lists how the C# types are exposed to the C API.
16 -----------------------------
27 IntPtr/UIntPtr gpointer
33 For ref and out paramaters you'll use the corresponding
36 So if you have a C# type listed as "ref int", you should use
37 "int *" in your implementation.
41 Arrays of any type must be described with a MonoArray* and the
42 elements must be accessed with the mono_array_* macros.
46 Any other type that has a matching C structure representation,
47 should use a pointer to the struct instead of a generic
52 Instance methods that are internal calls will receive as first argument
53 the instance object, so you must account for it in the C method signature:
55 [MethodImplAttribute(MethodImplOptions.InternalCall)]
56 public extern override int GetHashCode ();
60 gint32 ves_icall_System_String_GetHashCode (MonoString *this);
62 * How to hook internal calls with the runtime
64 Once you require an internal call in corlib, you need to
65 create a C implementation for it and register it in a static
66 table in metadata/icall.c. Add an entry in the table like:
68 "System.String::GetHashCode", ves_icall_System_String_GetHashCode,
70 Note that you need to include the full namespace.name of the
71 class. If there are overloaded methods, you need also to
72 specify the signature of _all_ of them:
74 [MethodImplAttribute(MethodImplOptions.InternalCall)]
75 public extern override void DoSomething ();
76 [MethodImplAttribute(MethodImplOptions.InternalCall)]
77 public extern override void DoSomething (bool useful);
79 should be mapped with:
81 "Namespace.ClassName::DoSomething()", ves_icall_Namespace_ClassName_DoSomething,
82 "Namespace.ClassName::DoSomething(bool)", ves_icall_Namespace_ClassName_DoSomething_bool,