rdl 1.0.0.rc2 → 1.0.0.rc3
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.
- checksums.yaml +4 -4
- data/lib/rdl/wrap.rb +17 -9
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 865f3153019b7c93742a00d8da6258278b067050
|
4
|
+
data.tar.gz: 51006514c6074ff9ebb6e13f48267966a6c4445f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e63cbe09247ef295b49ceb627f3f473950981d76cb2a4cd553fb0bf3a4c84ed824105fe5b0ec75b52eb5f540cad0a973a80b24ba6946069a081bcb77f32d2c8
|
7
|
+
data.tar.gz: 0a8e2be67f67638d5016cdc5f238ed4e2a88c64d99c588b8b76f6ae48e259b98884326c4b18d83add06dec3ad9ed075c57f1bcac63b9c62b50b295233d01d673
|
data/lib/rdl/wrap.rb
CHANGED
@@ -47,7 +47,7 @@ class RDL::Wrap
|
|
47
47
|
klass = klass.to_s
|
48
48
|
$__rdl_type_params[klass]
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
# [+klass+] may be a Class, String, or Symbol
|
52
52
|
# [+meth+] may be a String or Symbol
|
53
53
|
#
|
@@ -57,13 +57,14 @@ class RDL::Wrap
|
|
57
57
|
$__rdl_wrap_switch.off {
|
58
58
|
klass_str = klass_str.to_s
|
59
59
|
klass = RDL::Util.to_class klass_str
|
60
|
+
return if wrapped? klass, meth
|
60
61
|
return if RDL::Config.instance.nowrap.member? klass
|
61
62
|
raise ArgumentError, "Attempt to wrap #{klass.to_s}\##{meth.to_s}" if klass.to_s =~ /^RDL::/
|
62
63
|
meth_old = wrapped_name(klass, meth) # meth_old is a symbol
|
63
|
-
return if (klass.method_defined? meth_old)
|
64
|
+
# return if (klass.method_defined? meth_old) # now checked above by wrapped? call
|
64
65
|
is_singleton_method = RDL::Util.has_singleton_marker(klass_str)
|
65
66
|
full_method_name = RDL::Util.pp_klass_method(klass_str, meth)
|
66
|
-
|
67
|
+
|
67
68
|
klass.class_eval <<-RUBY, __FILE__, __LINE__
|
68
69
|
alias_method meth_old, meth
|
69
70
|
def #{meth}(*args, &blk)
|
@@ -111,6 +112,7 @@ RUBY
|
|
111
112
|
# [+name+] is the name to give the block as a contract
|
112
113
|
def self.process_pre_post_args(default_class, name, *args, &blk)
|
113
114
|
klass = slf = meth = contract = nil
|
115
|
+
default_class = "Object" if (default_class.is_a? Object) && (default_class.to_s == "main") # special case for main
|
114
116
|
if args.size == 3
|
115
117
|
klass = class_to_string args[0]
|
116
118
|
slf, meth = meth_to_sym args[1]
|
@@ -132,7 +134,7 @@ RUBY
|
|
132
134
|
contract = args[0]
|
133
135
|
elsif blk
|
134
136
|
klass = default_class.to_s
|
135
|
-
contract = RDL::Contract::FlatContract.new(name, &blk)
|
137
|
+
contract = RDL::Contract::FlatContract.new(name, &blk)
|
136
138
|
else
|
137
139
|
raise ArgumentError, "Invalid arguments"
|
138
140
|
end
|
@@ -145,6 +147,7 @@ RUBY
|
|
145
147
|
# [+default_class+] should be a class
|
146
148
|
def self.process_type_args(default_class, *args, &blk)
|
147
149
|
klass = meth = type = nil
|
150
|
+
default_class = "Object" if (default_class.is_a? Object) && (default_class.to_s == "main") # special case for main
|
148
151
|
if args.size == 3
|
149
152
|
klass = class_to_string args[0]
|
150
153
|
slf, meth = meth_to_sym args[1]
|
@@ -164,7 +167,7 @@ RUBY
|
|
164
167
|
klass = RDL::Util.add_singleton_marker(klass) if slf
|
165
168
|
return [klass, meth, type]
|
166
169
|
end
|
167
|
-
|
170
|
+
|
168
171
|
private
|
169
172
|
|
170
173
|
def self.wrapped_name(klass, meth)
|
@@ -290,6 +293,7 @@ class Object
|
|
290
293
|
def self.method_added(meth)
|
291
294
|
$__rdl_contract_switch.off {
|
292
295
|
klass = self.to_s
|
296
|
+
klass = "Object" if (klass.is_a? Object) && (klass.to_s == "main")
|
293
297
|
|
294
298
|
# Apply any deferred contracts and reset list
|
295
299
|
if $__rdl_deferred.size > 0
|
@@ -317,6 +321,7 @@ class Object
|
|
317
321
|
def self.singleton_method_added(meth)
|
318
322
|
$__rdl_contract_switch.off {
|
319
323
|
klass = self.to_s
|
324
|
+
klass = "Object" if (klass.is_a? Object) && (klass.to_s == "main")
|
320
325
|
sklass = RDL::Util.add_singleton_marker(klass)
|
321
326
|
|
322
327
|
# Apply any deferred contracts and reset list
|
@@ -337,20 +342,21 @@ class Object
|
|
337
342
|
end
|
338
343
|
}
|
339
344
|
end
|
340
|
-
|
345
|
+
|
341
346
|
# Aliases contracts for meth_old and meth_new. Currently, this must
|
342
347
|
# be called for any aliases or they will not be wrapped with
|
343
348
|
# contracts. Only creates aliases in the current class.
|
344
349
|
def rdl_alias(new_name, old_name)
|
345
350
|
$__rdl_contract_switch.off {
|
346
351
|
klass = self.to_s
|
352
|
+
klass = "Object" if (klass.is_a? Object) && (klass.to_s == "main")
|
347
353
|
$__rdl_aliases[klass] = {} unless $__rdl_aliases[klass]
|
348
354
|
if $__rdl_aliases[klass][new_name]
|
349
355
|
raise RuntimeError,
|
350
356
|
"Tried to alias #{new_name}, already aliased to #{$__rdl_aliases[klass][new_name]}"
|
351
357
|
end
|
352
358
|
$__rdl_aliases[klass][new_name] = old_name
|
353
|
-
|
359
|
+
|
354
360
|
if self.method_defined? new_name
|
355
361
|
RDL::Wrap.wrap(klass, new_name)
|
356
362
|
else
|
@@ -375,6 +381,7 @@ class Object
|
|
375
381
|
$__rdl_contract_switch.off {
|
376
382
|
raise RuntimeError, "Empty type parameters not allowed" if params.empty?
|
377
383
|
klass = self.to_s
|
384
|
+
klass = "Object" if (klass.is_a? Object) && (klass.to_s == "main")
|
378
385
|
if $__rdl_type_params[klass]
|
379
386
|
raise RuntimeError, "#{klass} already has type parameters #{$__rdl_type_params[klass]}"
|
380
387
|
end
|
@@ -399,13 +406,14 @@ class Object
|
|
399
406
|
RDL.config { |config| config.add_nowrap(self, self.singleton_class) }
|
400
407
|
}
|
401
408
|
end
|
402
|
-
|
409
|
+
|
403
410
|
# [+typs+] is an array of types, classes, symbols, or strings to instantiate
|
404
411
|
# the type parameters. If a class, symbol, or string is given, it is
|
405
412
|
# converted to a NominalType.
|
406
413
|
def instantiate!(*typs)
|
407
414
|
$__rdl_contract_switch.off {
|
408
415
|
klass = self.class.to_s
|
416
|
+
klass = "Object" if (klass.is_a? Object) && (klass.to_s == "main")
|
409
417
|
formals, variance, all = $__rdl_type_params[klass]
|
410
418
|
raise RuntimeError, "Receiver is of class #{klass}, which is not parameterized" unless formals
|
411
419
|
raise RuntimeError, "Expecting #{params.size} type parameters, got #{typs.size}" unless formals.size == typs.size
|
@@ -502,4 +510,4 @@ class Object
|
|
502
510
|
end
|
503
511
|
}
|
504
512
|
end
|
505
|
-
end
|
513
|
+
end
|
metadata
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Jeffrey S. Foster
|
8
|
+
- Brianna M. Ren
|
9
|
+
- T. Stephen Strickland
|
10
|
+
- Alexander T. Yu
|
8
11
|
autorequire:
|
9
12
|
bindir: bin
|
10
13
|
cert_chain: []
|