예제 #1
0
		public static void Parse(TheConstructor pConstructor, CodeBuilder pBuilder, FactoryExpressionCreator pCreator) {
			if (pConstructor.IsStaticConstructor) {
				pBuilder.Append("{");

			} else {
				pBuilder.AppendFormat("{4}{0}function {1}({2}){3} {{",
								ClassParser.IsMainClass ? "private " : As3Helpers.ConvertModifiers(pConstructor.Modifiers, _notValidConstructorMod),
								ClassParser.IsMainClass ? @"$ctor" : pConstructor.Name,
								As3Helpers.GetParameters(pConstructor.Arguments),
								ClassParser.IsMainClass ? ":void" : string.Empty,// pConstructor.MyClass.Name,
								pConstructor.OverridesBaseConstructor ? "override " : string.Empty
					);
			}

			pBuilder.AppendLine();

			if (pConstructor.HasBaseCall) {
				pBuilder.AppendFormat("\tsuper({0});", As3Helpers.GetCallingArguments(pConstructor.BaseArguments));
				pBuilder.AppendLine();
			}
		
			BlockParser.Parse(pConstructor.CodeBlock, pBuilder, pCreator);

			pBuilder.AppendLine("}");
			pBuilder.AppendLine();
		}
예제 #2
0
		public static void Parse(TheMethod pMethod, CodeBuilder pBuilder, FactoryExpressionCreator pCreator) {
			if (pMethod == null) return;
			bool isInterface = pMethod.MyClass.IsInterface;

			Dictionary<string,string> nonValidMethod = new Dictionary<string, string>(_notValidMethodMod);
			if (ClassParser.IsExtension) {
				nonValidMethod.Add("static",string.Empty);
			}

			pBuilder.AppendFormat("{0}function {1}({2}):{3}{4}",
				As3Helpers.ConvertModifiers(pMethod.Modifiers, nonValidMethod),
				pMethod.Name,
				As3Helpers.GetParameters(pMethod.Arguments),
				As3Helpers.Convert(pMethod.ReturnType),
				isInterface ? ";":" {"
			);

			pBuilder.AppendLine();

			if (isInterface)
				return;

			pBuilder.AppendLine();
			BlockParser.Parse(pMethod.CodeBlock, pBuilder, pCreator);
			pBuilder.AppendLine();
			pBuilder.AppendLine("}");
			pBuilder.AppendLine();
		}
예제 #3
0
		public Expression Parse(CsExpression pStatement, FactoryExpressionCreator pCreator) {
			CsLambdaExpression ex = (CsLambdaExpression)pStatement;

			LambdaMethodExpression lambda = new LambdaMethodExpression((CsLambdaExpression)pStatement, pCreator);

			CodeBuilder b = new CodeBuilder();
			b.AppendFormat("function ({0}):{1} {{",
			               As3Helpers.GetParameters(lambda.Arguments),
			               (lambda.ReturnType == null) ? "void" : As3Helpers.Convert(lambda.ReturnType)
				);

			b.Indent();
			b.Indent();
			b.Indent();
			b.AppendLine();

			if (!(lambda.CodeBlock is CsBlock)) {
				b.Append("return ");
			}

			BlockParser.ParseNode(lambda.CodeBlock, b, pCreator);

			b.AppendLine("}");
			b.AppendLine();
			b.Unindent();
			b.Unindent();
			b.Unindent();
			return new Expression(b.ToString(), ex.entity_typeref);
		}
예제 #4
0
		private void WriteDefinition(CodeBuilder cb, string type, string backingFieldType, bool isServer) {
			cb.AppendLine(string.Format("private {0} {1};", isServer ? backingFieldServerType : backingFieldClientType, backingFieldName));
			if (isServer && clientInject)
				cb.AppendLine("[ClientInject]");
			cb.Append(AccessModifierHelper.WriteDeclarator(accessModifier, type, name)).AppendLine(" {").Indent();
			if (hasGetter)
				cb.AppendLine("get { return " + (type != backingFieldType ? "(" + type + ")" : "") + backingFieldName + "; }");
			if (hasSetter)
				cb.AppendLine("set { " + backingFieldName + " = " + (type != backingFieldType ? "(" + backingFieldType + ")" : "") + "value; " + (!string.IsNullOrEmpty(valueChangedHookName) ? valueChangedHookName + "(); " : "") + "}");
			cb.Outdent().AppendLine("}").AppendLine();
		}
		public void WriteCode(ITemplate tpl, FragmentCodePoint point, CodeBuilder cb) {
			if (CustomInstantiate)
				cb.AppendLine("if (" + Id + " == null) throw new InvalidOperationException(\"The control instance " + Id + " must be assigned before the control can be rendered.\");");
			
			if (NumInnerFragments > 0) {
				cb.Append("((IControlHost)" + Id + ").SetInnerFragments(new string[] { ");
				for (int i = 0; i < NumInnerFragments; i++) {
					if (i > 0)
						cb.Append(", ");
					cb.Append(Id + "_inner" + (i + 1).ToString(System.Globalization.CultureInfo.InvariantCulture) + "()");
				}
				cb.AppendLine(" });");
			}

			cb.AppendLine(ParserUtils.RenderFunctionStringBuilderName + ".Append(((IControl)" + Id + ").Html);");
		}
예제 #6
0
		public void WriteCode(ITemplate tpl, FragmentCodePoint point, CodeBuilder cb) {
			if (!string.IsNullOrEmpty(code))
				cb.AppendLine(code);
			for (int i = 0; i < indentEffect; i++)
				cb.Indent();
			for (int i = 0; i < -indentEffect; i++)
				cb.Outdent();
		}
예제 #7
0
		public void WriteCode(ITemplate tpl, MemberCodePoint point, CodeBuilder cb) {
			switch (point) {
				case MemberCodePoint.ServerDefinition:
					if (serverType != null)
						cb.AppendLine("private " + serverType + " " + Name + ";").AppendLine();
					break;
				case MemberCodePoint.ClientDefinition:
					if (clientType != null)
						cb.AppendLine("private " + ClientType + " " + Name + ";").AppendLine();
					break;
				case MemberCodePoint.TransferConstructor:
					if (serverType != null && clientType != null)
						cb.AppendLine("this." + name + " = (" + clientType + ")" + ParserUtils.ConfigObjectName + "[\"" + name + "\"];");
					break;
				case MemberCodePoint.ConfigObjectInit:
					if (serverType != null && clientType != null)
						cb.AppendLine(ParserUtils.ConfigObjectName + "[\"" + name + "\"] = this." + name + ";");
					break;
			}
		}
예제 #8
0
		private static void parseUsingStatement(CsStatement pArg1, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			CsUsingStatement statement = (CsUsingStatement)pArg1;
			CsLocalVariableDeclaration declaration = statement.resource as CsLocalVariableDeclaration;

			string varname;

			if (declaration == null) {
				varname = "$$using$$";
				Expression e = pCreator.Parse(statement.resource);

				pSb.AppendFormat("var {0}:{1} = {2};", 
					varname,
					As3Helpers.Convert(Helpers.GetType(e.Type)),
					e.Value
				);

				pSb.AppendLine();

			} else {
				CsLocalVariableDeclarator declarator = declaration.declarators.First.Value;
				StringBuilder sb = new StringBuilder();

				sb.AppendFormat("var {0}:{1}",
					declarator.identifier.identifier,
					As3Helpers.Convert(Helpers.GetType(declaration.type))
				);

				varname = declarator.identifier.identifier;

				if (declarator.initializer == null) {
					sb.Append(";");

				} else {
					sb.AppendFormat(" = {0};", parseNode(declarator.initializer, pCreator));
				}

				pSb.Append(sb.ToString());
				pSb.AppendLine();

			}

			pSb.Append("try {");
			pSb.AppendLine();

			ParseNode(statement.statement, pSb, pCreator);

			pSb.Append("} finally {");
			pSb.AppendLine();
			pSb.AppendFormat("	if ({0} != null) {0}.Dispose();", varname);
			pSb.AppendLine();

			pSb.Append("}");
			pSb.AppendLine();
			pSb.AppendLine();
		}
예제 #9
0
		public static void Parse(TheConstant pConstant, CodeBuilder pBuilder) {
			string modifiers = As3Helpers.ConvertModifiers(pConstant.Modifiers);

			foreach (Constant declarator in pConstant.Constants) {
				StringBuilder sb = new StringBuilder();

				sb.AppendFormat(@"{0}const {1}:{2} = {3};",
					modifiers,
					declarator.Name,
					As3Helpers.Convert(declarator.ReturnType),
					declarator.Initializer.Value
				);

				pBuilder.Append(sb.ToString());
				pBuilder.AppendLine();
			}
		}
예제 #10
0
		public static void Parse(TheIndexer pGetIndexer, CodeBuilder pBuilder, FactoryExpressionCreator pCreator) {
			bool isInterface = pGetIndexer.MyClass.IsInterface;

			if (pGetIndexer.Getter != null) {
				pBuilder.AppendFormat("{0}function {1}({2}):{3}{4}",
					JsHelpers.ConvertModifiers(pGetIndexer.Getter.Modifiers, _notValidMod),
					pGetIndexer.Getter.Name,
					JsHelpers.GetParameters(pGetIndexer.Getter.Arguments),
					JsHelpers.Convert(pGetIndexer.ReturnType),
					isInterface ? ";":" {"
				);
				pBuilder.AppendLine();

				if (!isInterface) {
					BlockParser.Parse(pGetIndexer.Getter.CodeBlock, pBuilder, pCreator);
					pBuilder.AppendLine();
					pBuilder.AppendLine("}");
					pBuilder.AppendLine();
				}
			}

			if (pGetIndexer.Setter == null) {
				return;
			}

			pBuilder.AppendFormat(
				"{0}function {1}({2}):void{3}",
				  JsHelpers.ConvertModifiers(pGetIndexer.Setter.Modifiers, _notValidMod),
				  pGetIndexer.Setter.Name,
				  JsHelpers.GetParameters(pGetIndexer.Setter.Arguments),
				  isInterface ? ";" : " {"
			);

			pBuilder.AppendLine();
			if (isInterface)
				return;
			//BlockParser.InsideSetter = true;
			BlockParser.Parse(pGetIndexer.Setter.CodeBlock, pBuilder, pCreator);
			//BlockParser.InsideSetter = false;
			pBuilder.AppendLine();
			pBuilder.AppendLine("}");
			pBuilder.AppendLine();
		}
예제 #11
0
		public static void Parse(TheEvent pEvent, CodeBuilder pBuilder) {
			if (pEvent.IsFlashEvent) return;

			ImportStatementList.AddImport(@"System.EventHandler");

			bool isStatic = pEvent.Modifiers.Contains("static");

			pBuilder.AppendFormat(@"private {1} var _e{0}:EventHandler;
		{2}{1} function get {0}():EventHandler {{
			if (_e{0} == null) _e{0} = new EventHandler();
			return _e{0};
		}}", 
				pEvent.Name, 
				isStatic ? "static" : string.Empty,
				As3Helpers.ConvertModifiers(pEvent.Modifiers, _notValidClassMod)
				//,isStatic ? pEvent.MyClass.Name : "this"
			);

			pBuilder.AppendLine();
		}
예제 #12
0
		public static void Parse(TheVariable pVariable, CodeBuilder pBuilder) {
			foreach (Variable declarator in pVariable.Variables) {
				StringBuilder sb = new StringBuilder();

				sb.AppendFormat("{0}var {1}:{2}",
					JsHelpers.ConvertModifiers(pVariable.Modifiers, _notValidVariableMod),
					declarator.Name,
					JsHelpers.Convert(declarator.ReturnType)
				);

				if (declarator.Initializer == null) {
					sb.Append(";");

				} else {
					sb.AppendFormat(" = {0};", declarator.Initializer.Value);
				}

				pBuilder.Append(sb.ToString());
				pBuilder.AppendLine();
			}
		}
예제 #13
0
		public static void ParseNode(CsNode pNode, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			CsBlock block = pNode as CsBlock;
			if (block != null) {
				Parse(block, pSb, pCreator);
				return;
			}

			CsStatement statement = pNode as CsStatement;
			if (statement != null) {
				pSb.Indent();
				parseStatement(statement, pSb, pCreator);
				pSb.Unindent();
				return;
			}

			CsExpression expression = pNode as CsExpression;
			if (expression != null) {
				Expression ex = pCreator.Parse(pNode as CsExpression);
				pSb.Append(ex.Value + ";");
				pSb.AppendLine();
				return;
			}

			throw new Exception();
		}
 public override void EmitAssignFromNativeStructMember(CodeBuilder b, string var, string cefStruct = "self")
 {
     b.AppendLine("*{0}_str = {1}->{0}.str;", var, cefStruct);
     b.AppendLine("*{0}_length = (int){1}->{0}.length;", var, cefStruct);
 }
예제 #15
0
 public override void EmitPrePublicCallStatements(CodeBuilder b, string var)
 {
     b.AppendLine("PinnedString[] {0}_handles;", var);
     b.AppendLine("var {0}_unwrapped = StringFunctions.Unwrap{1}({0}, out {0}_handles);", var, ClassName);
 }
예제 #16
0
    private void BuildPInvokeApi(GeneratedFileManager fileManager)
    {
        var b = new CodeBuilder();

        b.AppendLine("using System.Runtime.InteropServices;");
        b.AppendLine();
        b.BeginCfxNamespace();
        b.BeginClass("CfxApi", "internal partial");

        b.AppendLine();

        b.BeginClass("Runtime", "internal static");

        foreach (var f in decls.ExportFunctions)
        {
            f.EmitPInvokeDeclaration(b);
        }
        b.AppendLine();

        foreach (var f in decls.StringCollectionFunctions)
        {
            f.EmitPInvokeDeclaration(b);
        }
        b.EndBlock();

        b.AppendLine();

        foreach (var t in decls.CefStructTypes)
        {
            t.ClassBuilder.EmitApiClass(b);
            b.AppendLine();
        }

        b.EndBlock();
        b.EndBlock();

        fileManager.WriteFileIfContentChanged("CfxApi.cs", b.ToString());
        b.Clear();

        var cfxfuncs = decls.GetCfxApiFunctionNames();

        b.BeginCfxNamespace();
        b.BeginClass("CfxApiLoader", "internal partial");
        b.BeginBlock("internal enum FunctionIndex");
        foreach (var f in cfxfuncs)
        {
            b.AppendLine(f + ",");
        }

        b.EndBlock();
        b.AppendLine();

        b.BeginFunction("void LoadCfxRuntimeApi()", "internal static");
        foreach (var f in decls.ExportFunctions)
        {
            if (f.Platform != CefPlatform.Independent)
            {
                b.BeginIf("CfxApi.PlatformOS == CfxPlatformOS.{0}", f.Platform.ToString());
            }
            CodeSnippets.EmitPInvokeDelegateInitialization(b, "Runtime", f.CfxApiFunctionName);
            if (f.Platform != CefPlatform.Independent)
            {
                b.EndBlock();
            }
        }
        b.EndBlock();
        b.AppendLine();

        b.BeginFunction("void LoadStringCollectionApi()", "internal static");
        b.AppendLine("CfxApi.Probe();");
        foreach (var f in decls.StringCollectionFunctions)
        {
            CodeSnippets.EmitPInvokeDelegateInitialization(b, "Runtime", f.CfxApiFunctionName);
        }
        b.EndBlock();
        b.AppendLine();

        foreach (var cefStruct in decls.CefStructTypes)
        {
            b.BeginBlock("internal static void Load{0}Api()", cefStruct.ClassName);
            b.AppendLine("CfxApi.Probe();");

            var apiClassName = cefStruct.ClassName.Substring(3);

            switch (cefStruct.ClassBuilder.Category)
            {
            case StructCategory.ApiCalls:
                foreach (var f in cefStruct.ClassBuilder.ExportFunctions)
                {
                    CodeSnippets.EmitPInvokeDelegateInitialization(b, f.PublicClassName.Substring(3), f.CfxApiFunctionName);
                }
                foreach (var cb in cefStruct.ClassBuilder.CallbackFunctions)
                {
                    CodeSnippets.EmitPInvokeDelegateInitialization(b, cb.PublicClassName.Substring(3), cb.CfxApiFunctionName);
                }

                break;

            case StructCategory.ApiCallbacks:
                b.AppendLine("CfxApi.{0}.{1}_ctor = (CfxApi.cfx_ctor_with_gc_handle_delegate)CfxApi.GetDelegate(FunctionIndex.{1}_ctor, typeof(CfxApi.cfx_ctor_with_gc_handle_delegate));", apiClassName, cefStruct.CfxName);
                b.AppendLine("CfxApi.{0}.{1}_get_gc_handle = (CfxApi.cfx_get_gc_handle_delegate)CfxApi.GetDelegate(FunctionIndex.{1}_get_gc_handle, typeof(CfxApi.cfx_get_gc_handle_delegate));", apiClassName, cefStruct.CfxName);
                b.AppendLine("CfxApi.{0}.{1}_set_callback = (CfxApi.cfx_set_callback_delegate)CfxApi.GetDelegate(FunctionIndex.{1}_set_callback, typeof(CfxApi.cfx_set_callback_delegate));", apiClassName, cefStruct.CfxName);
                b.AppendLine("{0}.SetNativeCallbacks();", cefStruct.ClassName);
                break;

            case StructCategory.Values:
                b.AppendLine("CfxApi.{0}.{1}_ctor = (CfxApi.cfx_ctor_delegate)CfxApi.GetDelegate(FunctionIndex.{1}_ctor, typeof(CfxApi.cfx_ctor_delegate));", apiClassName, cefStruct.CfxName);
                b.AppendLine("CfxApi.{0}.{1}_dtor = (CfxApi.cfx_dtor_delegate)CfxApi.GetDelegate(FunctionIndex.{1}_dtor, typeof(CfxApi.cfx_dtor_delegate));", apiClassName, cefStruct.CfxName);

                foreach (var sm in cefStruct.ClassBuilder.StructMembers)
                {
                    CodeSnippets.EmitPInvokeDelegateInitialization(b, apiClassName, cefStruct.CfxName + "_set_" + sm.Name);
                    CodeSnippets.EmitPInvokeDelegateInitialization(b, apiClassName, cefStruct.CfxName + "_get_" + sm.Name);
                }

                break;
            }
            b.EndBlock();
            b.AppendLine();
        }

        b.EndBlock();
        b.EndBlock();

        fileManager.WriteFileIfContentChanged("CfxApiLoader.cs", b.ToString());
    }
		private void WriteConfigObjectInitCode(CodeBuilder cb) {
			if (customInstantiate)
				cb.AppendLine(ParserUtils.ConfigObjectName + "[\"" + name + "$type\"] = this." + name + ".GetType().FullName;");
			cb.AppendLine(ParserUtils.ConfigObjectName + "[\"" + name + "\"] = this." + name + ".ConfigObject;");
		}
