rgen 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. data/CHANGELOG +28 -0
  2. data/Rakefile +3 -4
  3. data/lib/ea_support/uml13_ea_metamodel.rb +3 -3
  4. data/lib/ea_support/uml13_ea_to_uml13.rb +33 -2
  5. data/lib/ea_support/uml13_to_uml13_ea.rb +7 -0
  6. data/lib/mmgen/mm_ext/ecore_mmgen_ext.rb +4 -4
  7. data/lib/mmgen/templates/metamodel_generator.tpl +143 -143
  8. data/lib/rgen/ecore/ecore.rb +11 -1
  9. data/lib/rgen/ecore/ecore_interface.rb +47 -0
  10. data/lib/rgen/ecore/ecore_to_ruby.rb +166 -0
  11. data/lib/rgen/ecore/{ecore_transformer.rb → ruby_to_ecore.rb} +11 -11
  12. data/lib/rgen/environment.rb +15 -2
  13. data/lib/rgen/fragment/dump_file_cache.rb +63 -0
  14. data/lib/rgen/fragment/fragmented_model.rb +139 -0
  15. data/lib/rgen/fragment/model_fragment.rb +268 -0
  16. data/lib/rgen/instantiator/abstract_xml_instantiator.rb +44 -72
  17. data/lib/rgen/instantiator/default_xml_instantiator.rb +2 -2
  18. data/lib/rgen/instantiator/ecore_xml_instantiator.rb +16 -1
  19. data/lib/rgen/instantiator/json_instantiator.rb +16 -2
  20. data/lib/rgen/instantiator/nodebased_xml_instantiator.rb +118 -138
  21. data/lib/rgen/instantiator/qualified_name_resolver.rb +5 -1
  22. data/lib/rgen/instantiator/reference_resolver.rb +126 -24
  23. data/lib/rgen/instantiator/xmi11_instantiator.rb +6 -2
  24. data/lib/rgen/metamodel_builder.rb +18 -6
  25. data/lib/rgen/metamodel_builder/builder_extensions.rb +431 -407
  26. data/lib/rgen/metamodel_builder/builder_runtime.rb +8 -8
  27. data/lib/rgen/metamodel_builder/constant_order_helper.rb +4 -4
  28. data/lib/rgen/metamodel_builder/data_types.rb +5 -1
  29. data/lib/rgen/metamodel_builder/intermediate/feature.rb +167 -0
  30. data/lib/rgen/metamodel_builder/module_extension.rb +2 -2
  31. data/lib/rgen/model_builder.rb +10 -5
  32. data/lib/rgen/model_builder/builder_context.rb +17 -1
  33. data/lib/rgen/serializer/opposite_reference_filter.rb +18 -0
  34. data/lib/rgen/serializer/qualified_name_provider.rb +45 -0
  35. data/lib/rgen/template_language/template_container.rb +3 -1
  36. data/lib/rgen/{auto_class_creator.rb → util/auto_class_creator.rb} +6 -1
  37. data/lib/rgen/util/cached_glob.rb +67 -0
  38. data/lib/rgen/util/file_cache_map.rb +104 -0
  39. data/lib/rgen/util/file_change_detector.rb +78 -0
  40. data/lib/rgen/{method_delegation.rb → util/method_delegation.rb} +18 -3
  41. data/lib/rgen/{model_comparator.rb → util/model_comparator.rb} +17 -5
  42. data/lib/rgen/{model_comparator_base.rb → util/model_comparator_base.rb} +6 -1
  43. data/lib/rgen/{model_dumper.rb → util/model_dumper.rb} +6 -1
  44. data/lib/rgen/{name_helper.rb → util/name_helper.rb} +6 -1
  45. data/lib/rgen/util/pattern_matcher.rb +329 -0
  46. data/lib/transformers/uml13_to_ecore.rb +103 -60
  47. data/test/ecore_self_test.rb +43 -42
  48. data/test/json_test.rb +15 -0
  49. data/test/metamodel_builder_test.rb +361 -206
  50. data/test/metamodel_from_ecore_test.rb +45 -0
  51. data/test/metamodel_order_test.rb +10 -4
  52. data/test/metamodel_roundtrip_test.rb +2 -2
  53. data/test/metamodel_roundtrip_test/TestModel_Regenerated.rb +1 -1
  54. data/test/metamodel_roundtrip_test/houseMetamodel_Regenerated.ecore +50 -50
  55. data/test/method_delegation_test.rb +9 -9
  56. data/test/model_builder/ecore_internal.rb +19 -9
  57. data/test/model_builder/serializer_test.rb +1 -1
  58. data/test/reference_resolver_test.rb +79 -12
  59. data/test/rgen_test.rb +2 -0
  60. data/test/template_language_test.rb +7 -0
  61. data/test/template_language_test/templates/callback_indent_test/a.tpl +12 -0
  62. data/test/template_language_test/templates/callback_indent_test/b.tpl +5 -0
  63. data/test/testmodel/ea_testmodel_regenerated.xml +588 -583
  64. data/test/transformer_test.rb +3 -3
  65. data/test/util/file_cache_map_test.rb +91 -0
  66. data/test/util/file_cache_map_test/testdir/fileA +1 -0
  67. data/test/util_test.rb +4 -0
  68. data/test/xml_instantiator_test.rb +139 -135
  69. metadata +49 -104
  70. data/lib/rgen/ecore/ecore_instantiator.rb +0 -31
  71. data/lib/rgen/metamodel_builder/metamodel_description.rb +0 -232
  72. data/redist/xmlscan/ChangeLog +0 -1301
  73. data/redist/xmlscan/README +0 -34
  74. data/redist/xmlscan/THANKS +0 -11
  75. data/redist/xmlscan/doc/changes.html +0 -74
  76. data/redist/xmlscan/doc/changes.rd +0 -80
  77. data/redist/xmlscan/doc/en/conformance.html +0 -136
  78. data/redist/xmlscan/doc/en/conformance.rd +0 -152
  79. data/redist/xmlscan/doc/en/manual.html +0 -356
  80. data/redist/xmlscan/doc/en/manual.rd +0 -402
  81. data/redist/xmlscan/doc/ja/conformance.ja.html +0 -118
  82. data/redist/xmlscan/doc/ja/conformance.ja.rd +0 -134
  83. data/redist/xmlscan/doc/ja/manual.ja.html +0 -325
  84. data/redist/xmlscan/doc/ja/manual.ja.rd +0 -370
  85. data/redist/xmlscan/doc/src/Makefile +0 -41
  86. data/redist/xmlscan/doc/src/conformance.rd.src +0 -256
  87. data/redist/xmlscan/doc/src/langsplit.rb +0 -110
  88. data/redist/xmlscan/doc/src/manual.rd.src +0 -614
  89. data/redist/xmlscan/install.rb +0 -41
  90. data/redist/xmlscan/lib/xmlscan/encoding.rb +0 -311
  91. data/redist/xmlscan/lib/xmlscan/htmlscan.rb +0 -289
  92. data/redist/xmlscan/lib/xmlscan/namespace.rb +0 -352
  93. data/redist/xmlscan/lib/xmlscan/parser.rb +0 -299
  94. data/redist/xmlscan/lib/xmlscan/scanner.rb +0 -1109
  95. data/redist/xmlscan/lib/xmlscan/version.rb +0 -22
  96. data/redist/xmlscan/lib/xmlscan/visitor.rb +0 -158
  97. data/redist/xmlscan/lib/xmlscan/xmlchar.rb +0 -441
  98. data/redist/xmlscan/memo/CONFORMANCE +0 -1249
  99. data/redist/xmlscan/memo/PRODUCTIONS +0 -195
  100. data/redist/xmlscan/memo/contentspec.ry +0 -335
  101. data/redist/xmlscan/samples/chibixml.rb +0 -105
  102. data/redist/xmlscan/samples/getxmlchar.rb +0 -122
  103. data/redist/xmlscan/samples/rexml.rb +0 -159
  104. data/redist/xmlscan/samples/xmlbench.rb +0 -88
  105. data/redist/xmlscan/samples/xmlbench/parser/chibixml.rb +0 -22
  106. data/redist/xmlscan/samples/xmlbench/parser/nqxml.rb +0 -29
  107. data/redist/xmlscan/samples/xmlbench/parser/rexml.rb +0 -62
  108. data/redist/xmlscan/samples/xmlbench/parser/xmlparser.rb +0 -22
  109. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-0.0.10.rb +0 -62
  110. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-chibixml.rb +0 -22
  111. data/redist/xmlscan/samples/xmlbench/parser/xmlscan-rexml.rb +0 -22
  112. data/redist/xmlscan/samples/xmlbench/parser/xmlscan.rb +0 -99
  113. data/redist/xmlscan/samples/xmlbench/xmlbench-lib.rb +0 -116
  114. data/redist/xmlscan/samples/xmlconftest.rb +0 -200
  115. data/redist/xmlscan/test.rb +0 -7
  116. data/redist/xmlscan/tests/deftestcase.rb +0 -73
  117. data/redist/xmlscan/tests/runtest.rb +0 -47
  118. data/redist/xmlscan/tests/testall.rb +0 -14
  119. data/redist/xmlscan/tests/testencoding.rb +0 -438
  120. data/redist/xmlscan/tests/testhtmlscan.rb +0 -752
  121. data/redist/xmlscan/tests/testnamespace.rb +0 -457
  122. data/redist/xmlscan/tests/testparser.rb +0 -591
  123. data/redist/xmlscan/tests/testscanner.rb +0 -1749
  124. data/redist/xmlscan/tests/testxmlchar.rb +0 -143
  125. data/redist/xmlscan/tests/visitor.rb +0 -34
