Class: Protobuf::Field::Sfixed64Field

Inherits:
Int64Field show all
Defined in:
lib/protobuf/message/field.rb

Constant Summary

Constants inherited from VarintField

VarintField::INT32_MAX, VarintField::INT32_MIN, VarintField::INT64_MAX, VarintField::INT64_MIN, VarintField::UINT32_MAX, VarintField::UINT64_MAX

Instance Attribute Summary

Attributes inherited from BaseField

#default, #message_class, #name, #rule, #tag, #type

Instance Method Summary collapse

Methods inherited from Int64Field

max, min

Methods inherited from VarintField

#acceptable?, decode, default, encode

Methods inherited from BaseField

#acceptable?, #clear, default, #default_value, descriptor, #descriptor, #error_message, #get, #initialize, #initialized?, #max, #merge, #merge_array, #merge_value, #min, #optional?, #ready?, #repeated?, #required?, #set, #to_s, #typed_default_value

Constructor Details

This class inherits a constructor from Protobuf::Field::BaseField

Instance Method Details

#decode(bytes) ⇒ Object



516
517
518
519
520
521
522
# File 'lib/protobuf/message/field.rb', line 516

def decode(bytes)
  # we don't use 'Q' for pack/unpack. 'Q' is machine-dependent.
  values = bytes.unpack('VV')
  value  = values[0] + (values[1] << 32)
  value -= 0x1_0000_0000_0000_0000 if (value & 0x8000_0000_0000_0000).nonzero?
  value
end

#encode(value) ⇒ Object



524
525
526
527
# File 'lib/protobuf/message/field.rb', line 524

def encode(value)
  # we don't use 'Q' for pack/unpack. 'Q' is machine-dependent.
  [value & 0xffff_ffff, value >> 32].pack('VV')
end

#wire_typeObject



512
513
514
# File 'lib/protobuf/message/field.rb', line 512

def wire_type
  Protobuf::WireType::FIXED64
end