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

Function buildCCPPFunctionPointers

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

Source from the content-addressed store, hash-verified

536
537
538func buildCCPPFunctionPointers(component ComponentDefinition, w LanguageWriter, NameSpace string, useCPPTypes bool) (error) {
539 if len(component.Functions) == 0 {
540 return nil
541 }
542
543 w.Writeln("/*************************************************************************************************************************");
544 w.Writeln(" Declaration of function pointers ");
545 w.Writeln("**************************************************************************************************************************/");
546 for i := 0; i < len(component.Functions); i++ {
547 functiontype := component.Functions[i]
548 returnType := "void"
549 parameters := ""
550
551 w.Writeln("");
552 w.Writeln("/**");
553 if (useCPPTypes) {
554 w.Writeln("* %s - %s", functiontype.FunctionName, functiontype.FunctionDescription )
555 } else {
556 w.Writeln("* %s%s - %s", NameSpace, functiontype.FunctionName, functiontype.FunctionDescription )
557 }
558
559 w.Writeln("*")
560 for j := 0; j < len(functiontype.Params); j++ {
561 param := functiontype.Params[j]
562
563 cParams, err := generateCCPPParameter(param, "", functiontype.FunctionName, NameSpace, useCPPTypes)
564 if (err != nil) {
565 return err;
566 }
567 for _, cParam := range cParams {
568 w.Writeln(cParam.ParamComment);
569
570 if (parameters != "") {
571 parameters = parameters + ", "
572 }
573 parameters = parameters + cParam.ParamType
574 }
575 }
576 w.Writeln("*/");
577 if (useCPPTypes) {
578 w.Writeln("typedef %s(*%s)(%s);", returnType, functiontype.FunctionName, parameters);
579 } else {
580 w.Writeln("typedef %s(*%s%s)(%s);", returnType, NameSpace, functiontype.FunctionName, parameters);
581 }
582 }
583 w.Writeln("");
584 return nil
585}
586
587func getCParameterTypeName(ParamTypeName string, NameSpace string, ParamClass string)(string, error) {
588 paramNameSpace, paramClassName, err := decomposeParamClassName(ParamClass)

Callers 1

buildCCPPTypesHeaderFunction · 0.85

Calls 2

generateCCPPParameterFunction · 0.85
WritelnMethod · 0.80

Tested by

no test coverage detected