mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[sourcegen] Implement methods for specializations
This commit is contained in:
parent
fa3926ca0c
commit
ec9de7c897
@ -30,7 +30,8 @@ recipes:
|
||||
- name: isReversible
|
||||
- name: kineticsSpeciesIndex # previously: speciesIndex
|
||||
implements: Kinetics::kineticsSpeciesIndex(const string&)
|
||||
# - name: advanceCoverages # <--- needs to be implemented
|
||||
- name: advanceCoverages
|
||||
implements: InterfaceKinetics::advanceCoverages(double)
|
||||
# - name: getReactionString # <--- needs Reaction interface
|
||||
# - name: getReactionType # <--- needs Reaction interface
|
||||
# - name: getSourceTerms # <--- used by MATLAB interface for "massProdRate"
|
||||
|
@ -3,11 +3,12 @@
|
||||
|
||||
docstring: |-
|
||||
Auto-generated CLib API for %Cantera's ThermoPhase class.
|
||||
Partially implements a replacement for CLib's traditional @c ct library.
|
||||
Partially implements a replacement for CLib's traditional @c ct and
|
||||
@c ctsurf libraries.
|
||||
prefix: thermo3
|
||||
base: ThermoPhase
|
||||
parents: [Phase] # List of parent classes
|
||||
derived: [] # List of specializations
|
||||
derived: [SurfPhase] # List of specializations
|
||||
recipes:
|
||||
- name: report
|
||||
- name: name # previously: getName
|
||||
@ -126,6 +127,14 @@ recipes:
|
||||
- name: satPressure
|
||||
- name: setState_Psat
|
||||
- name: setState_Tsat
|
||||
- name: getCoverages # previously: used 'surf' prefix'
|
||||
- name: setCoverages # previously: used 'surf' prefix'
|
||||
- name: getConcentrations # previously: used 'surf' prefix'
|
||||
- name: setConcentrations # previously: used 'surf' prefix'
|
||||
- name: siteDensity # previously: used 'surf' prefix'
|
||||
- name: setSiteDensity # previously: used 'surf' prefix'
|
||||
- name: setCoveragesByName # previously: used 'surf' prefix'
|
||||
implements: SurfPhase::setCoveragesByName(const string&)
|
||||
- name: del
|
||||
what: noop
|
||||
brief: Destructor; required by some APIs although object is managed by Solution.
|
||||
|
@ -297,8 +297,9 @@ class CLibSourceGenerator(SourceGenerator):
|
||||
|
||||
ret = {
|
||||
"handle": handle, "lines": lines, "buffer": buffer, "uses": uses,
|
||||
"cxx_base": base, "cxx_name": cxx_func.name, "cxx_args": args,
|
||||
"cxx_implements": cxx_func.short_declaration(), "error": error,
|
||||
"base": base, "error": error,
|
||||
"cxx_base": cxx_func.base, "cxx_name": cxx_func.name, "cxx_args": args,
|
||||
"cxx_implements": cxx_func.short_declaration(),
|
||||
"c_func": c_func.name, "c_args": [arg.name for arg in c_func.arglist],
|
||||
}
|
||||
return ret, bases
|
||||
|
@ -20,8 +20,10 @@ includes:
|
||||
- cantera/base/Interface.h
|
||||
ThermoPhase:
|
||||
- cantera/thermo/ThermoFactory.h
|
||||
- cantera/thermo/SurfPhase.h
|
||||
Kinetics:
|
||||
- cantera/kinetics/KineticsFactory.h
|
||||
- cantera/kinetics/InterfaceKinetics.h
|
||||
Transport:
|
||||
- cantera/transport/TransportFactory.h
|
||||
Func1:
|
||||
|
@ -141,11 +141,11 @@ clib-constructor: |-
|
||||
{% endfor %}
|
||||
{% if uses %}
|
||||
{% if handle %}
|
||||
auto obj = {{ cxx_base }}Cabinet::at({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
auto obj = {{ base }}Cabinet::at({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
{% else %}
|
||||
auto obj = {{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
{% endif %}
|
||||
int id = {{ cxx_base }}Cabinet::add(obj);
|
||||
int id = {{ base }}Cabinet::add(obj);
|
||||
// add all associated objects
|
||||
{% for typ, getter in uses %}
|
||||
if (obj->{{ getter }}()) {
|
||||
@ -155,9 +155,9 @@ clib-constructor: |-
|
||||
return id;
|
||||
{% else %}
|
||||
{% if handle %}
|
||||
return {{ cxx_base }}Cabinet::add({{ cxx_base }}Cabinet::at({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }}));
|
||||
return {{ base }}Cabinet::add({{ base }}Cabinet::at({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }}));
|
||||
{% else %}
|
||||
return {{ cxx_base }}Cabinet::add({{ cxx_name }}({{ ', '.join(cxx_args) }}));
|
||||
return {{ base }}Cabinet::add({{ cxx_name }}({{ ', '.join(cxx_args) }}));
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
} catch (...) {
|
||||
@ -168,7 +168,7 @@ clib-destructor: |-
|
||||
// destructor
|
||||
try {
|
||||
{% if uses %}
|
||||
auto obj = {{ cxx_base }}Cabinet::at({{ handle }});
|
||||
auto obj = {{ base }}Cabinet::at({{ handle }});
|
||||
// remove all associated objects in reversed order
|
||||
{% for typ, getter in uses[-1::-1] %}
|
||||
if (obj->{{ getter }}()) {
|
||||
@ -179,7 +179,7 @@ clib-destructor: |-
|
||||
}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{{ cxx_base }}Cabinet::del({{ handle }});
|
||||
{{ base }}Cabinet::del({{ handle }});
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
@ -193,16 +193,28 @@ clib-method: |-
|
||||
{% endfor %}
|
||||
{% if buffer %}
|
||||
{% if buffer[0] %}
|
||||
{{ buffer[0] }} = {{ cxx_base }}Cabinet::at({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
{% if cxx_base == base %}
|
||||
{{ buffer[0] }} = {{ base }}Cabinet::at({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
{% else %}
|
||||
{{ cxx_base }}Cabinet::at({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
{{ buffer[0] }} = {{ base }}Cabinet::as<{{ cxx_base }}>({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if cxx_base == base %}
|
||||
{{ base }}Cabinet::at({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
{% else %}
|
||||
{{ base }}Cabinet::as<{{ cxx_base }}>({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if buffer[1] %}
|
||||
{{ buffer[1] }}
|
||||
{% endif %}
|
||||
return {{ buffer[2] }};
|
||||
{% else %}
|
||||
return {{ cxx_base }}Cabinet::at({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
{% if cxx_base == base %}
|
||||
return {{ base }}Cabinet::at({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
{% else %}
|
||||
return {{ base }}Cabinet::as<{{ cxx_base }}>({{ handle }})->{{ cxx_name }}({{ ', '.join(cxx_args) }});
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
} catch (...) {
|
||||
return handleAllExceptions({{ error[0] }}, {{ error[1] }});
|
||||
@ -211,7 +223,11 @@ clib-method: |-
|
||||
clib-array-getter: |-
|
||||
// getter: {{ cxx_implements }}
|
||||
try {
|
||||
auto& obj = {{ cxx_base }}Cabinet::at({{ handle }});
|
||||
{% if cxx_base == base %}
|
||||
auto& obj = {{ base }}Cabinet::at({{ handle }});
|
||||
{% else %}
|
||||
auto obj = {{ base }}Cabinet::as<{{ cxx_base }}>({{ handle }});
|
||||
{% endif %}
|
||||
{% if uses %}
|
||||
if ({{ c_args[1] }} < obj->{{ uses[0][1] }}()) {
|
||||
throw CanteraError("{{ c_func }}",
|
||||
@ -238,7 +254,11 @@ clib-array-getter: |-
|
||||
clib-array-setter: |-
|
||||
// setter: {{ cxx_implements }}
|
||||
try {
|
||||
auto& obj = {{ cxx_base }}Cabinet::at({{ handle }});
|
||||
{% if cxx_base == base %}
|
||||
auto& obj = {{ base }}Cabinet::at({{ handle }});
|
||||
{% else %}
|
||||
auto obj = {{ base }}Cabinet::as<{{ cxx_base }}>({{ handle }});
|
||||
{% endif %}
|
||||
{% if uses %}
|
||||
if ({{ c_args[1] }} != obj->{{ uses[0][1] }}()) {
|
||||
throw CanteraError("{{ c_func }}",
|
||||
@ -273,17 +293,17 @@ clib-implementation: |-
|
||||
}
|
||||
|
||||
clib-reserved-parentHandle-cpp: |-
|
||||
// reserved: {{ cxx_base }} cabinet parent
|
||||
// reserved: {{ base }} cabinet parent
|
||||
try {
|
||||
return {{ cxx_base }}Cabinet::parent(handle);
|
||||
return {{ base }}Cabinet::parent(handle);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-2, ERR);
|
||||
}
|
||||
|
||||
clib-reserved-cabinetSize-cpp: |-
|
||||
// reserved: int Cabinet<{{ cxx_base }}>.size()
|
||||
// reserved: int Cabinet<{{ base }}>.size()
|
||||
try {
|
||||
return {{ cxx_base }}Cabinet::size();
|
||||
return {{ base }}Cabinet::size();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user