예제 #18
0
    private void BuildFunctionPointers(GeneratedFileManager fileManager)
    {
        var b  = new CodeBuilder();
        var ff = new List <CefExportFunction>(decls.AllExportFunctions());

        ff.AddRange(decls.StringCollectionFunctions);

        foreach (var f in ff)
        {
            var retSymbol = f.ReturnType.OriginalSymbol;
            if (f.Signature.ReturnValueIsConst)
            {
                retSymbol = "const " + retSymbol;
            }
            if (f.Platform != CefPlatform.Independent)
            {
                b.AppendLine("#ifdef CFX_" + f.Platform.ToString().ToUpperInvariant());
            }
            b.AppendLine("static {0} (*{1}_ptr)({2});", retSymbol, f.Name, f.Signature.OriginalParameterList);
            if (f.Platform != CefPlatform.Independent)
            {
                b.AppendLine("#endif");
            }
        }
        b.AppendLine();

        b.BeginBlock("static void cfx_load_cef_function_pointers(void *libcef)");
        foreach (var f in ff)
        {
            if ((f.Name != "cef_api_hash"))
            {
                if (f.Platform != CefPlatform.Independent)
                {
                    b.AppendLine("#ifdef CFX_" + f.Platform.ToString().ToUpperInvariant());
                }
                b.AppendLine("{0}_ptr = ({1} (*)({2}))cfx_platform_get_fptr(libcef, \"{0}\");", f.Name, f.ReturnType.OriginalSymbol, f.Signature.OriginalParameterListUnnamed);
                if (f.Platform != CefPlatform.Independent)
                {
                    b.AppendLine("#endif");
                }
            }
        }
        b.EndBlock();
        b.AppendLine();

        foreach (var f in ff)
        {
            if (f.Platform != CefPlatform.Independent)
            {
                b.AppendLine("#ifdef CFX_" + f.Platform.ToString().ToUpperInvariant());
            }
            b.AppendLine("#define {0} {0}_ptr", f.Name);
            if (f.Platform != CefPlatform.Independent)
            {
                b.AppendLine("#endif");
            }
        }
        b.AppendLine();

        fileManager.WriteFileIfContentChanged("cef_function_pointers.c", b.ToString());
        b.Clear();

        var cfxfuncs = decls.GetCfxApiFunctionNames();

        b.BeginBlock("static void* cfx_function_pointers[{0}] = ", cfxfuncs.Count());
        for (var i = 0; i <= cfxfuncs.Length - 1; i++)
        {
            b.AppendLine("(void*){0},", cfxfuncs[i]);
        }
        b.EndBlock(";");

        fileManager.WriteFileIfContentChanged("cfx_function_pointers.c", b.ToString());
    }
예제 #19
0
        public override void VisitReturnStatement(ReturnStatementSyntax node)
        {
            MethodInfo mi = m_MethodInfoStack.Peek();

            mi.ExistTopLevelReturn = IsLastNodeOfMethod(node);

            bool isLastNode = IsLastNodeOfParent(node);

            if (!isLastNode || mi.TryUsingLayer > 0)
            {
                CodeBuilder.AppendFormat("{0}block{{", GetIndentString());
                CodeBuilder.AppendLine();
            }

            if (null != node.Expression)
            {
                IConversionOperation opd = null;
                var iret = m_Model.GetOperationEx(node) as IReturnOperation;
                if (null != iret)
                {
                    opd = iret.ReturnedValue as IConversionOperation;
                }
                var invocation = node.Expression as InvocationExpressionSyntax;
                if (null != invocation)
                {
                    var ci = m_ClassInfoStack.Peek();
                    CodeBuilder.AppendFormat("{0}", GetIndentString());
                    VisitInvocation(ci, invocation, mi.ReturnVarName, ";", true);
                    if (null != opd && null != opd.OperatorMethod)
                    {
                        IMethodSymbol  msym = opd.OperatorMethod;
                        InvocationInfo ii   = new InvocationInfo(GetCurMethodSemanticInfo(), node);
                        ii.Init(msym, m_Model);
                        CodeBuilder.AppendFormat("{0}{1}", GetIndentString(), mi.ReturnVarName);
                        CodeBuilder.AppendLine(" = ");
                        OutputConversionInvokePrefix(ii);
                        CodeBuilder.Append(mi.ReturnVarName);
                        CodeBuilder.AppendLine(");");
                    }
                }
                else
                {
                    CodeBuilder.AppendFormat("{0}{1} = ", GetIndentString(), mi.ReturnVarName);
                    OutputExpressionSyntax(node.Expression, opd);
                    CodeBuilder.AppendLine(";");
                }
            }

            if (mi.TryUsingLayer > 0)
            {
                var returnAnalysis = mi.TempReturnAnalysisStack.Peek();
                if (mi.IsAnonymousOrLambdaMethod)
                {
                    if (returnAnalysis.ExistReturnInLoopOrSwitch || null == returnAnalysis.RetValVar)
                    {
                        //return(1)代表是tryusing块里的return语句
                        CodeBuilder.AppendFormat("{0}return(1);", GetIndentString());
                        CodeBuilder.AppendLine();
                    }
                    else
                    {
                        //可以不使用函数对象实现的try块,不能使用return语句,换成变量赋值与break
                        CodeBuilder.AppendFormat("{0}{1} = 1;", GetIndentString(), returnAnalysis.RetValVar);
                        CodeBuilder.AppendLine();
                        CodeBuilder.AppendFormat("{0}break;", GetIndentString());
                        CodeBuilder.AppendLine();
                    }
                }
                else
                {
                    var    outParamsStr = returnAnalysis.OutParamsStr;
                    string prestr       = ", ";
                    //return(1)代表是tryusing块里的return语句
                    CodeBuilder.AppendFormat("{0}return(1", GetIndentString());
                    if (!string.IsNullOrEmpty(outParamsStr))
                    {
                        CodeBuilder.Append(prestr);
                        CodeBuilder.Append(outParamsStr);
                    }
                    CodeBuilder.AppendLine(");");
                }
            }
            else
            {
                string prestr;
                CodeBuilder.AppendFormat("{0}return({1}", GetIndentString(), mi.ReturnVarName);
                prestr = ", ";
                var names = mi.ReturnParamNames;
                if (names.Count > 0)
                {
                    for (int i = 0; i < names.Count; ++i)
                    {
                        CodeBuilder.Append(prestr);
                        CodeBuilder.Append(names[i]);
                        prestr = ", ";
                    }
                }
                CodeBuilder.AppendLine(");");
            }

            if (!isLastNode || mi.TryUsingLayer > 0)
            {
                CodeBuilder.AppendFormat("{0}}};", GetIndentString());
                CodeBuilder.AppendLine();
            }
        }
예제 #20
0
 public override void EmitPublicEventArgSetterStatements(CodeBuilder b, string var)
 {
     b.AppendLine("m_{0}_wrapped = value;", var);
 }
예제 #21
0
 public override void EmitProxyEventArgSetter(CodeBuilder b, string var)
 {
     b.AppendLine("e.{0} = {1};", var, StructPtr.ProxyUnwrapExpression("value"));
 }
예제 #22
0
 public override void EmitPublicEventArgFields(CodeBuilder b, string var)
 {
     b.AppendLine("internal {0} m_{1}_wrapped;", PublicSymbol, var);
 }
예제 #23
0
 public override void EmitPostPublicRaiseEventStatements(CodeBuilder b, string var)
 {
     b.AppendLine("{0} = {1};", var, StructPtr.PublicUnwrapExpression(string.Concat("e.m_", var, "_wrapped")));
 }
예제 #24
0
 public override void EmitPrePublicCallStatements(CodeBuilder b, string var)
 {
     b.AppendLine("IntPtr {0}_ptr;", var);
 }
예제 #25
0
 public override void EmitPostNativeCallbackStatements(CodeBuilder b, string var)
 {
     b.AppendLine("if(*{0})((cef_base_t*)*{0})->add_ref((cef_base_t*)*{0});", var);
 }
예제 #26
0
 public override void EmitPostPublicCallStatements(CodeBuilder b, string var)
 {
     b.AppendLine("StringFunctions.FreePinnedStrings({0}_handles);", var);
     b.AppendLine("StringFunctions.{0}CopyToManaged({1}_unwrapped, {1});", ClassName, var);
     b.AppendLine("CfxApi.Runtime.{0}_free({1}_unwrapped);", CfxName, var);
 }
예제 #27
0
		private static void parseLocalVariable(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			CsDeclarationStatement declarationStatement = (CsDeclarationStatement)pStatement;

			CsLocalVariableDeclaration localVariableDeclaration = declarationStatement.declaration as CsLocalVariableDeclaration;
			if (localVariableDeclaration == null) {
				parseLocalConstantDeclaration(pStatement, pSb, pCreator);
				return;
			}

			foreach (var declarator in localVariableDeclaration.declarators) {
				StringBuilder sb = new StringBuilder();

				sb.AppendFormat("var {0}:{1}",
					declarator.identifier.identifier,
					As3Helpers.Convert(Helpers.GetType(localVariableDeclaration.type))
				);

				if (declarator.initializer == null) {
					sb.Append(";");

				} else {
					sb.AppendFormat(" = {0};", parseNode(declarator.initializer, pCreator));
				}

				pSb.Append(sb.ToString());
				pSb.AppendLine();
			}
		}
