From 5871ed0d02ff69b20b65f577dd3be18a2e92dec7 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sun, 18 Jul 2010 22:45:15 -0700 Subject: First go at Lua bindings. --- core/upb_def.c | 4 ++-- core/upb_def.h | 8 ++++---- core/upb_string.h | 5 ++++- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'core') diff --git a/core/upb_def.c b/core/upb_def.c index fd00895..0d97982 100644 --- a/core/upb_def.c +++ b/core/upb_def.c @@ -190,7 +190,7 @@ void _upb_def_cyclic_ref(upb_def *def) { upb_cycle_ref_or_unref(upb_downcast_msgdef(def), NULL, open_defs, 0, true); } -static void upb_def_init(upb_def *def, upb_def_type type) { +static void upb_def_init(upb_def *def, upb_deftype type) { def->type = type; def->is_cyclic = 0; // We detect this later, after resolving refs. def->search_depth = 0; @@ -779,7 +779,7 @@ void _upb_symtab_free(upb_symtab *s) free(s); } -upb_def **upb_symtab_getdefs(upb_symtab *s, int *count, upb_def_type_t type) +upb_def **upb_symtab_getdefs(upb_symtab *s, int *count, upb_deftype_t type) { upb_rwlock_rdlock(&s->lock); int total = upb_strtable_count(&s->symtab); diff --git a/core/upb_def.h b/core/upb_def.h index 9cdc54d..ae9e0fa 100644 --- a/core/upb_def.h +++ b/core/upb_def.h @@ -48,15 +48,15 @@ typedef enum { // For specifying that defs of any type are requsted from getdefs. UPB_DEF_ANY = -1 -} upb_def_type; +} upb_deftype; // This typedef is more space-efficient than declaring an enum var directly. -typedef int8_t upb_def_type_t; +typedef int8_t upb_deftype_t; typedef struct { upb_string *fqname; // Fully qualified. upb_atomic_refcount_t refcount; - upb_def_type_t type; + upb_deftype_t type; // The is_cyclic flag could go in upb_msgdef instead of here, because only // messages can be involved in cycles. However, putting them here is free @@ -265,7 +265,7 @@ upb_def *upb_symtab_lookup(upb_symtab *s, upb_string *sym); // caller owns the returned array (which is of length *count) as well as a ref // to each symbol inside. If type is UPB_DEF_ANY then defs of all types are // returned, otherwise only defs of the required type are returned. -upb_def **upb_symtab_getdefs(upb_symtab *s, int *count, upb_def_type_t type); +upb_def **upb_symtab_getdefs(upb_symtab *s, int *count, upb_deftype_t type); // "fds" is a upb_src that will yield data from the // google.protobuf.FileDescriptorSet message type. upb_symtab_addfds() adds diff --git a/core/upb_string.h b/core/upb_string.h index 65ba404..bd89f67 100644 --- a/core/upb_string.h +++ b/core/upb_string.h @@ -197,7 +197,10 @@ void upb_string_substr(upb_string *str, upb_string *target_str, _UPB_STRING_INIT(str, sizeof(str)-1, _UPB_STRING_REFCOUNT_STATIC) #define UPB_STATIC_STRING_LEN(str, len) \ _UPB_STRING_INIT(str, len, _UPB_STRING_REFCOUNT_STATIC) -#define UPB_STACK_STRING(str) _UPB_STRING_INIT(str, _UPB_STRING_REFCOUNT_STACK) +#define UPB_STACK_STRING(str) \ + _UPB_STRING_INIT(str, sizeof(str)-1, _UPB_STRING_REFCOUNT_STACK) +#define UPB_STACK_STRING_LEN(str, len) \ + _UPB_STRING_INIT(str, len, _UPB_STRING_REFCOUNT_STACK) #define UPB_STRLIT(str) &(upb_string)UPB_STATIC_STRING(str) /* upb_string library functions ***********************************************/ -- cgit v1.2.3