Go to the documentation of this file.
53 ret.data = RSTRING_PTR(
str);
55 ret.size = RSTRING_LEN(
str);
69 "Expected number type for integral field '%s' (given %s).",
name,
70 rb_class2name(CLASS_OF(val)));
76 if (
TYPE(val) == T_FLOAT) {
77 double dbl_val = NUM2DBL(val);
78 if (floor(dbl_val) != dbl_val) {
79 rb_raise(rb_eRangeError,
80 "Non-integral floating point value assigned to integer field "
82 name, rb_class2name(CLASS_OF(val)));
86 if (NUM2DBL(val) < 0) {
89 "Assigning negative value to unsigned integer field '%s' (given %s).",
90 name, rb_class2name(CLASS_OF(val)));
104 val = NUM2INT(
value);
118 "Expected number or symbol type for enum field '%s'.",
name);
124 rb_raise(rb_eRangeError,
"Unknown symbol value for enum field '%s'.",
name);
131 switch (type_info.
type) {
134 rb_raise(
cTypeError,
"Expected number type for float field '%s' (given %s).",
141 rb_raise(
cTypeError,
"Expected number type for double field '%s' (given %s).",
147 if (
value == Qtrue) {
149 }
else if (
value == Qfalse) {
152 rb_raise(
cTypeError,
"Invalid argument for boolean field '%s' (given %s).",
158 VALUE utf8 = rb_enc_from_encoding(rb_utf8_encoding());
159 if (CLASS_OF(
value) == rb_cSymbol) {
160 value = rb_funcall(
value, rb_intern(
"to_s"), 0);
161 }
else if (CLASS_OF(
value) != rb_cString) {
162 rb_raise(
cTypeError,
"Invalid argument for string field '%s' (given %s).",
166 if (rb_obj_encoding(
value) != utf8) {
170 if (rb_enc_str_coderange(
value) == ENC_CODERANGE_BROKEN) {
171 rb_raise(rb_eEncodingError,
"String is invalid UTF-8");
179 VALUE
bytes = rb_enc_from_encoding(rb_ascii8bit_encoding());
180 if (CLASS_OF(
value) != rb_cString) {
181 rb_raise(
cTypeError,
"Invalid argument for bytes field '%s' (given %s).",
206 switch (type_info.
type) {
231 switch (type_info.
type) {
237 return upb_val.
bool_val ? Qtrue : Qfalse;
250 return ID2SYM(rb_intern(
name));
257 rb_enc_associate(str_rb, rb_utf8_encoding());
258 rb_obj_freeze(str_rb);
263 rb_enc_associate(str_rb, rb_ascii8bit_encoding());
264 rb_obj_freeze(str_rb);
271 rb_raise(rb_eRuntimeError,
"Convert_UpbToRuby(): Unexpected type %d",
272 (
int)type_info.
type);
280 switch (type_info.
type) {
282 memcpy(&new_msgval, &msgval,
sizeof(msgval));
303 switch (type_info.
type) {
305 return memcmp(&
val1, &
val2, 1) == 0;
310 return memcmp(&
val1, &
val2, 4) == 0;
314 return memcmp(&
val1, &
val2, 8) == 0;
317 return val1.str_val.size ==
val2.str_val.size &&
318 memcmp(
val1.str_val.data,
val2.str_val.data,
319 val1.str_val.size) == 0;
323 rb_raise(rb_eRuntimeError,
"Internal error, unexpected type");
328 switch (type_info.
type) {
346 rb_raise(rb_eRuntimeError,
"Internal error, unexpected type");
static void Convert_CheckInt(const char *name, upb_fieldtype_t type, VALUE val)
UPB_INLINE void * upb_arena_malloc(upb_arena *a, size_t size)
upb_msgval Convert_RubyToUpb(VALUE value, const char *name, TypeInfo type_info, upb_arena *arena)
VALUE Convert_UpbToRuby(upb_msgval upb_val, TypeInfo type_info, VALUE arena)
VALUE Message_GetRubyWrapper(upb_msg *msg, const upb_msgdef *m, VALUE arena)
static const uint8_t seed[20]
bool Message_GetUpbMessage(zval *val, const Descriptor *desc, upb_arena *arena, upb_msg **msg)
static upb_strview Convert_StringData(VALUE str, upb_arena *arena)
uint64_t Message_Hash(const upb_msg *msg, const upb_msgdef *m, uint64_t seed)
UPB_INLINE bool upb_enumdef_ntoiz(const upb_enumdef *e, const char *name, int32_t *num)
bool Message_Equal(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m)
grpc_core::ScopedArenaPtr arena
bool Msgval_IsEqual(upb_msgval val1, upb_msgval val2, TypeInfo type_info)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
bool upb_enumdef_ntoi(const upb_enumdef *def, const char *name, size_t len, int32_t *num)
VALUE Message_deep_copy(VALUE _self)
const upb_msgdef * msgdef
unsigned __int64 uint64_t
const char * upb_enumdef_iton(const upb_enumdef *def, int32_t num)
uint64_t Msgval_GetHash(upb_msgval val, TypeInfo type_info, uint64_t seed)
constexpr uint64_t kWyhashSalt[5]
const upb_enumdef * enumdef
uint64_t Wyhash(const void *data, size_t len, uint64_t seed, const uint64_t salt[])
UniquePtr< SSL_SESSION > ret
upb_msgval Msgval_DeepCopy(upb_msgval msgval, TypeInfo type_info, upb_arena *arena)
static bool is_ruby_num(VALUE value)
static int32_t Convert_ToEnum(VALUE value, const char *name, const upb_enumdef *e)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:02