예제 #28
0
 public override void EmitPreProxyCallStatements(CodeBuilder b, string var)
 {
     b.AppendLine("{0} {1}_local;", Struct.ClassName, var);
 }
예제 #29
0
		private static void parseForStatement(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			CsForStatement forStatement = (CsForStatement)pStatement;

			StringBuilder sb = new StringBuilder("for (");

			CsLocalVariableDeclaration localVariableDeclaration = forStatement.initializer as CsLocalVariableDeclaration;
			CsStatementExpressionList expressionList;

			if (localVariableDeclaration == null) {
				expressionList = forStatement.initializer as CsStatementExpressionList;
				foreach (CsExpression expression in expressionList.expressions) {
					Expression ex = pCreator.Parse(expression);
					sb.Append(ex.Value);
					sb.Append(", ");
				}

				sb.Remove(sb.Length - 2, 2);
				sb.Append("; ");

			} else if (localVariableDeclaration.declarators.Count > 0) {
				sb.Append("var ");
				int count = localVariableDeclaration.declarators.Count;
				int now = 0;

				foreach (CsLocalVariableDeclarator declarator in localVariableDeclaration.declarators) {

					sb.AppendFormat("{0}:{1}",
						declarator.identifier.identifier,
						As3Helpers.Convert(Helpers.GetType(localVariableDeclaration.type))
					);

					now++;

					if (declarator.initializer != null) {
						sb.AppendFormat(" = {0}", parseNode(declarator.initializer, pCreator));
					} 

					if (now < count) {
						sb.Append(", ");
					}
				}

				sb.Append("; ");
			}

			sb.Append(pCreator.Parse(forStatement.condition).Value);
			sb.Append("; ");

			expressionList = (CsStatementExpressionList) forStatement.iterator;

			if (expressionList != null) {
				foreach (CsExpression expression in expressionList.expressions) {
					Expression ex = pCreator.Parse(expression);
					sb.Append(ex.Value);
					sb.Append(", ");
				}

				sb.Remove(sb.Length - 2, 2);
			}

			sb.Append("){");
			pSb.AppendLine(sb.ToString());
			ParseNode(forStatement.statement, pSb, pCreator);
			pSb.AppendLine("}");
			pSb.AppendLine();

		}
예제 #30
0
 public override void EmitPostProxyCallStatements(CodeBuilder b, string var)
 {
     b.AppendLine("{0} = {1};", var, StructPtr.ProxyWrapExpression(var + "_local"));
 }
예제 #31
0
 public string OnNewObject(CodeBuilder codeBuilder, int indentLevel, Func <string, string> valueSetter)
 {
     codeBuilder.AppendLine(indentLevel, valueSetter("null"));
     return(null);
 }
예제 #32
0
    static void Main(string[] args)
    {
        bool bTraceTypeFiltering = false;

        String[] allPaths =
        {
            publicAsmPaths[0],
            publicAsmPaths[1],
            Path.Combine(vsInstallPath,@"Enterprise\Common7\IDE\PrivateAssemblies"),
            // Microsoft.VisualStudio.DataDesign.Interfaces.dll...
            Path.Combine(vsInstallPath,@"Common7\IDE"),
            // Microsoft.VisualStudio.ProjectSystem.VS.dll
            Path.Combine(vsInstallPath,@"Common7\IDE\CommonExtensions\Microsoft\Project")
        };

        String[] asmPathes = Directory.GetFiles(publicAsmPaths[0], "*.dll").
                             Concat(
            Directory.GetFiles(publicAsmPaths[1], "*.dll")
            ).ToArray();

        AppDomain.CurrentDomain.AssemblyResolve += (s, asmArgs) =>
        {
            String dllName = new AssemblyName(asmArgs.Name).Name + ".dll";

            foreach (String dir in allPaths)
            {
                string path = Path.Combine(dir, dllName);

                if (!File.Exists(path))
                {
                    continue;
                }

                return(Assembly.LoadFrom(path));
            }

            // Console.WriteLine("Warning: Required assembly not found: " + dllName);
            return(null);
        };

        Dictionary <String, int>  asmToVersion    = new Dictionary <string, int>();
        Dictionary <String, Type> classNameToType = new Dictionary <string, Type>();

        List <String> ignoreAsms = new List <string>();

        if (File.Exists("ignoreAsms.txt"))
        {
            ignoreAsms = File.ReadAllText("ignoreAsms.txt").Split('\n').ToList();
        }

        foreach (String dllPath in asmPathes)
        {
            Assembly asm = null;

            if (ignoreAsms.Contains(dllPath))
            {
                continue;
            }

            try
            {
                asm = Assembly.LoadFrom(dllPath);
            }
            catch { }

            if (asm == null)
            {
                ignoreAsms.Add(dllPath);
                continue;
            }

            if (bTraceTypeFiltering)
            {
                Console.WriteLine(Path.GetFileName(asm.Location));
            }

            bool bAtLeastOneTypeFound = false;

            foreach (Type type in GetLoadableTypes(asm))
            {
                String name = type.Name.ToLower();

                if (bTraceTypeFiltering)
                {
                    Console.WriteLine("    " + type.Name);
                }

                if (
                    !(
                        (name.Contains("configuration") && !name.Contains("configurations")) &&
                        !name.Contains("manager") &&
                        !name.Contains("callback") ||
                        name.Contains("linker") ||
                        name.Contains("project")
                        //name.Contains("serviceprovider")
                        )
                    )
                {
                    continue;
                }

                //if (!name.Contains("vcconfiguration"))
                //    continue;

                int    version  = 1;
                String baseName = type.Name;

                Match m = new Regex("^(.*)(\\d+)$").Match(type.Name);
                if (m.Success)
                {
                    version  = Int32.Parse(m.Groups[2].Value);
                    baseName = m.Groups[1].Value;
                }

                if (!asmToVersion.ContainsKey(baseName))
                {
                    asmToVersion.Add(baseName, version);
                    classNameToType.Add(baseName, type);
                    bAtLeastOneTypeFound = true;
                }
                else
                {
                    if (version > asmToVersion[baseName])
                    {
                        asmToVersion[baseName]    = version;
                        classNameToType[baseName] = type;
                        bAtLeastOneTypeFound      = true;
                    }
                }
            } //foreach Type

            if (!bAtLeastOneTypeFound)
            {
                ignoreAsms.Add(dllPath);
            }
        } //foreach asmPathes

        File.WriteAllText("ignoreAsms.txt", String.Join("\n", ignoreAsms));

        if (bTraceTypeFiltering)
        {
            Console.WriteLine("Collected types:");
            foreach (String baseName in asmToVersion.Keys)
            {
                Console.Write("    " + baseName);
                if (asmToVersion[baseName] != 1)
                {
                    Console.Write("(" + asmToVersion[baseName] + ")");
                }
                Console.WriteLine();
            }
        }

        Dictionary <String, List <String> > requiredNamespaces = new Dictionary <string, List <string> >();

        Console.WriteLine("Processing types:");
        foreach (String action in new String[] { "getinfo", "collect" })
        {
            foreach (String typeName in classNameToType.Keys)
            {
                if (!typeName.StartsWith("VC") && !typeName.StartsWith("CSharp"))
                {
                    continue;
                }

                Type type = classNameToType[typeName];

                // Collect namespace dependencies.
                if (action == "getinfo")
                {
                    String ns = getPlannedNamespace(type);

                    if (!requiredNamespaces.ContainsKey(ns))
                    {
                        requiredNamespaces.Add(ns, new List <string>());
                    }
                    List <String> namespaces = requiredNamespaces[ns];

                    foreach (PropertyInfo pi in type.GetProperties())
                    {
                        Type pitype = pi.PropertyType;

                        if (pitype != typeof(String) && pitype != typeof(Boolean) && !pitype.IsEnum)
                        {
                            continue;
                        }

                        String targetNs = getPlannedNamespace(pitype);
                        if (ns != targetNs && targetNs != "System" && !namespaces.Contains(targetNs))
                        {
                            namespaces.Add(targetNs);
                        }
                    }

                    continue;
                }

                Console.WriteLine("    " + typeName);

                CodeBuilder cb = getFileFromType(type, (cb2) =>
                {
                    // Dump all dependent namespace as "using ..."
                    foreach (String ns2 in requiredNamespaces[cb2.GetUserData <String>("namespace")])
                    {
                        cb2.AppendLine("using " + ns2 + ";");
                    }
                });

                if (cb == null)
                {
                    continue;
                }

                cb.AppendLine("public class " + type.Name);
                cb.AppendLine("{");

                XmlDocument doc = getDocumentation(type);


                foreach (PropertyInfo pi in type.GetProperties())
                {
                    Type pitype = pi.PropertyType;
                    if (pitype.IsEnum)
                    {
                        DumpEnum(pitype);
                    }

                    if (pitype != typeof(String) && pitype != typeof(Boolean) && !pitype.IsEnum)
                    {
                        cb.AppendLine("    // " + pitype.Name + " " + pi.Name + ";");
                        cb.AppendLine();
                        continue;
                    }
                    String propertyPath = type.Namespace + "." + typeName + "." + pi.Name;

                    cb.Indent();
                    cb.Append(getComments(doc, cb.IndentString + "/// ", "P:" + propertyPath));
                    cb.AppendLine("public " + pitype.Name + " " + pi.Name + ";");
                    cb.UnIndent();
                    cb.AppendLine();
                }
                cb.AppendLine("};");
                cb.AppendLine();
            }
        }

        String vsModelDir = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)), "vsmodel");

        if (!Directory.Exists(vsModelDir))
        {
            Directory.CreateDirectory(vsModelDir);
        }

        foreach (String asmName in modelFiles.Keys)
        {
            CodeBuilder cb = modelFiles[asmName];

            // Close all open braces.
            while (cb.IndentValue() != 0)
            {
                cb.UnIndent();
                cb.AppendLine("}");
            }

            File.WriteAllText(Path.Combine(vsModelDir, asmName + ".cs"), cb.ToString());
        }
    }
