Skip to content

Commit

Permalink
v0.11.19 CodeGenKit => dll
Browse files Browse the repository at this point in the history
  • Loading branch information
liangxiegame committed Jan 2, 2021
1 parent e23e787 commit a929412
Show file tree
Hide file tree
Showing 262 changed files with 1,830 additions and 6,660 deletions.
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; }
}
}
}
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);
}
}
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; }
}
}
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;
}
}
}
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;
}
}


}
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;
}
}
}
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;
}
}
}
Loading

0 comments on commit a929412

Please sign in to comment.