summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2011-09-04 19:29:36 -0700
committerJoshua Haberman <jhaberman@gmail.com>2011-09-04 19:29:36 -0700
commit621c0cdcb5efc4f7c2382031becded018ef0b62b (patch)
treed6af78ef0872c9db0f48c99e6c93b8d4c43fa689 /tools
parent8f2758dda2ba12b78ae8f8c7170decc5e88dd28c (diff)
Const invasion: large parts of upb made const-correct.
Diffstat (limited to 'tools')
-rw-r--r--tools/upbc.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/upbc.c b/tools/upbc.c
index 37ea2fe..a5d8897 100644
--- a/tools/upbc.c
+++ b/tools/upbc.c
@@ -36,8 +36,8 @@ static void to_preproc(char *str) {
/* The _const.h file defines the constants (enums) defined in the .proto
* file. */
-static void write_const_h(upb_def *defs[], int num_entries, char *outfile_name,
- FILE *stream) {
+static void write_const_h(const upb_def *defs[], int num_entries,
+ char *outfile_name, FILE *stream) {
/* Header file prologue. */
char *include_guard_name = strdup(outfile_name);
to_preproc(include_guard_name);
@@ -54,7 +54,7 @@ static void write_const_h(upb_def *defs[], int num_entries, char *outfile_name,
fprintf(stream, "/* Enums. */\n\n");
for(int i = 0; i < num_entries; i++) { /* Foreach enum */
if(defs[i]->type != UPB_DEF_ENUM) continue;
- upb_enumdef *enumdef = upb_downcast_enumdef(defs[i]);
+ const upb_enumdef *enumdef = upb_downcast_enumdef_const(defs[i]);
char *enum_name = strdup(upb_def_fqname(UPB_UPCAST(enumdef)));
char *enum_val_prefix = strdup(enum_name);
to_cident(enum_name);
@@ -83,7 +83,7 @@ static void write_const_h(upb_def *defs[], int num_entries, char *outfile_name,
/* Constants for field names and numbers. */
fprintf(stream, "/* Constants for field names and numbers. */\n\n");
for(int i = 0; i < num_entries; i++) { /* Foreach enum */
- upb_msgdef *m = upb_dyncast_msgdef(defs[i]);
+ const upb_msgdef *m = upb_dyncast_msgdef_const(defs[i]);
if(!m) continue;
char *msg_name = strdup(upb_def_fqname(UPB_UPCAST(m)));
char *msg_val_prefix = strdup(msg_name);
@@ -167,7 +167,7 @@ int main(int argc, char *argv[]) {
// importing descriptor.proto.
upb_symtab *s = upb_symtab_new();
upb_status status = UPB_STATUS_INIT;
- upb_read_descriptor(s, descriptor, len, &status);
+ upb_load_descriptor_into_symtab(s, descriptor, len, &status);
if(!upb_ok(&status)) {
error("Failed to parse input file descriptor: %s\n",
upb_status_getstr(&status));
@@ -184,7 +184,7 @@ int main(int argc, char *argv[]) {
if(!h_const_file) error("Failed to open _const.h output file\n");
int symcount;
- upb_def **defs = upb_symtab_getdefs(s, &symcount, UPB_DEF_ANY);
+ const upb_def **defs = upb_symtab_getdefs(s, &symcount, UPB_DEF_ANY);
write_const_h(defs, symcount, h_const_filename, h_const_file);
for (int i = 0; i < symcount; i++) upb_def_unref(defs[i]);
free(defs);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback