asterism 0.5.0 → 0.7.0
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/CHANGELOG.md +112 -0
- data/README.md +163 -31
- data/lib/asterism/cruby/objects.rb +23 -4
- data/lib/asterism/cruby/ros.rb +16 -4
- data/lib/asterism/cruby/zenoh.rb +32 -6
- data/lib/asterism/cruby.rb +51 -7
- data/lib/asterism/version.rb +4 -3
- data/mrblib/asterism.rb +340 -75
- data/mrblib/future.rb +11 -5
- data/mrblib/profile.rb +17 -4
- data/mrblib/proxy.rb +23 -5
- metadata +1 -1
data/lib/asterism/cruby.rb
CHANGED
|
@@ -9,12 +9,53 @@ module Asterism
|
|
|
9
9
|
ROS::TYPE_PATH.replace([MSGS_DIR])
|
|
10
10
|
|
|
11
11
|
module Codec
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
#
|
|
12
|
+
INT_MIN = -(2**63)
|
|
13
|
+
INT_MAX = 2**63 - 1
|
|
14
|
+
|
|
15
|
+
# msgpack-ruby packs a binary (ASCII-8BIT) String, such as a payload
|
|
16
|
+
# that came from Zenoh or File.binread, as a bin and any other String
|
|
17
|
+
# as a str (docs/protocol.md 3.1): no compatibility mode.
|
|
16
18
|
def self.pack(v)
|
|
17
|
-
::MessagePack.pack(check(v)
|
|
19
|
+
::MessagePack.pack(check(v))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class << self
|
|
23
|
+
alias_method :check_portable, :check
|
|
24
|
+
|
|
25
|
+
# An Integer outside the signed 64-bit range cannot be sent (the
|
|
26
|
+
# other implementations cannot hold it): EncodeError, before sending.
|
|
27
|
+
def check(v, depth = 0)
|
|
28
|
+
if v.is_a?(Integer) && (v < INT_MIN || v > INT_MAX)
|
|
29
|
+
raise ::Asterism::EncodeError, "Integer #{v} is outside the signed 64-bit range"
|
|
30
|
+
end
|
|
31
|
+
return v if v.is_a?(Integer)
|
|
32
|
+
check_portable(v, depth)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
alias_method :unpack_portable, :unpack
|
|
36
|
+
|
|
37
|
+
# Also nil for an integer above 2^63-1 (msgpack-ruby reads a uint64;
|
|
38
|
+
# the protocol carries signed 64-bit integers only).
|
|
39
|
+
def unpack(bytes)
|
|
40
|
+
v = unpack_portable(bytes)
|
|
41
|
+
return v unless bytes&.b&.include?("\xcf".b)
|
|
42
|
+
int64_only?(v) ? v : nil
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def int64_only?(v)
|
|
46
|
+
case v
|
|
47
|
+
when Integer then v <= INT_MAX
|
|
48
|
+
when Array then v.all? { int64_only?(_1) }
|
|
49
|
+
when Hash then v.all? { |k, x| int64_only?(k) && int64_only?(x) }
|
|
50
|
+
else true
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# A text field of the protocol is a str, whatever the String's
|
|
55
|
+
# encoding was.
|
|
56
|
+
def text(s)
|
|
57
|
+
s.to_s.dup.force_encoding(Encoding::UTF_8)
|
|
58
|
+
end
|
|
18
59
|
end
|
|
19
60
|
end
|
|
20
61
|
|
|
@@ -62,7 +103,10 @@ module Asterism
|
|
|
62
103
|
end
|
|
63
104
|
end
|
|
64
105
|
|
|
65
|
-
|
|
66
|
-
|
|
106
|
+
# The calls being answered, per thread: an exposed method runs on the
|
|
107
|
+
# thread that answers (the receiving thread, or whatever polls), and
|
|
108
|
+
# Asterism.current_call on another thread is not inside that call.
|
|
109
|
+
def self.call_stack
|
|
110
|
+
Thread.current[:asterism_call_stack] ||= []
|
|
67
111
|
end
|
|
68
112
|
end
|
data/lib/asterism/version.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module Asterism
|
|
2
2
|
# The gem's version (the CRuby gem asterism). The Zenoh binding it needs
|
|
3
|
-
# is in asterism.gemspec (asterism-zenoh ~> 0.4.0 for 0.5.0
|
|
4
|
-
# did not change; see CHANGELOG.md).
|
|
5
|
-
|
|
3
|
+
# is in asterism.gemspec (asterism-zenoh ~> 0.4.0 for 0.5.0 to 0.7.0:
|
|
4
|
+
# the bindings did not change; see CHANGELOG.md). 0.7.0 speaks wire
|
|
5
|
+
# protocol 1 only (Asterism::PROTOCOL, docs/protocol.md).
|
|
6
|
+
VERSION = "0.7.0"
|
|
6
7
|
end
|