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

Function buildCPPStubClass

Source/buildimplementationcpp.go:910–1114  ·  view source on GitHub ↗
(component ComponentDefinition, class ComponentDefinitionClass, NameSpace string, NameSpaceImplementation string, ClassIdentifier string, BaseName string, outputFolder string, indentString string, stubIdentifier string, forceRecreation bool)

Source from the content-addressed store, hash-verified

908
909
910func buildCPPStubClass(component ComponentDefinition, class ComponentDefinitionClass, NameSpace string, NameSpaceImplementation string, ClassIdentifier string, BaseName string, outputFolder string, indentString string, stubIdentifier string, forceRecreation bool) error {
911 outClassName := "C" + ClassIdentifier + class.ClassName
912
913 StubHeaderFileName := path.Join(outputFolder, BaseName + stubIdentifier + "_" +strings.ToLower(class.ClassName)+".hpp");
914 StubImplFileName := path.Join(outputFolder, BaseName + stubIdentifier + "_" + strings.ToLower(class.ClassName)+".cpp");
915 if !forceRecreation && ( FileExists(StubHeaderFileName) || FileExists(StubImplFileName) ) {
916 log.Printf("Omitting recreation of Stub implementation for \"%s\"", outClassName)
917 return nil
918 }
919
920 log.Printf("Creating \"%s\"", StubHeaderFileName)
921 stubheaderw, err := CreateLanguageFile(StubHeaderFileName, indentString)
922 if err != nil {
923 return err
924 }
925 stubheaderw.WriteCLicenseHeader(component,
926 fmt.Sprintf("This is the class declaration of %s", outClassName),
927 false)
928
929 log.Printf("Creating \"%s\"", StubImplFileName)
930 stubimplw, err := CreateLanguageFile(StubImplFileName, indentString)
931 if err != nil {
932 return err
933 }
934 stubimplw.WriteCLicenseHeader(component,
935 fmt.Sprintf("This is a stub class definition of %s", outClassName),
936 false)
937
938 stubheaderw.Writeln("")
939 stubheaderw.Writeln("#ifndef __%s_%s", strings.ToUpper(NameSpace), strings.ToUpper(class.ClassName))
940 stubheaderw.Writeln("#define __%s_%s", strings.ToUpper(NameSpace), strings.ToUpper(class.ClassName))
941 stubheaderw.Writeln("")
942
943 stubheaderw.Writeln("#include \"%s_interfaces.hpp\"", BaseName)
944 if (component.isBaseClass(class)) {
945 stubheaderw.Writeln("#include <vector>")
946 stubheaderw.Writeln("#include <list>")
947 stubheaderw.Writeln("#include <memory>")
948 }
949 stubheaderw.Writeln("")
950
951 if (!component.isBaseClass(class)) {
952 if (class.ParentClass == "") {
953 class.ParentClass = component.Global.BaseClassName
954 }
955 }
956
957 if class.ParentClass != "" {
958 stubheaderw.Writeln("// Parent classes")
959 stubheaderw.Writeln("#include \"%s%s_%s.hpp\"", BaseName, stubIdentifier, strings.ToLower(class.ParentClass))
960 stubheaderw.Writeln("#ifdef _MSC_VER")
961 stubheaderw.Writeln("#pragma warning(push)")
962 stubheaderw.Writeln("#pragma warning(disable : 4250)")
963 stubheaderw.Writeln("#endif")
964 }
965 stubheaderw.Writeln("")
966
967 stubheaderw.Writeln("// Include custom headers here.")

Callers 1

buildCPPStubFunction · 0.85

Calls 13

FileExistsFunction · 0.85
CreateLanguageFileFunction · 0.85
ClearErrorMessageMethodFunction · 0.85
IncRefCountMethodFunction · 0.85
DecRefCountMethodFunction · 0.85
PrintfMethod · 0.80
WriteCLicenseHeaderMethod · 0.80
WritelnMethod · 0.80
isBaseClassMethod · 0.80

Tested by

no test coverage detected