data/CHANGELOG CHANGED
@@ -123,3 +123,31 @@
123
123
  * Fixed ModelSerializer to add :as => in case of ambiguous child roles
124
124
  * Made JsonInstantiator search subpackages for unqualified class names
125
125
 
126
+ =0.6.0
127
+
128
+ * Added exception when trying to instantiate abstract class
129
+ * Replaced xmlscan by dependency to nokogiri
130
+ * Made RGen work with Ruby 1.9
131
+ * Cleaned up intermediate attribute and reference description, improvement of metamodel load time
132
+ * Added optional data property for MMProxy
133
+ * Added ECoreToRuby which can create Ruby classes and modules from ECore models in memory (without metamodel generator)
134
+ * Refactored out QualifiedNameProvider and OppositeReferenceFilter
135
+ * Added model fragment/fragmented models support
136
+ * Extended Instantiator::ReferenceResolver and changed it into a class
137
+ * Moved utilities into util folder/module
138
+ * Added FileCacheMap
139
+ * Fixed template language bug: indenting not correct after callback into same template container and iinc/idec
140
+ * Added support for fragmented models
141
+ * Added FileChangeDetector utility
142
+ * Added CachedGlob utility
143
+ * Added index parameter to model element add methods
144
+ * Added MMGeneric
145
+ * Modified has_many_attr to allow the same value in the same attribute multiple times
146
+ * Made Environment#delete faster on large models
147
+ * Added type check of ecore defaultValueLiteral content in MetamodelBuilder
148
+ * Many-feature setters can work with an Enumerable instead of an Array
149
+ * Added pattern matcher utility
150
+ * Fixed problem of Ruby hanging when exceptions occur
151
+ * Fixed metamodel generator to quote illegal enum literal symbols
152
+ * Imporved UML to ECore transformer and EA support
153
+
data/Rakefile CHANGED
@@ -3,21 +3,20 @@ require 'rake/rdoctask'
3
3
 
