Skip to content

Commit

Permalink
支持unity2018.2
Browse files Browse the repository at this point in the history
1,修正操作符重载判定
2,修正成员命名规则保证GameObject.GetComponent
3,修正接口中有重名成员 编译器崩溃问题
  • Loading branch information
wuxiaoyu committed Sep 17, 2018
1 parent 99437a0 commit b3bde8d
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 119 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ UnityPluginTool/obj/
ASCR/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
.vs/ASTool/v15/sqlite3/storage.ide
.vs/ASTool/v15/sqlite3/storage.ide
.vs/ASTool/v15/Server/sqlite3/db.lock
.vs/ASTool/v15/Server/sqlite3/storage.ide
.vs/ASTool/v15/Server/sqlite3/storage.ide-shm
.vs/ASTool/v15/Server/sqlite3/storage.ide-wal
2 changes: 1 addition & 1 deletion ASCR/compiler/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ private void build_srcFiles(List<ASTool.AS3.AS3SrcFile> tobuildfiles,bool isbuil
{
pushBuildError(
new BuildError(item.Key.token.line, item.Key.token.ptr, item.Key.token.sourceFile,
">,<,==,!=,>=,<=必须同时重载")
">,<;==,!=;>=,<=必须同时重载")
);


Expand Down
16 changes: 15 additions & 1 deletion ASCR/compiler/builds/AS3InterfaceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ Builder builder
// tooverridefunctions.Add(cls.classMembers[j]);
// continue;
// }

// if (cls.classMembers[j].inheritFrom == null
// )
// {
Expand All @@ -433,6 +433,20 @@ Builder builder
// }
// }
//}
for (int j = 0; j < cls.classMembers.Count; j++)
{
if (cls.classMembers[j].name == funcname
&&
cls.classMembers[j].inheritFrom == null
)
{

throw new BuildException(
new BuildError(stmt.Token.line, stmt.Token.ptr, stmt.Token.sourceFile,
"重复的接口成员:" + as3function.Name)
);
}
}

if (as3function.Access.IsStatic)
{
Expand Down
14 changes: 14 additions & 0 deletions ASCR/obj/Debug/ASCompiler.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,17 @@ F:\ASTool\ASCR\obj\Debug\ASCompiler.csproj.GenerateResource.Cache
F:\ASTool\ASCR\obj\Debug\ASCompiler.csproj.CoreCompileInputs.cache
F:\ASTool\ASCR\obj\Debug\ASCompiler.dll
F:\ASTool\ASCR\obj\Debug\ASCompiler.pdb
F:\GitHub\apple-juice-actionscript\ASCR\bin\Debug\ASCompiler.dll
F:\GitHub\apple-juice-actionscript\ASCR\bin\Debug\ASCompiler.pdb
F:\GitHub\apple-juice-actionscript\ASCR\bin\Debug\ASRuntime.dll
F:\GitHub\apple-juice-actionscript\ASCR\bin\Debug\ASTool.dll
F:\GitHub\apple-juice-actionscript\ASCR\bin\Debug\ASRuntime.pdb
F:\GitHub\apple-juice-actionscript\ASCR\bin\Debug\ASTool.pdb
F:\GitHub\apple-juice-actionscript\ASCR\bin\Debug\ASTool.xml
F:\GitHub\apple-juice-actionscript\ASCR\obj\Debug\ASCompiler.csprojAssemblyReference.cache
F:\GitHub\apple-juice-actionscript\ASCR\obj\Debug\ASCompiler.Properties.Resources.resources
F:\GitHub\apple-juice-actionscript\ASCR\obj\Debug\ASCompiler.csproj.GenerateResource.cache
F:\GitHub\apple-juice-actionscript\ASCR\obj\Debug\ASCompiler.csproj.CoreCompileInputs.cache
F:\GitHub\apple-juice-actionscript\ASCR\obj\Debug\ASCompiler.csproj.CopyComplete
F:\GitHub\apple-juice-actionscript\ASCR\obj\Debug\ASCompiler.dll
F:\GitHub\apple-juice-actionscript\ASCR\obj\Debug\ASCompiler.pdb
75 changes: 3 additions & 72 deletions ASCTest/testScript/AS3Testproj/src/Main.as
Original file line number Diff line number Diff line change
Expand Up @@ -284,79 +284,10 @@ package
}


import autogencodelib.Testobj;
import autogencodelib.ptt2;
import autogencodelib.pttest;
import system.Int64;

class et extends Testobj
interface iii
{
public function et(v:int=5)
{
super(v);
}

override public function dialog():void
{
super.dialog();

trace("override");

}

}

class ttt extends pttest
{
override protected function get b():int
{
return 987;
}

public function get b2():int
{
trace(testabsstring(9, 0));

return b;
}

override protected function testabsstring(a:int, b:system.Int64):String
{
trace(a, b);
trace(ptint());
return a + " " + b + super.testabsstring(0,0);
}

}

class t2 extends ptt2
{
public function t2()
{
var m = b;
trace(m,b);
//trace("getvvv", getvvv() );
//var m = b;
}

override protected function get b():int
{
return 99;
}

override public function getvvv():int
{
return 456;
}
function log();
function log(i);

}

var t22:pttest = new t2();


var t:ttt = new ttt();
trace(t.b2);

//.test();


102 changes: 69 additions & 33 deletions ASRuntime/ASBinCode/OperatorOverride.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,39 +118,75 @@ public bool Check(out rtti.FunctionDefine function)
{
foreach (var key in operFunctions[i].Keys)
{
if (i == (int)OverrideableOperator.Equality)
{
var dict = operFunctions[(int)OverrideableOperator.Inequality];
if (!dict.ContainsKey(key))
{
function = operFunctions[i][key].define;
return false;
}
}
else if (i == (int)OverrideableOperator.Inequality)
{
var dict = operFunctions[(int)OverrideableOperator.Equality];
if (!dict.ContainsKey(key))
{
function = operFunctions[i][key].define;
return false;
}
}
else
{
//***查找其他操作符定义***
for (int j = 0; j < (int)OverrideableOperator.Inequality; j++)
{

var dict = operFunctions[j];
if (!dict.ContainsKey(key))
{
function = operFunctions[i][key].define;
return false;
}

}
}
if (i == (int)OverrideableOperator.Equality)
{
var dict = operFunctions[(int)OverrideableOperator.Inequality];
if (!dict.ContainsKey(key))
{
function = operFunctions[i][key].define;
return false;
}
}
else if (i == (int)OverrideableOperator.Inequality)
{
var dict = operFunctions[(int)OverrideableOperator.Equality];
if (!dict.ContainsKey(key))
{
function = operFunctions[i][key].define;
return false;
}
}
else if (i == (int)OverrideableOperator.GreatherThan)
{
var dict = operFunctions[(int)OverrideableOperator.LessThan];
if (!dict.ContainsKey(key))
{
function = operFunctions[i][key].define;
return false;
}
}
else if (i == (int)OverrideableOperator.LessThan)
{
var dict = operFunctions[(int)OverrideableOperator.GreatherThan];
if (!dict.ContainsKey(key))
{
function = operFunctions[i][key].define;
return false;
}
}
else if (i == (int)OverrideableOperator.GreatherThanOrEqual)
{
var dict = operFunctions[(int)OverrideableOperator.LessThanOrEqual];
if (!dict.ContainsKey(key))
{
function = operFunctions[i][key].define;
return false;
}
}
else if (i == (int)OverrideableOperator.LessThanOrEqual)
{
var dict = operFunctions[(int)OverrideableOperator.GreatherThanOrEqual];
if (!dict.ContainsKey(key))
{
function = operFunctions[i][key].define;
return false;
}
}
//else
//{
// //***查找其他操作符定义***
// for (int j = 0; j < (int)OverrideableOperator.Inequality; j++)
// {

// var dict = operFunctions[j];
// if (!dict.ContainsKey(key))
// {
// function = operFunctions[i][key].define;
// return false;
// }

// }
//}


}
Expand Down
Binary file modified AutoGenCodeLib/bin/Debug/AutoGenCodeLib.dll
Binary file not shown.
Binary file modified AutoGenCodeLib/obj/Debug/AutoGenCodeLib.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ E:\ASTool\AutoGenCodeLib\obj\Debug\AutoGenCodeLib.dll
E:\ASTool\AutoGenCodeLib\obj\Debug\AutoGenCodeLib.pdb
F:\ASTool\AutoGenCodeLib\bin\Debug\AutoGenCodeLib.xml
E:\ASTool\AutoGenCodeLib\bin\Debug\AutoGenCodeLib.xml
F:\GitHub\apple-juice-actionscript\AutoGenCodeLib\bin\Debug\AutoGenCodeLib.xml
F:\GitHub\apple-juice-actionscript\AutoGenCodeLib\bin\Debug\AutoGenCodeLib.dll
F:\GitHub\apple-juice-actionscript\AutoGenCodeLib\bin\Debug\AutoGenCodeLib.pdb
F:\GitHub\apple-juice-actionscript\AutoGenCodeLib\obj\Debug\AutoGenCodeTestLib.csprojAssemblyReference.cache
F:\GitHub\apple-juice-actionscript\AutoGenCodeLib\obj\Debug\AutoGenCodeTestLib.csproj.CoreCompileInputs.cache
F:\GitHub\apple-juice-actionscript\AutoGenCodeLib\obj\Debug\AutoGenCodeLib.dll
F:\GitHub\apple-juice-actionscript\AutoGenCodeLib\obj\Debug\AutoGenCodeLib.pdb
Binary file modified BuildOutSDK/1.0.0/bin/ASCompiler.dll
Binary file not shown.
Binary file modified BuildOutSDK/1.0.0/bin/ASRuntime.dll
Binary file not shown.
Binary file modified BuildOutSDK/1.0.0/bin/ASTool.dll
Binary file not shown.
Binary file modified BuildOutSDK/1.0.0/linkcodegencli/ASCompiler.dll
Binary file not shown.
Binary file modified BuildOutSDK/1.0.0/linkcodegencli/ASRuntime.dll
Binary file not shown.
Binary file modified BuildOutSDK/1.0.0/linkcodegencli/ASTool.dll
Binary file not shown.
Binary file modified BuildOutSDK/1.0.0/linkcodegencli/LinkCodeGen.dll
Binary file not shown.
Binary file modified BuildOutSDK/1.0.0/linkcodegencli/LinkCodeGenCLI.exe
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ call bat\SetupSDK.bat
::@echo If FlashDevelop and Java are not installed, you can execute this bat, compile the code and publish it to unity.


"%ASRuntime_SDK%\bin\CMXMLCCLI.exe" -load-config+=obj\{HotFixProj}Config.xml -o "{UNITYPROJPATH}\Assets\StreamingAssets\hotfix.cswc"
%ASRuntime_SDK%\bin\CMXMLCCLI.exe -load-config+=obj\{HotFixProj}Config.xml -o "{UNITYPROJPATH}\Assets\StreamingAssets\hotfix.cswc"

IF ERRORLEVEL 1 goto error
@echo Compilation succeeded. Click the Unity Play button to see the change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cd %~dp0 & cd ..
:user_configuration

:: Static path to ASRuntime SDK
set ASRuntime_SDK={SDKPATH}
set ASRuntime_SDK="{SDKPATH}"

:validation
if not exist "%ASRuntime_SDK%\bin" goto asruntimesdk
Expand Down
9 changes: 6 additions & 3 deletions LinkCodeGen/ClassCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,8 @@ string linkcodenamespace
}
}
}




