File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,14 @@ class EcoreGenerator(multigen.jinja.JinjaGenerator):
109109
110110 @staticmethod
111111 def test_type (value , type_ ):
112- """Jinja test to check object type."""
112+ """Jinja test to check if an object's class is exactly the tested type."""
113+ return value .__class__ is type_
114+
115+ @staticmethod
116+ def test_kind (value , type_ ):
117+ """Jinja test to check the 'kind' or an object.
118+ An object is 'kind' of a type when the object's class isinstance from the tested type.
119+ """
113120 return isinstance (value , type_ )
114121
115122 @staticmethod
@@ -208,6 +215,7 @@ def create_environment(self, **kwargs):
208215 environment = super ().create_environment (** kwargs )
209216 environment .tests .update ({
210217 'type' : self .test_type ,
218+ 'kind' : self .test_kind ,
211219 'opposite_before_self' : self .test_opposite_before_self ,
212220 })
213221 environment .filters .update ({
Original file line number Diff line number Diff line change @@ -136,10 +136,10 @@ class {{ c.name }}({{ c | supertypes }}):
136136
137137{ #- -------------------------------------------------------------------------------------------- -#}
138138
139- {% - for c in element.eClassifiers if c is type(ecore.EEnum) %}
139+ {% - for c in element.eClassifiers if c is type(ecore.EEnum) - %}
140140{ { generate_enum(c) } }
141141{% - endfor %}
142- {% - for c in element.eClassifiers if c is type(ecore.EDataType) and c is not type(ecore.EEnum) %}
142+ {% for c in element.eClassifiers if c is type(ecore.EDataType) - %}
143143{ { generate_edatatype(c) } }
144144{% - endfor %}
145145
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ eSuperPackage = {{ element.eSuperPackage.name | default('None') }}
4646 {% - endwith %}
4747{% - endif %}
4848
49- otherClassifiers = [{ { element.eClassifiers | select(' type ' , ecore.EDataType) | map(attribute= ' name' ) | join(' , ' ) } }]
49+ otherClassifiers = [{ { element.eClassifiers | select(' kind ' , ecore.EDataType) | map(attribute= ' name' ) | join(' , ' ) } }]
5050
5151for classif in otherClassifiers:
5252 eClassifiers[classif.name] = classif
You can’t perform that action at this time.
0 commit comments