public string GenerateStruct(string aIndent, string aStructName, StructCType aStructType) { var fieldStrings = aStructType.Fields.Select(x => { var csharpType = GetCSharpMarshalType(x.CType, x.Name, false); var attribute = csharpType.CreateFieldAttribute(); if (attribute != "") { attribute = aIndent + SingleIndent + attribute + "\n"; } return(String.Format( StructFieldTemplate, aIndent + SingleIndent, csharpType.CreateFieldDeclaration(x.Name), attribute)); }); var joinedFieldStrings = String.Join("", fieldStrings); ApiStructConfiguration config; if (!iStructConfigurations.TryGetValue(aStructName, out config)) { config = new ApiStructConfiguration { ManagedName = ManagedNameForNativeType(aStructName), NativeName = aStructName, ForcePublic = false }; } string visibility = config.ForcePublic ? "public" : "internal"; return(String.Format(StructTemplate, aIndent, config.ManagedName, joinedFieldStrings, visibility).Replace("\n", Environment.NewLine)); }
public void AddDeclarations(IEnumerable <Declaration> aDeclarations) { foreach (var decl in aDeclarations) { if (DeclarationsToIgnore.Contains(decl.Name)) { continue; } //== "sp_uint64" || decl.Name == "bool" || decl.Name == "byte") continue; if (decl.Kind == "typedef") { StructCType structType = decl.CType as StructCType; EnumCType enumType = decl.CType as EnumCType; FunctionCType functionType = decl.CType as FunctionCType; if (structType != null) { if (structType.Fields == null) { HandleTable.Add(decl.Name); } else { StructTable.Add(decl.Name, structType); } } else if (enumType != null) { EnumTable.Add(decl.Name, enumType); } else if (functionType != null) { FunctionTypedefTable.Add(decl.Name, functionType); } } else if (decl.Kind == "instance") { FunctionCType funcType = decl.CType as FunctionCType; if (funcType == null) { continue; } FunctionTable.Add(decl.Name, funcType); } } }
public string GenerateStruct(string aIndent, string aStructName, StructCType aStructType) { var fieldStrings = aStructType.Fields.Select(x => { var csharpType = GetCSharpMarshalType(x.CType, x.Name, false); var attribute = csharpType.CreateFieldAttribute(); if (attribute != "") attribute = aIndent + SingleIndent + attribute + "\n"; return String.Format( StructFieldTemplate, aIndent + SingleIndent, csharpType.CreateFieldDeclaration(x.Name), attribute); }); var joinedFieldStrings = String.Join("", fieldStrings); ApiStructConfiguration config; if (!iStructConfigurations.TryGetValue(aStructName, out config)) { config = new ApiStructConfiguration{ ManagedName = ManagedNameForNativeType(aStructName), NativeName = aStructName, ForcePublic = false }; } string visibility = config.ForcePublic ? "public" : "internal"; return String.Format(StructTemplate, aIndent, config.ManagedName, joinedFieldStrings, visibility).Replace("\n", Environment.NewLine); }