Skip to content

Commit 2531108

Browse files
committed
Fixed #763
1 parent 477258a commit 2531108

File tree

95 files changed

+642
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+642
-146
lines changed

ILRuntime/Runtime/CLRBinding/ConstructorBindingGenerator.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,20 @@ internal static string GenerateConstructorWraperCode(this Type type, Constructor
161161
sb.AppendLine();
162162
}
163163
sb.AppendLine();
164+
if (!type.IsValueType)
165+
{
166+
sb.AppendLine(" if(!isNewObj) ");
167+
sb.AppendLine(" {");
168+
if (paramCnt > 0)
169+
sb.AppendLine($" ptr_of_this_method = __esp - {paramCnt + 1};");
170+
else
171+
sb.AppendLine($" StackObject* ptr_of_this_method = __esp - {paramCnt + 1};");
172+
sb.AppendLine($" {typeClsName} __this = ({typeClsName})typeof({typeClsName}).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack));");
173+
sb.AppendLine($" __intp.Free(ptr_of_this_method);");
174+
sb.AppendLine($" if(__this is CrossBindingAdaptorType)");
175+
sb.AppendLine($" return __esp - {paramCnt + 1};");
176+
sb.AppendLine(" }");
177+
}
164178
sb.Append(" var result_of_this_method = ");
165179
{
166180
string clsName, realClsName;

ILRuntimeTest/TestMainForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private void UpdateBtnState()
228228

229229
private void button1_Click(object sender, EventArgs e)
230230
{
231-
var msg = ILRuntime.Runtime.Enviorment.CrossBindingCodeGenerator.GenerateCrossBindingAdapterCode(typeof(TestClass2), "ILRuntimeTest");
231+
var msg = ILRuntime.Runtime.Enviorment.CrossBindingCodeGenerator.GenerateCrossBindingAdapterCode(typeof(ClassInheritanceTest), "ILRuntimeTest");
232232
MessageBox.Show(msg);
233233
msg = ILRuntime.Runtime.Enviorment.CrossBindingCodeGenerator.GenerateCrossBindingAdapterCode(typeof(IAsyncStateMachine), "ILRuntimeTest");
234234
MessageBox.Show(msg);
@@ -256,7 +256,7 @@ private void btnGenerateBinding_Click(object sender, EventArgs e)
256256

257257
//Crossbind Adapter is needed to generate the correct binding code
258258
ILRuntimeHelper.Init(domain);
259-
string outputPath = ".." + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + "ILRuntimeTestBase/AutoGenerate"; // "..\\..\\AutoGenerate"
259+
string outputPath = ".." + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + "ILRuntimeTestBase/AutoGenerate"; // "..\\..\\AutoGenerate"
260260
ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(domain, outputPath);
261261
}
262262
}

ILRuntimeTestBase/AutoGenerate/CLRBindings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app)
162162
System_Reflection_PropertyInfo_Binding.Register(app);
163163
System_Collections_Generic_List_1_String_Binding.Register(app);
164164
System_Collections_Generic_List_1_FieldInfo_Binding.Register(app);
165+
ILRuntimeTest_TestFramework_TestCLRAttribute2_Binding.Register(app);
165166
ILRuntimeTest_TestFramework_TestCLREnumClass_Binding.Register(app);
166167
System_Action_2_Int32_ILTypeInstance_Binding.Register(app);
167168
System_Nullable_1_Int32_Binding.Register(app);

ILRuntimeTestBase/AutoGenerate/ILRuntimeTest_TestBase_ExtensionClass_1_Int32_Binding.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
4242
ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
4343
StackObject* __ret = __esp - 0;
4444

45+
if(!isNewObj)
46+
{
47+
StackObject* ptr_of_this_method = __esp - 1;
48+
ILRuntimeTest.TestBase.ExtensionClass<System.Int32> __this = (ILRuntimeTest.TestBase.ExtensionClass<System.Int32>)typeof(ILRuntimeTest.TestBase.ExtensionClass<System.Int32>).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack));
49+
__intp.Free(ptr_of_this_method);
50+
if(__this is CrossBindingAdaptorType)
51+
return __esp - 1;
52+
}
4553
var result_of_this_method = new ILRuntimeTest.TestBase.ExtensionClass<System.Int32>();
4654

4755
return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);

ILRuntimeTestBase/AutoGenerate/ILRuntimeTest_TestBase_ExtensionClass_Binding.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
4242
ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
4343
StackObject* __ret = __esp - 0;
4444

45+
if(!isNewObj)
46+
{
47+
StackObject* ptr_of_this_method = __esp - 1;
48+
ILRuntimeTest.TestBase.ExtensionClass __this = (ILRuntimeTest.TestBase.ExtensionClass)typeof(ILRuntimeTest.TestBase.ExtensionClass).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack));
49+
__intp.Free(ptr_of_this_method);
50+
if(__this is CrossBindingAdaptorType)
51+
return __esp - 1;
52+
}
4553
var result_of_this_method = new ILRuntimeTest.TestBase.ExtensionClass();
4654

4755
return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);

ILRuntimeTestBase/AutoGenerate/ILRuntimeTest_TestBase_SubExtensionClass_1_Int32_Binding.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
4242
ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
4343
StackObject* __ret = __esp - 0;
4444

