Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/ACT.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@
<xs:attribute name="baseclassname" type="ST_Name" use="required">
<xs:annotation><xs:documentation xml:lang="en">The &lt;baseclassname&gt; must match a class with the same name and specifies the name of a class that is the base class for all classes of the generated component.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="stringoutclass" type="ST_Name" use="optional">
<xs:annotation><xs:documentation xml:lang="en">The &lt;stringoutclass&gt; specifies the class used for the error method's instance parameter. Defaults to &lt;baseclassname&gt; if not specified.</xs:documentation></xs:annotation>
</xs:attribute>
<xs:attribute name="acquiremethod" type="ST_Name" use="required">
<xs:annotation><xs:documentation xml:lang="en">The &lt;acquiremethod&gt; must match a method with the same name and the correct signature.</xs:documentation></xs:annotation>
</xs:attribute>
Expand Down
6 changes: 3 additions & 3 deletions Source/buildimplementationcpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func buildCPPInterfaceWrapperMethods(component ComponentDefinition, class Compon

for j := 0; j < len(class.Methods); j++ {
method := class.Methods[j]
err := writeCImplementationMethod(component, method, w, BaseName, NameSpace, ClassIdentifier, class.ClassName, component.Global.BaseClassName, false, doJournal, eSpecialMethodNone)
err := writeCImplementationMethod(component, method, w, BaseName, NameSpace, ClassIdentifier, class.ClassName, component.Global.StringOutClass, false, doJournal, eSpecialMethodNone)
if err != nil {
return err
}
Expand Down Expand Up @@ -666,7 +666,7 @@ func buildCPPInterfaceWrapper(component ComponentDefinition, w LanguageWriter, N
journalParameter = fmt.Sprintf(", C%sInterfaceJournalEntry * pJournalEntry = nullptr", NameSpace)
}

IBaseClassName := "I" + ClassIdentifier + component.Global.BaseClassName
IBaseClassName := "I" + ClassIdentifier + component.Global.StringOutClass
registerErrorMethod := RegisterErrorMessageMethod()
w.Writeln("%sResult handle%sException(%s * pIBaseClass, E%sInterfaceException & Exception%s)", NameSpace, NameSpace, IBaseClassName, NameSpace, journalParameter)
w.Writeln("{")
Expand Down Expand Up @@ -759,7 +759,7 @@ func buildCPPInterfaceWrapper(component ComponentDefinition, w LanguageWriter, N
}

// Write Static function implementation
err = writeCImplementationMethod(component, method, w, BaseName, NameSpace, ClassIdentifier, "Wrapper", component.Global.BaseClassName, true, doMethodJournal, isSpecialFunction)
err = writeCImplementationMethod(component, method, w, BaseName, NameSpace, ClassIdentifier, "Wrapper", component.Global.StringOutClass, true, doMethodJournal, isSpecialFunction)
if err != nil {
return err
}
Expand Down
24 changes: 23 additions & 1 deletion Source/componentdefinition.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ type ComponentDefinitionGlobal struct {
ComponentDiffableElement
XMLName xml.Name `xml:"global"`
BaseClassName string `xml:"baseclassname,attr"`
StringOutClass string `xml:"stringoutclass,attr"`
ErrorMethod string `xml:"errormethod,attr"`
ReleaseMethod string `xml:"releasemethod,attr"`
AcquireMethod string `xml:"acquiremethod,attr"`
Expand Down Expand Up @@ -972,6 +973,10 @@ func (component *ComponentDefinition) CheckComponentDefinition() error {
if component.Global.BaseClassName == "" {
return errors.New("No base class name specified")
}
// Default StringOutClass to BaseClassName if not specified
if component.Global.StringOutClass == "" {
component.Global.StringOutClass = component.Global.BaseClassName
}
found := 0
for i := 0; i < len(component.Classes); i++ {
if component.Classes[i].ClassName == component.Global.BaseClassName {
Expand All @@ -983,6 +988,18 @@ func (component *ComponentDefinition) CheckComponentDefinition() error {
} else if found > 1 {
return errors.New("Base clase defined more than once")
}
// Validate StringOutClass references an existing class
if component.Global.StringOutClass != component.Global.BaseClassName {
foundStringOut := 0
for i := 0; i < len(component.Classes); i++ {
if component.Classes[i].ClassName == component.Global.StringOutClass {
foundStringOut++
}
}
if foundStringOut == 0 {
return errors.New("Specified stringoutclass not found")
}
}
return nil
}

Expand Down Expand Up @@ -1103,10 +1120,15 @@ func CheckHeaderSpecialFunction(method ComponentDefinitionMethod, global Compone
return eSpecialMethodNone, errors.New("Error method does not match the expected function template")
}

// Use StringOutClass if specified, otherwise fall back to BaseClassName
errorMethodClass := global.StringOutClass
if errorMethodClass == "" {
errorMethodClass = global.BaseClassName
}
if (method.Params[0].ParamType != "class") || (method.Params[0].ParamPass != "in") ||
(method.Params[1].ParamType != "string") || (method.Params[1].ParamPass != "out") ||
(method.Params[2].ParamType != "bool") || (method.Params[2].ParamPass != "return") ||
(method.Params[0].ParamClass != global.BaseClassName) {
(method.Params[0].ParamClass != errorMethodClass) {
return eSpecialMethodNone, errors.New("Error method does not match the expected function template")
}

Expand Down
7 changes: 7 additions & 0 deletions Source/componentdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,13 @@ func diffGlobal(path string, globalA ComponentDefinitionGlobal, globalB Componen
change.NewValue = globalB.JournalMethod
changes = append(changes, change)
}
if globalA.StringOutClass != globalB.StringOutClass {
var change ComponentDiffAttributeChange
change.Path = pathA + "/stringoutclass"
change.OldValue = globalA.StringOutClass
change.NewValue = globalB.StringOutClass
changes = append(changes, change)
}
if globalA.ReleaseMethod != globalB.ReleaseMethod {
var change ComponentDiffAttributeChange
change.Path = pathA + "/releasemethod"
Expand Down