4
4
  RGenGemSpec = Gem::Specification.new do |s|
5
5
  s.name = %q{rgen}
6
- s.version = "0.5.4"
6
+ s.version = "0.6.0"
7
7
  s.date = Time.now.strftime("%Y-%m-%d")
8
8
  s.summary = %q{Ruby Modelling and Generator Framework}
9
9
  s.email = %q{martin dot thiede at gmx de}
10
10
  s.homepage = %q{http://ruby-gen.org}
11
11
  s.rubyforge_project = %q{rgen}
12
12
  s.description = %q{RGen is a framework supporting Model Driven Software Development (MDSD). This means that it helps you build Metamodels, instantiate Models, modify and transform Models and finally generate arbitrary textual content from it.}
13
- s.has_rdoc = true
14
13
  s.authors = ["Martin Thiede"]
15
14
  gemfiles = Rake::FileList.new
16
- gemfiles.include("{lib,test,redist}/**/*")
15
+ gemfiles.include("{lib,test}/**/*")
17
16
  gemfiles.include("README", "CHANGELOG", "MIT-LICENSE", "Rakefile")
18
17
  gemfiles.exclude(/\b\.bak\b/)
19
18
  s.files = gemfiles
20
- s.rdoc_options = ["--main", "README", "-x", "redist", "-x", "test", "-x", "metamodels", "-x", "ea_support/uml13*"]
19
+ s.rdoc_options = ["--main", "README", "-x", "test", "-x", "metamodels", "-x", "ea_support/uml13*"]
21
20
  s.extra_rdoc_files = ["README", "CHANGELOG", "MIT-LICENSE"]
22
21
  end
23
22
 
@@ -12,7 +12,7 @@ module UML13EA
12
12
  ScopeKind = Enum.new(:name => 'ScopeKind', :literals =>[ :instance, :classifier ])
13
13
  OrderingKind = Enum.new(:name => 'OrderingKind', :literals =>[ :unordered, :ordered, :sorted ])
14
14
  CallConcurrencyKind = Enum.new(:name => 'CallConcurrencyKind', :literals =>[ :sequential, :guarded, :concurrent ])
15
- AggregationKind = Enum.new(:name => 'AggregationKind', :literals =>[ :none, :aggregate, :composite ])
15
+ AggregationKind = Enum.new(:name => 'AggregationKind', :literals =>[ :none, :aggregate, :composite, :shared ])
16
16
  VisibilityKind = Enum.new(:name => 'VisibilityKind', :literals =>[ :public, :protected, :private ])
17
17
  end
18
18
 
@@ -188,7 +188,7 @@ class UML13EA::SubactivityState < UML13EA::SubmachineState
188
188
  end
189
189
 
190
190
  class UML13EA::StructuralFeature < UML13EA::Feature
191
- has_attr 'changeability', UML13EA::ChangeableKind, :defaultValueLiteral => "changeable"
191
+ has_attr 'changeable', UML13EA::ChangeableKind, :defaultValueLiteral => "changeable"
192
192
  has_attr 'targetScope', UML13EA::ScopeKind, :defaultValueLiteral => "instance"
193
193
  end
194
194
 
@@ -259,7 +259,7 @@ end
259
259
 
260
260
  class UML13EA::AssociationEnd < RGen::MetamodelBuilder::MMMultiple(UML13EA::ModelElement, UML13EA::XmiIdProvider)
261
261
  has_attr 'isNavigable', Boolean, :defaultValueLiteral => "false"
262
- has_attr 'isOrdered', Boolean, :defaultValueLiteral => "unordered"
262
+ has_attr 'isOrdered', Boolean, :defaultValueLiteral => "false"
263
263
  has_attr 'aggregation', UML13EA::AggregationKind, :defaultValueLiteral => "none"
264
264
  has_attr 'targetScope', UML13EA::ScopeKind, :defaultValueLiteral => "instance"
265
265
  has_attr 'changeable', UML13EA::ChangeableKind, :defaultValueLiteral => "changeable"
@@ -8,6 +8,10 @@ class UML13EAToUML13 < RGen::Transformer
8
8
  def transform
9
9
  trans(:class => Package)
10
10
  trans(:class => Class)
11
+ @env_out.find(:class => UML13::Attribute).each do |me|
12
+ # remove tagged vales internally used by EA which have been converted to UML
13
+ me.taggedValue = me.taggedValue.reject{|tv| ["lowerBound", "upperBound"].include?(tv.tag)}
14
+ end
11
15
  end
12
16
 
13
17
  def cleanModel
@@ -20,10 +24,12 @@ class UML13EAToUML13 < RGen::Transformer
20
24
  XmiIdProvider
21
25
  AssociationEnd AssociationEndRole
22
26
  StructuralFeature
27
+ Attribute
23
28
  Generalization
24
29
  ActivityModel
25
30
  CompositeState
26
31
  PseudoState
32
+ Dependency
27
33
  )
