Go to the documentation of this file.
33 #include <ruby/version.h>
70 const size_t cap = 128;
84 size_t have =
b->cap -
b->size;
95 have =
b->cap -
b->size;
108 VALUE
ret = rb_str_new(
b->data,
b->size);
109 rb_enc_associate(
ret, rb_utf8_encoding());
177 rb_gc_mark(
arena->pinned_objs);
189 "Google::Protobuf::Internal::Arena",
191 .flags = RUBY_TYPED_FREE_IMMEDIATELY,
197 arena->pinned_objs = Qnil;
211 rb_raise(rb_eRuntimeError,
212 "Unable to fuse arenas. This should never happen since Ruby does "
213 "not use initial blocks");
224 if (
arena->pinned_objs == Qnil) {
225 arena->pinned_objs = rb_ary_new();
227 rb_ary_push(
arena->pinned_objs,
obj);
231 VALUE
internal = rb_define_module_under(
module,
"Internal");
232 VALUE
klass = rb_define_class_under(
internal,
"Arena", rb_cObject);
234 rb_gc_register_address(&
cArena);
260 #if RUBY_API_VERSION_CODE >= 20700 && SIZEOF_LONG >= SIZEOF_VALUE
261 #define USE_SECONDARY_MAP 0
263 #define USE_SECONDARY_MAP 1
266 #if USE_SECONDARY_MAP
292 "->(secondary, weak) {\n"
293 " secondary.delete_if { |k, v| !weak.key?(v) }\n"
296 length = rb_intern(
"length");
315 if (secondary_len < weak_len) {
329 size_t waste = secondary_len - weak_len;
334 size_t threshold =
PBRUBY_MAX(secondary_len * 0.2, 2000);
335 if (waste > threshold) {
347 ret = rb_class_new_instance(0, NULL, rb_cObject);
357 VALUE key_val = (VALUE)
key;
359 VALUE
ret = LL2NUM(key_val >> 2);
360 #if USE_SECONDARY_MAP
374 VALUE
klass = rb_eval_string(
"ObjectSpace::WeakMap");
378 #if USE_SECONDARY_MAP
385 #if USE_SECONDARY_MAP
390 #if USE_SECONDARY_MAP
413 rb_raise(rb_eRuntimeError,
"Messages nested too deeply.");
452 VALUE
google = rb_define_module(
"Google");
466 rb_define_singleton_method(
protobuf,
"discard_unknown",
468 rb_define_singleton_method(
protobuf,
"deep_copy",
void RepeatedField_register(VALUE module)
OPENSSL_EXPORT const ASN1_OBJECT * obj
int __cdecl vsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
void StringBuilder_Free(StringBuilder *b)
const rb_data_type_t Arena_type
VALUE Message_GetRubyWrapper(upb_msg *msg, const upb_msgdef *m, VALUE arena)
static void SecondaryMap_MaybeGC()
static VALUE SecondaryMap_Get(VALUE key, bool create)
void upb_arena_free(upb_arena *a)
void Message_register(VALUE protobuf)
static void Arena_free(void *data)
void Arena_Pin(VALUE _arena, VALUE obj)
#define PBRUBY_ASSERT(expr)
upb_arena * Arena_get(VALUE _arena)
VALUE RepeatedField_deep_copy(VALUE _self)
grpc_core::ScopedArenaPtr arena
const upb_msgdef * upb_fielddef_msgsubdef(const upb_fielddef *f)
const upb_fielddef * map_field_key(const upb_fielddef *field)
void Map_register(VALUE module)
def create(intercept_call)
bool upb_msg_discardunknown(upb_msg *msg, const upb_msgdef *m, int maxdepth)
VALUE Message_deep_copy(VALUE _self)
void Message_PrintMessage(StringBuilder *b, const upb_msg *msg, const upb_msgdef *m)
__attribute__((visibility("default")))
const upb_msgdef * msgdef
struct StringBuilder StringBuilder
const char * upb_enumdef_iton(const upb_enumdef *def, int32_t num)
UPB_INLINE upb_arena * upb_arena_new(void)
void StringBuilder_PrintMsgval(StringBuilder *b, upb_msgval val, TypeInfo info)
upb_msg * Message_GetMutable(VALUE msg_rb, const upb_msgdef **m)
VALUE secondary_map_mutex
void ObjectCache_Add(const void *key, VALUE val)
VALUE Map_deep_copy(VALUE _self)
const upb_fielddef * upb_msgdef_itof(const upb_msgdef *m, uint32_t i)
void StringBuilder_Printf(StringBuilder *b, const char *fmt,...)
static VALUE Google_Protobuf_discard_unknown(VALUE self, VALUE msg_rb)
static void StringBuilder_PrintEnum(StringBuilder *b, int32_t val, const upb_enumdef *e)
const upb_fielddef * map_field_value(const upb_fielddef *field)
const upb_enumdef * enumdef
static VALUE Arena_alloc(VALUE klass)
void Defs_register(VALUE module)
GTEST_API_ const char * fmt
const FieldDescriptor * field
VALUE StringBuilder_ToRubyString(StringBuilder *b)
const upb_msg * Message_Get(VALUE msg_rb, const upb_msgdef **m)
#define ALLOC(class_name)
UniquePtr< SSL_SESSION > ret
StringBuilder * StringBuilder_New()
static VALUE ObjectCache_GetKey(const void *key, bool create)
VALUE gc_secondary_map_lambda
bool upb_arena_fuse(upb_arena *a1, upb_arena *a2)
static void ObjectCache_Init()
static void SecondaryMap_Init()
static size_t StringBuilder_SizeOf(size_t cap)
void Arena_fuse(VALUE _arena, upb_arena *other)
static void Arena_mark(void *data)
VALUE ObjectCache_Get(const void *key)
void Arena_register(VALUE module)
VALUE Google_Protobuf_deep_copy(VALUE self, VALUE obj)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:47