jrubyfx-fxmlloader 0.2-java → 0.3-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +15 -3
- data/Rakefile +1 -1
- data/lib/FXMLLoader-j8.jar +0 -0
- data/lib/fxmlloader/elts.rb +68 -59
- data/lib/fxmlloader/fxml_jit_info.rb +158 -0
- data/lib/fxmlloader/j8_expression_value.rb +148 -101
- data/lib/fxmlloader/real_elts.rb +195 -184
- data/lib/fxmlloader/rorba.rb +3 -29
- data/lib/fxmlloader/rrba.rb +161 -399
- data/lib/fxmlloader/value_elts.rb +13 -23
- data/lib/jrubyfx-fxmlloader.rb +240 -124
- metadata +6 -5
@@ -43,8 +43,6 @@ class StupidFixTODOInsets < Java::javafx::geometry::InsetsBuilder
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def size
|
46
|
-
dputs "GAAAAAAAAAAAAAA!!!!!"
|
47
|
-
dputs caller
|
48
46
|
990
|
49
47
|
end
|
50
48
|
def to_s
|
@@ -71,44 +69,35 @@ class ValueElement < Element
|
|
71
69
|
end
|
72
70
|
|
73
71
|
def processEndElement()
|
74
|
-
dputs callz + "process end super?"
|
75
72
|
super
|
76
|
-
dputs callz + "process end superd!"
|
77
|
-
dp value
|
78
73
|
|
79
74
|
# Build the value, if necessary
|
80
75
|
if (value.is_a? Builder)
|
81
|
-
dputs "build it"
|
82
76
|
updateValue(value.build());
|
83
|
-
dputs "process it"
|
84
77
|
processValue();
|
85
78
|
else
|
86
79
|
processInstancePropertyAttributes();
|
87
80
|
end
|
88
|
-
dputs "donet"
|
89
81
|
processEventHandlerAttributes();
|
90
|
-
dputs "ahndersAtrrs"
|
91
82
|
# Process static property attributes
|
92
83
|
if (staticPropertyAttributes.length > 0)
|
93
84
|
for attribute in staticPropertyAttributes
|
94
|
-
dputs "process prodp attr-----------"
|
95
|
-
dp attribute
|
96
85
|
processPropertyAttribute(attribute);
|
97
86
|
end
|
98
87
|
end
|
99
|
-
dputs "staticpro"
|
100
88
|
# Process static property elements
|
101
89
|
if (staticPropertyElements.length > 0)
|
102
90
|
for element in staticPropertyElements
|
103
91
|
RubyWrapperBeanAdapter.put(value, element.sourceType, element.name, element.value);
|
104
92
|
end
|
105
93
|
end
|
106
|
-
|
94
|
+
|
95
|
+
rnest -1
|
96
|
+
rputs value, ((rfx_id(value) && rfx_id_set?(value)) || rno_show?(value) ? "" : "end")
|
107
97
|
if (parent != nil)
|
108
98
|
if (parent.isCollection())
|
109
99
|
parent.add(value);
|
110
100
|
else
|
111
|
-
dputs callz + " ANd setting #{value} on #{parent}"
|
112
101
|
parent.set value
|
113
102
|
end
|
114
103
|
end
|
@@ -150,8 +139,13 @@ dputs "parentS>AS"
|
|
150
139
|
# checking the version JavaFX API - print warning if not supported
|
151
140
|
defaultNSURI = xmlStreamReader.getNamespaceContext().getNamespaceURI("");
|
152
141
|
if (defaultNSURI != nil)
|
153
|
-
nsVersion = defaultNSURI[(defaultNSURI.
|
154
|
-
if
|
142
|
+
nsVersion = defaultNSURI[(defaultNSURI.rindex("/") + 1)..-1]
|
143
|
+
jfx_version = if defined? FXL::JAVAFX_VERSION
|
144
|
+
FXL::JAVAFX_VERSION
|
145
|
+
else
|
146
|
+
"http://javafx.com/javafx/2.2"
|
147
|
+
end
|
148
|
+
if (parentLoader.compareJFXVersions(jfx_version, nsVersion) < 0)
|
155
149
|
Logging.getJavaFXLogger().warning("Loading FXML document with JavaFX API of version " + nsVersion + " by JavaFX runtime of version " + FXL::JAVAFX_VERSION);
|
156
150
|
end
|
157
151
|
end
|
@@ -169,16 +163,15 @@ dputs "parentS>AS"
|
|
169
163
|
# set fx:id property value to Node.id only if Node.id was not
|
170
164
|
# already set when processing start element attributes
|
171
165
|
if (properties[idProperty.value] == nil)
|
172
|
-
dputs callz + "saving ID property #{idProperty.value}"
|
173
166
|
properties[idProperty.value()]= @fx_id;
|
174
167
|
end
|
175
168
|
end
|
176
|
-
|
169
|
+
rputs value, "__local_fx_id_setter.call(#{@fx_id.inspect}, self)"
|
170
|
+
rfx_id value, @fx_id
|
177
171
|
# Set the controller field value
|
178
172
|
if (parentLoader.controller != nil)
|
179
173
|
field = parentLoader.controller.instance_variable_set("@" + @fx_id, value)
|
180
174
|
end
|
181
|
-
dputs callz + "Set.."
|
182
175
|
end
|
183
176
|
end
|
184
177
|
|
@@ -221,7 +214,6 @@ dputs "parentS>AS"
|
|
221
214
|
# raise LoadException.new("Invalid identifier.");
|
222
215
|
# end
|
223
216
|
# end
|
224
|
-
dputs callz + "Found FXID is #{value}"
|
225
217
|
@fx_id = value;
|
226
218
|
|
227
219
|
elsif (localName == (FXL::FX_CONTROLLER_ATTRIBUTE))
|
@@ -229,7 +221,6 @@ dputs callz + "Found FXID is #{value}"
|
|
229
221
|
raise LoadException.new(FXL::FX_NAMESPACE_PREFIX + ":" + FXL::FX_CONTROLLER_ATTRIBUTE + " can only be applied to root element.");
|
230
222
|
end
|
231
223
|
|
232
|
-
dputs callz + "Found controller attrib is #{value} (#{parentLoader.controller}, #{staticLoad})"
|
233
224
|
if (parentLoader.controller != nil)
|
234
225
|
raise LoadException.new("Controller value already specified.");
|
235
226
|
end
|
@@ -237,7 +228,7 @@ dputs callz + "Found controller attrib is #{value} (#{parentLoader.controller},
|
|
237
228
|
if (!staticLoad)
|
238
229
|
type = nil
|
239
230
|
begin
|
240
|
-
type =
|
231
|
+
type = value.constantize_by
|
241
232
|
rescue ClassNotFoundException => exception
|
242
233
|
raise LoadException.new(exception);
|
243
234
|
end
|
@@ -259,7 +250,6 @@ dputs callz + "Found controller attrib is #{value} (#{parentLoader.controller},
|
|
259
250
|
raise LoadException.new("Invalid attribute.");
|
260
251
|
end
|
261
252
|
else
|
262
|
-
dputs callz + "Super Again!"
|
263
253
|
super(prefix, localName, value);
|
264
254
|
end
|
265
255
|
end
|
data/lib/jrubyfx-fxmlloader.rb
CHANGED
@@ -33,11 +33,6 @@ rescue LoadError, NameError
|
|
33
33
|
exit -2
|
34
34
|
end
|
35
35
|
|
36
|
-
#java_import 'javax.xml.stream.util.StreamReaderDelegate'
|
37
|
-
#java_import 'javax.xml.stream.XMLStreamException', 'javax.xml.stream.XMLInputFactory',
|
38
|
-
# 'java.io.InputStreamReader', 'javax.xml.stream.XMLStreamConstants'
|
39
|
-
java_import 'java.net.URL', 'java.nio.charset.Charset', 'java.lang.ClassNotFoundException'
|
40
|
-
#java_import 'javafx.fxml.LoadException'
|
41
36
|
java_import 'javafx.fxml.JavaFXBuilderFactory'
|
42
37
|
java_import 'java.lang.InstantiationException', 'java.lang.IllegalAccessException'
|
43
38
|
|
@@ -45,23 +40,15 @@ java_import *%w[com.sun.javafx.Logging
|
|
45
40
|
java.io.IOException
|
46
41
|
java.io.InputStream
|
47
42
|
java.io.InputStreamReader
|
48
|
-
java.lang.
|
43
|
+
java.lang.ClassNotFoundException
|
49
44
|
java.lang.reflect.InvocationTargetException
|
50
45
|
java.lang.reflect.Modifier
|
51
46
|
java.lang.reflect.ParameterizedType
|
52
|
-
java.lang.reflect.Type
|
53
47
|
java.net.URL
|
54
48
|
java.nio.charset.Charset
|
55
49
|
java.util.AbstractMap
|
56
|
-
java.util.ArrayList
|
57
|
-
java.util.Collections
|
58
|
-
java.util.HashMap
|
59
|
-
java.util.LinkedList
|
60
50
|
java.util.List
|
61
|
-
java.util.Map
|
62
51
|
java.util.ResourceBundle
|
63
|
-
java.util.Set
|
64
|
-
java.util.regex.Pattern
|
65
52
|
|
66
53
|
javafx.beans.DefaultProperty
|
67
54
|
javafx.beans.property.Property
|
@@ -122,6 +109,149 @@ end
|
|
122
109
|
def dprint(*args)
|
123
110
|
print *args if $DEBUG_IT_FXML
|
124
111
|
end
|
112
|
+
# TODO: clean this up
|
113
|
+
$RB_PREFIX = ""
|
114
|
+
def rnest(num)
|
115
|
+
if num > 0
|
116
|
+
$RB_PREFIX += " "
|
117
|
+
else
|
118
|
+
$RB_PREFIX = $RB_PREFIX[0...-1]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
$RB_MAPPER = {}
|
122
|
+
$RB_CMAPPER = {}
|
123
|
+
$RB_IDMAPPER = {}
|
124
|
+
$RB_NShowMAPPER = {}
|
125
|
+
$last_elt = nil
|
126
|
+
|
127
|
+
def rno_show(elt)
|
128
|
+
$RB_NShowMAPPER[elt]=true
|
129
|
+
end
|
130
|
+
def rno_show?(elt)
|
131
|
+
!!$RB_NShowMAPPER[elt]
|
132
|
+
end
|
133
|
+
|
134
|
+
def rmap_wrap(elt)
|
135
|
+
if elt.kind_of? Java::ComSunJavafxCollections::ObservableListWrapper
|
136
|
+
SecretHashCompararator.new(elt)
|
137
|
+
else
|
138
|
+
elt
|
139
|
+
end
|
140
|
+
end
|
141
|
+
def rputs(elt, args)
|
142
|
+
if $DEBUG_IT_FXML_RB
|
143
|
+
if elt == nil
|
144
|
+
elt = $last_elt
|
145
|
+
else
|
146
|
+
$last_elt = elt = rmap_wrap(elt)
|
147
|
+
end
|
148
|
+
unless $RB_MAPPER[elt]
|
149
|
+
$RB_MAPPER[elt] = ""
|
150
|
+
end
|
151
|
+
$RB_MAPPER[elt] << $RB_PREFIX
|
152
|
+
$RB_MAPPER[elt] << args
|
153
|
+
$RB_MAPPER[elt] << "\n"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def rfx_id(elt, val=nil)
|
158
|
+
elt = rmap_wrap elt
|
159
|
+
if val
|
160
|
+
$RB_IDMAPPER[elt] = val
|
161
|
+
else
|
162
|
+
$RB_IDMAPPER[elt]
|
163
|
+
end
|
164
|
+
end
|
165
|
+
def rfx_id_set?(elt)
|
166
|
+
elt = rmap_wrap elt
|
167
|
+
!$RB_MAPPER[elt] or $RB_MAPPER[elt].include? "instance_variable_get(#{("@" + rfx_id(elt)).to_sym.inspect})"
|
168
|
+
end
|
169
|
+
def rmorph(old, new)
|
170
|
+
elt = rmap_wrap elt
|
171
|
+
$RB_MAPPER[new] = "build(FxmlBuilderBuilder, #{($RB_CMAPPER[old]||{}).inspect}, #{old.wrapped_class.ruby_class.inspect}) do\n"
|
172
|
+
end
|
173
|
+
|
174
|
+
def rctor(elt, k, v)
|
175
|
+
if $DEBUG_IT_FXML_RB
|
176
|
+
elt = rmap_wrap elt
|
177
|
+
$RB_CMAPPER[elt] = {} unless $RB_CMAPPER[elt]
|
178
|
+
$RB_CMAPPER[elt][k] = v
|
179
|
+
end
|
180
|
+
end
|
181
|
+
def rget(elt, action=:nuke_from_standard_orbit_captain)
|
182
|
+
elt = rmap_wrap elt
|
183
|
+
tmp = $RB_MAPPER[elt]
|
184
|
+
tmp.strip! if tmp
|
185
|
+
$RB_MAPPER[elt] = rfx_id(elt) ? "__local_fxml_controller.instance_variable_get(#{("@" + rfx_id(elt)).to_sym.inspect})" : nil
|
186
|
+
|
187
|
+
tmp
|
188
|
+
end
|
189
|
+
$RB_SCRIPT_ENGINE_MAPPINGS = {}
|
190
|
+
def rputs_script(sem, lang)
|
191
|
+
$RB_SCRIPT_ENGINE_MAPPINGS[sem] = lang
|
192
|
+
end
|
193
|
+
|
194
|
+
def rget_sem(sem)
|
195
|
+
$RB_SCRIPT_ENGINE_MAPPINGS[sem]
|
196
|
+
end
|
197
|
+
|
198
|
+
def rsem_out
|
199
|
+
if $RB_SCRIPT_ENGINE_MAPPINGS != {}
|
200
|
+
["(__local_sem_inst = Java.javax.script.ScriptEngineManager.new).setBindings(javax.script.SimpleBindings.new(__local_namespace))",
|
201
|
+
*$RB_SCRIPT_ENGINE_MAPPINGS.map{|sem, lang|
|
202
|
+
"(__local_sem_lang_inst_#{lang} = __local_sem_inst.getEngineByName(#{lang.inspect}))" +
|
203
|
+
".setBindings(__local_sem_inst.getBindings(), javax.script.ScriptContext.ENGINE_SCOPE)"
|
204
|
+
}
|
205
|
+
].join("\n")
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
class SecretHashCompararator
|
210
|
+
attr_accessor :obj
|
211
|
+
def initialize(obj)
|
212
|
+
@obj = obj
|
213
|
+
end
|
214
|
+
def hash
|
215
|
+
@obj.object_id
|
216
|
+
end
|
217
|
+
def eql?(rhs)
|
218
|
+
self == rhs
|
219
|
+
end
|
220
|
+
def ==(rhs)
|
221
|
+
@obj.object_id == rhs.object_id or (rhs.is_a? SecretHashCompararator and @obj.object_id == rhs.hash)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
class FxmlBuilderBuilder # the builder builder (builds builders)
|
226
|
+
@@bf = Java::javafx.fxml.JavaFXBuilderFactory.new
|
227
|
+
def self.new(arg_map, builder_type)
|
228
|
+
builder = @@bf.getBuilder(builder_type)
|
229
|
+
arg_map.each do |k, v|
|
230
|
+
builder.put(k, v) # DON't use []= or we have to wrap it
|
231
|
+
end
|
232
|
+
builder.build
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
class FactoryBuilderBuilder # builder to build factories
|
237
|
+
def self.new(type, factory)
|
238
|
+
type = type.java_class
|
239
|
+
factoryMethod = nil
|
240
|
+
begin
|
241
|
+
factoryMethod = MethodUtil.getMethod(type, factory, []);
|
242
|
+
rescue NoSuchMethodException => exception
|
243
|
+
raise LoadException.new(exception);
|
244
|
+
end
|
245
|
+
|
246
|
+
begin
|
247
|
+
return MethodUtil.invoke(factoryMethod, nil, []);
|
248
|
+
rescue IllegalAccessException => exception
|
249
|
+
raise LoadException.new(exception);
|
250
|
+
rescue InvocationTargetException => exception
|
251
|
+
raise LoadException.new(exception);
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
125
255
|
|
126
256
|
# Override to safely get ruby class of non-java_class objects
|
127
257
|
class Class
|
@@ -130,26 +260,17 @@ class Class
|
|
130
260
|
end
|
131
261
|
end
|
132
262
|
|
133
|
-
#Long to avoid collisions
|
134
|
-
MAGIC_FXML_JAVAFX_JRUBYFX_FXMLLOADER__FILE__LOCATION_SUPER_SECRET = __FILE__
|
135
|
-
|
136
263
|
FXL = java_import('javafx.fxml.FXMLLoader')[0]
|
137
264
|
class FxmlLoader
|
138
|
-
attr_accessor :location, :root, :template, :builderFactory, :namespace, :staticLoad, :current, :controllerFactory
|
265
|
+
attr_accessor :location, :root, :template, :builderFactory, :namespace, :staticLoad, :current, :controllerFactory, :charset
|
266
|
+
attr_accessor :scriptEngine
|
139
267
|
attr_reader :controller
|
140
268
|
FX_NAMESPACE_VERSION="1"
|
269
|
+
@@fxml_jit_info = {}
|
141
270
|
def initialize(url=nil, ctrlr=nil, resourcs=nil, buildFactory=nil, charset=nil, loaders=nil)
|
142
271
|
@location = url
|
143
272
|
@builderFactory = buildFactory || JavaFXBuilderFactory.new
|
144
273
|
@template = false
|
145
|
-
if resourcs
|
146
|
-
dputs "WHOA WHOAT!!!! resources"
|
147
|
-
dp resourcs
|
148
|
-
end
|
149
|
-
if loaders
|
150
|
-
dputs "WHOA WHOAT!!!! loaders"
|
151
|
-
dp loaders
|
152
|
-
end
|
153
274
|
@namespace = FXCollections.observableHashMap()
|
154
275
|
self.controller = ctrlr
|
155
276
|
@packages = []
|
@@ -167,9 +288,15 @@ class FxmlLoader
|
|
167
288
|
end
|
168
289
|
end
|
169
290
|
|
170
|
-
|
171
|
-
|
291
|
+
# either :no_jit, or a number above 0 representing the number of times before jitting a fxml file
|
292
|
+
def load(jruby_exts = {jruby_ext: {}})
|
293
|
+
@jruby_ext = {jit: 0}.merge(jruby_exts[:jruby_ext])
|
172
294
|
# TODO: actually open it properly
|
295
|
+
unless jit_info = @@fxml_jit_info[file_path = @location.to_s]
|
296
|
+
validate = true
|
297
|
+
validate = @jruby_ext[:jit_validate] if @jruby_ext.has_key? :jit_validate
|
298
|
+
jit_info = @@fxml_jit_info[file_path] = FxmlJitInfo.new(file_path, @jruby_ext[:jit], @jruby_ext[:jit_save_to], @jruby_ext[:jit_cache], validate, @jruby_ext[:jit_opts])
|
299
|
+
end
|
173
300
|
inputStream = @location.open_stream
|
174
301
|
if @template
|
175
302
|
@root = nil
|
@@ -182,6 +309,22 @@ class FxmlLoader
|
|
182
309
|
|
183
310
|
@script_engine = nil
|
184
311
|
|
312
|
+
$DEBUG_IT_FXML_RB = jit_info.should_jit?
|
313
|
+
# if we have it cached, use the jitted method
|
314
|
+
if jit_info.compiled?
|
315
|
+
begin
|
316
|
+
return :dont_load if @jruby_ext[:dont_load]
|
317
|
+
return jit_info.__build_via_jit(@controller, @namespace, @jruby_ext)
|
318
|
+
rescue Exception, java.lang.Throwable
|
319
|
+
puts "JIT compiled method for #{@location.to_s} FAILED with error:"
|
320
|
+
puts $!
|
321
|
+
puts $!.backtrace
|
322
|
+
puts "Reverting to normal parsing..."
|
323
|
+
jit_info.jit_settings = :no_jit
|
324
|
+
jit_info.decompile
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
185
328
|
begin
|
186
329
|
xmlInputFactory = XMLInputFactory.newFactory
|
187
330
|
xmlInputFactory.setProperty("javax.xml.stream.isCoalescing", true)
|
@@ -197,38 +340,40 @@ class FxmlLoader
|
|
197
340
|
# Parse the XML stream
|
198
341
|
begin
|
199
342
|
while @xmlStreamReader.hasNext()
|
200
|
-
dputs "......"
|
201
343
|
event = @xmlStreamReader.next();
|
202
|
-
dputs "#{event} aout happened, dude"
|
203
344
|
case event
|
204
345
|
when XMLStreamConstants::PROCESSING_INSTRUCTION
|
205
|
-
dputs "processing instr"
|
206
346
|
processProcessingInstruction
|
207
347
|
when XMLStreamConstants::COMMENT
|
208
|
-
dputs "processing comment"
|
209
348
|
processComment
|
210
349
|
when XMLStreamConstants::START_ELEMENT
|
211
|
-
dputs "processing start"
|
212
350
|
processStartElement
|
213
351
|
when XMLStreamConstants::END_ELEMENT
|
214
|
-
dputs "processing end"
|
215
352
|
processEndElement
|
216
353
|
when XMLStreamConstants::CHARACTERS
|
217
|
-
dputs "processing chars"
|
218
354
|
processCharacters
|
219
355
|
end
|
220
356
|
end
|
221
357
|
rescue XMLStreamException => exception
|
222
358
|
raise Exception.new(exception)
|
223
359
|
end
|
224
|
-
dputs "Saving stuff!!!!s"
|
225
360
|
if @controller
|
226
361
|
# TODO: initialize should be called here
|
227
362
|
# Inject controller fields
|
228
363
|
@controller.instance_variable_set("@" + FXL::LOCATION_KEY, @location)
|
229
364
|
@controller.instance_variable_set("@" + FXL::RESOURCES_KEY, @resources)
|
230
365
|
end
|
231
|
-
|
366
|
+
if $DEBUG_IT_FXML_RB
|
367
|
+
code = "#{rsem_out}\n#{rget @root}"
|
368
|
+
jit_info.compile(code)
|
369
|
+
end
|
370
|
+
$RB_CMAPPER = {}
|
371
|
+
$RB_IDMAPPER = {}
|
372
|
+
$RB_MAPPER = {}
|
373
|
+
$RB_PREFIX = ""
|
374
|
+
$RB_NShowMAPPER = {}
|
375
|
+
$last_elt = nil
|
376
|
+
$RB_SCRIPT_ENGINE_MAPPINGS = {}
|
232
377
|
|
233
378
|
@xmlStreamReader = nil
|
234
379
|
return @root
|
@@ -261,8 +406,9 @@ class FxmlLoader
|
|
261
406
|
|
262
407
|
unless staticLoad
|
263
408
|
scriptEngineManager = getScriptEngineManager()
|
264
|
-
scriptEngine = scriptEngineManager.getEngineByName(language)
|
265
|
-
|
409
|
+
@scriptEngine = scriptEngineManager.getEngineByName(language)
|
410
|
+
rputs_script @scriptEngine, language
|
411
|
+
@scriptEngine.setBindings(scriptEngineManager.getBindings(), ScriptContext.ENGINE_SCOPE)
|
266
412
|
end
|
267
413
|
end
|
268
414
|
|
@@ -294,6 +440,8 @@ class FxmlLoader
|
|
294
440
|
# Set the root value
|
295
441
|
unless @root
|
296
442
|
@root = @current.value;
|
443
|
+
rputs @root, "__local_jruby_ext[:on_root_set].call(self) if __local_jruby_ext[:on_root_set]"
|
444
|
+
@jruby_ext[:on_root_set].call(@root) if @jruby_ext[:on_root_set]
|
297
445
|
end
|
298
446
|
end
|
299
447
|
|
@@ -348,11 +496,6 @@ class FxmlLoader
|
|
348
496
|
pppn = pppn.parent
|
349
497
|
end
|
350
498
|
prefixz = (" " * numz) + prefixz
|
351
|
-
dputs "#{prefixz}Creating new stuff"
|
352
|
-
dprint prefixz
|
353
|
-
dp localName
|
354
|
-
dprint prefixz
|
355
|
-
dp type
|
356
499
|
|
357
500
|
if type
|
358
501
|
if @loadListener
|
@@ -415,7 +558,6 @@ class FxmlLoader
|
|
415
558
|
end
|
416
559
|
|
417
560
|
def processEndElement()
|
418
|
-
dputs "ending!!!!!!!!"
|
419
561
|
@current.processEndElement();
|
420
562
|
if @loadListener
|
421
563
|
@loadListener.endElement(@current.value);
|
@@ -443,82 +585,6 @@ class FxmlLoader
|
|
443
585
|
raise LoadException.new(exception);
|
444
586
|
end
|
445
587
|
end
|
446
|
-
|
447
|
-
# steal handy methods from activesupport
|
448
|
-
# Tries to find a constant with the name specified in the argument string.
|
449
|
-
#
|
450
|
-
# 'Module'.constantize # => Module
|
451
|
-
# 'Test::Unit'.constantize # => Test::Unit
|
452
|
-
#
|
453
|
-
# The name is assumed to be the one of a top-level constant, no matter
|
454
|
-
# whether it starts with "::" or not. No lexical context is taken into
|
455
|
-
# account:
|
456
|
-
#
|
457
|
-
# C = 'outside'
|
458
|
-
# module M
|
459
|
-
# C = 'inside'
|
460
|
-
# C # => 'inside'
|
461
|
-
# 'C'.constantize # => 'outside', same as ::C
|
462
|
-
# end
|
463
|
-
#
|
464
|
-
# NameError is raised when the name is not in CamelCase or the constant is
|
465
|
-
# unknown.
|
466
|
-
def constantize(camel_cased_word)
|
467
|
-
names = camel_cased_word.split('.')
|
468
|
-
names.shift if names.empty? || names.first.empty?
|
469
|
-
|
470
|
-
names.inject(Object) do |constant, name|
|
471
|
-
if constant == Object
|
472
|
-
constant.const_get(name)
|
473
|
-
else
|
474
|
-
candidate = constant.const_get(name)
|
475
|
-
next candidate if constant.const_defined?(name, false)
|
476
|
-
next candidate unless Object.const_defined?(name)
|
477
|
-
|
478
|
-
# Go down the ancestors to check it it's owned
|
479
|
-
# directly before we reach Object or the end of ancestors.
|
480
|
-
constant = constant.ancestors.inject do |const, ancestor|
|
481
|
-
break const if ancestor == Object
|
482
|
-
break ancestor if ancestor.const_defined?(name, false)
|
483
|
-
const
|
484
|
-
end
|
485
|
-
|
486
|
-
# owner is in Object, so raise
|
487
|
-
constant.const_get(name, false)
|
488
|
-
end
|
489
|
-
end
|
490
|
-
end
|
491
|
-
|
492
|
-
# Tries to find a constant with the name specified in the argument string.
|
493
|
-
#
|
494
|
-
# 'Module'.safe_constantize # => Module
|
495
|
-
# 'Test::Unit'.safe_constantize # => Test::Unit
|
496
|
-
#
|
497
|
-
# The name is assumed to be the one of a top-level constant, no matter
|
498
|
-
# whether it starts with "::" or not. No lexical context is taken into
|
499
|
-
# account:
|
500
|
-
#
|
501
|
-
# C = 'outside'
|
502
|
-
# module M
|
503
|
-
# C = 'inside'
|
504
|
-
# C # => 'inside'
|
505
|
-
# 'C'.safe_constantize # => 'outside', same as ::C
|
506
|
-
# end
|
507
|
-
#
|
508
|
-
# +nil+ is returned when the name is not in CamelCase or the constant (or
|
509
|
-
# part of it) is unknown.
|
510
|
-
#
|
511
|
-
# 'blargle'.safe_constantize # => nil
|
512
|
-
# 'UnknownModule'.safe_constantize # => nil
|
513
|
-
# 'UnknownModule::Foo::Bar'.safe_constantize # => nil
|
514
|
-
def safe_constantize(camel_cased_word)
|
515
|
-
constantize(camel_cased_word)
|
516
|
-
rescue NameError => e
|
517
|
-
raise unless e.message =~ /(uninitialized constant|wrong constant name) #{const_regexp(camel_cased_word)}$/ ||
|
518
|
-
e.name.to_s == camel_cased_word.to_s
|
519
|
-
rescue ArgumentError => e
|
520
|
-
raise unless e.message =~ /not missing constant #{const_regexp(camel_cased_word)}\!$/
|
521
|
-
end
|
522
588
|
|
523
589
|
def getType(name)
|
524
590
|
type = nil
|
@@ -548,8 +614,8 @@ class FxmlLoader
|
|
548
614
|
# check for ruby
|
549
615
|
# TODO: this should require an import or something perhaps? need to think more about this?
|
550
616
|
begin
|
551
|
-
type =
|
552
|
-
rescue
|
617
|
+
type = name.constantize_by(".")
|
618
|
+
rescue
|
553
619
|
# No-op
|
554
620
|
end
|
555
621
|
end
|
@@ -675,6 +741,55 @@ class FxmlLoader
|
|
675
741
|
end
|
676
742
|
end
|
677
743
|
|
744
|
+
class String
|
745
|
+
|
746
|
+
# steal handy methods from activesupport
|
747
|
+
# Tries to find a constant with the name specified in the argument string.
|
748
|
+
#
|
749
|
+
# 'Module'.constantize # => Module
|
750
|
+
# 'Test::Unit'.constantize # => Test::Unit
|
751
|
+
#
|
752
|
+
# The name is assumed to be the one of a top-level constant, no matter
|
753
|
+
# whether it starts with "::" or not. No lexical context is taken into
|
754
|
+
# account:
|
755
|
+
#
|
756
|
+
# C = 'outside'
|
757
|
+
# module M
|
758
|
+
# C = 'inside'
|
759
|
+
# C # => 'inside'
|
760
|
+
# 'C'.constantize # => 'outside', same as ::C
|
761
|
+
# end
|
762
|
+
#
|
763
|
+
# NameError is raised when the name is not in CamelCase or the constant is
|
764
|
+
# unknown.
|
765
|
+
def constantize_by(splitter="::")
|
766
|
+
camel_cased_word = self
|
767
|
+
names = camel_cased_word.split(splitter)
|
768
|
+
names.shift if names.empty? || names.first.empty?
|
769
|
+
|
770
|
+
names.inject(Object) do |constant, name|
|
771
|
+
if constant == Object
|
772
|
+
constant.const_get(name)
|
773
|
+
else
|
774
|
+
candidate = constant.const_get(name)
|
775
|
+
next candidate if constant.const_defined?(name, false)
|
776
|
+
next candidate unless Object.const_defined?(name)
|
777
|
+
|
778
|
+
# Go down the ancestors to check it it's owned
|
779
|
+
# directly before we reach Object or the end of ancestors.
|
780
|
+
constant = constant.ancestors.inject do |const, ancestor|
|
781
|
+
break const if ancestor == Object
|
782
|
+
break ancestor if ancestor.const_defined?(name, false)
|
783
|
+
const
|
784
|
+
end
|
785
|
+
|
786
|
+
# owner is in Object, so raise
|
787
|
+
constant.const_get(name, false)
|
788
|
+
end
|
789
|
+
end
|
790
|
+
end
|
791
|
+
end
|
792
|
+
|
678
793
|
|
679
794
|
class SRDelegateClass < StreamReaderDelegate
|
680
795
|
def getPrefix()
|
@@ -703,6 +818,7 @@ require_relative 'fxmlloader/value_elts'
|
|
703
818
|
require_relative 'fxmlloader/real_elts'
|
704
819
|
require_relative 'fxmlloader/rrba'
|
705
820
|
require_relative 'fxmlloader/rorba'
|
821
|
+
require_relative 'fxmlloader/fxml_jit_info'
|
706
822
|
require_relative 'FXMLLoader-j8.jar'
|
707
823
|
|
708
824
|
java_import 'org.jruby.jfx8.KeyPath'
|
@@ -721,4 +837,4 @@ class RRBAdapters < org.jruby.jfx8.RubyBeanAdapter
|
|
721
837
|
end
|
722
838
|
end
|
723
839
|
|
724
|
-
org.jruby.jfx8.RubyBeanAdapter.load_ruby_space RRBAdapters.new
|
840
|
+
org.jruby.jfx8.RubyBeanAdapter.load_ruby_space RRBAdapters.new
|