本文整理汇总了C#中Op.GenerateStructCode方法的典型用法代码示例。如果您正苦于以下问题:C# Op.GenerateStructCode方法的具体用法?C# Op.GenerateStructCode怎么用?C# Op.GenerateStructCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Op
的用法示例。
在下文中一共展示了Op.GenerateStructCode方法的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());
}