(component ComponentDefinition, w LanguageWriter, NameSpace string, useCPPTypes bool)
| 175 | } |
| 176 | |
| 177 | func buildCCPPTypesHeader(component ComponentDefinition, w LanguageWriter, NameSpace string, useCPPTypes bool) (error) { |
| 178 | sIncludeGuard := "__"+strings.ToUpper(NameSpace)+"_TYPES_HEADER" |
| 179 | if useCPPTypes { |
| 180 | sIncludeGuard += "_CPP" |
| 181 | } |
| 182 | |
| 183 | w.Writeln("#ifndef %s", sIncludeGuard); |
| 184 | w.Writeln("#define %s", sIncludeGuard); |
| 185 | w.Writeln(""); |
| 186 | |
| 187 | if (!useCPPTypes) { |
| 188 | w.Writeln("#include <stdbool.h>"); |
| 189 | } |
| 190 | w.Writeln(""); |
| 191 | |
| 192 | err := buildSharedCCPPTypesHeader(component, w, NameSpace) |
| 193 | if (err != nil) { |
| 194 | return err |
| 195 | } |
| 196 | |
| 197 | if useCPPTypes { |
| 198 | w.Writeln("namespace %s {", NameSpace); |
| 199 | w.Writeln(""); |
| 200 | w.AddIndentationLevel(1); |
| 201 | } |
| 202 | |
| 203 | err = buildCCPPEnums(component, w, NameSpace, useCPPTypes) |
| 204 | if (err!=nil) { |
| 205 | return err |
| 206 | } |
| 207 | err = buildCCPPStructs(component, w, NameSpace, useCPPTypes) |
| 208 | if (err!=nil) { |
| 209 | return err |
| 210 | } |
| 211 | err = buildCCPPFunctionPointers(component, w, NameSpace, useCPPTypes) |
| 212 | if (err != nil) { |
| 213 | return err |
| 214 | } |
| 215 | |
| 216 | if (useCPPTypes) { |
| 217 | w.AddIndentationLevel(-1); |
| 218 | w.Writeln("} // namespace %s;", NameSpace); |
| 219 | w.Writeln("") |
| 220 | w.Writeln("// define legacy C-names for enums, structs and function types") |
| 221 | for i := 0; i < len(component.Enums); i++ { |
| 222 | enum := component.Enums[i]; |
| 223 | w.Writeln("typedef %s::e%s e%s%s;", NameSpace, enum.Name, NameSpace, enum.Name); |
| 224 | } |
| 225 | for i := 0; i < len(component.Structs); i++ { |
| 226 | structinfo := component.Structs[i]; |
| 227 | w.Writeln("typedef %s::s%s s%s%s;", NameSpace, structinfo.Name, NameSpace, structinfo.Name); |
| 228 | } |
| 229 | for i := 0; i < len(component.Functions); i++ { |
| 230 | functiontype := component.Functions[i] |
| 231 | w.Writeln("typedef %s::%s %s%s;", NameSpace, functiontype.FunctionName, NameSpace, functiontype.FunctionName); |
| 232 | } |
| 233 | } |
| 234 |
no test coverage detected