summaryrefslogtreecommitdiff
path: root/upbc
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2018-12-24 10:22:31 -0800
committerJoshua Haberman <jhaberman@gmail.com>2018-12-24 10:22:31 -0800
commita3a02d63190c99d6b53545ef23f6aa3671c2e8c0 (patch)
treef3f3cd34131662e29e6ae60b9b97a60d67ba602c /upbc
parent16becd2bd655f3cf64c371b9dca026b8291b6ebd (diff)
parent618981a60f2668c4c0ffc59833945514eb3dfdfa (diff)
Merge branch 'arrayapi' into defcleanup
Diffstat (limited to 'upbc')
-rw-r--r--upbc/generator.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/upbc/generator.cc b/upbc/generator.cc
index 35bd546..76b88be 100644
--- a/upbc/generator.cc
+++ b/upbc/generator.cc
@@ -437,6 +437,20 @@ void GenerateMessageInHeader(const protobuf::Descriptor* message, Output& output
output("UPB_FIELD_AT(msg, $0, $1) = value; }\n", CType(field),
GetSizeInit(layout.GetFieldOffset(field)));
}
+ if (field->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_MESSAGE) {
+ output(
+ "UPB_INLINE struct $0* $1_mutable_$2($1 *msg, upb_arena *arena) {\n"
+ " struct $0* sub = (struct $0*)$1_$2(msg);\n"
+ " if (sub == NULL) {\n"
+ " sub = (struct $0*)upb_msg_new(&$3, arena);\n"
+ " if (!sub) return NULL;\n"
+ " $1_set_$2(msg, sub);\n"
+ " }\n"
+ " return sub;\n"
+ "}\n",
+ MessageName(field->message_type()), msgname, field->name(),
+ MessageInit(field->message_type()));
+ }
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback