当前位置: 首页>>代码示例>>C#>>正文


C# Op.GenerateHandlerDecleration方法代码示例

本文整理汇总了C#中Op.GenerateHandlerDecleration方法的典型用法代码示例。如果您正苦于以下问题:C# Op.GenerateHandlerDecleration方法的具体用法?C# Op.GenerateHandlerDecleration怎么用?C# Op.GenerateHandlerDecleration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Op的用法示例。


在下文中一共展示了Op.GenerateHandlerDecleration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main


//.........这里部分代码省略.........

            if (paramType == "literal")
            {
              paramType = "LiteralNumber";
              paramName = paramName.Replace("See", "").Replace(".", "").Trim('[', ']');
            }
            else if(paramType == "optionalliteral(s)")
            {
              isList = true;
              paramType = "LiteralNumber";
              paramName = paramName.Replace("See", "").Replace(".", "").Trim('[', ']');
            }
              }

              if (isList)
              {
            paramName = paramName.Replace("0", "").Replace("1", "").Replace(",", "").Trim('[', ']');
            if (!paramName.EndsWith("s"))
            {
              paramName += "s";
            }
              }

              switch (paramName)
              {
            case "Thenameoftheopaquetype.": paramName = "OpaqueTypeName"; break;
              }

              op.Parameters.Add(new Parameter() { Type = paramType, Name = paramName, IsList = isList });
            }
            ops.Add(op);
              }

              ops = ops.OrderBy(o => o.Index).ToList();

              ops.ForEach(o => Console.WriteLine(o));

              StringBuilder fileContents = new StringBuilder();

              fileContents.AppendLine("#pragma once");
              fileContents.AppendLine("#include \"types.h\"");
              fileContents.AppendLine("#include \"lookups.h\"");
              fileContents.AppendLine("");

              fileContents.AppendLine("struct Program;");

              fileContents.AppendLine("");
              fileContents.AppendLine("#pragma pack(push, 1)");

              foreach (var op in ops)
              {
            fileContents.AppendLine(op.GenerateHandlerDecleration() + ";");
            fileContents.AppendLine(op.GenerateStructCode());
              }
              fileContents.AppendLine("#pragma pack(pop)");

              fileContents.AppendLine("");
              foreach (var op in ops)
              {
            fileContents.AppendLine(op.GenerateLookupCode());
              }

              fileContents.AppendLine("static void* LUTOpWordTypes[] {");
              foreach (var op in ops)
              {
            fileContents.AppendLine(string.Format("  &{0}WordTypes,", op.Name));
              }
              fileContents.AppendLine("};");
              fileContents.AppendLine("");

              fileContents.AppendLine("static uint32 LUTOpWordTypesCount[] {");
              foreach (var op in ops)
              {
            fileContents.AppendLine(string.Format("  {0}WordTypesCount,", op.Name));
              }
              fileContents.AppendLine("};");
              fileContents.AppendLine("");

              fileContents.AppendLine("typedef void(*OpHandler)(void*, Program*);");
              fileContents.AppendLine("static OpHandler LUTHandlerMethods[] {");
              foreach (var op in ops)
              {
            fileContents.AppendLine(string.Format("  Handle{0},", op.Name));
              }
              fileContents.AppendLine("};");
              File.WriteAllText("lookups_gen.h", fileContents.ToString());

              fileContents.Clear();
              fileContents.AppendLine("#include \"lookups_gen.h\"");
              fileContents.AppendLine("#include \"parser_definitions.h\"");
              fileContents.AppendLine("");

              foreach (var op in ops)
              {
            fileContents.AppendLine(op.GenerateHandlerDecleration() + " {");
            fileContents.AppendLine(String.Format("  S{0}* op{0} = (S{0}*)op;", op.Name));
            fileContents.AppendLine("}\n");
              }
              File.WriteAllText("lookups_gen.cpp", fileContents.ToString());
        }
开发者ID:syoyo,项目名称:otherside,代码行数:101,代码来源:Program.cs


注:本文中的Op.GenerateHandlerDecleration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。