forked from liangxiegame/QFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e23e787
commit a929412
Showing
262 changed files
with
1,830 additions
and
6,660 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
QFramework/QFramework.Unity.Runtime/Core/CodeGen/Code/Framework/CodeScope.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2017 ~ 2021.1 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
namespace QFramework | ||
{ | ||
using System.Collections.Generic; | ||
|
||
public abstract class CodeScope : ICodeScope | ||
{ | ||
public bool Semicolon { get; set; } | ||
|
||
public void Gen(ICodeWriter writer) | ||
{ | ||
GenFirstLine(writer); | ||
|
||
new OpenBraceCode().Gen(writer); | ||
|
||
writer.IndentCount++; | ||
|
||
foreach (var code in Codes) | ||
{ | ||
code.Gen(writer); | ||
} | ||
|
||
writer.IndentCount--; | ||
|
||
new CloseBraceCode(Semicolon).Gen(writer); | ||
} | ||
|
||
protected abstract void GenFirstLine(ICodeWriter codeWriter); | ||
|
||
private List<ICode> mCodes = new List<ICode>(); | ||
|
||
public List<ICode> Codes | ||
{ | ||
get { return mCodes; } | ||
set { mCodes = value; } | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
QFramework/QFramework.Unity.Runtime/Core/CodeGen/Code/Framework/ICode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2017 ~ 2021.1 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
namespace QFramework | ||
{ | ||
public interface ICode | ||
{ | ||
void Gen(ICodeWriter writer); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
QFramework/QFramework.Unity.Runtime/Core/CodeGen/Code/Framework/ICodeScope.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2017 ~ 2021.1 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
namespace QFramework | ||
{ | ||
using System.Collections.Generic; | ||
|
||
public interface ICodeScope : ICode | ||
{ | ||
List<ICode> Codes { get; set; } | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
QFramework/QFramework.Unity.Runtime/Core/CodeGen/Code/Language/ClassCodeScope.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2017 ~ 2021.1 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
namespace QFramework | ||
{ | ||
using System; | ||
|
||
public class ClassCodeScope : CodeScope | ||
{ | ||
public ClassCodeScope(string className, string parentClassName, bool isPartial, bool isStatic) | ||
{ | ||
mClassName = className; | ||
mParentClassName = parentClassName; | ||
mIsPartial = isPartial; | ||
mIsStatic = isStatic; | ||
} | ||
|
||
private string mClassName; | ||
private string mParentClassName; | ||
private bool mIsPartial; | ||
private bool mIsStatic; | ||
|
||
protected override void GenFirstLine(ICodeWriter codeWriter) | ||
{ | ||
var staticKey = mIsStatic ? " static" : string.Empty; | ||
var partialKey = mIsPartial ? " partial" : string.Empty; | ||
var parentClassKey = !string.IsNullOrEmpty(mParentClassName) ? " : " + mParentClassName : string.Empty; | ||
|
||
codeWriter.WriteLine(string.Format("public{0}{1} class {2}{3}", staticKey, partialKey, mClassName, | ||
parentClassKey)); | ||
} | ||
} | ||
|
||
public static partial class ICodeScopeExtensions | ||
{ | ||
public static ICodeScope Class(this ICodeScope self,string className, string parentClassName, bool isPartial, bool isStatic,Action<ClassCodeScope> classCodeScopeSetting) | ||
{ | ||
var classCodeScope = new ClassCodeScope(className,parentClassName,isPartial,isStatic); | ||
classCodeScopeSetting(classCodeScope); | ||
self.Codes.Add(classCodeScope); | ||
return self; | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
QFramework/QFramework.Unity.Runtime/Core/CodeGen/Code/Language/CustomCode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2017 ~ 2021.1 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
namespace QFramework | ||
{ | ||
public class CustomCode : ICode | ||
{ | ||
private string mLine; | ||
|
||
public CustomCode(string line) | ||
{ | ||
mLine = line; | ||
} | ||
|
||
public void Gen(ICodeWriter writer) | ||
{ | ||
writer.WriteLine(mLine); | ||
} | ||
} | ||
|
||
public static partial class ICodeScopeExtensions | ||
{ | ||
public static ICodeScope Custom(this ICodeScope self, string line) | ||
{ | ||
self.Codes.Add(new CustomCode(line)); | ||
return self; | ||
} | ||
} | ||
|
||
|
||
} |
57 changes: 57 additions & 0 deletions
57
QFramework/QFramework.Unity.Runtime/Core/CodeGen/Code/Language/CustomCodeScope.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2017 ~ 2021.1 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
namespace QFramework | ||
{ | ||
using System; | ||
|
||
public class CustomCodeScope : CodeScope | ||
{ | ||
private string mFirstLine { get; set; } | ||
|
||
public CustomCodeScope(string firstLine) | ||
{ | ||
mFirstLine = firstLine; | ||
} | ||
|
||
protected override void GenFirstLine(ICodeWriter codeWriter) | ||
{ | ||
codeWriter.WriteLine(mFirstLine); | ||
} | ||
} | ||
|
||
public static partial class ICodeScopeExtensions | ||
{ | ||
public static ICodeScope CustomScope(this ICodeScope self,string firstLine,bool semicolon, Action<CustomCodeScope> customCodeScopeSetting) | ||
{ | ||
var custom = new CustomCodeScope(firstLine); | ||
custom.Semicolon = semicolon; | ||
customCodeScopeSetting(custom); | ||
self.Codes.Add(custom); | ||
return self; | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
QFramework/QFramework.Unity.Runtime/Core/CodeGen/Code/Language/NamespaceCodeScope.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/**************************************************************************** | ||
* Copyright (c) 2017 ~ 2021.1 liangxie | ||
* | ||
* https://qframework.cn | ||
* https://github.com/liangxiegame/QFramework | ||
* https://gitee.com/liangxiegame/QFramework | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
****************************************************************************/ | ||
|
||
using System; | ||
|
||
namespace QFramework | ||
{ | ||
public class NamespaceCodeScope : CodeScope | ||
{ | ||
private string mNamespace { get; set; } | ||
|
||
public NamespaceCodeScope(string ns) | ||
{ | ||
mNamespace = ns; | ||
} | ||
|
||
protected override void GenFirstLine(ICodeWriter codeWriter) | ||
{ | ||
codeWriter.WriteLine(string.Format("namespace {0}", mNamespace)); | ||
} | ||
} | ||
|
||
public static partial class ICodeScopeExtensions | ||
{ | ||
public static ICodeScope Namespace(this ICodeScope self, string ns, | ||
Action<NamespaceCodeScope> namespaceCodeScopeSetting) | ||
{ | ||
var namespaceCodeScope = new NamespaceCodeScope(ns); | ||
namespaceCodeScopeSetting(namespaceCodeScope); | ||
self.Codes.Add(namespaceCodeScope); | ||
return self; | ||
} | ||
} | ||
} |
Oops, something went wrong.