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

Function buildGoExample

Source/buildbindinggo.go:97–146  ·  view source on GitHub ↗
(component ComponentDefinition, w LanguageWriter, outputFolder string)

Source from the content-addressed store, hash-verified

95}
96
97func buildGoExample(component ComponentDefinition, w LanguageWriter, outputFolder string) {
98 packageName := component.BaseName
99 NameSpace := component.NameSpace
100
101 w.Writeln("")
102 w.Writeln("package main")
103 w.Writeln("")
104 w.Writeln("import (")
105 w.Writeln(" \"fmt\"")
106 w.Writeln(" \"log\"")
107 w.Writeln(" \"../../Bindings/Go\"")
108 w.Writeln(")")
109 w.Writeln("")
110 w.Writeln("func main() {")
111 w.Writeln(" wrapper, err := %s.%sLoadWrapper(\"../../Implementations/Cpp/build/Debug/%s.dll\") // TODO: add-path here", packageName, NameSpace, component.BaseName)
112 w.Writeln(" if (err != nil) {")
113 w.Writeln(" log.Fatal(err)")
114 w.Writeln(" }")
115 w.Writeln(" ")
116 w.Writeln(" nMajor, nMinor, nMicro, err := wrapper.%s()", component.Global.VersionMethod)
117 w.Writeln(" if (err != nil) {")
118 w.Writeln(" log.Fatal(err)")
119 w.Writeln(" }")
120 w.Writeln(" versionString := fmt.Sprintf(\"%s.version = %s\", nMajor, nMinor, nMicro)", component.BaseName, "%d.%d.%d")
121 w.Writeln(" ")
122 if len(component.Global.PrereleaseMethod) > 0 {
123 w.Writeln(" hasInfo, preReleaseInfo, err := wrapper.%s()", component.Global.PrereleaseMethod)
124 w.Writeln(" if (err != nil) {")
125 w.Writeln(" log.Fatal(err)")
126 w.Writeln(" }")
127 w.Writeln(" if (hasInfo) {")
128 w.Writeln(" versionString += \"-\"+preReleaseInfo")
129 w.Writeln(" }")
130 w.Writeln("")
131 }
132 if len(component.Global.BuildinfoMethod) > 0 {
133 w.Writeln(" hasInfo, buildInfo, err := wrapper.%s()", component.Global.BuildinfoMethod)
134 w.Writeln(" if (err != nil) {")
135 w.Writeln(" log.Fatal(err)")
136 w.Writeln(" }")
137 w.Writeln(" if (hasInfo) {")
138 w.Writeln(" versionString += \"+\"+buildInfo")
139 w.Writeln(" }")
140 w.Writeln("")
141 }
142
143 w.Writeln(" fmt.Println(versionString)")
144 w.Writeln("}")
145 w.Writeln("")
146}
147
148
149func buildGoEnums(component ComponentDefinition, w LanguageWriter) {

Callers 1

BuildBindingGoFunction · 0.85

Calls 1

WritelnMethod · 0.80

Tested by

no test coverage detected