xamplr-gen 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/COPYING +619 -0
  4. data/LICENSE +4 -0
  5. data/Makefile +11 -0
  6. data/README.md +33 -0
  7. data/Rakefile +66 -0
  8. data/VERSION +1 -0
  9. data/bin/xampl-gen +17 -0
  10. data/features/step_definitions/xamplr-gen_steps.rb +0 -0
  11. data/features/support/env.rb +6 -0
  12. data/features/xamplr-gen.feature +9 -0
  13. data/lib/xamplr-gen.rb +13 -0
  14. data/lib/xamplr-gen/.cvsignore +1 -0
  15. data/lib/xamplr-gen/graphml-out.rb +449 -0
  16. data/lib/xamplr-gen/my.gen.elements.xml +461 -0
  17. data/lib/xamplr-gen/simpleTemplate/danger.rx +4 -0
  18. data/lib/xamplr-gen/simpleTemplate/obsolete/input-c.r4 +35 -0
  19. data/lib/xamplr-gen/simpleTemplate/obsolete/play.r6.txt +12 -0
  20. data/lib/xamplr-gen/simpleTemplate/obsolete/play_more.r6.txt +20 -0
  21. data/lib/xamplr-gen/simpleTemplate/obsolete/test001.r5 +8 -0
  22. data/lib/xamplr-gen/simpleTemplate/obsolete/test002.r5 +13 -0
  23. data/lib/xamplr-gen/simpleTemplate/obsolete/test003.r5 +37 -0
  24. data/lib/xamplr-gen/simpleTemplate/old/r6.000.rb +122 -0
  25. data/lib/xamplr-gen/simpleTemplate/old/r6.001.rb +145 -0
  26. data/lib/xamplr-gen/simpleTemplate/play.r6 +12 -0
  27. data/lib/xamplr-gen/simpleTemplate/play_more.r6 +20 -0
  28. data/lib/xamplr-gen/simpleTemplate/play_noblanks.r6 +21 -0
  29. data/lib/xamplr-gen/simpleTemplate/playq.r6 +16 -0
  30. data/lib/xamplr-gen/simpleTemplate/r6.rb +87 -0
  31. data/lib/xamplr-gen/simpleTemplate/simple-template.rb +75 -0
  32. data/lib/xamplr-gen/templates/.cvsignore +3 -0
  33. data/lib/xamplr-gen/templates/child.template +47 -0
  34. data/lib/xamplr-gen/templates/child_indexed.template +89 -0
  35. data/lib/xamplr-gen/templates/child_modules.template +5 -0
  36. data/lib/xamplr-gen/templates/element_classes.template +11 -0
  37. data/lib/xamplr-gen/templates/element_data.template +283 -0
  38. data/lib/xamplr-gen/templates/element_empty.template +277 -0
  39. data/lib/xamplr-gen/templates/element_mixed.template +278 -0
  40. data/lib/xamplr-gen/templates/element_simple.template +277 -0
  41. data/lib/xamplr-gen/templates/package.template +38 -0
  42. data/lib/xamplr-gen/xampl-cl-gen.rb +89 -0
  43. data/lib/xamplr-gen/xampl-generator.rb +561 -0
  44. data/lib/xamplr-gen/xampl-hand-generated.rb +1534 -0
  45. data/lib/xamplr-gen/yuml-out.rb +127 -0
  46. data/licence.rb +17 -0
  47. data/test/helper.rb +10 -0
  48. data/test/test_xamplr-gen.rb +7 -0
  49. data/xamplr-gen.gemspec +98 -0
  50. metadata +124 -0
