summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2010-07-21 18:59:01 -0700
committerJoshua Haberman <joshua@reverberate.org>2010-07-21 18:59:01 -0700
commit21ee24a7300dbdabef707457d2407b4f9187603b (patch)
tree4dae7c1ca0c6f4587c00561cd65d474680f0949b /core
parent71ac83fe7a15b27f34e9da452eaeee8df460a2aa (diff)
Updated Lua extension to handle fielddefs.
Diffstat (limited to 'core')
-rw-r--r--core/upb_def.c1
-rw-r--r--core/upb_def.h22
-rw-r--r--core/upb_table.c2
3 files changed, 15 insertions, 10 deletions
diff --git a/core/upb_def.c b/core/upb_def.c
index 1feaf9d..e40e1f0 100644
--- a/core/upb_def.c
+++ b/core/upb_def.c
@@ -355,6 +355,7 @@ static bool upb_addfield(upb_src *src, upb_msgdef *m, upb_status *status)
f->name = NULL;
f->def = NULL;
f->owned = false;
+ f->msgdef = m;
upb_fielddef *parsed_f;
int32_t tmp;
while((parsed_f = upb_src_getdef(src))) {
diff --git a/core/upb_def.h b/core/upb_def.h
index ae9e0fa..5c19a7a 100644
--- a/core/upb_def.h
+++ b/core/upb_def.h
@@ -87,23 +87,27 @@ INLINE void upb_def_unref(upb_def *def) {
// is either a field of a upb_msgdef or contained inside a upb_extensiondef.
// It is also reference-counted.
typedef struct _upb_fielddef {
- upb_atomic_refcount_t refcount;
- upb_string *name;
- upb_field_number_t number;
- upb_field_type_t type;
- upb_label_t label;
upb_value default_value;
+ upb_string *name;
+
+ struct _upb_msgdef *msgdef;
+
// For the case of an enum or a submessage, points to the def for that type.
upb_def *def;
- // True if we own a ref on "def" (above). This is true unless this edge is
- // part of a cycle.
- bool owned;
+ upb_atomic_refcount_t refcount;
+ uint32_t byte_offset; // Where in a upb_msg to find the data.
// These are set only when this fielddef is part of a msgdef.
- uint32_t byte_offset; // Where in a upb_msg to find the data.
upb_field_count_t field_index; // Indicates set bit.
+
+ upb_field_number_t number;
+ upb_field_type_t type;
+ upb_label_t label;
+ // True if we own a ref on "def" (above). This is true unless this edge is
+ // part of a cycle.
+ bool owned;
} upb_fielddef;
// A variety of tests about the type of a field.
diff --git a/core/upb_table.c b/core/upb_table.c
index b860204..a6e0a56 100644
--- a/core/upb_table.c
+++ b/core/upb_table.c
@@ -28,7 +28,7 @@ void upb_table_init(upb_table *t, uint32_t size, uint16_t entry_size)
{
t->count = 0;
t->entry_size = entry_size;
- t->size_lg2 = 1;
+ t->size_lg2 = 0;
while(size >>= 1) t->size_lg2++;
size_t bytes = upb_table_size(t) * t->entry_size;
t->mask = upb_table_size(t) - 1;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback