Skip to content

Commit 9875592

Browse files
committed
+ merge icall binder
1 parent 07d7143 commit 9875592

40 files changed

Lines changed: 4486 additions & 95 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
/BindGenerater/glue
66
/DemoProject
77
/Glue
8-
/ScriptEngine
8+
/ScriptEngine/Win32
9+
/ScriptEngine/x64
910
/packages
1011
/Test
1112
/back

BindGenerater/BindGenerater.csproj

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,30 @@
9191
</ItemGroup>
9292
<ItemGroup>
9393
<Compile Include="Generater\Binder.cs" />
94-
<Compile Include="Generater\CustomOutputVisitor.cs" />
95-
<Compile Include="Generater\MethodResolver.cs" />
96-
<Compile Include="Generater\TypeResolver.cs" />
97-
<Compile Include="Generater\ClassGenerater.cs" />
98-
<Compile Include="Generater\CodeGenerater.cs" />
99-
<Compile Include="Generater\DelegateGenerater.cs" />
100-
<Compile Include="Generater\GenerateBindings.cs" />
101-
<Compile Include="Generater\MethodGenerater.cs" />
94+
<Compile Include="Generater\CBinder.cs" />
95+
<Compile Include="Generater\CSharp\CustomOutputVisitor.cs" />
96+
<Compile Include="Generater\CSharp\MethodResolver.cs" />
97+
<Compile Include="Generater\CSharp\TypeResolver.cs" />
98+
<Compile Include="Generater\CSharp\ClassGenerater.cs" />
99+
<Compile Include="Generater\CSharp\CodeGenerater.cs" />
100+
<Compile Include="Generater\CSharp\DelegateGenerater.cs" />
101+
<Compile Include="Generater\CSharp\GenerateBindings.cs" />
102+
<Compile Include="Generater\CSharp\MethodGenerater.cs" />
102103
<Compile Include="Generater\CodeWriter.cs" />
103-
<Compile Include="Generater\PropertyGenerater.cs" />
104+
<Compile Include="Generater\CSharp\PropertyGenerater.cs" />
105+
<Compile Include="Generater\C\ClassCacheGenerater.cs" />
106+
<Compile Include="Generater\C\CTypeResolver.cs" />
107+
<Compile Include="Generater\C\CUtils.cs" />
108+
<Compile Include="Generater\C\EventGenerater.cs" />
109+
<Compile Include="Generater\C\ICallGenerater.cs" />
104110
<Compile Include="Generater\TypeDefinitionExtensions.cs" />
105111
<Compile Include="Generater\Utils.cs" />
106112
<Compile Include="Program.cs" />
107113
<Compile Include="Properties\AssemblyInfo.cs" />
108114
</ItemGroup>
109115
<ItemGroup>
110116
<None Include="App.config" />
111-
<None Include="packages.config" />
112117
</ItemGroup>
118+
<ItemGroup />
113119
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
114120
</Project>

BindGenerater/Generater/Binder.cs

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ public static class Binder
2323
public static CSharpDecompiler Decompiler;
2424
public static DecompilerSettings DecompilerSetting;
2525

26+
private static string[] IcallSupportTypes = new string[]
27+
{
28+
"Object",
29+
"Application",
30+
"Debug",
31+
"Vector3",
32+
"Vector2",
33+
"Quaternion",
34+
"Color",
35+
"Color32",
36+
};
2637

2738
private static string[] IgnorTypes = new string[]
2839
{
@@ -55,6 +66,9 @@ public static void Init(string outDir)
5566
FuncDefineWriter = new CodeWriter(File.CreateText(Path.Combine(outDir, "Binder.define.cs")));
5667
FuncSerWriter = new CodeWriter(File.CreateText(Path.Combine(outDir, "Binder.funcser.cs")));
5768
FuncDeSerWriter = new CodeWriter(File.CreateText(Path.Combine(outDir, "Binder.funcdeser.cs")));
69+
70+
Utils.IgnoreTypeSet.UnionWith(IgnorTypes);
71+
Utils.IcallSupportClass.UnionWith(IcallSupportTypes);
5872
}
5973

6074
public static void End()
@@ -82,26 +96,13 @@ public static void Bind(string dllPath)
8296
ModuleDefinition module = ModuleDefinition.ReadModule(dllPath, parameters);
8397

8498
moduleTypes = new HashSet<TypeReference>(module.Types);
85-
var ignorSet = Utils.IgnoreTypeSet;
86-
foreach(var type in IgnorTypes)
87-
{
88-
ignorSet.Add(type);
89-
}
90-
91-
//var typeSet = new HashSet<string>(BindTypes);
9299

93100
foreach (TypeDefinition type in moduleTypes)
94101
{
95102
if (!type.IsPublic)
96103
continue;
97104

98105
AddType(type);
99-
100-
/* Console.WriteLine(type.FullName);
101-
if (typeSet.Contains(type.Name))
102-
{
103-
AddType(type);
104-
}*/
105106
}
106107

107108
TypeResolver.WrapperSide = true;
@@ -126,34 +127,7 @@ public static void AddType(TypeDefinition type)
126127
return;
127128

128129
generaters.Enqueue(new ClassGenerater(type));
129-
130-
/*CodeGenerater gener = null;
131-
if (type.IsValueType || type.IsEnum || type.IsDelegate())
132-
{
133-
CopyGenerater.AddTpe(type);
134-
}
135-
else if (type.IsClass)
136-
{
137-
var baseType = type.BaseType;
138-
var bt = baseType.Resolve();
139-
if (baseType.Resolve().IsAbstract)
140-
baseType = bt.BaseType;
141-
while (baseType != null && baseType.FullName != "System.Object")
142-
{
143-
bt = baseType.Resolve();
144-
AddType(bt);
145-
baseType = bt.BaseType;
146-
}
147-
148-
gener = new ClassGenerater(type);
149-
}
150-
else if(type.IsInterface)
151-
{
152-
gener = new ClassGenerater(type);
153-
}
154130

155-
if(gener != null)
156-
generaters.Enqueue(gener);*/
157131
}
158132
}
159133
}

0 commit comments

Comments
 (0)