Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def lib():
package = Ecore.EPackage('mypackage')
package.nsURI = 'http://simplemetamodel/1.0'
package.nsPrefix = 'simplemm'
AbsA = Ecore.EClass('AbsA', abstract=True)
AbsA.eStructuralFeatures.append(Ecore.EReference('toa', AbsA))
A = Ecore.EClass('A', superclass=(AbsA,))
SubA = Ecore.EClass('SubA', superclass=(A,))
MyRoot = Ecore.EClass('MyRoot')
MyRoot.a_container = Ecore.EReference('a_container', eType=AbsA, upper=-1,
containment=True)
MyRoot.eStructuralFeatures.append(MyRoot.a_container)
package.eClassifiers.extend([MyRoot, A, SubA, AbsA])
package.MyRoot = MyRoot
package.SubA = SubA
package.A = A
# we register the metamodel first
global_registry[package.nsURI] = package
return package
def lib():
package = Ecore.EPackage('mypackage')
package.nsURI = 'http://simplemetamodel/1.0'
package.nsPrefix = 'simplemm'
AbsA = Ecore.EClass('AbsA', abstract=True)
A = Ecore.EClass('A', superclass=(AbsA,))
SubA = Ecore.EClass('SubA', superclass=(A,))
MyRoot = Ecore.EClass('MyRoot')
MyRoot.a_container = Ecore.EReference('a_container', eType=AbsA, upper=-1,
containment=True)
MyRoot.eStructuralFeatures.append(MyRoot.a_container)
MyRoot.eStructuralFeatures.append(Ecore.EAttribute('trans',
eType=Ecore.EString,
transient=True))
package.eClassifiers.extend([MyRoot, A, SubA, AbsA])
package.MyRoot = MyRoot
package.SubA = SubA
package.A = A
# we register the metamodel first
global_registry[package.nsURI] = package
return package
EStructuralFeature.changeable = EAttribute('changeable', EBoolean,
default_value=True)
EStructuralFeature.volatile = EAttribute('volatile', EBoolean)
EStructuralFeature.transient = EAttribute('transient', EBoolean)
EStructuralFeature.unsettable = EAttribute('unsettable', EBoolean)
EStructuralFeature.derived = EAttribute('derived', EBoolean)
EStructuralFeature.defaultValueLiteral = EAttribute('defaultValueLiteral',
EString)
EAttribute.iD = EAttribute('iD', EBoolean)
EPackage.nsURI = EAttribute('nsURI', EString)
EPackage.nsPrefix = EAttribute('nsPrefix', EString)
EPackage.eClassifiers = EReference('eClassifiers', EClassifier,
upper=-1, containment=True)
EPackage.eSubpackages = EReference('eSubpackages', EPackage,
upper=-1, containment=True)
EPackage.eSuperPackage = EReference('eSuperPackage', EPackage,
lower=1, eOpposite=EPackage.eSubpackages)
EClassifier.ePackage = EReference('ePackage', EPackage,
eOpposite=EPackage.eClassifiers)
EClassifier.eTypeParameters = EReference('eTypeParameters', ETypeParameter,
upper=-1, containment=True)
EClassifier.instanceTypeName = EAttribute('instanceTypeName', EString)
EClassifier.instanceClass = EAttribute('instanceClass', EJavaClass)
EClassifier.defaultValue = EAttribute('defaultValue', EJavaObject)
EClassifier.instanceTypeName = EAttribute('instanceTypeName', EString,
volatile=True, unsettable=True)
EDataType.instanceClassName_ = EAttribute('instanceClassName', EString)
EDataType.serializable = EAttribute('serializable', EBoolean)
EStructuralFeature.derived = EAttribute('derived', EBoolean)
EStructuralFeature.defaultValueLiteral = EAttribute('defaultValueLiteral',
EString)
EAttribute.iD = EAttribute('iD', EBoolean)
EPackage.nsURI = EAttribute('nsURI', EString)
EPackage.nsPrefix = EAttribute('nsPrefix', EString)
EPackage.eClassifiers = EReference('eClassifiers', EClassifier,
upper=-1, containment=True)
EPackage.eSubpackages = EReference('eSubpackages', EPackage,
upper=-1, containment=True)
EPackage.eSuperPackage = EReference('eSuperPackage', EPackage,
lower=1, eOpposite=EPackage.eSubpackages)
EClassifier.ePackage = EReference('ePackage', EPackage,
eOpposite=EPackage.eClassifiers)
EClassifier.eTypeParameters = EReference('eTypeParameters', ETypeParameter,
upper=-1, containment=True)
EClassifier.instanceTypeName = EAttribute('instanceTypeName', EString)
EClassifier.instanceClass = EAttribute('instanceClass', EJavaClass)
EClassifier.defaultValue = EAttribute('defaultValue', EJavaObject)
EClassifier.instanceTypeName = EAttribute('instanceTypeName', EString,
volatile=True, unsettable=True)
EDataType.instanceClassName_ = EAttribute('instanceClassName', EString)
EDataType.serializable = EAttribute('serializable', EBoolean)
EClass.abstract = EAttribute('abstract', EBoolean)
EClass.eStructuralFeatures = EReference('eStructuralFeatures',
EStructuralFeature,
upper=-1, containment=True)
ENamedElement.name._isset.add(ETypedElement.eType) # special case
EStructuralFeature.changeable = EAttribute('changeable', EBoolean,
default_value=True)
EStructuralFeature.volatile = EAttribute('volatile', EBoolean)
EStructuralFeature.transient = EAttribute('transient', EBoolean)
EStructuralFeature.unsettable = EAttribute('unsettable', EBoolean)
EStructuralFeature.derived = EAttribute('derived', EBoolean)
EStructuralFeature.defaultValueLiteral = EAttribute('defaultValueLiteral',
EString)
EAttribute.iD = EAttribute('iD', EBoolean)
EPackage.nsURI = EAttribute('nsURI', EString)
EPackage.nsPrefix = EAttribute('nsPrefix', EString)
EPackage.eClassifiers = EReference('eClassifiers', EClassifier,
upper=-1, containment=True)
EPackage.eSubpackages = EReference('eSubpackages', EPackage,
upper=-1, containment=True)
EPackage.eSuperPackage = EReference('eSuperPackage', EPackage,
lower=1, eOpposite=EPackage.eSubpackages)
EClassifier.ePackage = EReference('ePackage', EPackage,
eOpposite=EPackage.eClassifiers)
EClassifier.eTypeParameters = EReference('eTypeParameters', ETypeParameter,
upper=-1, containment=True)
EClassifier.instanceTypeName = EAttribute('instanceTypeName', EString)
EClassifier.instanceClass = EAttribute('instanceClass', EJavaClass)
EClassifier.defaultValue = EAttribute('defaultValue', EJavaObject)
EClassifier.instanceTypeName = EAttribute('instanceTypeName', EString,
volatile=True, unsettable=True)
EClass.eAttributes_ = EReference('eAttributes', EAttribute,
upper=-1, derived=True)
EClass.eReferences_ = EReference('eReferences', EReference,
upper=-1, derived=True)
EClass.eSuperTypes = EReference('eSuperTypes', EClass, upper=-1)
EClass.eOperations = EReference('eOperations', EOperation,
upper=-1, containment=True)
EClass.instanceClassName = EAttribute('instanceClassName', EString)
EClass.interface = EAttribute('interface', EBoolean)
EStructuralFeature.eContainingClass = \
EReference('eContainingClass', EClass,
eOpposite=EClass.eStructuralFeatures)
EReference.containment = EAttribute('containment', EBoolean)
EReference.eOpposite_ = EReference('eOpposite', EReference)
EReference.resolveProxies = EAttribute('resolveProxies', EBoolean)
EEnum.eLiterals = EReference('eLiterals', EEnumLiteral, upper=-1,
containment=True)
EEnumLiteral.eEnum = EReference('eEnum', EEnum, eOpposite=EEnum.eLiterals)
EEnumLiteral.name = EAttribute('name', EString)
EEnumLiteral.value = EAttribute('value', EInteger)
EEnumLiteral.literal = EAttribute('literal', EString)
EOperation.eContainingClass = EReference('eContainingClass', EClass,
eOpposite=EClass.eOperations)
EOperation.eParameters = EReference('eParameters', EParameter, upper=-1,
containment=True)
EOperation.eExceptions = EReference('eExceptions', EClassifier, upper=-1)
EOperation.eTypeParameters = EReference('eTypeParameters', ETypeParameter,
EReference.eOpposite_ = EReference('eOpposite', EReference)
EReference.resolveProxies = EAttribute('resolveProxies', EBoolean)
EEnum.eLiterals = EReference('eLiterals', EEnumLiteral, upper=-1,
containment=True)
EEnumLiteral.eEnum = EReference('eEnum', EEnum, eOpposite=EEnum.eLiterals)
EEnumLiteral.name = EAttribute('name', EString)
EEnumLiteral.value = EAttribute('value', EInteger)
EEnumLiteral.literal = EAttribute('literal', EString)
EOperation.eContainingClass = EReference('eContainingClass', EClass,
eOpposite=EClass.eOperations)
EOperation.eParameters = EReference('eParameters', EParameter, upper=-1,
containment=True)
EOperation.eExceptions = EReference('eExceptions', EClassifier, upper=-1)
EOperation.eTypeParameters = EReference('eTypeParameters', ETypeParameter,
upper=-1, containment=True)
EOperation.eGenericExceptions = EReference('eGenericExceptions', EGenericType,
upper=-1)
EParameter.eOperation = EReference('eOperation', EOperation,
eOpposite=EOperation.eParameters)
ETypeParameter.eBounds = EReference('eBounds', EGenericType,
upper=-1, containment=True)
ETypeParameter.eGenericType = EReference('eGenericType', EGenericType,
upper=-1)
EGenericType.eClassifier = EReference('eClassifier', EClassifier)
EGenericType.eTypeArguments = EReference('eTypeArguments', EGenericType,
containment=True, upper=-1)
EGenericType.eTypeParameter = EReference('eTypeParameter', ETypeParameter,
EOperation.eContainingClass = EReference('eContainingClass', EClass,
eOpposite=EClass.eOperations)
EOperation.eParameters = EReference('eParameters', EParameter, upper=-1,
containment=True)
EOperation.eExceptions = EReference('eExceptions', EClassifier, upper=-1)
EOperation.eTypeParameters = EReference('eTypeParameters', ETypeParameter,
upper=-1, containment=True)
EOperation.eGenericExceptions = EReference('eGenericExceptions', EGenericType,
upper=-1)
EParameter.eOperation = EReference('eOperation', EOperation,
eOpposite=EOperation.eParameters)
ETypeParameter.eBounds = EReference('eBounds', EGenericType,
upper=-1, containment=True)
ETypeParameter.eGenericType = EReference('eGenericType', EGenericType,
upper=-1)
EGenericType.eClassifier = EReference('eClassifier', EClassifier)
EGenericType.eTypeArguments = EReference('eTypeArguments', EGenericType,
containment=True, upper=-1)
EGenericType.eTypeParameter = EReference('eTypeParameter', ETypeParameter,
eOpposite=ETypeParameter.eGenericType)
EGenericType.eUpperBound = EReference('eUpperBound', EGenericType)
EGenericType.eLowerBound = EReference('eLowerBound', EGenericType)
eClass = EPackage(name=name, nsURI=nsURI, nsPrefix=nsPrefix)
Core.register_classifier(EObject, promote=True)
Core.register_classifier(EModelElement, promote=True)
Core.register_classifier(ENamedElement, promote=True)
Core.register_classifier(EAnnotation, promote=True)
Core.register_classifier(EPackage, promote=True)
Core.register_classifier(EGenericType, promote=True)