MCPcopy Create free account
hub / github.com/Autodesk/AutomaticComponentToolkit / buildCCPPEnums

Function buildCCPPEnums

Source/languagec.go:481–535  ·  view source on GitHub ↗
(component ComponentDefinition, w LanguageWriter, NameSpace string, useCPPTypes bool)

Source from the content-addressed store, hash-verified

479}
480
481func buildCCPPEnums(component ComponentDefinition, w LanguageWriter, NameSpace string, useCPPTypes bool) (error) {
482 if (len(component.Enums) == 0) {
483 return nil
484 }
485
486 w.Writeln("/*************************************************************************************************************************");
487 w.Writeln(" Declaration of enums");
488 w.Writeln("**************************************************************************************************************************/");
489 w.Writeln("");
490
491 for i := 0; i < len(component.Enums); i++ {
492 enum := component.Enums[i];
493 if (useCPPTypes) {
494 w.Writeln("enum class e%s : %s_int32 {", enum.Name, NameSpace);
495 } else {
496 w.Writeln("typedef enum e%s%s {", NameSpace, enum.Name);
497 }
498
499 for j := 0; j < len(enum.Options); j++ {
500 comma := "";
501 if (j < len(enum.Options) - 1) {
502 comma = ",";
503 }
504 option := enum.Options[j];
505 if (useCPPTypes) {
506 w.Writeln(" %s = %d%s", option.Name, option.Value, comma);
507 } else {
508 w.Writeln(" e%s%s = %d%s", enum.Name, option.Name, option.Value, comma);
509 }
510 }
511 if (useCPPTypes) {
512 w.Writeln("};");
513 } else {
514 w.Writeln("} e%s%s;", NameSpace, enum.Name);
515 }
516 w.Writeln("");
517 }
518
519 if (!useCPPTypes) {
520 w.Writeln("/*************************************************************************************************************************");
521 w.Writeln(" Declaration of enum members for 4 byte struct alignment");
522 w.Writeln("**************************************************************************************************************************/");
523 w.Writeln("");
524
525 for i := 0; i < len(component.Enums); i++ {
526 enum := component.Enums[i];
527 w.Writeln("typedef union {");
528 w.Writeln(" e%s%s m_enum;", NameSpace, enum.Name);
529 w.Writeln(" int m_code;");
530 w.Writeln("} structEnum%s%s;", NameSpace, enum.Name);
531 w.Writeln("");
532 }
533 }
534 return nil
535}
536
537
538func buildCCPPFunctionPointers(component ComponentDefinition, w LanguageWriter, NameSpace string, useCPPTypes bool) (error) {

Callers 1

buildCCPPTypesHeaderFunction · 0.85

Calls 1

WritelnMethod · 0.80

Tested by

no test coverage detected