45+
if(!isNewObj)
46+
{
47+
StackObject* ptr_of_this_method = __esp - 1;
48+
ILRuntimeTest.TestBase.SubExtensionClass<System.Int32> __this = (ILRuntimeTest.TestBase.SubExtensionClass<System.Int32>)typeof(ILRuntimeTest.TestBase.SubExtensionClass<System.Int32>).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack));
49+
__intp.Free(ptr_of_this_method);
50+
if(__this is CrossBindingAdaptorType)
51+
return __esp - 1;
52+
}
4553
var result_of_this_method = new ILRuntimeTest.TestBase.SubExtensionClass<System.Int32>();
4654

4755
return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);

ILRuntimeTestBase/AutoGenerate/ILRuntimeTest_TestBase_SubExtensionClass_Binding.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
4242
ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
4343
StackObject* __ret = __esp - 0;
4444

45+
if(!isNewObj)
46+
{
47+
StackObject* ptr_of_this_method = __esp - 1;
48+
ILRuntimeTest.TestBase.SubExtensionClass __this = (ILRuntimeTest.TestBase.SubExtensionClass)typeof(ILRuntimeTest.TestBase.SubExtensionClass).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack));
49+
__intp.Free(ptr_of_this_method);
50+
if(__this is CrossBindingAdaptorType)
51+
return __esp - 1;
52+
}
4553
var result_of_this_method = new ILRuntimeTest.TestBase.SubExtensionClass();
4654

4755
return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);

ILRuntimeTestBase/AutoGenerate/ILRuntimeTest_TestFramework_BindableProperty_1_Int64_Binding.cs renamed to ILRuntimeTestBase/AutoGenerate/ILRuntimeTest_TestFramework_BindableProperty_1_Int64_Bind.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ static void set_OnChangeWithOldVal_0(ref object o, object v)
9898
System.Int64 @val = *(long*)&ptr_of_this_method->Value;
9999

100100

101+
if(!isNewObj)
102+
{
103+
ptr_of_this_method = __esp - 2;
104+
ILRuntimeTest.TestFramework.BindableProperty<System.Int64> __this = (ILRuntimeTest.TestFramework.BindableProperty<System.Int64>)typeof(ILRuntimeTest.TestFramework.BindableProperty<System.Int64>).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack));
105+
__intp.Free(ptr_of_this_method);
106+
if(__this is CrossBindingAdaptorType)
107+
return __esp - 2;
108+
}
101109
var result_of_this_method = new ILRuntimeTest.TestFramework.BindableProperty<System.Int64>(@val);
102110

103111
return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);

ILRuntimeTestBase/AutoGenerate/ILRuntimeTest_TestFramework_ClassInheritanceTest2_1_ILRuntim.cs renamed to ILRuntimeTestBase/AutoGenerate/ILRuntimeTest_TestFramework_ClassInheritanceTest2_1_ILRun.cs

File renamed without changes.

ILRuntimeTestBase/AutoGenerate/ILRuntimeTest_TestFramework_ClassInheritanceTest_Binding.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
5454
app.RegisterCLRFieldSetter(field, set_staticField_1);
5555
app.RegisterCLRFieldBinding(field, CopyToStack_staticField_1, AssignFromStack_staticField_1);
5656

57+
args = new Type[]{};
58+
method = type.GetConstructor(flag, null, args, null);
59+
app.RegisterCLRMethodRedirection(method, Ctor_0);
60+
args = new Type[]{typeof(System.Int32), typeof(System.Int32)};
61+
method = type.GetConstructor(flag, null, args, null);
62+
app.RegisterCLRMethodRedirection(method, Ctor_1);
5763

5864
}
5965

@@ -237,6 +243,49 @@ static void set_staticField_1(ref object o, object v)
237243
}
238244

239245

246+
static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, AutoList __mStack, CLRMethod __method, bool isNewObj)
247+
{
248+
ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
249+
StackObject* __ret = __esp - 0;
250+
251+
if(!isNewObj)
252+
{
253+
StackObject* ptr_of_this_method = __esp - 1;
254+
ILRuntimeTest.TestFramework.ClassInheritanceTest __this = (ILRuntimeTest.TestFramework.ClassInheritanceTest)typeof(ILRuntimeTest.TestFramework.ClassInheritanceTest).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack));
255+
__intp.Free(ptr_of_this_method);
256+
if(__this is CrossBindingAdaptorType)
257+
return __esp - 1;
258+
}
259+
var result_of_this_method = new ILRuntimeTest.TestFramework.ClassInheritanceTest();
260+
261+
return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
262+
}
263+
264+
static StackObject* Ctor_1(ILIntepreter __intp, StackObject* __esp, AutoList __mStack, CLRMethod __method, bool isNewObj)
265+
{
266+
ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
267+
StackObject* ptr_of_this_method;
268+
StackObject* __ret = __esp - 2;
269+
ptr_of_this_method = __esp - 1;
270+
System.Int32 @b = ptr_of_this_method->Value;
271+
272+
ptr_of_this_method = __esp - 2;
273+
System.Int32 @a = ptr_of_this_method->Value;
274+
275+
276+
if(!isNewObj)
277+
{
278+
ptr_of_this_method = __esp - 3;
279+
ILRuntimeTest.TestFramework.ClassInheritanceTest __this = (ILRuntimeTest.TestFramework.ClassInheritanceTest)typeof(ILRuntimeTest.TestFramework.ClassInheritanceTest).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack));
280+
__intp.Free(ptr_of_this_method);
281+
if(__this is CrossBindingAdaptorType)
282+
return __esp - 3;
283+
}
284+
var result_of_this_method = new ILRuntimeTest.TestFramework.ClassInheritanceTest(@a, @b);
285+
286+
return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
287+
}
288+
240289

241290
}
242291
}

0 commit comments

Comments
 (0)