Load system types from referenced mscorlib

This commit is contained in:
Stefanos A 2013-11-30 02:32:10 +01:00
parent 76f0782fb1
commit 6f535ec095

View file

@ -142,7 +142,7 @@ namespace OpenTK.Rewrite
var rewritten_constructor = type.GetConstructors().First(); var rewritten_constructor = type.GetConstructors().First();
var rewritten = new CustomAttribute(rewritten_constructor); var rewritten = new CustomAttribute(rewritten_constructor);
rewritten.ConstructorArguments.Add(new CustomAttributeArgument( rewritten.ConstructorArguments.Add(new CustomAttributeArgument(
type.Module.Import(typeof(bool)), true)); type.Module.Import(mscorlib.MainModule.GetType("System.Boolean")), true));
type.Module.Assembly.CustomAttributes.Add(rewritten); type.Module.Assembly.CustomAttributes.Add(rewritten);
} }
} }
@ -266,7 +266,7 @@ namespace OpenTK.Rewrite
// String return-type wrapper // String return-type wrapper
// return new string((sbyte*)((void*)GetString())); // return new string((sbyte*)((void*)GetString()));
var intptr_to_voidpointer = wrapper.Module.Import(typeof(IntPtr).GetMethods() var intptr_to_voidpointer = wrapper.Module.Import(mscorlib.MainModule.GetType("System.IntPtr").GetMethods()
.First(m => .First(m =>
{ {
return return
@ -274,11 +274,11 @@ namespace OpenTK.Rewrite
m.ReturnType.Name == "Void*"; m.ReturnType.Name == "Void*";
})); }));
var string_constructor = wrapper.Module.Import(typeof(string).GetConstructors() var string_constructor = wrapper.Module.Import(mscorlib.MainModule.GetType("System.String").GetConstructors()
.First(m => .First(m =>
{ {
var p = m.GetParameters(); var p = m.Parameters;
return p.Length > 0 && p[0].ParameterType.Name == "SByte*"; return p.Count > 0 && p[0].ParameterType.Name == "SByte*";
})); }));
il.Emit(OpCodes.Call, intptr_to_voidpointer); il.Emit(OpCodes.Call, intptr_to_voidpointer);