Commit graph

24 commits

Author SHA1 Message Date
Stefanos A
d5137d6057 Initial implementation of manual StringBuilder marshaling (WIP)
The implementation is based on Marshal.AllocHGlobal and
Marshal.FreeHGlobal. This is not working correctly yet.
2013-12-02 11:59:40 +01:00
Stefanos A
6ccab1784f Use StdCall calling convention by default
It appears that calli callsites cannot be decorated with the
“platformapi” calling convention like DllImport signatures can. This is
problematic since Windows uses stdcall by default and most other
platforms use cdecl.

There are three approaches to this issue, without going back to
delegate calls: (a) generate an unmanaged thunk that cleans up the
stack after a GL call; (b) use libFFI; (c) use cdecl *or* stdcall
everywhere and hope that the runtime can cope.

.Net 2.0 can detect and fix stdcall functions invoked through a cdecl
callsite. .Net 4.0 adds a configuration option to enable or disable
this fixup (faster p/invoke if disabled) and raise a MDA exception when
this condition is detected. (This affects x86 only.)

Mono appears to be able to cope with cdecl functions invoked through a
stdcall callsite.

More testing is required.
2013-12-01 21:25:03 +01:00
Stefanos A
12c9c14133 Enabled symbol generation; minor code cleanup 2013-12-01 18:28:11 +01:00
Stefanos A
6f535ec095 Load system types from referenced mscorlib 2013-11-30 02:32:10 +01:00
Stefanos A.
76f0782fb1 Use C calling convention even on Windows 2013-11-30 02:16:34 +01:00
Stefanos A.
31d14cebff Corrected the handling of arrays
This includes arrays of primitives and arrays of generics. Our code is
similar to the code generated by the Mono C# compiler for the "fixed"
construct. The .Net compiler produces slightly different code (two local
variables instead of one) - more research is required.
2013-11-30 02:00:07 +01:00
Stefanos A.
0d9df5ad72 Refactored il emitters into methods 2013-11-29 19:24:38 +01:00
Stefanos A.
78c0c6fd4c Use unmanaged StdCall calling convention
Default results in a managed calling convention which does not generate
unmanaged thunking code for parameter marshaling.
System.Runtime.InteropServices.CallingConvention.Winapi appears to
correspond to StdCall for calli callsites (this might be different for
pinvoke, which supports an unmanaged "platformapi" calling convention.)
Needs more testing to prove this is doing the right thing on non-Windows
platforms.
2013-11-29 19:11:52 +01:00
Stefanos A.
fb99c7d7a1 Enable InitLocals to make peverify happy 2013-11-27 09:16:23 +01:00
Stefanos A.
e48a624003 Fixed convenience return type implementation 2013-11-27 09:09:33 +01:00
Stefanos A.
ec67232e88 Corrected RewrittenAttribute definition 2013-11-27 08:45:28 +01:00
Stefanos A.
f5b33b6487 Build 3.5 profile with Visual Studio 2013-11-27 08:28:39 +01:00
Stefanos A.
6bde1beb91 Rewrite nested types
Fixes zero-RVA exception for OpenGL extensions (e.g. GL.Ext etc)
2013-11-27 08:28:22 +01:00
Stefanos A
daf5b828c9 Implemented string return types 2013-11-27 01:40:12 +01:00
Stefanos A
4f58348502 Implemented convenience wrapper types 2013-11-27 00:03:03 +01:00
Stefanos A
bb7980b6a9 Update to latest version from git 2013-11-26 19:07:01 +01:00
Stefanos A
83868b45c6 Protect against multiple runs; optimize il 2013-11-26 19:06:39 +01:00
Stefanos A
40f992b5bd Rewrite support for [Slot] attribute 2013-11-26 01:31:10 +01:00
Stefanos A.
84a1e5a739 Initial work on Pin<> statements (WIP) 2013-11-25 20:00:22 +01:00
Stefanos A.
bb15844deb Fixed build on Visual Studio 2013-11-25 10:06:10 +01:00
Stefanos A
27d5e7a43e Applied MonoDevelop project style 2013-11-25 08:54:15 +01:00
Stefanos A
793dac65e5 Corrected patch for CallReturn<TRet, ...> signatures
.Net will happily execute a calli with a generic return type, whereas
Mono will refuse to. Mono is probably doing the right thing here. Fixed
by resolving the generic return into a concrete type.
2013-11-25 08:53:27 +01:00
Stefanos A.
0f609f6e22 Fixed calling convention for non-Windows platforms 2013-11-25 00:58:09 +01:00
Stefanos A.
1868b5e3db Implemented dll rewriter using Mono.Cecil 2013-11-25 00:19:54 +01:00