@@ -0,0 +1,277 @@
1
+
2
+ class #{@element.class_name}
3
+ |
4
+ |if @element.persisted then
5
+ |
6
+ include Xampl::XamplPersistedObject
7
+
8
+ #supports class based over-ride of persister format
9
+ @@default_persister_format = nil
10
+
11
+ def default_persister_format
12
+ @@default_persister_format
13
+ end
14
+ def #{@element.class_name}.default_persister_format
15
+ @@default_persister_format
16
+ end
17
+ def #{@element.class_name}.set_default_persister_format(format)
18
+ @@default_persister_format = format
19
+ end
20
+
21
+ def #{@element.class_name}.find_by_query
22
+ things = Xampl.find_xampl do | q |
23
+ q.add_condition('class', :equals, self.name)
24
+ yield(q)
25
+ end
26
+ end
27
+
28
+ |
29
+ |else
30
+ |
31
+ include Xampl::XamplObject
32
+ |
33
+ |end
34
+ |
35
+ include Xampl::XamplWithoutContent
36
+
37
+ @@tag = "#{element.name}"
38
+ @@ns = "#{@element.namespace}"
39
+ @@ns_tag = "{#{@element.namespace}}#{element.name}"
40
+ @@module_name = "#{@package_name}"
41
+ @@safe_name = "#{@package_name}_#{@element.attribute_name}"
42
+ @@attributes = [
43
+ |
44
+ |@element.attribute_child.each{ | attribute |
45
+ | if attribute.namespace then
46
+ |
47
+ [ :@#{attribute.name}, "#{attribute.name}", "#{attribute.namespace}" ],
48
+ |
49
+ | else
50
+ |
51
+ [ :@#{attribute.name}, "#{attribute.name}" ],
52
+ |
53
+ | end
54
+ |}
55
+ |
56
+ ]
57
+ |
58
+ |@element.child_element_child.each{ | child_element |
59
+ | element_class_name = @lookup_element[child_element.name].class_name
60
+ | element_package = @lookup_element[child_element.name].package
61
+ |
62
+ include #{element_package}::#{element_class_name}AsChild
63
+ |
64
+ |}
65
+ |
66
+ |if @element.persisted then
67
+ |
68
+
69
+ def #{@element.class_name}.lookup(pid)
70
+ Xampl.lookup(#{@element.class_name}, pid)
71
+ end
72
+
73
+ def #{@element.class_name}.[](pid)
74
+ Xampl.lookup(#{@element.class_name}, pid)
75
+ end
76
+ |
77
+ |end
78
+ |
79
+ |@element.attribute_child.each{ | attribute |
80
+ | if attribute.name == @element.indexed_by_attr and @element.persisted then
81
+ |
82
+
83
+ def #{attribute.name}
84
+ @#{attribute.name}
85
+ end
86
+
87
+ def #{attribute.name}=(v)
88
+ accessed
89
+ # This is kind of optimistic, I think you are in trouble if you do this
90
+ Xampl.auto_uncache(self) if @#{attribute.name}
91
+ @#{attribute.name} = v
92
+ changed
93
+ Xampl.auto_cache(self) if v
94
+ end
95
+ |
96
+ | else
97
+ |
98
+
99
+ def #{attribute.name}
100
+ accessed
101
+ @#{attribute.name}
102
+ end
103
+
104
+ def #{attribute.name}=(v)
105
+ accessed
106
+ changed
107
+ @#{attribute.name} = v
108
+ end
109
+ |
110
+ | end
111
+ |}
112
+ |
113
+ | if @element.indexed_by_attr then
114
+ |
115
+
116
+ def initialize(index=nil)
117
+ @#{@element.indexed_by_attr} = index if index
118
+ super()
119
+ |
120
+ | else
121
+ |
122
+
123
+ def initialize
124
+ super
125
+ |
126
+ |end
127
+ |
128
+ |if 0 < @element.attribute_child.size then
129
+ |
130
+
131
+ |
132
+ |end
133
+ |
134
+ |@element.attribute_child.each{ | attribute |
135
+ |
136
+ @#{attribute.name} = nil if not defined? @#{attribute.name}
137
+ |
138
+ |}
139
+ |
140
+
141
+ init_xampl_object
142
+ |
143
+ |@element.child_element_child.each{ | child_element |
144
+ | element_attribute_name = @lookup_element[child_element.name].attribute_name
145
+ |
146
+ init_#{element_attribute_name}_as_child
147
+ |
148
+ |}
149
+ |
150
+
151
+ yield(self) if block_given?
152
+ init_hook
153
+
154
+ changed
155
+ end
156
+
157
+ def clear_non_persistent_index_attributes
158
+ |
159
+ |@element.attribute_child.each{ | attribute |
160
+ | unless attribute.name == @element.indexed_by_attr and @element.persisted then
161
+ |
162
+ @#{attribute.name} = nil
163
+ |
164
+ | end
165
+ |}
166
+ |
167
+ end
168
+
169
+ def append_to(other)
170
+ other.add_#{element.attribute_name}(self)
171
+ end
172
+
173
+ |
174
+ |if @element.persisted then
175
+ |
176
+ def #{@element.class_name}.persisted?
177
+ return :#{@element.indexed_by_attr}
178
+ end
179
+
180
+ def persisted?
181
+ return :#{@element.indexed_by_attr}
182
+ end
183
+
184
+ |
185
+ |else
186
+ |
187
+ def #{@element.class_name}.persisted?
188
+ return nil
189
+ end
190
+
191
+ def persisted?
192
+ return nil
193
+ end
194
+
195
+ |
196
+ |end
197
+ |
198
+ def #{@element.class_name}.tag
199
+ @@tag
200
+ end
201
+
202
+ def #{@element.class_name}.ns
203
+ @@ns
204
+ end
205
+
206
+ def #{@element.class_name}.ns_tag
207
+ @@ns_tag
208
+ end
209
+
210
+ def #{@element.class_name}.safe_name
211
+ @@safe_name
212
+ end
213
+
214
+ def #{@element.class_name}.module_name
215
+ @@module_name
216
+ end
217
+
218
+ def tag
219
+ @@tag
220
+ end
221
+
222
+ def ns
223
+ @@ns
224
+ end
225
+
226
+ def ns_tag
227
+ @@ns_tag
228
+ end
229
+
230
+ def safe_name
231
+ @@safe_name
232
+ end
233
+
234
+ def module_name
235
+ @@module_name
236
+ end
237
+
238
+ def attributes
239
+ @@attributes
240
+ end
241
+ |
242
+ |if @element.indexed_by_attr
243
+ |
244
+
245
+ def indexed_by
246
+ :#{@element.indexed_by_attr}
247
+ end
248
+
249
+ def get_the_index
250
+ @#{@element.indexed_by_attr}
251
+ end
252
+
253
+ def set_the_index(index)
254
+ @#{@element.indexed_by_attr} = index
255
+ end
256
+ |
257
+ |end
258
+ |
259
+
260
+ def substitute_in_visit(visitor)
261
+ return visitor.substitute_in_visit_#{@element.attribute_name}(self) || self
262
+ end
263
+
264
+ def before_visit(visitor)
265
+ visitor.before_visit_#{@element.attribute_name}(self)
266
+ end
267
+
268
+ def visit(visitor)
269
+ visitor.visit_#{@element.attribute_name}(self)
270
+ end
271
+
272
+ def after_visit(visitor)
273
+ visitor.after_visit_#{@element.attribute_name}(self)
274
+ end
275
+
276
+ Xampl::FromXML::register(#{@element.class_name}::tag, #{@element.class_name}::ns_tag, #{@element.class_name})
277
+ end
@@ -0,0 +1,278 @@
1
+
2
+ class #{@element.class_name}
3
+ |
4
+ |if @element.persisted then
5
+ |
6
+ include Xampl::XamplPersistedObject
7
+
8
+ #supports class based over-ride of persister format
9
+ @@default_persister_format = nil
10
+
11
+ def default_persister_format
12
+ @@default_persister_format
13
+ end
14
+ def #{@element.class_name}.default_persister_format
15
+ @@default_persister_format
16
+ end
17
+ def #{@element.class_name}.set_default_persister_format(format)
18
+ @@default_persister_format = format
19
+ end
20
+
21
+ def #{@element.class_name}.find_by_query
22
+ things = Xampl.find_xampl do | q |
23
+ q.add_condition('class', :equals, self.name)
24
+ yield(q)
25
+ end
26
+ end
27
+
28
+ |
29
+ |else
30
+ |
31
+ include Xampl::XamplObject
32
+ |
33
+ |end
34
+ |
35
+ include Xampl::XamplWithMixedContent
36
+
37
+ @@tag = "#{@element.name}"
38
+ @@ns = "#{@element.namespace}"
39
+ @@ns_tag = "{#{@element.namespace}}#{@element.name}"
40
+ @@module_name = "#{@package_name}"
41
+ @@safe_name = "#{@package_name}_#{@element.attribute_name}"
42
+ @@attributes = [
43
+ |
44
+ |@element.attribute_child.each{ | attribute |
45
+ | if attribute.namespace then
46
+ |
47
+ [ :@#{attribute.name}, "#{attribute.name}", "#{attribute.namespace}" ],
48
+ |
49
+ | else
50
+ |
51
+ [ :@#{attribute.name}, "#{attribute.name}" ],
52
+ |
53
+ | end
54
+ |}
55
+ |
56
+ ]
57
+ |
58
+ |@element.child_element_child.each{ | child_element |
59
+ | element_class_name = @lookup_element[child_element.name].class_name
60
+ | element_package = @lookup_element[child_element.name].package
61
+ |
62
+ include #{element_package}::#{element_class_name}AsChild
63
+ |
64
+ |}
65
+ |
66
+ |if @element.persisted then
67
+ |
68
+
69
+ def #{@element.class_name}.lookup(pid)
70
+ Xampl.lookup(#{@element.class_name}, pid)
71
+ end
72
+
73
+ def #{@element.class_name}.[](pid)
74
+ Xampl.lookup(#{@element.class_name}, pid)
75
+ end
76
+ |
77
+ |end
78
+ |
79
+ |@element.attribute_child.each{ | attribute |
80
+ | if attribute.name == @element.indexed_by_attr and @element.persisted then
81
+ |
82
+
83
+ def #{attribute.name}
84
+ @#{attribute.name}
85
+ end
86
+
87
+ def #{attribute.name}=(v)
88
+ accessed
89
+ # This is kind of optimistic, I think you are in trouble if you do this
90
+ Xampl.auto_uncache(self) if @#{attribute.name}
91
+ @#{attribute.name} = v
92
+ changed
93
+ Xampl.auto_cache(self) if v
94
+ end
95
+ |
96
+ | else
97
+ |
98
+
99
+ def #{attribute.name}
100
+ accessed
101
+ @#{attribute.name}
102
+ end
103
+
104
+ def #{attribute.name}=(v)
105
+ accessed
106
+ changed
107
+ @#{attribute.name} = v
108
+ end
109
+ |
110
+ | end
111
+ |}
112
+ |
113
+ | if @element.indexed_by_attr then
114
+ |
115
+
116
+ def initialize(index=nil)
117
+ @#{@element.indexed_by_attr} = index if index
118
+ super()
119
+ |
120
+ | else
121
+ |
122
+
123
+ def initialize
124
+ super
125
+ |
126
+ |end
127
+ |
128
+ |if 0 < @element.attribute_child.size then
129
+ |
130
+
131
+ |
132
+ |end
133
+ |
134
+ |@element.attribute_child.each{ | attribute |
135
+ |
136
+ @#{attribute.name} = nil if not defined? @#{attribute.name}
137
+ |
138
+ |}
139
+ |
140
+
141
+ init_xampl_object
142
+ init_mixed_content
143
+ |
144
+ |@element.child_element_child.each{ | child_element |
145
+ | element_attribute_name = @lookup_element[child_element.name].attribute_name
146
+ |
147
+ init_#{element_attribute_name}_as_child
148
+ |
149
+ |}
150
+ |
151
+
152
+ yield(self) if block_given?
153
+ init_hook
154
+
155
+ changed
156
+ end
157
+
158
+ def clear_non_persistent_index_attributes
159
+ |
160
+ |@element.attribute_child.each{ | attribute |
161
+ | unless attribute.name == @element.indexed_by_attr and @element.persisted then
162
+ |
163
+ @#{attribute.name} = nil
164
+ |
165
+ | end
166
+ |}
167
+ |
168
+ end
169
+
170
+ def append_to(other)
171
+ other.add_#{@element.attribute_name}(self)
172
+ end
173
+
174
+ |
175
+ |if @element.persisted then
176
+ |
177
+ def #{@element.class_name}.persisted?
178
+ return :#{@element.indexed_by_attr}
179
+ end
180
+
181
+ def persisted?
182
+ return :#{@element.indexed_by_attr}
183
+ end
184
+
185
+ |
186
+ |else
187
+ |
188
+ def #{@element.class_name}.persisted?
189
+ return nil
190
+ end
191
+
192
+ def persisted?
193
+ return nil
194
+ end
195
+
196
+ |
197
+ |end
198
+ |
199
+ def #{@element.class_name}.tag
200
+ @@tag
201
+ end
202
+
203
+ def #{@element.class_name}.ns
204
+ @@ns
205
+ end
206
+
207
+ def #{@element.class_name}.ns_tag
208
+ @@ns_tag
209
+ end
210
+
211
+ def #{@element.class_name}.safe_name
212
+ @@safe_name
213
+ end
214
+
215
+ def #{@element.class_name}.module_name
216
+ @@module_name
217
+ end
218
+
219
+ def tag
220
+ @@tag
221
+ end
222
+
223
+ def ns
224
+ @@ns
225
+ end
226
+
227
+ def ns_tag
228
+ @@ns_tag
229
+ end
230
+
231
+ def safe_name
232
+ @@safe_name
233
+ end
234
+
235
+ def module_name
236
+ @@module_name
237
+ end
238
+
239
+ def attributes
240
+ @@attributes
241
+ end
242
+ |
243
+ |if @element.indexed_by_attr
244
+ |
245
+
246
+ def indexed_by
247
+ :#{@element.indexed_by_attr}
248
+ end
249
+
250
+ def get_the_index
251
+ @#{@element.indexed_by_attr}
252
+ end
253
+
254
+ def set_the_index(index)
255
+ @#{@element.indexed_by_attr} = index
256
+ end
257
+ |
258
+ |end
259
+ |
260
+
261
+ def substitute_in_visit(visitor)
262
+ return visitor.substitute_in_visit_#{@element.attribute_name}(self) || self
263
+ end
264
+
265
+ def before_visit(visitor)
266
+ visitor.before_visit_#{@element.attribute_name}(self)
267
+ end
268
+
269
+ def visit(visitor)
270
+ visitor.visit_#{@element.attribute_name}(self)
271
+ end
272
+
273
+ def after_visit(visitor)
274
+ visitor.after_visit_#{@element.attribute_name}(self)
275
+ end
276
+
277
+ Xampl::FromXML::register(#{@element.class_name}::tag, #{@element.class_name}::ns_tag, #{@element.class_name})
278
+ end