therubyrhino 1.73.0 → 1.73.1
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/lib/rhino.rb +27 -9
- data/lib/rhino/context.rb +127 -100
- data/lib/rhino/deprecations.rb +52 -0
- data/lib/rhino/error.rb +44 -0
- data/lib/rhino/object.rb +10 -1
- data/lib/rhino/rhino_ext.rb +237 -0
- data/lib/rhino/ruby.rb +225 -0
- data/lib/rhino/ruby/access.rb +8 -0
- data/lib/rhino/ruby/attribute_access.rb +55 -0
- data/lib/rhino/ruby/default_access.rb +54 -0
- data/lib/rhino/version.rb +1 -1
- data/lib/rhino/wormhole.rb +63 -57
- data/spec/rhino/access_spec.rb +69 -0
- data/spec/rhino/context_spec.rb +24 -10
- data/spec/rhino/deprecations_spec.rb +41 -0
- data/spec/rhino/error_spec.rb +38 -0
- data/spec/rhino/rhino_ext_spec.rb +234 -0
- data/spec/rhino/ruby_spec.rb +390 -0
- data/spec/rhino/wormhole_spec.rb +99 -78
- data/spec/spec_helper.rb +1 -0
- data/therubyrhino.gemspec +1 -0
- metadata +26 -8
- data/lib/rhino/java.rb +0 -24
- data/lib/rhino/native_function.rb +0 -29
- data/lib/rhino/native_object.rb +0 -71
- data/lib/rhino/ruby_function.rb +0 -14
- data/lib/rhino/ruby_object.rb +0 -71
data/lib/rhino/ruby_function.rb
DELETED
data/lib/rhino/ruby_object.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
|
2
|
-
module Rhino
|
3
|
-
class RubyObject < J::ScriptableObject
|
4
|
-
include J::Wrapper
|
5
|
-
|
6
|
-
def initialize(object)
|
7
|
-
super()
|
8
|
-
@ruby = object
|
9
|
-
end
|
10
|
-
|
11
|
-
def unwrap
|
12
|
-
@ruby
|
13
|
-
end
|
14
|
-
|
15
|
-
def getClassName()
|
16
|
-
@ruby.class.name
|
17
|
-
end
|
18
|
-
|
19
|
-
def getPrototype()
|
20
|
-
Prototype::Generic
|
21
|
-
end
|
22
|
-
|
23
|
-
def put(key, start, value)
|
24
|
-
if @ruby.respond_to?("#{key}=")
|
25
|
-
@ruby.send("#{key}=", To.ruby(value))
|
26
|
-
value
|
27
|
-
else
|
28
|
-
super
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def getIds()
|
33
|
-
@ruby.public_methods(false).map {|m| m.gsub(/(.)_(.)/) {java.lang.String.new("#{$1}#{$2.upcase}")}}.to_java
|
34
|
-
end
|
35
|
-
|
36
|
-
def to_s
|
37
|
-
"[Native #{@ruby.class.name}]"
|
38
|
-
end
|
39
|
-
|
40
|
-
alias_method :prototype, :getPrototype
|
41
|
-
|
42
|
-
|
43
|
-
class Prototype < J::ScriptableObject
|
44
|
-
|
45
|
-
def get(name, start)
|
46
|
-
robject = To.ruby(start)
|
47
|
-
if name == "toString"
|
48
|
-
return RubyFunction.new(lambda { "[Ruby #{robject.class.name}]"})
|
49
|
-
end
|
50
|
-
rb_name = name.gsub(/([a-z])([A-Z])/) {"#{$1}_#{$2.downcase}"}.to_sym
|
51
|
-
if (robject.public_methods(false).collect(&:to_sym).include?(rb_name))
|
52
|
-
method = robject.method(rb_name)
|
53
|
-
if method.arity == 0
|
54
|
-
To.javascript(method.call)
|
55
|
-
else
|
56
|
-
RubyFunction.new(method)
|
57
|
-
end
|
58
|
-
else
|
59
|
-
super(name, start)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def has(name, start)
|
64
|
-
rb_name = name.gsub(/([a-z])([A-Z])/) {"#{$1}_#{$2.downcase}"}.to_sym
|
65
|
-
To.ruby(start).public_methods(false).collect(&:to_sym).include?(rb_name) ? true : super(name,start)
|
66
|
-
end
|
67
|
-
|
68
|
-
Generic = new
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|