Class: Google::Protobuf::Internal::Arena

Inherits:
Object
  • Object
show all
Extended by:
FFI::DataConverter, TypeSafety
Defined in:
lib/google/protobuf/ffi/internal/arena.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TypeSafety

to_native

Constructor Details

#initialize(pointer) ⇒ Arena

Returns a new instance of Arena.



36
37
38
39
# File 'lib/google/protobuf/ffi/internal/arena.rb', line 36

def initialize(pointer)
  @arena = ::FFI::AutoPointer.new(pointer, Google::Protobuf::FFI.method(:free_arena))
  @pinned_messages = []
end

Class Method Details

.from_native(value, _) ⇒ Object

Parameters:

  • value (::FFI::Pointer)

    Arena pointer to be wrapped

  • _ (Object)

    Unused



31
32
33
# File 'lib/google/protobuf/ffi/internal/arena.rb', line 31

def from_native(value, _)
  new(value)
end

.to_native(value, _) ⇒ Object

Parameters:

  • value (Arena)

    Arena to convert to an FFI native type

  • _ (Object)

    Unused



24
25
26
# File 'lib/google/protobuf/ffi/internal/arena.rb', line 24

def to_native(value, _)
  value.instance_variable_get(:@arena) || ::FFI::Pointer::NULL
end

Instance Method Details

#fuse(other_arena) ⇒ Object



41
42
43
44
45
46
# File 'lib/google/protobuf/ffi/internal/arena.rb', line 41

def fuse(other_arena)
  return if other_arena == self
  unless Google::Protobuf::FFI.fuse_arena(self, other_arena)
    raise RuntimeError.new "Unable to fuse arenas. This should never happen since Ruby does not use initial blocks"
  end
end