예제 #33
0
        public override void VisitSwitchStatement(SwitchStatementSyntax node)
        {
            string     varName = string.Format("__compiler_switch_{0}", node.GetLocation().GetLineSpan().StartLinePosition.Line);
            SwitchInfo si      = new SwitchInfo();

            si.SwitchVarName = varName;
            m_SwitchInfoStack.Push(si);

            CodeBuilder.AppendFormat("{0}local {1} = ", GetIndentString(), varName);
            VisitExpressionSyntax(node.Expression);
            CodeBuilder.AppendLine(";");

            int ct = node.Sections.Count;
            SwitchSectionSyntax defaultSection = null;

            for (int i = 0; i < ct; ++i)
            {
                var section = node.Sections[i];
                int lct     = section.Labels.Count;
                for (int j = 0; j < lct; ++j)
                {
                    var label = section.Labels[j];
                    if (label is DefaultSwitchLabelSyntax)
                    {
                        defaultSection = section;
                        break;
                    }
                }
            }
            for (int i = 0; i < ct; ++i)
            {
                var section = node.Sections[i];
                if (section == defaultSection)
                {
                    continue;
                }
                ContinueInfo ci = new ContinueInfo();
                ci.Init(section);
                m_ContinueInfoStack.Push(ci);

                BreakAnalysis ba = new BreakAnalysis();
                ba.Visit(section);
                if (ba.BreakCount > 1)
                {
                    ci.IsIgnoreBreak = false;
                }
                else
                {
                    ci.IsIgnoreBreak = true;
                }

                CodeBuilder.AppendFormat("{0}{1} ", GetIndentString(), i == 0 ? "if" : "elseif");
                int lct = section.Labels.Count;
                for (int j = 0; j < lct; ++j)
                {
                    var label = section.Labels[j] as CaseSwitchLabelSyntax;
                    if (null != label)
                    {
                        if (lct > 1)
                        {
                            CodeBuilder.Append("(");
                        }
                        CodeBuilder.AppendFormat("{0} == ", varName);
                        VisitExpressionSyntax(label.Value);
                        if (lct > 1)
                        {
                            CodeBuilder.Append(")");
                            if (j < lct - 1)
                            {
                                CodeBuilder.Append(" and ");
                            }
                        }
                    }
                }
                CodeBuilder.AppendLine(" then");
                if (ba.BreakCount > 1)
                {
                    CodeBuilder.AppendFormat("{0}repeat", GetIndentString());
                    CodeBuilder.AppendLine();
                }
                ++m_Indent;

                int sct = section.Statements.Count;
                for (int j = 0; j < sct; ++j)
                {
                    var statement = section.Statements[j];
                    statement.Accept(this);
                }

                --m_Indent;
                if (ba.BreakCount > 1)
                {
                    CodeBuilder.AppendFormat("{0}until 0 ~= 0;", GetIndentString());
                    CodeBuilder.AppendLine();
                }

                m_ContinueInfoStack.Pop();
            }
            if (null != defaultSection)
            {
                ContinueInfo ci = new ContinueInfo();
                ci.Init(defaultSection);
                m_ContinueInfoStack.Push(ci);

                BreakAnalysis ba = new BreakAnalysis();
                ba.Visit(defaultSection);
                if (ba.BreakCount > 1)
                {
                    ci.IsIgnoreBreak = false;
                }
                else
                {
                    ci.IsIgnoreBreak = true;
                }
                CodeBuilder.AppendFormat("{0}else", GetIndentString());
                CodeBuilder.AppendLine();
                if (ba.BreakCount > 1)
                {
                    CodeBuilder.AppendFormat("{0}repeat", GetIndentString());
                    CodeBuilder.AppendLine();
                }
                ++m_Indent;

                int sct = defaultSection.Statements.Count;
                for (int j = 0; j < sct; ++j)
                {
                    var statement = defaultSection.Statements[j];
                    statement.Accept(this);
                }

                --m_Indent;
                if (ba.BreakCount > 1)
                {
                    CodeBuilder.AppendFormat("{0}until 0 ~= 0;", GetIndentString());
                    CodeBuilder.AppendLine();
                }
                CodeBuilder.AppendFormat("{0}end;", GetIndentString());
                CodeBuilder.AppendLine();

                m_ContinueInfoStack.Pop();
            }
            else
            {
                CodeBuilder.AppendFormat("{0}end;", GetIndentString());
                CodeBuilder.AppendLine();
            }

            m_SwitchInfoStack.Pop();
        }
 public override void EmitAssignToNativeStructMember(CodeBuilder b, string var, string cefStruct = "self")
 {
     b.AppendLine("cef_string_utf16_set({0}_str, {0}_length, &({1}->{0}), 1);", var, cefStruct);
 }
		private void WriteTransferConstructorCode(CodeBuilder cb) {
			if (customInstantiate) {
				cb.AppendLine("this.controls[\"" + name + "\"] = (" + TypeName + ")Container.CreateObjectByTypeNameWithConstructorArg((string)" + ParserUtils.ConfigObjectName + "[\"" + name + "$type\"], " + ParserUtils.ConfigObjectName + "[\"" + name + "\"]);");
			}
			else {
				cb.AppendLine("this.controls[\"" + name + "\"] = (" + TypeName + ")Container.CreateObjectWithConstructorArg(typeof(" + TypeName + "), " + ParserUtils.ConfigObjectName + "[\"" + name + "\"]);");
			}
		}
 public override void EmitPostPublicCallStatements(CodeBuilder b, string var)
 {
     b.AppendLine("{0}_pinned.Obj.Free();", var);
 }
		private void WriteAttachCode(CodeBuilder cb) {
			if (customInstantiate)
				cb.AppendLine("if (this." + name + " == null) throw new Exception(\"Must instantiate the control 'CtlName' before attach.\");");
			cb.AppendLine("this." + name + ".Attach();");
		}
예제 #38
0
		public static void Parse(TheProperty pProperty, CodeBuilder pBuilder, FactoryExpressionCreator pCreator) {
			if (pProperty == null) return;
			bool isInterface = pProperty.MyClass.IsInterface;
			string type = JsHelpers.Convert(pProperty.ReturnType);

			if (pProperty.IsEmpty && !isInterface) {
				pBuilder.AppendFormat("private var _{0}:{1};", pProperty.Name, type);
				pBuilder.AppendLine();
			}

			TheClass parent = pProperty.MyClass;
			bool isStandardGetSet = false;
			while (parent.Base != null) {
				isStandardGetSet |= parent.FullName.StartsWith("flash.");
				parent = parent.Base;
			}

			if (pProperty.Getter != null) {//Getter
				if (isStandardGetSet) {//base is flash, use standard setter/getter
					pBuilder.AppendFormat("{0}function get {1}():{2}{3}",
						JsHelpers.ConvertModifiers(pProperty.Getter.Modifiers, _notValidPropertyMod),
						pProperty.Name,
						type,
						isInterface ? ";" : " {"
					);

				} else {
					bool isEnum = false;

					foreach (string s in pProperty.MyClass.Implements) {
						if (!s.StartsWith("IEnumerator", StringComparison.Ordinal)) {
							continue;
						}

						isEnum = true;
						break;
					}

					isEnum &= pProperty.Getter.Name.Equals("get_Current");

					//bool isEnum =
					//    pProperty.Getter.Name.Equals("get_Current") &&
					//    pProperty.MyClass.Implements.Contains()

					pBuilder.AppendFormat("{0}function {1}():{2}{3}",
						JsHelpers.ConvertModifiers(pProperty.Getter.Modifiers, _notValidPropertyMod),
						pProperty.Getter.Name,
						isEnum ? "*" : type,
						isInterface ? ";" : " {"
					);
				}

				pBuilder.AppendLine();

				if (!isInterface) {
					if (pProperty.IsEmpty) {
						pBuilder.Indent();
						pBuilder.AppendFormat("return _{0};", pProperty.Name);
						pBuilder.Unindent();

					} else {
						BlockParser.Parse(pProperty.Getter.CodeBlock, pBuilder, pCreator);
					}

					pBuilder.AppendLine();
					pBuilder.AppendLine("}");
					pBuilder.AppendLine();
				}
			}

			if (pProperty.Setter == null) {
				return;
			}

			if (isStandardGetSet) {//Setter
//base is flash, use standard setter/getter
				pBuilder.AppendFormat("{0}function set {1}(value:{2}):void{3}",
				                      JsHelpers.ConvertModifiers(pProperty.Setter.Modifiers, _notValidPropertyMod),
				                      pProperty.Name,
				                      type,
									  isInterface ? ";" : " {"
					);
			} else {
				pBuilder.AppendFormat("{0}function {1}(value:{2}):{2}{3}",
				                      JsHelpers.ConvertModifiers(pProperty.Setter.Modifiers, _notValidPropertyMod),
				                      pProperty.Setter.Name,
				                      type,
									  isInterface ? ";" : " {"
					);
			}

			pBuilder.AppendLine();

			if (!isInterface) {
				if (pProperty.IsEmpty) {
					pBuilder.Indent();
					pBuilder.AppendFormat("_{0} = value;", pProperty.Name);
					pBuilder.AppendLine();
					pBuilder.Append("return value;");
					pBuilder.Unindent();

				} else {
					BlockParser.InsideSetter = !isStandardGetSet;
					BlockParser.Parse(pProperty.Setter.CodeBlock, pBuilder, pCreator);
					BlockParser.InsideSetter = false;
					if (!isStandardGetSet)
						pBuilder.AppendLine("	return value;");
				}

				pBuilder.AppendLine();
				pBuilder.AppendLine("}");
			}

			pBuilder.AppendLine();
		}
예제 #39
0
    /// <summary>
    /// Gets CodeBuilder class where given type will be 'printed'
    /// </summary>
    /// <returns>null if type is going outside of public location</returns>
    static CodeBuilder getFileFromType(Type type, Action <CodeBuilder> onCreateCb = null)
    {
        String asmPath  = type.Assembly.Location;
        bool   bCreated = false;
        //if (!asmPath.StartsWith(publicAsmPath) && !type.Name.StartsWith("CSharpProjectConfigurationProperties"))
        //    return null;

        String asmName = Path.GetFileNameWithoutExtension(asmPath);
        String name    = asmName;

        if (type.IsEnum)
        {
            name += "_enums";
        }

        CodeBuilder cb;

        if (!modelFiles.ContainsKey(name))
        {
            cb = new CodeBuilder();
            modelFiles.Add(name, cb);
            cb.AppendLine("using System;");
            bCreated = true;
        }
        else
        {
            cb = modelFiles[name];
        }

        // Specify namespace using what where we keep original type.
        String ns = getPlannedNamespace(type);

        // Already saved, no need to double save
        if (savedTypes.ContainsKey(ns + "." + type.Name))
        {
            return(null);
        }
        savedTypes.Add(ns + "." + type.Name, true);

        if (cb.GetUserData <String>("namespace") != ns)
        {
            cb.SetUserData("namespace", ns);

            if (bCreated)
            {
                if (onCreateCb != null)
                {
                    onCreateCb(cb);
                }
                cb.AppendLine();
            }

            if (cb.IndentValue() != 0)
            {
                cb.UnIndent();
                cb.AppendLine("}");
            }

            cb.AppendLine("namespace " + ns);
            cb.AppendLine("{");
            cb.AppendLine();
            cb.Indent();
        }

        return(modelFiles[name]);
    }
예제 #40
0
    private void BuildRemoteCalls(GeneratedFileManager fileManager)
    {
        var callIds = new List <string>();

        var b = new CodeBuilder();

        b.BeginCfxNamespace(".Remote");
        foreach (var f in remoteDecls.ExportFunctions)
        {
            if (!f.PrivateWrapper)
            {
                b.BeginRemoteCallClass("CfxRuntime" + f.PublicName, callIds);
                f.Signature.EmitRemoteCallClassBody(b, "Runtime", f.CfxApiFunctionName);
                b.EndBlock();
                b.AppendLine();
            }
        }
        b.EndBlock();
        fileManager.WriteFileIfContentChanged("CfxRuntimeRemoteCalls.cs", b.ToString());

        foreach (var t in remoteDecls.CefStructTypes)
        {
            b.Clear();
            b.BeginCfxNamespace(".Remote");
            t.ClassBuilder.EmitRemoteCalls(b, callIds);
            b.EndBlock();
            fileManager.WriteFileIfContentChanged(t.ClassName + "RemoteCalls.cs", b.ToString());
        }

        foreach (var t in remoteDecls.CefStructTypes)
        {
            if (t.ClassBuilder is CfxClientClass)
            {
                b.Clear();
                b.BeginCfxNamespace(".Remote");
                (t.ClassBuilder as CfxClientClass).EmitRemoteClient(b);
                b.EndBlock();
                fileManager.WriteFileIfContentChanged(t.ClassName + "RemoteClient.cs", b.ToString());
            }
        }

        callIds.AddRange(GeneratorConfig.AdditionalCallIds);
        callIds.Sort();

        b.Clear();

        b.BeginCfxNamespace(".Remote");
        b.BeginBlock("internal enum RemoteCallId : ushort");
        foreach (var id in callIds)
        {
            b.AppendLine(id + ",");
        }
        b.TrimRight();
        b.CutRight(1);
        b.AppendLine();
        b.EndBlock();
        b.EndBlock();
        fileManager.WriteFileIfContentChanged("RemoteCallId.cs", b.ToString());

        b.Clear();
        b.BeginCfxNamespace(".Remote");
        b.BeginClass("RemoteCallFactory", "internal");
        b.AppendLine("private delegate RemoteCall RemoteCallCtor();");
        b.BeginBlock("private static RemoteCallCtor[] callConstructors = ");
        foreach (var id in callIds)
        {
            b.AppendLine("() => {{ return new {0}(); }},", id);
        }
        b.EndBlock(";");
        b.AppendLine();

        b.BeginBlock("internal static RemoteCall ForCallId(RemoteCallId id)");
        b.AppendLine("return callConstructors[(int)id]();");
        b.EndBlock();
        b.EndBlock();
        b.EndBlock();
        fileManager.WriteFileIfContentChanged("RemoteCallFactory.cs", b.ToString());
    }
 public override void EmitValueStructGetterVars(CodeBuilder b, string var)
 {
     b.AppendLine("IntPtr {0}_str;", var);
     b.AppendLine("int {0}_length;", var);
 }
예제 #42
0
        public void GenerateFromJson(CodeBuilder codeBuilder, int indentLevel, JsonType type, Func <string, string> valueSetter, string valueGetter)
        {
            var listElementType = type.GenericArguments[0];
            var generator       = _getGeneratorForType(listElementType);

            string foundVariable = $"found{UniqueNumberGenerator.UniqueNumber}";

            codeBuilder.AppendLine(indentLevel, $"json = json.SkipWhitespaceTo('[', 'n', out char {foundVariable});");

            codeBuilder.AppendLine(indentLevel, $"if({foundVariable} == 'n')");
            codeBuilder.AppendLine(indentLevel, "{");
            codeBuilder.AppendLine(indentLevel + 1, "json = json.Slice(3);");
            codeBuilder.AppendLine(indentLevel + 1, valueSetter("null"));
            codeBuilder.AppendLine(indentLevel, "}");
            codeBuilder.AppendLine(indentLevel, "else");
            codeBuilder.AppendLine(indentLevel, "{");

            indentLevel++;

            codeBuilder.AppendLine(indentLevel, $"if({valueGetter} == null)");
            codeBuilder.AppendLine(indentLevel, "{");
            codeBuilder.AppendLine(indentLevel + 1, valueSetter($"new List<{listElementType.FullName}>()"));
            codeBuilder.AppendLine(indentLevel, "}");
            codeBuilder.AppendLine(indentLevel, "else");
            codeBuilder.AppendLine(indentLevel, "{");
            codeBuilder.AppendLine(indentLevel + 1, $"{valueGetter}.Clear();");
            codeBuilder.AppendLine(indentLevel, "}");



            Func <string, string> listAdder = value => $"{valueGetter}.Add({value});";

            codeBuilder.AppendLine(indentLevel, "while(true)");
            codeBuilder.AppendLine(indentLevel, "{");

            codeBuilder.AppendLine(indentLevel + 1, "if(json[0] == ']')");
            codeBuilder.AppendLine(indentLevel + 1, "{");
            codeBuilder.AppendLine(indentLevel + 2, "json = json.Slice(1);");
            codeBuilder.AppendLine(indentLevel + 2, "break;");
            codeBuilder.AppendLine(indentLevel + 1, "}");

            generator.GenerateFromJson(codeBuilder, indentLevel + 1, listElementType, listAdder, null);
            codeBuilder.AppendLine(indentLevel + 1, "json = json.SkipWhitespace();");
            codeBuilder.AppendLine(indentLevel + 1, "switch (json[0])");
            codeBuilder.AppendLine(indentLevel + 1, "{");
            codeBuilder.AppendLine(indentLevel + 2, "case ',':");
            codeBuilder.AppendLine(indentLevel + 3, "json = json.Slice(1);");
            codeBuilder.AppendLine(indentLevel + 3, "continue;");
            codeBuilder.AppendLine(indentLevel + 2, "case ']':");
            codeBuilder.AppendLine(indentLevel + 3, "json = json.Slice(1);");
            codeBuilder.AppendLine(indentLevel + 3, "break;");
            codeBuilder.AppendLine(indentLevel + 2, "default:");
            codeBuilder.AppendLine(indentLevel + 3, "throw new InvalidJsonException($\"Unexpected character while parsing list Expected ',' or ']' but got '{json[0]}'\", json);");
            codeBuilder.AppendLine(indentLevel + 1, "}");
            codeBuilder.AppendLine(indentLevel + 1, "break;");
            codeBuilder.AppendLine(indentLevel, "}");
            indentLevel--;
            codeBuilder.AppendLine(indentLevel, "}");
        }
 public override void EmitPrePublicCallStatements(CodeBuilder b, string var)
 {
     b.AppendLine("var {0}_pinned = new PinnedString({1});", var, CSharp.Escape(var));
 }