28
34
 
29
35
  transform AssociationEndRole, :to => UML13::AssociationEndRole do
@@ -46,12 +52,30 @@ class UML13EAToUML13 < RGen::Transformer
46
52
  end
47
53
  end
48
54
 
49
- transform StructuralFeature, :to => UML13::StructuralFeature do
55
+ transform StructuralFeature, :to => UML13::StructuralFeature,
56
+ :if => lambda{|c| !@current_object.is_a?(UML13EA::Attribute)} do
50
57
  copy_features :except => [:changeable] do
51
58
  {:changeability => {:none => :frozen}[changeable] }
52
59
  end
53
60
  end
54
61
 
62
+ transform StructuralFeature, :to => UML13::Attribute,
63
+ :if => lambda{|c| @current_object.is_a?(UML13EA::Attribute)} do
64
+ _lowerBound = taggedValue.find{|tv| tv.tag == "lowerBound"}
65
+ _upperBound = taggedValue.find{|tv| tv.tag == "upperBound"}
66
+ if _lowerBound || _upperBound
67
+ _multiplicity = UML13::Multiplicity.new(
68
+ :range => [UML13::MultiplicityRange.new(
69
+ :lower => (_lowerBound && _lowerBound.value) || "0",
70
+ :upper => (_upperBound && _upperBound.value) || "1"
71
+ )])
72
+ end
73
+ copy_features :except => [:changeable] do
74
+ {:changeability => {:none => :frozen}[changeable],
75
+ :multiplicity => _multiplicity }
76
+ end
77
+ end
78
+
55
79
  transform Generalization, :to => UML13::Generalization do
56
80
  copy_features :except => [:subtype, :supertype] do
57
81
  { :child => trans(subtype),
@@ -68,5 +92,12 @@ class UML13EAToUML13 < RGen::Transformer
68
92
  end
69
93
 
70
94
  copy PseudoState, :to => UML13::Pseudostate
95
+
96
+ transform Dependency, :to => UML13::Dependency do
97
+ _name_tag = taggedValue.find{|tv| tv.tag == "dst_name"}
98
+ copy_features do
99
+ { :name => (_name_tag && _name_tag.value) || "Anonymous" }
100
+ end
101
+ end
71
102
 
72
- end
103
+ end
@@ -18,6 +18,7 @@ class UML13ToUML13EA < RGen::Transformer
18
18
  Association AssociationEnd AssociationEndRole
19
19
  Generalization
20
20
  Pseudostate
21
+ Attribute
21
22
  )
22
23
 
23
24
  copy ActivityGraph, :to => UML13EA::ActivityModel
@@ -72,6 +73,12 @@ class UML13ToUML13EA < RGen::Transformer
72
73
  end
73
74
  end
74
75
 
