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.
@@ -1,14 +0,0 @@
1
-
2
- module Rhino
3
- class RubyFunction < J::BaseFunction
4
-
5
- def initialize(callable)
6
- super()
7
- @callable = callable
8
- end
9
-
10
- def call(cxt, scope, this, args)
11
- To.javascript @callable.call(*Array(args).map {|a| To.ruby(a)})
12
- end
13
- end
14
- end
@@ -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