예제 #44
0
		private static void parseForeachStatement(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			CsForeachStatement fes = (CsForeachStatement)pStatement;

			Expression ex = pCreator.Parse(fes.expression);
			string type = As3Helpers.Convert(Helpers.GetType(fes.type));

			pSb.AppendLine();

			TheClass theClass = TheClassFactory.Get(ex.Type, pCreator);

			if (ex.Type.type == cs_entity_type.et_array || ex.IsAs3Generic
				|| (theClass != null && @"System.Array".Equals(theClass.FullName))) {//foreach
				pSb.AppendFormat("for each(var {0}:{1} in {2}){{",
					fes.identifier.identifier,
					type,
					ex.Value);
				pSb.AppendLine();

			} else if (ex.Type.type == cs_entity_type.et_object ||
						ex.Type.type == cs_entity_type.et_generic_param || 
					(theClass != null && @"flash.utils.Dictionary".Equals(theClass.FullName))) {

				pSb.AppendFormat("for (var {0}:{1} in {2}){{",
					fes.identifier.identifier,
					type,
					ex.Value);

				pSb.AppendLine();
				if (ex.Type.type == cs_entity_type.et_object) {
					pSb.AppendFormat("	if (!{1}.hasOwnProperty({0})) continue;",
						fes.identifier.identifier,
						ex.Value
					);
				}

				pSb.AppendLine();

			} else {
				_enumCount++;
				//TheClass theClass = TheClassFactory.Get(fes.expression.entity_typeref);

				string enumName = String.Format(@"__ie{0}", _enumCount);
				pSb.AppendFormat("var {0}:IEnumerator = {1}.GetEnumerator();", enumName, ex.Value);
				pSb.AppendLine();
				pSb.AppendFormat("while ({0}.MoveNext()){{", enumName);
				pSb.AppendLine();

				pSb.AppendFormat("\tvar {1}:{2} = {0}.get_Current() as {2};",
					enumName,
					fes.identifier.identifier,
					type
				);

				pSb.AppendLine();
			}

			ParseNode(fes.statement, pSb, pCreator);
			pSb.AppendLine("}");
			pSb.AppendLine();
		}
예제 #45
0
		private static void parseThrowStatement(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			CsThrowStatement throwStatement = (CsThrowStatement)pStatement;
			pSb.AppendFormat("throw {0};", parseNode(throwStatement.expression, pCreator));
			pSb.AppendLine();
		}
예제 #46
0
		private static void parseBreakStatement(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			pSb.Append("break;");
			pSb.AppendLine();
			pSb.AppendLine();
		}
예제 #47
0
		private static void parseLocalConstantDeclaration(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			CsDeclarationStatement declarationStatement = (CsDeclarationStatement)pStatement;

			CsLocalConstantDeclaration lcd = (CsLocalConstantDeclaration)declarationStatement.declaration;

			foreach (CsLocalConstantDeclarator declarator in lcd.declarators) {
				StringBuilder sb = new StringBuilder();

				sb.AppendFormat(@"const {0}:{1} = {2};",
					declarator.identifier.identifier,
					As3Helpers.Convert(Helpers.GetType(lcd.type)),
					pCreator.Parse(declarator.expression).Value
				);

				pSb.Append(sb.ToString());
				pSb.AppendLine();
			}
		}
예제 #48
0
		private static void parseReturnStatement(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			CsReturnStatement returnStatement = (CsReturnStatement) pStatement;
			if (returnStatement.expression == null) {
				//pSb.AppendLine(InsideConstructor ? "return this" : InsideSetter ? "return value;" : "return;");
				pSb.AppendLine(InsideSetter ? "return value;" : "return;");

			} else {
				pSb.AppendFormat("return {0};", pCreator.Parse(returnStatement.expression).Value);
				pSb.AppendLine();
			}
		}
예제 #49
0
		private static void parseIfStatement(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			CsIfStatement ifStatement = (CsIfStatement)pStatement;

			pSb.AppendFormat("if ({0}){{", pCreator.Parse(ifStatement.condition));
			pSb.AppendLine();

			ParseNode(ifStatement.if_statement, pSb, pCreator);

			if (ifStatement.else_statement != null) {
				pSb.AppendLine();
				pSb.Append("} else {");
				pSb.AppendLine();
				pSb.AppendLine();
				ParseNode(ifStatement.else_statement, pSb, pCreator);
			}

			pSb.Append("}");
			pSb.AppendLine();
			pSb.AppendLine();
		}
예제 #50
0
		private static void parseWhileStatement(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			CsWhileStatement whileStatement = (CsWhileStatement)pStatement;

			pSb.AppendFormat("while ({0}){{", pCreator.Parse(whileStatement.condition));
			pSb.AppendLine();
			ParseNode(whileStatement.statement, pSb, pCreator);
			pSb.Append("}");
			pSb.AppendLine();
			pSb.AppendLine();
		}
예제 #51
0
        public void GenerateToJson(CodeBuilder codeBuilder, int indentLevel, StringBuilder appendBuilder, JsonType type, string valueGetter)
        {
            codeBuilder.MakeAppend(indentLevel, appendBuilder);

            string listName = $"list{_listNumber}";

            _listNumber++;

            codeBuilder.AppendLine(indentLevel, $"var {listName} = {valueGetter};");
            codeBuilder.AppendLine(indentLevel, $"if({listName} == null)");
            codeBuilder.AppendLine(indentLevel, "{");
            appendBuilder.Append("null");
            codeBuilder.MakeAppend(indentLevel + 1, appendBuilder);
            codeBuilder.AppendLine(indentLevel, "}");
            codeBuilder.AppendLine(indentLevel, "else");
            codeBuilder.AppendLine(indentLevel, "{");

            var listElementType = type.GenericArguments[0];
            var generator       = _getGeneratorForType(listElementType);

            appendBuilder.Append("[");
            codeBuilder.MakeAppend(indentLevel + 1, appendBuilder);



            codeBuilder.AppendLine(indentLevel + 1, $"for(int index = 0; index < {valueGetter}.Count-1; index++)");
            codeBuilder.AppendLine(indentLevel + 1, "{");

            generator.GenerateToJson(codeBuilder, indentLevel + 2, appendBuilder, listElementType, $"{listName}[index]");

            appendBuilder.Append(",");
            codeBuilder.MakeAppend(indentLevel + 2, appendBuilder);


            codeBuilder.AppendLine(indentLevel + 1, "}");

            codeBuilder.AppendLine(indentLevel + 1, $"if({valueGetter}.Count > 1)");
            codeBuilder.AppendLine(indentLevel + 1, "{");
            generator.GenerateToJson(codeBuilder, indentLevel + 2, appendBuilder, listElementType, $"{listName}[{valueGetter}.Count-1]");
            codeBuilder.AppendLine(indentLevel + 1, "}");

            appendBuilder.Append("]");
            codeBuilder.MakeAppend(indentLevel + 1, appendBuilder);
            codeBuilder.AppendLine(indentLevel, "}");
        }
예제 #52
0
    public void EmitRemoteCallClassBody(CodeBuilder b, string apiClassName, string apiFunctionName)
    {
        b.AppendLine();

        foreach (var arg in ManagedParameters)
        {
            arg.EmitRemoteCallFields(b);
        }

        if (!PublicReturnType.IsVoid)
        {
            PublicReturnType.EmitRemoteCallFields(b, "__retval");
        }

        b.AppendLine();
        if (ManagedParameters.Length > 0)
        {
            b.BeginBlock("protected override void WriteArgs(StreamHandler h)");
            foreach (var arg in ManagedParameters)
            {
                if (arg.ParameterType.IsIn)
                {
                    arg.EmitRemoteWrite(b);
                }
            }
            b.EndBlock();
            b.AppendLine();

            b.BeginBlock("protected override void ReadArgs(StreamHandler h)");
            foreach (var arg in ManagedParameters)
            {
                if (arg.ParameterType.IsIn)
                {
                    arg.EmitRemoteRead(b);
                }
            }
            b.EndBlock();
            b.AppendLine();
        }

        var outArgs = new List <Parameter>();

        foreach (var arg in ManagedParameters)
        {
            if (arg.ParameterType.IsOut)
            {
                outArgs.Add(arg);
            }
            else if (arg.ParameterType.IsStringCollectionType && arg.ParameterType.AsStringCollectionType.ClassName == "CfxStringList")
            {
                outArgs.Add(arg);
            }
        }

        if (outArgs.Count > 0 || !PublicReturnType.IsVoid)
        {
            b.BeginBlock("protected override void WriteReturn(StreamHandler h)");
            foreach (var arg in outArgs)
            {
                arg.EmitRemoteWrite(b);
            }
            if (!PublicReturnType.IsVoid)
            {
                b.AppendLine("h.Write(__retval);", PublicReturnType.PublicSymbol);
            }
            b.EndBlock();
            b.AppendLine();

            b.BeginBlock("protected override void ReadReturn(StreamHandler h)");
            foreach (var arg in outArgs)
            {
                arg.EmitRemoteRead(b);
            }
            if (!PublicReturnType.IsVoid)
            {
                b.AppendLine("h.Read(out __retval);", PublicReturnType.PublicSymbol);
            }
            b.EndBlock();
            b.AppendLine();
        }

        b.BeginBlock("protected override void RemoteProcedure()");
        EmitRemoteProcedure(b, apiClassName, apiFunctionName);
        b.EndBlock();
    }
