Class: Capnp::Reference

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

Constant Summary collapse

EMPTY =
T.let(
  Capnp::Reference.new(
    Capnp::FlatMessage.new(Capnp::StringBuffer.new("")).segment(0),
    0
  ),
  Capnp::Reference
)
NULL_POINTER =
T.let(
  Capnp::Reference.new(
    Capnp::FlatMessage.new(Capnp::StringBuffer.new("\x00\x00\x00\x00\x00\x00\x00\x00")).segment(0),
    0
  ),
  Capnp::Reference
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(segment, position) ⇒ Reference

Returns a new instance of Reference.



11
12
13
14
# File 'lib/capnp/runtime/reference.rb', line 11

def initialize(segment, position)
  @segment = segment
  @position = position
end

Instance Attribute Details

#positionObject (readonly)

Returns the value of attribute position.



36
37
38
# File 'lib/capnp/runtime/reference.rb', line 36

def position
  @position
end

#segmentObject (readonly)

Returns the value of attribute segment.



33
34
35
# File 'lib/capnp/runtime/reference.rb', line 33

def segment
  @segment
end

Instance Method Details

#offset_position(offset) ⇒ Object



39
# File 'lib/capnp/runtime/reference.rb', line 39

def offset_position(offset) = self.class.new(@segment, @position + offset)

#read_bytes(offset, length) ⇒ Object



47
48
49
# File 'lib/capnp/runtime/reference.rb', line 47

def read_bytes(offset, length)
  @segment.read_bytes(@position + offset, length)
end

#read_f32(offset) ⇒ Object



92
93
94
# File 'lib/capnp/runtime/reference.rb', line 92

def read_f32(offset)
  @segment.read_f32(@position + offset)
end

#read_f64(offset) ⇒ Object



97
98
99
# File 'lib/capnp/runtime/reference.rb', line 97

def read_f64(offset)
  @segment.read_f64(@position + offset)
end

#read_s16(offset) ⇒ Object



77
78
79
# File 'lib/capnp/runtime/reference.rb', line 77

def read_s16(offset)
  @segment.read_s16(@position + offset)
end

#read_s32(offset) ⇒ Object



82
83
84
# File 'lib/capnp/runtime/reference.rb', line 82

def read_s32(offset)
  @segment.read_s32(@position + offset)
end

#read_s64(offset) ⇒ Object



87
88
89
# File 'lib/capnp/runtime/reference.rb', line 87

def read_s64(offset)
  @segment.read_s64(@position + offset)
end

#read_s8(offset) ⇒ Object



72
73
74
# File 'lib/capnp/runtime/reference.rb', line 72

def read_s8(offset)
  @segment.read_s8(@position + offset)
end

#read_string(offset, length) ⇒ Object



42
43
44
# File 'lib/capnp/runtime/reference.rb', line 42

def read_string(offset, length)
  @segment.read_string(@position + offset, length)
end

#read_u16(offset) ⇒ Object



57
58
59
# File 'lib/capnp/runtime/reference.rb', line 57

def read_u16(offset)
  @segment.read_u16(@position + offset)
end

#read_u32(offset) ⇒ Object



62
63
64
# File 'lib/capnp/runtime/reference.rb', line 62

def read_u32(offset)
  @segment.read_u32(@position + offset)
end

#read_u64(offset) ⇒ Object



67
68
69
# File 'lib/capnp/runtime/reference.rb', line 67

def read_u64(offset)
  @segment.read_u64(@position + offset)
end

#read_u8(offset) ⇒ Object



52
53
54
# File 'lib/capnp/runtime/reference.rb', line 52

def read_u8(offset)
  @segment.read_u8(@position + offset)
end