Class: Capnp::Message

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/capnp/runtime/message/message.rb

Direct Known Subclasses

FlatMessage, StreamMessage

Instance Method Summary collapse

Instance Method Details

#dereference_pointer(pointer_ref) ⇒ Object

Raises:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/capnp/runtime/message/message.rb', line 43

def dereference_pointer(pointer_ref)
  target_ref, single_far_pointer = dereference_far_pointer(pointer_ref)

  # Return if the pointer is not a far pointer
  return pointer_ref, nil if target_ref.nil?

  # Check if the target is a single far pointer
  # If so, the first word is the new pointer
  return target_ref, nil if single_far_pointer

  # The first word is a far pointer to a block of content
  content_ref, single_far_pointer = dereference_far_pointer(target_ref)
  raise Capnp::Error.new("First word of double far pointer is not a far pointer") if content_ref.nil?
  raise Capnp::Error.new("Double far pointer pointing to another double far pointer") unless single_far_pointer

  # The second word is the new pointer
  target_ref = target_ref.offset_position(Capnp::WORD_SIZE)
  [target_ref, content_ref]
end

#rootObject



16
17
18
# File 'lib/capnp/runtime/message/message.rb', line 16

def root
  segment(0).to_reference
end

#segment(id) ⇒ Object



12
13
# File 'lib/capnp/runtime/message/message.rb', line 12

def segment(id)
end