constructorlist = new List<System.Reflection.ConstructorInfo>();
protectedonstructorList = new List<ConstructorInfo>();
Expand Down Expand Up @@ -2067,7 +2068,7 @@ public void SetAS3RuntimeEnvironment(Player player, Class typeclass, ASBinCode.r
}
}




string returntype = GetAS3TypeString(method.ReturnType, typeimports,null,null,null);
Expand Down Expand Up @@ -2756,7 +2757,9 @@ public void SetAS3RuntimeEnvironment(Player player, Class typeclass, ASBinCode.r
}
else
{
regfunctions.Add(string.Format("\t\t\tbin.regNativeFunction(\"{0}\",\"{1}\");", LinkCodeNampScapePart + nativefunctionname, nativefunctionname));


regfunctions.Add(string.Format("\t\t\tbin.regNativeFunction(\"{0}\",\"{1}\");", LinkCodeNampScapePart + nativefunctionname, nativefunctionname));

if (method.IsStatic)
{
Expand Down
28 changes: 26 additions & 2 deletions LinkCodeGen/CreatorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,32 @@ protected static string GetMethodName(string dotName, System.Reflection.MethodIn
//***加上受保护的方法***
var pmem = methodAtType.GetMember(dotName, BindingFlags.Instance | BindingFlags.NonPublic);
List<MemberInfo> _tempmembers = new List<MemberInfo>();
_tempmembers.AddRange(members);
foreach (var item in pmem)
//_tempmembers.AddRange(members);
foreach (var item in members)
{
if (IsSkipMember(item))
continue;
if (item is FieldInfo)
{
if (IsSkipType(((FieldInfo)item).FieldType))
continue;

_tempmembers.Add(item);

}
else if (item is MethodInfo)
{
if (InterfaceCreator.isMethodSkip((MethodInfo)item))
continue;
_tempmembers.Add(item);
}
else
{
_tempmembers.Add(item);
}
}

foreach (var item in pmem)
{
if (item is FieldInfo)
{
Expand Down
3 changes: 2 additions & 1 deletion LinkCodeGen/InterfaceCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ public static string GetMethodNativeFunctionName(System.Reflection.MethodInfo me
{
string nativefunName;

System.Reflection.PropertyInfo pinfo;

System.Reflection.PropertyInfo pinfo;
if (MethodNativeCodeCreator.CheckIsIndexerGetter(method, type, out pinfo)

&& method.GetParameters().Length == 1
Expand Down
3 changes: 1 addition & 2 deletions LinkCodeGenCLI/LinkCodeGenCLI.csproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartArguments>
</StartArguments>
<StartArguments>config=F:\UnityAS3\AS_1\HotFixProj\genapi.config</StartArguments>
</PropertyGroup>
</Project>
5 changes: 3 additions & 2 deletions LinkCodeGenCLI/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@

<!--<assembly value="E:\Manju-pc\blacksmithHorizontal\blacksmith\Library\ScriptAssemblies\Assembly-CSharp.dll"></assembly>
-->
<assembly value="F:\ASTool\AutoGenCodeLib\bin\Debug\AutoGenCodeLib.dll"></assembly>

<!--<assembly value="..\..\..\AutoGenCodeLib\bin\Debug\AutoGenCodeLib.dll"></assembly>-->
</buildassemblys>
<!--在哪些路径下查找dll.例如当加载ScriptAssemblies\Assembly-CSharp.dll时,可能需要到Unity安装目录下查找等。在这里配置dll查找路径-->
<resolvepath>

<item value="D:\Program Files\Unity56\Editor\Data\Managed"></item>
<item value="D:\Program Files\Unity\Editor\Data\Managed"></item>

</resolvepath>

Expand Down

0 comments on commit b3bde8d

Please sign in to comment.