Files
acceptance-tests
data
debian
docs
HtmlAgilityPack
deploy
sources
svgs
Makefile.am
Makefile.in
README
TODO
abc-removal.txt
api-style.css
check-coverage
check-exports
convert.cs
docs.make
embedded-api
exdoc
file-share-modes
gc-issues
gc-variables-in-c
glossary.txt
ignore
internal-calls
ir-desc
jit-imt
jit-thoughts
jit-trampolines
mini-doc.txt
mono-api-metadata.html
mono-file-formats.config
mono-file-formats.source
mono-tools.config
mono-tools.source
monoapi.source
object-layout
precise-gc
produce-lists
remoting
ssapre.txt
stack-overflow.txt
threading
toc.xml
unmanaged-calls
eglib
external
ikvm-native
libgc
llvm
m4
man
mcs
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/docs/internal-calls

83 lines
2.2 KiB
Plaintext
Raw Normal View History

Internal Call Topics
* Introduction
The Common Language Infrastructure allows for methods to be
implemented in unmanaged code. Unlike the Platform Invocation
services which provide marshalling and unmarshalling of data
from managed to unmanaged and viceversa the Internal calls do
not perform any kind of marshalling.
* Basic Type mapping
The following lists how the C# types are exposed to the C API.
C# type C type
-----------------------------
char gunichar2
bool MonoBoolean
sbyte signed char
byte guchar
short gint16
ushort guint16
int gint32
uint guint32
long gint64
ulong guint64
IntPtr/UIntPtr gpointer
object MonoObject*
string MonoString*
* Pointers
For ref and out paramaters you'll use the corresponding
pointer type.
So if you have a C# type listed as "ref int", you should use
"int *" in your implementation.
* Arrays
Arrays of any type must be described with a MonoArray* and the
elements must be accessed with the mono_array_* macros.
* Other Structures
Any other type that has a matching C structure representation,
should use a pointer to the struct instead of a generic
MonoObject pointer.
* Instance Methods.
Instance methods that are internal calls will receive as first argument
the instance object, so you must account for it in the C method signature:
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern override int GetHashCode ();
becomes:
gint32 ves_icall_System_String_GetHashCode (MonoString *this);
* How to hook internal calls with the runtime
Once you require an internal call in corlib, you need to
create a C implementation for it and register it in a
table in metadata/icall-def.h. See the top of that file
for more information.
If there are overloaded methods, you need also to
specify the signature of _all_ of them:
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern override void DoSomething ();
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern override void DoSomething (bool useful);
should be mapped with the following method names:
"DoSomething()", ves_icall_Namespace_ClassName_DoSomething,
"DoSomething(bool)", ves_icall_Namespace_ClassName_DoSomething_bool,