예제 #53
0
		private static void parseSwitchStatement(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			CsSwitchStatement switchStatement = (CsSwitchStatement)pStatement;

			pSb.AppendFormat("switch ({0}){{", pCreator.Parse(switchStatement.expression).Value);
			pSb.AppendLine();
			pSb.Indent();

			foreach (CsSwitchSection caseNode in switchStatement.sections) {
				LinkedList<CsSwitchLabel> labels = caseNode.labels;
				foreach (CsSwitchLabel label in labels){
					if (label.default_label) {
						pSb.Append("default:");
						pSb.AppendLine();

					} else {
						Expression txt = pCreator.Parse(label.expression);
						pSb.AppendFormat("case {0}:", txt.Value);
						pSb.AppendLine();
					}
				}

				foreach (CsStatement statementNode in caseNode.statements) {
					pSb.Indent();
					parseStatement(statementNode, pSb, pCreator);
					pSb.Unindent();
				}
			}

			pSb.Unindent();
			pSb.Append("}");
			pSb.AppendLine();
		}
        public static MonoScript CreateOrEditCustomBlackboard(string path, InternalBlackboard blackboard)
        {
            try {
                // opens the file if it allready exists, creates it otherwise
                using (FileStream stream = File.Open(path, FileMode.Create, FileAccess.Write)) {
                    // Create the string builder
                    var code = new CodeBuilder();
                    // Has Namespace
                    bool hasNamespace = !string.IsNullOrEmpty(blackboard.Namespace);

                    // Add header
                    code.AppendLine(BlackboardCodeGenerator.GetHeader());
                    // Add namespaces
                    code.AppendLine("using UnityEngine;");
                    code.AppendLine("using BehaviourMachine;");
                    code.AppendLine();

                    // Add namespace?
                    if (hasNamespace)
                    {
                        code.AppendLine("namespace " + blackboard.Namespace + " {");
                        // Add more one tab
                        code.tabSize += 1;
                    }

                    // It is the GlobalBlackboard?
                    if (blackboard.GetType().Name == "GlobalBlackboard")
                    {
                        // Add Componente Menu
                        code.AppendLine("[AddComponentMenu(\"\")]");
                        // Add class
                        code.AppendLine("public class " + BlackboardCodeGenerator.GetClassName(path) + " : InternalGlobalBlackboard {");
                        // Add more one tab
                        code.tabSize += 1;

                        // Add Instance property
                        code.AppendLine("/// <summary>");
                        code.AppendLine("/// The GlobalBlackboard instance.");
                        code.AppendLine("/// </summary>");
                        code.AppendLine("public static new GlobalBlackboard Instance {get {return InternalGlobalBlackboard.Instance as GlobalBlackboard;}}");
                        code.AppendLine();
                    }
                    else
                    {
                        // Add class
                        code.AppendLine("public class " + BlackboardCodeGenerator.GetClassName(path) + " : Blackboard {");
                        // Add more one tab
                        code.tabSize += 1;
                    }

                    // FloatVar
                    FloatVar[] floatVars = blackboard.floatVars;
                    if (floatVars.Length > 0)
                    {
                        code.AppendLine("// FloatVars");
                        for (int i = 0; i < floatVars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(floatVars[i]));
                        }
                    }

                    // IntVar
                    IntVar[] intVars = blackboard.intVars;
                    if (intVars.Length > 0)
                    {
                        code.AppendLine("// IntVars");
                        for (int i = 0; i < intVars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(intVars[i]));
                        }
                    }

                    // BoolVar
                    BoolVar[] boolVars = blackboard.boolVars;
                    if (boolVars.Length > 0)
                    {
                        code.AppendLine("// BoolVars");
                        for (int i = 0; i < boolVars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(boolVars[i]));
                        }
                    }

                    // StringVar
                    StringVar[] stringVars = blackboard.stringVars;
                    if (stringVars.Length > 0)
                    {
                        code.AppendLine("// StringVars");
                        for (int i = 0; i < stringVars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(stringVars[i]));
                        }
                    }

                    // Vector3Var
                    Vector3Var[] vector3Vars = blackboard.vector3Vars;
                    if (vector3Vars.Length > 0)
                    {
                        code.AppendLine("// Vector3Vars");
                        for (int i = 0; i < vector3Vars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(vector3Vars[i]));
                        }
                    }

                    // RectVar
                    RectVar[] rectVars = blackboard.rectVars;
                    if (rectVars.Length > 0)
                    {
                        code.AppendLine("// RectVars");
                        for (int i = 0; i < rectVars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(rectVars[i]));
                        }
                    }

                    // ColorVar
                    ColorVar[] colorVars = blackboard.colorVars;
                    if (colorVars.Length > 0)
                    {
                        code.AppendLine("// ColorVars");
                        for (int i = 0; i < colorVars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(colorVars[i]));
                        }
                    }

                    // QuaternionVar
                    QuaternionVar[] quaternionVars = blackboard.quaternionVars;
                    if (quaternionVars.Length > 0)
                    {
                        code.AppendLine("// QuaternionVars");
                        for (int i = 0; i < quaternionVars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(quaternionVars[i]));
                        }
                    }

                    // GameObjectVar
                    GameObjectVar[] gameObjectVars = blackboard.gameObjectVars;
                    if (gameObjectVars.Length > 0)
                    {
                        code.AppendLine("// GameObjectVars");
                        for (int i = 0; i < gameObjectVars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(gameObjectVars[i]));
                        }
                    }

                    // TextureVar
                    TextureVar[] textureVars = blackboard.textureVars;
                    if (textureVars.Length > 0)
                    {
                        code.AppendLine("// TextureVars");
                        for (int i = 0; i < textureVars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(textureVars[i]));
                        }
                    }

                    // MaterialVar
                    MaterialVar[] materialVars = blackboard.materialVars;
                    if (materialVars.Length > 0)
                    {
                        code.AppendLine("// MaterialVars");
                        for (int i = 0; i < materialVars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(materialVars[i]));
                        }
                    }

                    // ObjectVar
                    ObjectVar[] objectVars = blackboard.objectVars;
                    if (objectVars.Length > 0)
                    {
                        code.AppendLine("// ObjectVars");
                        for (int i = 0; i < objectVars.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(objectVars[i]));
                        }
                    }

                    // FsmEvents
                    FsmEvent[] fsmEvents = blackboard.fsmEvents;
                    if (fsmEvents.Length > 0)
                    {
                        code.AppendLine("// FsmEvents");
                        for (int i = 0; i < fsmEvents.Length; i++)
                        {
                            code.AppendLine(BlackboardCodeGenerator.GetVariableMember(fsmEvents[i]));
                        }
                    }

                    // Remove one tab
                    code.tabSize -= 1;

                    // Close class brackets
                    code.AppendLine("}");

                    // Close namespace brackets
                    if (hasNamespace)
                    {
                        // Remove one tab
                        code.tabSize -= 1;
                        // Close brackets
                        code.AppendLine("}");
                    }

                    // Write data on file
                    using (StreamWriter writer = new StreamWriter(stream)) {
                        writer.Write(code.ToString());
                    }
                }

                AssetDatabase.Refresh();
                return(AssetDatabase.LoadAssetAtPath(path, typeof(MonoScript)) as MonoScript);
            }
            catch (System.Exception e) {
                Debug.LogException(e);
                return(null);
            }
        }
예제 #55
0
		private static void parseExpressionStatement(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			Expression ex = pCreator.Parse(((CsExpressionStatement)pStatement).expression);
			pSb.Append(ex.Value+";");
			pSb.AppendLine();
		}
 public override void EmitPrePublicCallStatements(CodeBuilder b, string var)
 {
     base.EmitPrePublicCallStatements(b, var);
     b.AppendLine("int {0}_nomem;", var);
 }
예제 #57
0
		private static void parseContinueStatement(CsStatement pStatement, CodeBuilder pSb, FactoryExpressionCreator pCreator) {
			//CsContinueStatement continueStatement = (CsContinueStatement)pStatement;

			pSb.Append("continue");
			pSb.AppendLine();
			pSb.AppendLine();
		}
 public override void EmitPostNativeCallStatements(CodeBuilder b, string var)
 {
     b.AppendLine("if({0}_tmp) free({0}_tmp);", var);
 }
예제 #59
0
		public void WriteCode(ITemplate tpl, FragmentCodePoint point, CodeBuilder cb) {
			cb.AppendLine(ParserUtils.RenderFunctionStringBuilderName + ".Append(PositionHelper.CreateStyle(Position, -1, -1));");
		}
 public override void EmitPublicEventCtorStatements(CodeBuilder b, string var)
 {
     b.AppendLine("m_{0} = {0};", var);
     b.AppendLine("m_{0}_structsize = {0}_structsize;", var);
     b.AppendLine("m_{0} = {0};", CountArg.VarName);
 }