76
+ transform Attribute, :to => UML13EA::Attribute do
77
+ copy_features :except => [:changeability] do
78
+ { :changeable => {:frozen => :none}[changeability] }
79
+ end
80
+ end
81
+
75
82
  transform Generalization, :to => UML13EA::Generalization do
76
83
  copy_features :except => [:child, :parent] do
77
84
  { :taggedValue => trans(taggedValue) + [@env_out.new(UML13EA::TaggedValue, :tag => "ea_type", :value => "Generalization")],
@@ -1,11 +1,11 @@
1
- require 'rgen/name_helper'
1
+ require 'rgen/util/name_helper'
2
2
 
3
3
  module RGen
4
4
 
5
5
  module ECore
6
6
 
7
7
  module EPackage::ClassModule
8
- include RGen::NameHelper
8
+ include RGen::Util::NameHelper
9
9
 
10
10
  def moduleName
11
11
  firstToUpper(name)
@@ -58,7 +58,7 @@ module RGen
58
58
  end
59
59
 
60
60
  module EClassifier::ClassModule
61
- include RGen::NameHelper
61
+ include RGen::Util::NameHelper
62
62
  def classifierName
63
63
  firstToUpper(name)
64
64
  end
@@ -88,4 +88,4 @@ module RGen
88
88
 
89
89
  end
90
90
 
91
- end
91
+ end
@@ -1,172 +1,172 @@
1
1
 
2
2
  <% define 'GenerateMetamodel', :for => EPackage do |filename| %>
3
- <% file filename do %>
4
- require 'rgen/metamodel_builder'
5
- <%nl%>
6
- <% if needClassReorder? %>
7
- <% expand 'GeneratePackagesOnly' %>
8
- <% expand 'GenerateClassesReordered' %>
9
- <% else %>
10
- <% expand 'GeneratePackage' %>
11
- <% end %>
12
- <%nl%>
13
- <% expand 'GenerateAssocs' %>
14
- <% end %>
3
+ <% file filename do %>
4
+ require 'rgen/metamodel_builder'
5
+ <%nl%>
6
+ <% if needClassReorder? %>
7
+ <% expand 'GeneratePackagesOnly' %>
8
+ <% expand 'GenerateClassesReordered' %>
9
+ <% else %>
10
+ <% expand 'GeneratePackage' %>
11
+ <% end %>
12
+ <%nl%>
13
+ <% expand 'GenerateAssocs' %>
14
+ <% end %>
15
15
  <% end %>
16
-
16
+
17
17
  <% define 'GeneratePackage', :for => EPackage do %>
18
- module <%= moduleName %><% iinc %>
19
- extend RGen::MetamodelBuilder::ModuleExtension
20
- include RGen::MetamodelBuilder::DataTypes
21
- <% expand 'annotations::Annotations' %>
22
- <%nl%>
23
- <% expand 'EnumTypes' %>
24
- <% for c in ownClasses %><%nl%>
25
- <% expand 'ClassHeader', this, :for => c %><%iinc%>
26
- <% if c.abstract %>abstract<% end %>
27
- <% expand 'annotations::Annotations', :for => c %>
28
- <% expand 'Attribute', this, :foreach => c.eAttributes %>
29
- <%idec%>
30
- end
31
- <% end %><%nl%>
32
- <% for p in eSubpackages %>
33
- <%nl%><% expand 'GeneratePackage', :for => p %>
34
- <% end %><%idec%>
35
- end
18
+ module <%= moduleName %><% iinc %>
19
+ extend RGen::MetamodelBuilder::ModuleExtension
20
+ include RGen::MetamodelBuilder::DataTypes
21
+ <% expand 'annotations::Annotations' %>
22
+ <%nl%>
23
+ <% expand 'EnumTypes' %>
24
+ <% for c in ownClasses %><%nl%>
25
+ <% expand 'ClassHeader', this, :for => c %><%iinc%>
26
+ <% if c.abstract %>abstract<% end %>
27
+ <% expand 'annotations::Annotations', :for => c %>
28
+ <% expand 'Attribute', this, :foreach => c.eAttributes %>
29
+ <%idec%>
30
+ end
31
+ <% end %><%nl%>
32
+ <% for p in eSubpackages %>
33
+ <%nl%><% expand 'GeneratePackage', :for => p %>
34
+ <% end %><%idec%>
35
+ end
36
36
  <% end %>
37
37
 
38
38
  <% define 'GenerateClassesReordered', :for => EPackage do %>
39
- <% for c in allClassesSorted %><%nl%>
40
- <% expand 'ClassHeaderFullyQualified', this, :for => c %><%iinc%>
41
- <% if c.abstract %>abstract<% end %>
42
- <% expand 'annotations::Annotations', :for => c %>
43
- <% expand 'Attribute', this, :foreach => c.eAttributes %>
44
- <%idec%>
45
- end
46
- <% end %><%nl%>
39
+ <% for c in allClassesSorted %><%nl%>
40
+ <% expand 'ClassHeaderFullyQualified', this, :for => c %><%iinc%>
41
+ <% if c.abstract %>abstract<% end %>
42
+ <% expand 'annotations::Annotations', :for => c %>
43
+ <% expand 'Attribute', this, :foreach => c.eAttributes %>
44
+ <%idec%>
45
+ end
46
+ <% end %><%nl%>
47
47
  <% end %>
48
48
 
49
49
  <% define 'GeneratePackagesOnly', :for => EPackage do %>
50
- module <%= moduleName %><% iinc %>
51
- extend RGen::MetamodelBuilder::ModuleExtension
52
- include RGen::MetamodelBuilder::DataTypes
53
- <% expand 'annotations::Annotations' %>
54
- <%nl%>
55
- <% expand 'EnumTypes' %>
56
- <% for p in eSubpackages %>
57
- <%nl%><% expand 'GeneratePackagesOnly', :for => p %>
58
- <% end %><%idec%>
59
- end
50
+ module <%= moduleName %><% iinc %>
51
+ extend RGen::MetamodelBuilder::ModuleExtension
52
+ include RGen::MetamodelBuilder::DataTypes
53
+ <% expand 'annotations::Annotations' %>
54
+ <%nl%>
55
+ <% expand 'EnumTypes' %>
56
+ <% for p in eSubpackages %>
57
+ <%nl%><% expand 'GeneratePackagesOnly', :for => p %>
58
+ <% end %><%idec%>
59
+ end
60
60
  <% end %>
61
61
 
62
62
  <% define 'Attribute', :for => EAttribute do |rootp| %>
63
- <% if upperBound == 1%>has_attr<% else %>has_many_attr<% end %> '<%= name %>', <%nows%>
64
- <% if eType.is_a?(EEnum) %><%nows%>
65
- <%= eType.qualifiedClassifierName(rootp) %><%nows%>
66
- <% else %><%nows%>
67
- <%= eType && eType.instanceClass.to_s %><%nows%>
68
- <% end %><%nows%>
69
- <% for p in RGen::MetamodelBuilder::AttributeDescription.propertySet %>
70
- <% unless p == :name || (p == :upperBound && (upperBound == 1 || upperBound == -1)) ||
71
- RGen::MetamodelBuilder::AttributeDescription.default_value(p) == getGeneric(p) %>
72
- , :<%=p%> => <%nows%>
73
- <% if getGeneric(p).is_a?(String) %>
74
- "<%= getGeneric(p) %>"<%nows%>
75
- <% elsif getGeneric(p).is_a?(Symbol) %>
76
- :<%= getGeneric(p) %><%nows%>
77
- <% else %>
78
- <%= getGeneric(p) %><%nows%>
79
- <% end %>
80
- <% end %>
81
- <% end %>
82
- <%ws%><% expand 'annotations::Annotations' %><%nl%>
63
+ <% if upperBound == 1%>has_attr<% else %>has_many_attr<% end %> '<%= name %>', <%nows%>
64
+ <% if eType.is_a?(EEnum) %><%nows%>
65
+ <%= eType.qualifiedClassifierName(rootp) %><%nows%>
66
+ <% else %><%nows%>
67
+ <%= eType && eType.instanceClass.to_s %><%nows%>
68
+ <% end %><%nows%>
69
+ <% for p in RGen::MetamodelBuilder::Intermediate::Attribute.properties %>
70
+ <% unless p == :name || (p == :upperBound && (upperBound == 1 || upperBound == -1)) ||
71
+ RGen::MetamodelBuilder::Intermediate::Attribute.default_value(p) == getGeneric(p) %>
72
+ , :<%=p%> => <%nows%>
73
+ <% if getGeneric(p).is_a?(String) %>
74
+ "<%= getGeneric(p) %>"<%nows%>
75
+ <% elsif getGeneric(p).is_a?(Symbol) %>
76
+ :<%= getGeneric(p) %><%nows%>
77
+ <% else %>
78
+ <%= getGeneric(p) %><%nows%>
79
+ <% end %>
80
+ <% end %>
81
+ <% end %>
82
+ <%ws%><% expand 'annotations::Annotations' %><%nl%>
83
83
  <% end %>
84
84
 
85
85
  <% define 'EnumTypes', :for => EPackage do %>
86
- <% for enum in eClassifiers.select{|c| c.is_a?(EEnum)} %>
87
- <%= enum.name %> = Enum.new(:name => '<%= enum.name %>', :literals =>[ <%nows%>
88
- <%= enum.eLiterals.collect { |lit| ":"+lit.name }.join(', ') %> ])
89
- <% end %>
86
+ <% for enum in eClassifiers.select{|c| c.is_a?(EEnum)} %>
87
+ <%= enum.name %> = Enum.new(:name => '<%= enum.name %>', :literals =>[ <%nows%>
88
+ <%= enum.eLiterals.collect { |lit| ":"+(lit.name =~ /^\d|\W/ ? "'"+lit.name+"'" : lit.name) }.join(', ') %> ])
89
+ <% end %>
90
90
  <% end %>
91
91
 
92
92
  <% define 'GenerateAssocs', :for => EPackage do %>
93
- <% refDone = {} %>
94
- <% for ref in eAllClassifiers.select{|c| c.is_a?(EClass)}.eReferences %>
95
- <% if !refDone[ref] && ref.eOpposite %>
96
- <% ref = ref.eOpposite if ref.eOpposite.containment %>
97
- <% refDone[ref] = refDone[ref.eOpposite] = true %>
98
- <% if !ref.many && !ref.eOpposite.many %>
99
- <% if ref.containment %>
100
- <% expand 'Reference', "contains_one", this, :for => ref %>
101
- <% else %>
102
- <% expand 'Reference', "one_to_one", this, :for => ref %>
103
- <% end %>
104
- <% elsif !ref.many && ref.eOpposite.many %>
105
- <% expand 'Reference', "many_to_one", this, :for => ref %>
106
- <% elsif ref.many && !ref.eOpposite.many %>
107
- <% if ref.containment %>
108
- <% expand 'Reference', "contains_many", this, :for => ref %>
109
- <% else %>
110
- <% expand 'Reference', "one_to_many", this, :for => ref %>
111
- <% end %>
112
- <% elsif ref.many && ref.eOpposite.many %>
113
- <% expand 'Reference', "many_to_many", this, :for => ref %>
114
- <% end %>
115
- <% expand 'annotations::Annotations', :for => ref %><%nl%>
116
- <% elsif !refDone[ref] %>
117
- <% refDone[ref] = true %>
118
- <% if !ref.many %>
119
- <% if ref.containment %>
120
- <% expand 'Reference', "contains_one_uni", this, :for => ref %>
121
- <% else %>
122
- <% expand 'Reference', "has_one", this, :for => ref %>
123
- <% end %>
124
- <% elsif ref.many %>
125
- <% if ref.containment %>
126
- <% expand 'Reference', "contains_many_uni", this, :for => ref %>
127
- <% else %>
128
- <% expand 'Reference', "has_many", this, :for => ref %>
129
- <% end %>
130
- <% end %>
131
- <% expand 'annotations::Annotations', :for => ref %><%nl%>
132
- <% end %>
133
- <% end %>
93
+ <% refDone = {} %>
94
+ <% for ref in eAllClassifiers.select{|c| c.is_a?(EClass)}.eReferences %>
95
+ <% if !refDone[ref] && ref.eOpposite %>
96
+ <% ref = ref.eOpposite if ref.eOpposite.containment %>
97
+ <% refDone[ref] = refDone[ref.eOpposite] = true %>
98
+ <% if !ref.many && !ref.eOpposite.many %>
99
+ <% if ref.containment %>
100
+ <% expand 'Reference', "contains_one", this, :for => ref %>
101
+ <% else %>
102
+ <% expand 'Reference', "one_to_one", this, :for => ref %>
103
+ <% end %>
104
+ <% elsif !ref.many && ref.eOpposite.many %>
105
+ <% expand 'Reference', "many_to_one", this, :for => ref %>
106
+ <% elsif ref.many && !ref.eOpposite.many %>
107
+ <% if ref.containment %>
108
+ <% expand 'Reference', "contains_many", this, :for => ref %>
109
+ <% else %>
110
+ <% expand 'Reference', "one_to_many", this, :for => ref %>
111
+ <% end %>
112
+ <% elsif ref.many && ref.eOpposite.many %>
113
+ <% expand 'Reference', "many_to_many", this, :for => ref %>
114
+ <% end %>
115
+ <% expand 'annotations::Annotations', :for => ref %><%nl%>
116
+ <% elsif !refDone[ref] %>
117
+ <% refDone[ref] = true %>
118
+ <% if !ref.many %>
119
+ <% if ref.containment %>
120
+ <% expand 'Reference', "contains_one_uni", this, :for => ref %>
121
+ <% else %>
122
+ <% expand 'Reference', "has_one", this, :for => ref %>
123
+ <% end %>
124
+ <% elsif ref.many %>
125
+ <% if ref.containment %>
126
+ <% expand 'Reference', "contains_many_uni", this, :for => ref %>
127
+ <% else %>
128
+ <% expand 'Reference', "has_many", this, :for => ref %>
129
+ <% end %>
130
+ <% end %>
131
+ <% expand 'annotations::Annotations', :for => ref %><%nl%>
132
+ <% end %>
133
+ <% end %>
134
134
  <% end %>
135
135
 
136
136
  <% define 'Reference', :for => EReference do |cmd, rootpackage| %>
137
- <%= eContainingClass.qualifiedClassifierName(rootpackage) %>.<%= cmd %> '<%= name %>', <%= eType && eType.qualifiedClassifierName(rootpackage) %><%nows%>
138
- <% if eOpposite %><%nows%>
139
- , '<%= eOpposite.name%>'<%nows%>
140
- <% end %><%nows%>
141
- <% pset = RGen::MetamodelBuilder::ReferenceDescription.propertySet.reject{|p| p == :name || p == :upperBound || p == :containment} %>
142
- <% for p in pset.reject{|p| RGen::MetamodelBuilder::ReferenceDescription.default_value(p) == getGeneric(p)} %>
143
- , :<%=p%> => <%=getGeneric(p)%><%nows%>
144
- <% end %>
145
- <% if eOpposite %>
146
- <% for p in pset.reject{|p| RGen::MetamodelBuilder::ReferenceDescription.default_value(p) == eOpposite.getGeneric(p)} %>
147
- , :opposite_<%=p%> => <%=eOpposite.getGeneric(p)%><%nows%>
148
- <% end %>
149
- <% end %><%ws%>
137
+ <%= eContainingClass.qualifiedClassifierName(rootpackage) %>.<%= cmd %> '<%= name %>', <%= eType && eType.qualifiedClassifierName(rootpackage) %><%nows%>
138
+ <% if eOpposite %><%nows%>
139
+ , '<%= eOpposite.name%>'<%nows%>
140
+ <% end %><%nows%>
141
+ <% pset = RGen::MetamodelBuilder::Intermediate::Reference.properties.reject{|p| p == :name || p == :upperBound || p == :containment} %>
142
+ <% for p in pset.reject{|p| RGen::MetamodelBuilder::Intermediate::Reference.default_value(p) == getGeneric(p)} %>
143
+ , :<%=p%> => <%=getGeneric(p)%><%nows%>
144
+ <% end %>
145
+ <% if eOpposite %>
146
+ <% for p in pset.reject{|p| RGen::MetamodelBuilder::Intermediate::Reference.default_value(p) == eOpposite.getGeneric(p)} %>
147
+ , :opposite_<%=p%> => <%=eOpposite.getGeneric(p)%><%nows%>
148
+ <% end %>
149
+ <% end %><%ws%>
150
150
  <% end %>
151
151
 
152
152
  <% define 'ClassHeader', :for => EClass do |rootp| %>
153
- class <%= classifierName %> < <% nows %>
154
- <% if eSuperTypes.size > 1 %><% nows %>
155
- RGen::MetamodelBuilder::MMMultiple(<%= eSuperTypes.collect{|t| t.qualifiedClassifierNameIfRequired(rootp)}.join(', ') %>)
156
- <% elsif eSuperTypes.size > 0 %><% nows %>
157
- <%= eSuperTypes.first.qualifiedClassifierNameIfRequired(rootp) %>
158
- <% else %><% nows %>
159
- RGen::MetamodelBuilder::MMBase
160
- <% end %>
153
+ class <%= classifierName %> < <% nows %>
154
+ <% if eSuperTypes.size > 1 %><% nows %>
155
+ RGen::MetamodelBuilder::MMMultiple(<%= eSuperTypes.collect{|t| t.qualifiedClassifierNameIfRequired(rootp)}.join(', ') %>)
156
+ <% elsif eSuperTypes.size > 0 %><% nows %>
157
+ <%= eSuperTypes.first.qualifiedClassifierNameIfRequired(rootp) %>
158
+ <% else %><% nows %>
159
+ RGen::MetamodelBuilder::MMBase
160
+ <% end %>
161
161
  <% end %>
162
162
 
163
163
  <% define 'ClassHeaderFullyQualified', :for => EClass do |rootp| %>
164
- class <%= qualifiedClassifierName(rootp) %> < <% nows %>
165
- <% if eSuperTypes.size > 1 %><% nows %>
166
- RGen::MetamodelBuilder::MMMultiple(<%= eSuperTypes.collect{|t| t.qualifiedClassifierName(rootp)}.join(', ') %>)
167
- <% elsif eSuperTypes.size > 0 %><% nows %>
168
- <%= eSuperTypes.first.qualifiedClassifierName(rootp) %>
169
- <% else %><% nows %>
170
- RGen::MetamodelBuilder::MMBase
171
- <% end %>
164
+ class <%= qualifiedClassifierName(rootp) %> < <% nows %>
165
+ <% if eSuperTypes.size > 1 %><% nows %>
166
+ RGen::MetamodelBuilder::MMMultiple(<%= eSuperTypes.collect{|t| t.qualifiedClassifierName(rootp)}.join(', ') %>)
167
+ <% elsif eSuperTypes.size > 0 %><% nows %>
168
+ <%= eSuperTypes.first.qualifiedClassifierName(rootp) %>
169
+ <% else %><% nows %>
170
+ RGen::MetamodelBuilder::MMBase
171
+ <% end %>
172
172
  <% end %>