rgen 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +20 -1
- data/MIT-LICENSE +1 -1
- data/README +12 -9
- data/lib/instantiators/ea_instantiator.rb +36 -0
- data/lib/metamodels/uml13_metamodel.rb +559 -0
- data/lib/metamodels/uml13_metamodel_ext.rb +26 -0
- data/lib/mmgen/metamodel_generator.rb +5 -5
- data/lib/mmgen/mm_ext/ecore_ext.rb +95 -0
- data/lib/mmgen/mmgen.rb +6 -4
- data/lib/mmgen/templates/annotations.tpl +37 -0
- data/lib/mmgen/templates/metamodel_generator.tpl +171 -0
- data/lib/rgen/ecore/ecore.rb +190 -0
- data/lib/rgen/ecore/ecore_instantiator.rb +25 -0
- data/lib/rgen/ecore/ecore_transformer.rb +85 -0
- data/lib/rgen/environment.rb +9 -24
- data/lib/rgen/find_helper.rb +68 -0
- data/lib/rgen/{instantiator.rb → instantiator/abstract_instantiator.rb} +6 -2
- data/lib/rgen/instantiator/abstract_xml_instantiator.rb +59 -0
- data/lib/rgen/instantiator/default_xml_instantiator.rb +117 -0
- data/lib/rgen/instantiator/ecore_xml_instantiator.rb +144 -0
- data/lib/rgen/instantiator/nodebased_xml_instantiator.rb +157 -0
- data/lib/rgen/instantiator/xmi11_instantiator.rb +164 -0
- data/lib/rgen/metamodel_builder.rb +103 -9
- data/lib/rgen/metamodel_builder/build_helper.rb +26 -4
- data/lib/rgen/metamodel_builder/builder_extensions.rb +285 -88
- data/lib/rgen/metamodel_builder/builder_runtime.rb +7 -1
- data/lib/rgen/metamodel_builder/data_types.rb +67 -0
- data/lib/rgen/metamodel_builder/intermediate/annotation.rb +30 -0
- data/lib/rgen/metamodel_builder/metamodel_description.rb +232 -0
- data/lib/rgen/metamodel_builder/mm_multiple.rb +23 -0
- data/lib/rgen/metamodel_builder/module_extension.rb +33 -0
- data/lib/rgen/model_comparator.rb +56 -0
- data/lib/rgen/model_dumper.rb +5 -5
- data/lib/rgen/name_helper.rb +17 -1
- data/lib/rgen/template_language.rb +148 -28
- data/lib/rgen/template_language/directory_template_container.rb +56 -38
- data/lib/rgen/template_language/output_handler.rb +93 -77
- data/lib/rgen/template_language/template_container.rb +186 -143
- data/lib/rgen/transformer.rb +19 -14
- data/lib/transformers/uml13_to_ecore.rb +75 -0
- data/redist/xmlscan/ChangeLog +1301 -0
- data/redist/xmlscan/README +34 -0
- data/redist/xmlscan/THANKS +11 -0
- data/redist/xmlscan/doc/changes.html +74 -0
- data/redist/xmlscan/doc/changes.rd +80 -0
- data/redist/xmlscan/doc/en/conformance.html +136 -0
- data/redist/xmlscan/doc/en/conformance.rd +152 -0
- data/redist/xmlscan/doc/en/manual.html +356 -0
- data/redist/xmlscan/doc/en/manual.rd +402 -0
- data/redist/xmlscan/doc/ja/conformance.ja.html +118 -0
- data/redist/xmlscan/doc/ja/conformance.ja.rd +134 -0
- data/redist/xmlscan/doc/ja/manual.ja.html +325 -0
- data/redist/xmlscan/doc/ja/manual.ja.rd +370 -0
- data/redist/xmlscan/doc/src/Makefile +41 -0
- data/redist/xmlscan/doc/src/conformance.rd.src +256 -0
- data/redist/xmlscan/doc/src/langsplit.rb +110 -0
- data/redist/xmlscan/doc/src/manual.rd.src +614 -0
- data/redist/xmlscan/install.rb +41 -0
- data/redist/xmlscan/lib/xmlscan/encoding.rb +311 -0
- data/redist/xmlscan/lib/xmlscan/htmlscan.rb +289 -0
- data/redist/xmlscan/lib/xmlscan/namespace.rb +352 -0
- data/redist/xmlscan/lib/xmlscan/parser.rb +299 -0
- data/redist/xmlscan/lib/xmlscan/scanner.rb +1109 -0
- data/redist/xmlscan/lib/xmlscan/version.rb +22 -0
- data/redist/xmlscan/lib/xmlscan/visitor.rb +158 -0
- data/redist/xmlscan/lib/xmlscan/xmlchar.rb +441 -0
- data/redist/xmlscan/memo/CONFORMANCE +1249 -0
- data/redist/xmlscan/memo/PRODUCTIONS +195 -0
- data/redist/xmlscan/memo/contentspec.ry +335 -0
- data/redist/xmlscan/samples/chibixml.rb +105 -0
- data/redist/xmlscan/samples/getxmlchar.rb +122 -0
- data/redist/xmlscan/samples/rexml.rb +159 -0
- data/redist/xmlscan/samples/xmlbench.rb +88 -0
- data/redist/xmlscan/samples/xmlbench/parser/chibixml.rb +22 -0
- data/redist/xmlscan/samples/xmlbench/parser/nqxml.rb +29 -0
- data/redist/xmlscan/samples/xmlbench/parser/rexml.rb +62 -0
- data/redist/xmlscan/samples/xmlbench/parser/xmlparser.rb +22 -0
- data/redist/xmlscan/samples/xmlbench/parser/xmlscan-0.0.10.rb +62 -0
- data/redist/xmlscan/samples/xmlbench/parser/xmlscan-chibixml.rb +22 -0
- data/redist/xmlscan/samples/xmlbench/parser/xmlscan-rexml.rb +22 -0
- data/redist/xmlscan/samples/xmlbench/parser/xmlscan.rb +99 -0
- data/redist/xmlscan/samples/xmlbench/xmlbench-lib.rb +116 -0
- data/redist/xmlscan/samples/xmlconftest.rb +200 -0
- data/redist/xmlscan/test.rb +7 -0
- data/redist/xmlscan/tests/deftestcase.rb +73 -0
- data/redist/xmlscan/tests/runtest.rb +47 -0
- data/redist/xmlscan/tests/testall.rb +14 -0
- data/redist/xmlscan/tests/testencoding.rb +438 -0
- data/redist/xmlscan/tests/testhtmlscan.rb +752 -0
- data/redist/xmlscan/tests/testnamespace.rb +457 -0
- data/redist/xmlscan/tests/testparser.rb +591 -0
- data/redist/xmlscan/tests/testscanner.rb +1749 -0
- data/redist/xmlscan/tests/testxmlchar.rb +143 -0
- data/redist/xmlscan/tests/visitor.rb +34 -0
- data/test/array_extensions_test.rb +2 -2
- data/test/ea_instantiator_test.rb +41 -0
- data/test/ecore_self_test.rb +53 -0
- data/test/environment_test.rb +11 -6
- data/test/metamodel_builder_test.rb +404 -245
- data/test/metamodel_roundtrip_test.rb +52 -0
- data/test/metamodel_roundtrip_test/TestModel.rb +65 -0
- data/test/metamodel_roundtrip_test/TestModel_Regenerated.rb +64 -0
- data/test/metamodel_roundtrip_test/houseMetamodel.ecore +32 -0
- data/test/metamodel_roundtrip_test/houseMetamodel_from_ecore.rb +39 -0
- data/test/rgen_test.rb +3 -3
- data/test/template_language_test.rb +65 -39
- data/test/template_language_test/expected_result.txt +24 -3
- data/test/template_language_test/templates/code/array.tpl +11 -0
- data/test/template_language_test/templates/content/author.tpl +7 -0
- data/test/template_language_test/templates/content/chapter.tpl +1 -1
- data/test/template_language_test/templates/root.tpl +17 -8
- data/test/template_language_test/testout.txt +24 -3
- data/test/testmodel/class_model_checker.rb +119 -0
- data/test/{xmi_instantiator_test/testmodel.eap → testmodel/ea_testmodel.eap} +0 -0
- data/test/{xmi_instantiator_test/testmodel.xml → testmodel/ea_testmodel.xml} +81 -14
- data/test/testmodel/ea_testmodel_partial.xml +317 -0
- data/test/testmodel/ecore_model_checker.rb +101 -0
- data/test/testmodel/manual_testmodel.xml +22 -0
- data/test/testmodel/object_model_checker.rb +67 -0
- data/test/transformer_test.rb +18 -10
- data/test/xml_instantiator_test.rb +81 -8
- data/test/xml_instantiator_test/simple_ecore_model_checker.rb +94 -0
- data/test/xml_instantiator_test/simple_xmi_ecore_instantiator.rb +53 -0
- data/test/xml_instantiator_test/simple_xmi_metamodel.rb +49 -0
- data/test/xml_instantiator_test/simple_xmi_to_ecore.rb +75 -0
- metadata +126 -28
- data/lib/ea/xmi_class_instantiator.rb +0 -46
- data/lib/ea/xmi_helper.rb +0 -26
- data/lib/ea/xmi_metamodel.rb +0 -34
- data/lib/ea/xmi_object_instantiator.rb +0 -46
- data/lib/ea/xmi_to_classmodel.rb +0 -78
- data/lib/ea/xmi_to_objectmodel.rb +0 -92
- data/lib/mmgen/mm_ext/uml_classmodel_ext.rb +0 -71
- data/lib/mmgen/templates/uml_classmodel.tpl +0 -63
- data/lib/rgen/xml_instantiator.rb +0 -132
- data/lib/uml/objectmodel_instantiator.rb +0 -53
- data/lib/uml/uml_classmodel.rb +0 -92
- data/lib/uml/uml_objectmodel.rb +0 -65
- data/test/metamodel_generator_test.rb +0 -44
- data/test/metamodel_generator_test/TestModel.rb +0 -40
- data/test/metamodel_generator_test/expected_result.txt +0 -40
- data/test/xmi_class_instantiator_test.rb +0 -24
- data/test/xmi_instantiator_test/class_model_checker.rb +0 -97
- data/test/xmi_object_instantiator_test.rb +0 -65
- data/test/xml_instantiator_test/testmodel.xml +0 -7
@@ -0,0 +1,52 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rgen/array_extensions'
|
5
|
+
require 'rgen/model_comparator'
|
6
|
+
require 'mmgen/metamodel_generator'
|
7
|
+
require 'rgen/instantiator/ecore_xml_instantiator'
|
8
|
+
|
9
|
+
class MetamodelGeneratorTest < Test::Unit::TestCase
|
10
|
+
|
11
|
+
TEST_DIR = File.dirname(__FILE__)+"/metamodel_roundtrip_test"
|
12
|
+
|
13
|
+
include MMGen::MetamodelGenerator
|
14
|
+
include RGen::ModelComparator
|
15
|
+
|
16
|
+
module Regenerated
|
17
|
+
Inside = binding
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_generator
|
21
|
+
require TEST_DIR+"/TestModel.rb"
|
22
|
+
outfile = TEST_DIR+"/TestModel_Regenerated.rb"
|
23
|
+
generateMetamodel(HouseMetamodel.ecore, outfile)
|
24
|
+
|
25
|
+
File.open(outfile) do |f|
|
26
|
+
eval(f.read, Regenerated::Inside)
|
27
|
+
end
|
28
|
+
|
29
|
+
assert modelEqual?(HouseMetamodel.ecore, Regenerated::HouseMetamodel.ecore, ["instanceClassName"])
|
30
|
+
end
|
31
|
+
|
32
|
+
module UMLRegenerated
|
33
|
+
Inside = binding
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_generate_from_ecore
|
37
|
+
outfile = TEST_DIR+"/houseMetamodel_from_ecore.rb"
|
38
|
+
|
39
|
+
env = RGen::Environment.new
|
40
|
+
File.open(TEST_DIR+"/houseMetamodel.ecore") { |f|
|
41
|
+
ECoreXMLInstantiator.new(env).instantiate(f.read)
|
42
|
+
}
|
43
|
+
rootpackage = env.find(:class => RGen::ECore::EPackage).first
|
44
|
+
rootpackage.name = "HouseMetamodel"
|
45
|
+
generateMetamodel(rootpackage, outfile)
|
46
|
+
|
47
|
+
File.open(outfile) do |f|
|
48
|
+
eval(f.read, UMLRegenerated::Inside, "test_eval", 0)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rgen/metamodel_builder'
|
2
|
+
|
3
|
+
module HouseMetamodel
|
4
|
+
extend RGen::MetamodelBuilder::ModuleExtension
|
5
|
+
include RGen::MetamodelBuilder::DataTypes
|
6
|
+
|
7
|
+
# TODO: Datatypes
|
8
|
+
# AggregationKind = Enum.new([ :none, :aggregate, :composite ])
|
9
|
+
|
10
|
+
class MeetingPlace < RGen::MetamodelBuilder::MMBase
|
11
|
+
annotation :source => "testmodel", :details => { 'complexity' => '1', 'date_created' => '2006-07-12 08:40:46', 'date_modified' => '2006-07-12 08:44:02', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0' }
|
12
|
+
end
|
13
|
+
|
14
|
+
class Person < RGen::MetamodelBuilder::MMBase
|
15
|
+
annotation 'complexity' => '1', 'date_created' => '2006-06-27 08:34:23', 'date_modified' => '2006-06-27 08:34:26', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
|
16
|
+
end
|
17
|
+
|
18
|
+
class House < RGen::MetamodelBuilder::MMBase
|
19
|
+
annotation 'complexity' => '1', 'date_created' => '2005-09-16 19:52:18', 'date_modified' => '2006-02-28 08:29:19', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'stereotype' => 'dummy', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
|
20
|
+
has_attr 'size', Integer
|
21
|
+
has_attr 'module'
|
22
|
+
has_attr 'address', String, :changeable => false do
|
23
|
+
annotation 'collection' => 'false', 'containment' => 'Not Specified', 'derived' => '0', 'duplicates' => '0', 'ea_guid' => '{A8DF581B-9AC6-4f75-AB48-8FAEDFC6E068}', 'lowerBound' => '1', 'ordered' => '0', 'position' => '0', 'styleex' => 'volatile=0;', 'type' => 'String', 'upperBound' => '1'
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
module Rooms
|
30
|
+
extend RGen::MetamodelBuilder::ModuleExtension
|
31
|
+
|
32
|
+
|
33
|
+
class Room < RGen::MetamodelBuilder::MMBase
|
34
|
+
annotation 'complexity' => '1', 'date_created' => '2005-09-16 19:52:28', 'date_modified' => '2006-06-22 21:15:25', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
|
35
|
+
end
|
36
|
+
|
37
|
+
class Bathroom < Room
|
38
|
+
annotation 'complexity' => '1', 'date_created' => '2006-06-27 08:32:25', 'date_modified' => '2006-06-27 08:34:23', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
|
39
|
+
end
|
40
|
+
|
41
|
+
class Kitchen < RGen::MetamodelBuilder::MMMultiple(HouseMetamodel::MeetingPlace, Room)
|
42
|
+
annotation 'complexity' => '1', 'date_created' => '2005-11-30 19:26:13', 'date_modified' => '2006-06-22 21:15:34', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
module DependingOnRooms
|
48
|
+
extend RGen::MetamodelBuilder::ModuleExtension
|
49
|
+
class RoomSub < Rooms::Room
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
HouseMetamodel::Person.has_many 'home', HouseMetamodel::House do
|
55
|
+
annotation 'containment' => 'Unspecified'
|
56
|
+
end
|
57
|
+
HouseMetamodel::House.has_one 'bathroom', HouseMetamodel::Rooms::Bathroom, :lowerBound => 1, :transient => true
|
58
|
+
HouseMetamodel::House.one_to_one 'kitchen', HouseMetamodel::Rooms::Kitchen, 'house', :lowerBound => 1, :opposite_lowerBound => 1 do
|
59
|
+
annotation 'containment' => 'Unspecified'
|
60
|
+
opposite_annotation 'containment' => 'Unspecified'
|
61
|
+
end
|
62
|
+
HouseMetamodel::House.contains_many 'room', HouseMetamodel::Rooms::Room, 'house', :lowerBound => 1 do
|
63
|
+
# only an opposite annotation
|
64
|
+
opposite_annotation 'containment' => 'Unspecified'
|
65
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rgen/metamodel_builder'
|
2
|
+
|
3
|
+
module HouseMetamodel
|
4
|
+
extend RGen::MetamodelBuilder::ModuleExtension
|
5
|
+
include RGen::MetamodelBuilder::DataTypes
|
6
|
+
|
7
|
+
|
8
|
+
module Rooms
|
9
|
+
extend RGen::MetamodelBuilder::ModuleExtension
|
10
|
+
include RGen::MetamodelBuilder::DataTypes
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
module DependingOnRooms
|
15
|
+
extend RGen::MetamodelBuilder::ModuleExtension
|
16
|
+
include RGen::MetamodelBuilder::DataTypes
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class HouseMetamodel::House < RGen::MetamodelBuilder::MMBase
|
22
|
+
annotation 'complexity' => '1', 'date_created' => '2005-09-16 19:52:18', 'date_modified' => '2006-02-28 08:29:19', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'stereotype' => 'dummy', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
|
23
|
+
has_attr 'size', Integer
|
24
|
+
has_attr 'module', String
|
25
|
+
has_attr 'address', String, :changeable => false do
|
26
|
+
annotation 'collection' => 'false', 'containment' => 'Not Specified', 'derived' => '0', 'duplicates' => '0', 'ea_guid' => '{A8DF581B-9AC6-4f75-AB48-8FAEDFC6E068}', 'lowerBound' => '1', 'ordered' => '0', 'position' => '0', 'styleex' => 'volatile=0;', 'type' => 'String', 'upperBound' => '1'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class HouseMetamodel::MeetingPlace < RGen::MetamodelBuilder::MMBase
|
31
|
+
annotation :source => "testmodel", :details => {'complexity' => '1', 'date_created' => '2006-07-12 08:40:46', 'date_modified' => '2006-07-12 08:44:02', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'}
|
32
|
+
end
|
33
|
+
|
34
|
+
class HouseMetamodel::Person < RGen::MetamodelBuilder::MMBase
|
35
|
+
annotation 'complexity' => '1', 'date_created' => '2006-06-27 08:34:23', 'date_modified' => '2006-06-27 08:34:26', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
|
36
|
+
end
|
37
|
+
|
38
|
+
class HouseMetamodel::Rooms::Room < RGen::MetamodelBuilder::MMBase
|
39
|
+
annotation 'complexity' => '1', 'date_created' => '2005-09-16 19:52:28', 'date_modified' => '2006-06-22 21:15:25', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
|
40
|
+
end
|
41
|
+
|
42
|
+
class HouseMetamodel::Rooms::Kitchen < RGen::MetamodelBuilder::MMMultiple(HouseMetamodel::MeetingPlace, HouseMetamodel::Rooms::Room)
|
43
|
+
annotation 'complexity' => '1', 'date_created' => '2005-11-30 19:26:13', 'date_modified' => '2006-06-22 21:15:34', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
|
44
|
+
end
|
45
|
+
|
46
|
+
class HouseMetamodel::Rooms::Bathroom < HouseMetamodel::Rooms::Room
|
47
|
+
annotation 'complexity' => '1', 'date_created' => '2006-06-27 08:32:25', 'date_modified' => '2006-06-27 08:34:23', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
|
48
|
+
end
|
49
|
+
|
50
|
+
class HouseMetamodel::DependingOnRooms::RoomSub < HouseMetamodel::Rooms::Room
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
HouseMetamodel::House.has_one 'bathroom', HouseMetamodel::Rooms::Bathroom, :transient => true, :lowerBound => 1
|
55
|
+
HouseMetamodel::House.one_to_one 'kitchen', HouseMetamodel::Rooms::Kitchen, 'house', :lowerBound => 1, :opposite_lowerBound => 1 do
|
56
|
+
annotation 'containment' => 'Unspecified'
|
57
|
+
opposite_annotation 'containment' => 'Unspecified'
|
58
|
+
end
|
59
|
+
HouseMetamodel::House.contains_many 'room', HouseMetamodel::Rooms::Room, 'house', :lowerBound => 1 do
|
60
|
+
opposite_annotation 'containment' => 'Unspecified'
|
61
|
+
end
|
62
|
+
HouseMetamodel::Person.has_many 'home', HouseMetamodel::House do
|
63
|
+
annotation 'containment' => 'Unspecified'
|
64
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ecore:EPackage xmi:version="2.0"
|
3
|
+
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="HouseMetamodel">
|
5
|
+
<eClassifiers xsi:type="ecore:EClass" name="House">
|
6
|
+
<eStructuralFeatures xsi:type="ecore:EAttribute" name="address" eType="#//String"
|
7
|
+
changeable="false"/>
|
8
|
+
<eStructuralFeatures xsi:type="ecore:EReference" name="bathroom" lowerBound="1"
|
9
|
+
eType="#//Rooms/Bathroom"/>
|
10
|
+
<eStructuralFeatures xsi:type="ecore:EReference" name="kitchen" lowerBound="1"
|
11
|
+
eType="#//Rooms/Kitchen" eOpposite="#//Rooms/Kitchen/house"/>
|
12
|
+
<eStructuralFeatures xsi:type="ecore:EReference" name="room" upperBound="-1" eType="#//Rooms/Room"
|
13
|
+
containment="true" eOpposite="#//Rooms/Room/house"/>
|
14
|
+
</eClassifiers>
|
15
|
+
<eClassifiers xsi:type="ecore:EClass" name="MeetingPlace"/>
|
16
|
+
<eClassifiers xsi:type="ecore:EClass" name="Person">
|
17
|
+
<eStructuralFeatures xsi:type="ecore:EReference" name="house" upperBound="-1"
|
18
|
+
eType="#//House"/>
|
19
|
+
</eClassifiers>
|
20
|
+
<eClassifiers xsi:type="ecore:EDataType" name="String" instanceClassName="java.lang.String"/>
|
21
|
+
<eSubpackages name="Rooms">
|
22
|
+
<eClassifiers xsi:type="ecore:EClass" name="Room">
|
23
|
+
<eStructuralFeatures xsi:type="ecore:EReference" name="house" eType="#//House"
|
24
|
+
defaultValueLiteral="" eOpposite="#//House/room"/>
|
25
|
+
</eClassifiers>
|
26
|
+
<eClassifiers xsi:type="ecore:EClass" name="Bathroom" eSuperTypes="#//Rooms/Room"/>
|
27
|
+
<eClassifiers xsi:type="ecore:EClass" name="Kitchen" eSuperTypes="#//Rooms/Room #//MeetingPlace">
|
28
|
+
<eStructuralFeatures xsi:type="ecore:EReference" name="house" eType="#//House"
|
29
|
+
eOpposite="#//House/kitchen"/>
|
30
|
+
</eClassifiers>
|
31
|
+
</eSubpackages>
|
32
|
+
</ecore:EPackage>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rgen/metamodel_builder'
|
2
|
+
|
3
|
+
module HouseMetamodel
|
4
|
+
extend RGen::MetamodelBuilder::ModuleExtension
|
5
|
+
include RGen::MetamodelBuilder::DataTypes
|
6
|
+
|
7
|
+
|
8
|
+
class House < RGen::MetamodelBuilder::MMBase
|
9
|
+
has_attr 'address', String, :ordered => :true, :unique => :true, :changeable => false, :volatile => :false, :transient => :false, :unsettable => :false, :derived => :false
|
10
|
+
end
|
11
|
+
|
12
|
+
class MeetingPlace < RGen::MetamodelBuilder::MMBase
|
13
|
+
end
|
14
|
+
|
15
|
+
class Person < RGen::MetamodelBuilder::MMBase
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
module Rooms
|
20
|
+
extend RGen::MetamodelBuilder::ModuleExtension
|
21
|
+
include RGen::MetamodelBuilder::DataTypes
|
22
|
+
|
23
|
+
|
24
|
+
class Room < RGen::MetamodelBuilder::MMBase
|
25
|
+
end
|
26
|
+
|
27
|
+
class Bathroom < Room
|
28
|
+
end
|
29
|
+
|
30
|
+
class Kitchen < RGen::MetamodelBuilder::MMMultiple(Room, HouseMetamodel::MeetingPlace)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
HouseMetamodel::House.contains_one_uni 'bathroom', HouseMetamodel::Rooms::Bathroom, :ordered => true, :unique => true, :changeable => true, :volatile => false, :transient => false, :unsettable => false, :derived => false, :lowerBound => 1, :resolveProxies => true
|
37
|
+
HouseMetamodel::Rooms::Kitchen.contains_one 'house', HouseMetamodel::House, 'kitchen', :ordered => true, :unique => true, :changeable => true, :volatile => false, :transient => false, :unsettable => false, :derived => false, :resolveProxies => true, :opposite_ordered => true, :opposite_unique => true, :opposite_changeable => true, :opposite_volatile => false, :opposite_transient => false, :opposite_unsettable => false, :opposite_derived => false, :opposite_lowerBound => 1, :opposite_resolveProxies => true
|
38
|
+
HouseMetamodel::Rooms::Room.many_to_one 'house', HouseMetamodel::House, 'room', :ordered => true, :unique => true, :changeable => true, :volatile => false, :transient => false, :unsettable => false, :derived => false, :resolveProxies => true, :opposite_ordered => true, :opposite_unique => true, :opposite_changeable => true, :opposite_volatile => false, :opposite_transient => false, :opposite_unsettable => false, :opposite_derived => false, :opposite_resolveProxies => true
|
39
|
+
HouseMetamodel::Person.contains_many_uni 'house', HouseMetamodel::House, :ordered => true, :unique => true, :changeable => true, :volatile => false, :transient => false, :unsettable => false, :derived => false, :resolveProxies => true
|
data/test/rgen_test.rb
CHANGED
@@ -3,12 +3,12 @@ $:.unshift File.dirname(__FILE__)
|
|
3
3
|
require 'test/unit'
|
4
4
|
|
5
5
|
require 'array_extensions_test'
|
6
|
+
require 'ea_instantiator_test'
|
7
|
+
require 'ecore_self_test'
|
6
8
|
require 'environment_test'
|
7
9
|
require 'metamodel_builder_test'
|
10
|
+
require 'metamodel_roundtrip_test'
|
8
11
|
require 'output_handler_test'
|
9
12
|
require 'template_language_test'
|
10
|
-
require 'xmi_class_instantiator_test'
|
11
|
-
require 'xmi_object_instantiator_test'
|
12
|
-
require 'metamodel_generator_test'
|
13
13
|
require 'transformer_test'
|
14
14
|
require 'xml_instantiator_test'
|
@@ -2,45 +2,71 @@ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
4
|
require 'rgen/template_language'
|
5
|
+
require 'rgen/metamodel_builder'
|
5
6
|
|
6
7
|
class TemplateContainerTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
8
|
+
|
9
|
+
TEMPLATES_DIR = File.dirname(__FILE__)+"/template_language_test/templates"
|
10
|
+
OUTPUT_DIR = File.dirname(__FILE__)+"/template_language_test"
|
11
|
+
|
12
|
+
module MyMM
|
13
|
+
|
14
|
+
class Chapter
|
15
|
+
attr_reader :title
|
16
|
+
def initialize(title)
|
17
|
+
@title = title
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Document
|
22
|
+
attr_reader :title, :authors, :chapters
|
23
|
+
attr_accessor :sampleArray
|
24
|
+
def initialize(title)
|
25
|
+
@title = title
|
26
|
+
@chapters = []
|
27
|
+
@authors = []
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Author
|
32
|
+
attr_reader :name, :email
|
33
|
+
def initialize(name, email)
|
34
|
+
@name, @email = name, email
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
module CCodeMM
|
41
|
+
class CArray < RGen::MetamodelBuilder::MMBase
|
42
|
+
has_attr 'name'
|
43
|
+
has_attr 'size', Integer
|
44
|
+
has_attr 'type'
|
45
|
+
end
|
46
|
+
class PrimitiveInitValue < RGen::MetamodelBuilder::MMBase
|
47
|
+
has_attr 'value', Integer
|
48
|
+
end
|
49
|
+
CArray.has_many 'initvalue', PrimitiveInitValue
|
50
|
+
end
|
51
|
+
|
52
|
+
TEST_MODEL = MyMM::Document.new("SomeDocument")
|
53
|
+
TEST_MODEL.authors << MyMM::Author.new("Martin", "martin@somewhe.re")
|
54
|
+
TEST_MODEL.authors << MyMM::Author.new("Otherguy", "other@somewhereel.se")
|
55
|
+
TEST_MODEL.chapters << MyMM::Chapter.new("Intro")
|
56
|
+
TEST_MODEL.chapters << MyMM::Chapter.new("MainPart")
|
57
|
+
TEST_MODEL.chapters << MyMM::Chapter.new("Summary")
|
58
|
+
TEST_MODEL.sampleArray = CCodeMM::CArray.new(:name => "myArray", :type => "int", :size => 5,
|
59
|
+
:initvalue => (1..5).collect { |v| CCodeMM::PrimitiveInitValue.new(:value => v) })
|
60
|
+
|
61
|
+
def test_with_model
|
62
|
+
tc = RGen::TemplateLanguage::DirectoryTemplateContainer.new([MyMM, CCodeMM], OUTPUT_DIR)
|
63
|
+
tc.load(TEMPLATES_DIR)
|
64
|
+
File.delete(OUTPUT_DIR+"/testout.txt") if File.exists? OUTPUT_DIR+"/testout.txt"
|
65
|
+
tc.expand('root::Root', :for => TEST_MODEL, :indent => 1)
|
66
|
+
result = expected = ""
|
67
|
+
File.open(OUTPUT_DIR+"/testout.txt") {|f| result = f.read}
|
68
|
+
File.open(OUTPUT_DIR+"/expected_result.txt") {|f| expected = f.read}
|
69
|
+
assert_equal expected, result
|
70
|
+
end
|
71
|
+
|
46
72
|
end
|
@@ -1,10 +1,31 @@
|
|
1
1
|
Document: SomeDocument
|
2
|
+
|
3
|
+
by Martin, EMail: martin(at)somewhe.re and Otherguy, EMail: other(at)somewhereel.se
|
4
|
+
|
2
5
|
Index:
|
3
6
|
1 Intro in SomeDocument
|
4
7
|
2 MainPart in SomeDocument
|
5
8
|
3 Summary in SomeDocument
|
6
|
-
|
9
|
+
|
7
10
|
----------------
|
8
|
-
|
9
|
-
|
11
|
+
|
12
|
+
Chapters in one line:
|
13
|
+
*** Intro ***, *** MainPart ***, *** Summary ***
|
14
|
+
|
15
|
+
Chapters each in one line:
|
16
|
+
*** Intro ***,
|
17
|
+
*** MainPart ***,
|
10
18
|
*** Summary ***
|
19
|
+
|
20
|
+
Here are some code examples:
|
21
|
+
Text from Root
|
22
|
+
Text from Root
|
23
|
+
int myArray[5] = {
|
24
|
+
1,
|
25
|
+
2,
|
26
|
+
3,
|
27
|
+
4,
|
28
|
+
5
|
29
|
+
};
|
30
|
+
Text from Root
|
31
|
+
Text from Root
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% define 'ArrayDefinition', :for => CArray do %>
|
2
|
+
<%= getType %> <%= name %>[<%= size %>] = {<%iinc%>
|
3
|
+
<% expand 'InitValue', :foreach => initvalue, :separator => ",\n" %><%nl%><%idec%>
|
4
|
+
};
|
5
|
+
<% expand '../root::TextFromRoot' %>
|
6
|
+
<% expand '/root::TextFromRoot' %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% define 'InitValue', :for => PrimitiveInitValue do %>
|
10
|
+
<%= value %><%nows%>
|
11
|
+
<% end %>
|