You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently ACT does not support generic classes (aka template classes) which makes it hard to define certain types such as (type-safe) generic containers and algorithms.
For example, to define types like Map<int,IFoo*>, Map<string,IBar*>, and Map<int,double> in the API today, you would need to define the following:
<classname="Map"abstract="true">
<!-- Base methods that do not use the value type (Size, IsEmpty, etc.) -->
</class>
<classname="IntFooMap"parent="Map">
<!-- Methods with key type="int32" and value type="class" class="Foo" -->
</class>
<classname="StringBarMap">
<!-- Same methods copy-pasted, but with key type="string" and value type="class" class="Bar" -->
</class>
<classname="IntDoubleMap">
<!-- Same methods copy-pasted, but with key type="int32" and value type="double" -->
</class>
This quickly becomes unmaintainable as for N instantiations you need to:
Copy-paste and adjust the method definitions N times
Maintain N implementation classes by:
Writing the same code N times, or
Writing a generic Map class yourself and inheriting from that N times (something like class StringBarMap : public Map<std::string, IBar*>)
Instead, ACT could provide support for generic classes, and it could look something like this (following previous discussions with @martinweismann and @alexanderoster):
<templateclassname="Map">
<!-- template<typename TKey, typename TValue> -->
<templateparamname="TKey"description="" />
<templateparamname="TValue"description="" />
<!-- template methods -->
<templatemethodname="Add"description="adds an entry to the map.">
<paramname="Key"type="template"templateparam="TKey"pass="in"description="Key String."/>
<paramname="Value"type="template"templateparam="TValue"pass="in"description="Value to store."/>
</templatemethod>
<templatemethodname="Get"description="returns an entry of the map.">
<paramname="Key"type="template"templateparam="TKey"pass="in"description="Key String."/>
<paramname="Instance"type="template"templateparam="TValue"pass="return"description="Class Instance."/>
</templatemethod>
<templatemethodname="GetOut"description="returns an entry of the map.">
<paramname="Key"type="template"templateparam="TKey"pass="in"description="Key String."/>
<paramname="Instance"type="template"templateparam="TValue"pass="out"description="Class Instance."/>
</templatemethod>
<!-- non-template methods -->
<methodname="Clear"description="clears the map." />
<methodname="Count"description="returns the entry count of the map.">
<paramname="Count"type="uint32"pass="return"description="Entry count of the map."/>
</method>
</templateclass>
<classname="IntFooMap"parent="Map">
<templateargparam="TKey"type="int32"/>
<templateargparam="TValue"type="class"class="Foo" />
</class>
<classname="StringBarMap"parent="Map">
<templateargparam="TKey"type="string"/>
<templateargparam="TValue"type="class"class="Bar" />
</class>
<classname="IntDoubleMap"parent="Map">
<templateargparam="TKey"type="int32"/>
<templateargparam="TValue"type="double" />
</class>
The implementation stubs could then be generated as follows:
Currently ACT does not support generic classes (aka template classes) which makes it hard to define certain types such as (type-safe) generic containers and algorithms.
For example, to define types like
Map<int,IFoo*>
,Map<string,IBar*>
, andMap<int,double>
in the API today, you would need to define the following:This quickly becomes unmaintainable as for N instantiations you need to:
Map
class yourself and inheriting from that N times (something likeclass StringBarMap : public Map<std::string, IBar*>
)Instead, ACT could provide support for generic classes, and it could look something like this (following previous discussions with @martinweismann and @alexanderoster):
The implementation stubs could then be generated as follows:
And the bindings:
The API author would then only need to implement the template class CMap once.
Notes:
const std::string&
/std::string &
/std::string
)pLhs->Compare(pRhs)
?pLhs < pRhs
?The text was updated successfully, but these errors were encountered: