cddl 0.8.13 → 0.8.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cddl.gemspec +1 -1
- data/lib/cddl.rb +55 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 182b4b76590226a9f1f72dd534266693e566b2dea3188e5f0c073c69474c1f07
|
4
|
+
data.tar.gz: 49170c49b5f8153a0fd589d31ffd7d4b10f7b394828a816c8a240e8880487754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b1cced35bb95e5eaded068c3f66f25498ff8f03c0de30a992132aa7d254fb6ce4fc8571dc7d4d7cc32799acc97da8cbe6b43b9c90b8254ad0bf54a645763667
|
7
|
+
data.tar.gz: f8a7c15619656ae72b792f9fcac5c408a9180a81f51c825e148b086c21a7ba1fa85ef69f4c329bb0cad019198458c33ebe2e0cfa3a030bd11b46eea324e6645d
|
data/cddl.gemspec
CHANGED
data/lib/cddl.rb
CHANGED
@@ -441,6 +441,29 @@ module CDDL
|
|
441
441
|
generate1(target, inmap)
|
442
442
|
when :feature
|
443
443
|
generate1(target, inmap)
|
444
|
+
when :cat
|
445
|
+
lhs = generate1(target, inmap)
|
446
|
+
rhs = generate1(control)
|
447
|
+
begin
|
448
|
+
lhs + rhs
|
449
|
+
rescue Exception => e
|
450
|
+
fail "Can't #{lhs.inspect} .cat #{rhs.inspect}: #{e.message}"
|
451
|
+
end
|
452
|
+
when :plus
|
453
|
+
lhs = generate1(target, inmap)
|
454
|
+
rhs = generate1(control)
|
455
|
+
begin
|
456
|
+
case lhs
|
457
|
+
when Integer
|
458
|
+
lhs + Integer(rhs)
|
459
|
+
when Numeric
|
460
|
+
lhs + rhs
|
461
|
+
else
|
462
|
+
fail "#{lhs.inspect}: Not a number"
|
463
|
+
end
|
464
|
+
rescue Exception => e
|
465
|
+
fail "Can't #{lhs.inspect} .plus #{rhs.inspect}: #{e.message}"
|
466
|
+
end
|
444
467
|
when :eq
|
445
468
|
content = generate1(control)
|
446
469
|
if validate1(content, where)
|
@@ -542,9 +565,24 @@ module CDDL
|
|
542
565
|
[true, t[1], vt]
|
543
566
|
elsif v = SIMPLE_VALUE[t]
|
544
567
|
v
|
545
|
-
|
546
|
-
|
547
|
-
|
568
|
+
elsif t[0] == :anno
|
569
|
+
_, conop, target, control = t
|
570
|
+
# warn ["EXV0", conop, target, control].inspect
|
571
|
+
if conop == :cat || conop == :plus
|
572
|
+
ok1, v1, vt1 = extract_value(target)
|
573
|
+
ok2, v2, vt2 = extract_value(control)
|
574
|
+
# warn ["EXV", ok1, v1, vt1, ok2, v2, vt2].inspect
|
575
|
+
if ok1 && ok2
|
576
|
+
if vt1 == Integer
|
577
|
+
[true, v1 + Integer(v2), Integer] if vt2 == Integer || vt2 == Float
|
578
|
+
elsif vt1 == Float
|
579
|
+
[true, v1 + v2, vt1] if vt2 == Integer || vt2 == Float
|
580
|
+
else
|
581
|
+
[true, v1 + v2, vt1] if vt1 == vt2
|
582
|
+
end
|
583
|
+
end rescue nil
|
584
|
+
end
|
585
|
+
end || [false]
|
548
586
|
end
|
549
587
|
|
550
588
|
def extract_array(t)
|
@@ -772,10 +810,18 @@ module CDDL
|
|
772
810
|
when :range
|
773
811
|
[] if where[2] === d && where[1].include?(d)
|
774
812
|
when :anno
|
775
|
-
target = where
|
776
|
-
if
|
777
|
-
|
778
|
-
|
813
|
+
_, conop, target, control = where
|
814
|
+
if conop == :cat || conop == :plus
|
815
|
+
ok1, v1, vt1 = extract_value(target)
|
816
|
+
ok2, v2, vt2 = extract_value(control)
|
817
|
+
# warn ["ANNO0", ok1, v1, vt1, ok2, v2, vt2, d].inspect
|
818
|
+
if ok1 && ok2
|
819
|
+
v2 = Integer(v2) if vt1 == Integer
|
820
|
+
# warn ["ANNO", ok1, v1, vt1, ok2, v2, vt2, d].inspect
|
821
|
+
[] if d == v1 + v2 # XXX Focus ArgumentError
|
822
|
+
end
|
823
|
+
elsif ann = validate1a(d, target)
|
824
|
+
case conop
|
779
825
|
when :size
|
780
826
|
case d
|
781
827
|
when Integer
|
@@ -831,7 +877,7 @@ module CDDL
|
|
831
877
|
$features[nm][det] = true
|
832
878
|
ann
|
833
879
|
when :lt, :le, :gt, :ge, :eq, :ne
|
834
|
-
op = OPERATORS[
|
880
|
+
op = OPERATORS[conop]
|
835
881
|
ok, v, _vt = extract_value(control)
|
836
882
|
if ok
|
837
883
|
ann if d.send(op, v) rescue nil # XXX Focus ArgumentError
|
@@ -1201,7 +1247,7 @@ module CDDL
|
|
1201
1247
|
BRACE = {"{" => :map, "[" => :array}
|
1202
1248
|
RANGE_EXCLUDE_END = {".." => false, "..." => true}
|
1203
1249
|
SUPPORTED_ANNOTATIONS = [:bits, :size, :regexp, :cbor, :cborseq, :within, :and,
|
1204
|
-
:default, :lt, :le, :gt, :ge, :eq, :ne, :feature]
|
1250
|
+
:default, :lt, :le, :gt, :ge, :eq, :ne, :feature, :cat, :plus]
|
1205
1251
|
|
1206
1252
|
def type1(n, canbegroup = false)
|
1207
1253
|
# puts "NVALUE #{n.value.inspect}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cddl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cbor-diag
|