Example #1
0
 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);
         }
     }
 }
Example #2
0
        public string GenerateEnumDeclaration(string aIndent, string aEnumName, EnumCType aEnumType)
        {
            ApiEnumConfiguration configuration;

            iEnumConfigurations.TryGetValue(aEnumName, out configuration);
            string managedName = configuration != null ? configuration.ManagedName : null;

            managedName = managedName ?? DefaultManagedEnumName(aEnumName);
            string memberPrefix = configuration != null ? configuration.NativeConstantPrefix : null;

            memberPrefix = memberPrefix ?? DefaultNativeConstantPrefix(aEnumName);
            string managedMemberPrefix = configuration != null ? configuration.ManagedConstantPrefix : null;

            managedMemberPrefix = managedMemberPrefix ?? "";
            var constantStrings = aEnumType.Constants.Select(x =>
                                                             String.Format(
                                                                 EnumConstantTemplate,
                                                                 aIndent + SingleIndent,
                                                                 managedMemberPrefix + PascalCaseMemberName(DropPrefix(x.Name, memberPrefix)),
                                                                 x.Value));
            var joinedConstantStrings = String.Join("", constantStrings);

            return(String.Format(EnumTemplate, aIndent, managedName, joinedConstantStrings).Replace("\n", Environment.NewLine));
        }
Example #3
0
 public string GenerateEnumDeclaration(string aIndent, string aEnumName, EnumCType aEnumType)
 {
     ApiEnumConfiguration configuration;
     iEnumConfigurations.TryGetValue(aEnumName, out configuration);
     string managedName = configuration != null ? configuration.ManagedName : null;
     managedName = managedName ?? DefaultManagedEnumName(aEnumName);
     string memberPrefix = configuration != null ? configuration.NativeConstantPrefix : null;
     memberPrefix = memberPrefix ?? DefaultNativeConstantPrefix(aEnumName);
     string managedMemberPrefix = configuration != null ? configuration.ManagedConstantPrefix : null;
     managedMemberPrefix = managedMemberPrefix ?? "";
     var constantStrings = aEnumType.Constants.Select(x =>
         String.Format(
             EnumConstantTemplate,
             aIndent + SingleIndent,
             managedMemberPrefix + PascalCaseMemberName(DropPrefix(x.Name, memberPrefix)),
             x.Value));
     var joinedConstantStrings = String.Join("", constantStrings);
     return String.Format(EnumTemplate, aIndent, managedName, joinedConstantStrings).Replace("\n", Environment.NewLine);
 }