예제 #1
0
/**
 * Writes a 128 bit decimal to the byte buffer.
 */
VALUE rb_bson_byte_buffer_put_decimal128(VALUE self, VALUE low, VALUE high)
{
  byte_buffer_t *b;
  const int64_t low64 = BSON_UINT64_TO_LE(NUM2ULL(low));
  const int64_t high64 = BSON_UINT64_TO_LE(NUM2ULL(high));

  TypedData_Get_Struct(self, byte_buffer_t, &rb_byte_buffer_data_type, b);
  ENSURE_BSON_WRITE(b, 8);
  memcpy(WRITE_PTR(b), &low64, 8);
  b->write_position += 8;

  ENSURE_BSON_WRITE(b, 8);
  memcpy(WRITE_PTR(b), &high64, 8);
  b->write_position += 8;

  return self;
}
예제 #2
0
/**
 * Writes a 64 bit integer to the byte buffer.
 */
VALUE rb_bson_byte_buffer_put_int64(VALUE self, VALUE i)
{
  byte_buffer_t *b;
  const int64_t i64 = BSON_UINT64_TO_LE(NUM2LL(i));

  TypedData_Get_Struct(self, byte_buffer_t, &rb_byte_buffer_data_type, b);
  ENSURE_BSON_WRITE(b, 8);
  memcpy(WRITE_PTR(b), (char*)&i64, 8);
  b->write_position += 8;

  return self;
}