summaryrefslogtreecommitdiff
path: root/src/upb_text.c
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-12-29 19:41:51 -0800
committerJoshua Haberman <joshua@reverberate.org>2009-12-29 19:41:51 -0800
commit3f0d126b2a35952e97555378f7ea5d370e1c424e (patch)
tree69e9de6e157c6b8b5a93085da4f94eb47276ecfe /src/upb_text.c
parentcc396257679698852380822bc6bfb61d33244172 (diff)
Only remaining undefined symbol is upb_msg_parsestr.
Diffstat (limited to 'src/upb_text.c')
-rw-r--r--src/upb_text.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/src/upb_text.c b/src/upb_text.c
index 103468c..17efa9f 100644
--- a/src/upb_text.c
+++ b/src/upb_text.c
@@ -7,9 +7,7 @@
#include <inttypes.h>
#include "descriptor.h"
#include "upb_text.h"
-#include "upb_string.h"
-#include "upb_msg.h"
-#include "upb_array.h"
+#include "upb_data.h"
void upb_text_printval(upb_field_type_t type, union upb_value val, FILE *file)
{
@@ -51,7 +49,7 @@ static void print_indent(struct upb_text_printer *p, FILE *stream)
}
void upb_text_printfield(struct upb_text_printer *p,
- struct upb_string *name,
+ upb_string *name,
upb_field_type_t valtype, union upb_value val,
FILE *stream)
{
@@ -65,7 +63,7 @@ void upb_text_printfield(struct upb_text_printer *p,
}
void upb_text_push(struct upb_text_printer *p,
- struct upb_string *submsg_type,
+ upb_string *submsg_type,
FILE *stream)
{
print_indent(p, stream);
@@ -82,49 +80,48 @@ void upb_text_pop(struct upb_text_printer *p,
fprintf(stream, "}\n");
}
-static void printval(struct upb_text_printer *printer, union upb_value_ptr p,
+static void printval(struct upb_text_printer *printer, union upb_value v,
struct upb_fielddef *f,
FILE *stream);
-static void printmsg(struct upb_text_printer *printer, struct upb_msg *msg,
- FILE *stream)
+static void printmsg(struct upb_text_printer *printer,
+ upb_msg *msg, struct upb_msgdef *md, FILE *stream)
{
- struct upb_msgdef *m = msg->def;
- for(upb_field_count_t i = 0; i < m->num_fields; i++) {
- struct upb_fielddef *f = &m->fields[i];
- if(!upb_msg_isset(msg, f)) continue;
- union upb_value_ptr p = upb_msg_getptr(msg, f);
+ for(upb_field_count_t i = 0; i < md->num_fields; i++) {
+ struct upb_fielddef *f = &md->fields[i];
+ if(!upb_msg_has(msg, f)) continue;
+ union upb_value v = upb_msg_get(msg, f);
if(upb_isarray(f)) {
- struct upb_array *arr = *p.arr;
- for(uint32_t j = 0; j < arr->len; j++) {
- union upb_value_ptr elem_p = upb_array_getelementptr(arr, j);
- printval(printer, elem_p, f, stream);
+ upb_array *arr = v.arr;
+ for(uint32_t j = 0; j < upb_array_len(arr); j++) {
+ union upb_value elem = upb_array_get(arr, f, j);
+ printval(printer, elem, f, stream);
}
} else {
- printval(printer, p, f, stream);
+ printval(printer, v, f, stream);
}
}
}
-static void printval(struct upb_text_printer *printer, union upb_value_ptr p,
+static void printval(struct upb_text_printer *printer, union upb_value v,
struct upb_fielddef *f,
FILE *stream)
{
if(upb_issubmsg(f)) {
upb_text_push(printer, f->name, stream);
- printmsg(printer, *p.msg, stream);
+ printmsg(printer, v.msg, upb_downcast_msgdef(f->def), stream);
upb_text_pop(printer, stream);
} else {
- upb_text_printfield(printer, f->name, f->type,
- upb_value_read(p, f->type), stream);
+ upb_text_printfield(printer, f->name, f->type, v, stream);
}
}
-void upb_msg_print(struct upb_msg *msg, bool single_line, FILE *stream)
+void upb_msg_print(upb_msg *msg, struct upb_msgdef *md, bool single_line,
+ FILE *stream)
{
struct upb_text_printer printer;
upb_text_printer_init(&printer, single_line);
- printmsg(&printer, msg, stream);
+ printmsg(&printer, msg, md, stream);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback