Skip to content

Commit f46be73

Browse files
Add name to struct
Give a name to the function table structs based on the typedef name with "Struct" appended to make it unique.
1 parent 37ededc commit f46be73

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ debug
1818
*_component
1919

2020
Examples/*.xml
21+
*.txt
22+
*.py
23+
ACT.code-workspace
24+
test/AbstractCAM.xml
25+
test/dcamcomponents.xml

Source/buildbindingccpp.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func buildDynamicCCPPHeader(component ComponentDefinition, w LanguageWriter, Nam
246246
w.Writeln(" Function Table Structure")
247247
w.Writeln("**************************************************************************************************************************/")
248248
w.Writeln("")
249-
w.Writeln("typedef struct {")
249+
w.Writeln("typedef struct s%sDynamicWrapperTableStruct {", NameSpace)
250250
w.Writeln(" void * m_LibraryHandle;")
251251

252252
for i := 0; i < len(component.Classes); i++ {
@@ -267,22 +267,24 @@ func buildDynamicCCPPHeader(component ComponentDefinition, w LanguageWriter, Nam
267267

268268
for i := 0; i < len(component.Classes); i++ {
269269
class := component.Classes[i]
270+
structName := fmt.Sprintf("s%sFunctionTable%sStruct", NameSpace, class.ClassName)
271+
typedefName := fmt.Sprintf("s%sFunctionTable%s", NameSpace, class.ClassName)
270272
if len(class.ParentClass) > 0 {
271273
paramNameSpace, paramClassName, _ := decomposeParamClassName(class.ParentClass)
272274
if len(paramNameSpace) == 0 {
273-
w.Writeln("typedef struct : s%sFunctionTable%s {", NameSpace, class.ParentClass)
275+
w.Writeln("typedef struct %s : s%sFunctionTable%s {", structName, NameSpace, class.ParentClass)
274276
} else {
275-
w.Writeln("typedef struct : s%sFunctionTable%s {", component.ImportedComponentDefinitions[paramNameSpace].NameSpace, paramClassName)
277+
w.Writeln("typedef struct %s : s%sFunctionTable%s {", structName, component.ImportedComponentDefinitions[paramNameSpace].NameSpace, paramClassName)
276278
}
277279
} else {
278-
w.Writeln("typedef struct {")
280+
w.Writeln("typedef struct %s {", structName)
279281
}
280282

281283
for j := 0; j < len(class.Methods); j++ {
282284
method := class.Methods[j]
283285
w.Writeln(" P%s%s_%sPtr m_%s_%s;", NameSpace, class.ClassName, method.MethodName, class.ClassName, method.MethodName)
284286
}
285-
w.Writeln("} s%sFunctionTable%s;", NameSpace, class.ClassName)
287+
w.Writeln("} %s;", typedefName)
286288
w.Writeln("")
287289
}
288290

0 commit comments

Comments
 (0)