jtor-stdlib 0.1.3-java → 0.1.4-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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jtor-stdlib/base.rb +21 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e83350fe555fd5b1c74ca926dfdbe203ef7f09f2
4
- data.tar.gz: 23a1e40c02f00d3177a0eeb1f9aebdd9cce9b7ad
3
+ metadata.gz: 788765015218496bf8ce81d2ed3838276ac4d3ae
4
+ data.tar.gz: 9fdc417d377720e73b8e422b738b55a8ae7aa8ee
5
5
  SHA512:
6
- metadata.gz: 030ad6a50c4bb8fad4194d4b8d8273a54da1fd9b01038ca5f99862f3392de19ce792f3cdf68554f3da7f0a373551f46cc2dd7db990ae4c4d12f1aecfd5c51d75
7
- data.tar.gz: 749d3a27f0ac97f27c74ecdda710869e6e708754df44482f3f4e8d8419a0d484cc4a5364f100d2137e3bb60221d529d202e1664a6ab5e5d7c1bc30aad0efaeb6
6
+ metadata.gz: 5fb439909e96c479f34295bd0cd9aa8809ed0ed668387ac7359c31016297ddc4887a3ba132b151300ecd33ed25fae9abdd0a29a12cf3cd001665e12fff086281
7
+ data.tar.gz: 3fd35e1e3689304d0bb4c6f371a3541c81da6f34a4559ae6e2c05398d635e3896e0ce53d7de1da341fd55a11b8757224beac7844b5dbea2a76d8524185b7f09a
@@ -14,6 +14,10 @@ module Jtor
14
14
  @_lookup_table ||= {}
15
15
  end
16
16
 
17
+ def _lookup_table_static
18
+ @_lookup_table_static ||= {}
19
+ end
20
+
17
21
  def _constructor_calls
18
22
  @_constructor_calls ||= {}
19
23
  end
@@ -21,16 +25,25 @@ module Jtor
21
25
  # Method overloading is not a ruby thing, so we implement a pseudo-lookup
22
26
  # mechanism for method based on the type/count of their args
23
27
  def add_java_method(name, param_types, &block)
24
- previously_defined = _lookup_table[name]
25
- add_method_to_lookup(name, param_types, &block)
28
+ previously_defined = add_method_to_lookup(_lookup_table, name,
29
+ param_types, &block)
26
30
  return if previously_defined
27
31
  define_method(name) do |*args|
28
32
  instance_exec(*args, &self.class.lookup(name, *args))
29
33
  end
30
34
  end
31
35
 
36
+ def add_static_java_method(name, param_types, &block)
37
+ previously_defined = add_method_to_lookup(_lookup_table_static, name,
38
+ param_types, &block)
39
+ return if previously_defined
40
+ define_singleton_method(name) do |*args|
41
+ instance_exec(*args, &lookup(name, *args))
42
+ end
43
+ end
44
+
32
45
  def add_java_constructor(param_types, constructor_call = nil, &block)
33
- add_method_to_lookup(:initialize, param_types, &block)
46
+ add_method_to_lookup(_lookup_table, :initialize, param_types, &block)
34
47
  previously_defined = _constructor_calls.any?
35
48
  _constructor_calls[param_types] = constructor_call
36
49
  return if previously_defined
@@ -72,9 +85,11 @@ module Jtor
72
85
  true
73
86
  end
74
87
 
75
- def add_method_to_lookup(name, param_types, &block)
76
- _lookup_table[name] ||= {}
77
- _lookup_table[name][param_types] = block
88
+ def add_method_to_lookup(lookup_table, name, param_types, &block)
89
+ previously_defined = lookup_table[name]
90
+ lookup_table[name] ||= {}
91
+ lookup_table[name][param_types] = block
92
+ previously_defined
78
93
  end
79
94
  end
80
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jtor-stdlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: java
6
6
  authors:
7
7
  - Alejandro Rodríguez