summaryrefslogtreecommitdiff
path: root/upb/handlers.c
diff options
context:
space:
mode:
authorChris Fallin <cfallin@c1f.net>2014-12-11 18:58:04 -0800
committerChris Fallin <cfallin@c1f.net>2014-12-12 14:49:12 -0800
commitb3f6daf83d8adf0040a1bf9401342c811502f690 (patch)
tree2b51257e4b9cebfc3640d98cda45f9b8be36fdb2 /upb/handlers.c
parent56913be6bb57f81dbbf7baf9cc9a0a2cd1a36493 (diff)
Amalgamated distribution (upb.c/upb.h) tool.
There are a number of tweaks to get this to work: - The #include dependence graph wasn't quite complete, and I had to add a few #includes to get the tool to work. - I had to change a number of symbol names to avoid conflicts between 'static' definitions in different .c files. This could be avoided if the tool were smart enough to rename static symbols to have unique prefixes instead, but (i) this requires semantic understanding of C, and (ii) the macro-defined static functions (e.g., handlers for primitive types in several places) would probably trip this up. Verified that the resulting upb.h/upb.c compiles and doesn't have any unresolved references.
Diffstat (limited to 'upb/handlers.c')
-rw-r--r--upb/handlers.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/upb/handlers.c b/upb/handlers.c
index 90df8a6..c0fd271 100644
--- a/upb/handlers.c
+++ b/upb/handlers.c
@@ -120,7 +120,7 @@ static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f,
return sel;
}
-static upb_selector_t getsel(upb_handlers *h, const upb_fielddef *f,
+static upb_selector_t handlers_getsel(upb_handlers *h, const upb_fielddef *f,
upb_handlertype_t type) {
int32_t sel = trygetsel(h, f, type);
assert(sel >= 0);
@@ -129,7 +129,7 @@ static upb_selector_t getsel(upb_handlers *h, const upb_fielddef *f,
static const void **returntype(upb_handlers *h, const upb_fielddef *f,
upb_handlertype_t type) {
- return &h->table[getsel(h, f, type)].attr.return_closure_type_;
+ return &h->table[handlers_getsel(h, f, type)].attr.return_closure_type_;
}
static bool doset(upb_handlers *h, int32_t sel, const upb_fielddef *f,
@@ -213,18 +213,18 @@ const void *effective_closure_type(upb_handlers *h, const upb_fielddef *f,
if (upb_fielddef_isseq(f) &&
type != UPB_HANDLER_STARTSEQ &&
type != UPB_HANDLER_ENDSEQ &&
- h->table[sel = getsel(h, f, UPB_HANDLER_STARTSEQ)].func) {
+ h->table[sel = handlers_getsel(h, f, UPB_HANDLER_STARTSEQ)].func) {
ret = upb_handlerattr_returnclosuretype(&h->table[sel].attr);
}
if (type == UPB_HANDLER_STRING &&
- h->table[sel = getsel(h, f, UPB_HANDLER_STARTSTR)].func) {
+ h->table[sel = handlers_getsel(h, f, UPB_HANDLER_STARTSTR)].func) {
ret = upb_handlerattr_returnclosuretype(&h->table[sel].attr);
}
// The effective type of the submessage; not used yet.
// if (type == SUBMESSAGE &&
- // h->table[sel = getsel(h, f, UPB_HANDLER_STARTSUBMSG)].func) {
+ // h->table[sel = handlers_getsel(h, f, UPB_HANDLER_STARTSUBMSG)].func) {
// ret = upb_handlerattr_returnclosuretype(&h->table[sel].attr);
// }
@@ -237,7 +237,7 @@ const void *effective_closure_type(upb_handlers *h, const upb_fielddef *f,
// the return closure type of this handler's attr.
bool checkstart(upb_handlers *h, const upb_fielddef *f, upb_handlertype_t type,
upb_status *status) {
- upb_selector_t sel = getsel(h, f, type);
+ upb_selector_t sel = handlers_getsel(h, f, type);
if (h->table[sel].func) return true;
const void *closure_type = effective_closure_type(h, f, type);
const upb_handlerattr *attr = &h->table[sel].attr;
@@ -444,14 +444,18 @@ bool upb_handlers_freeze(upb_handlers *const*handlers, int n, upb_status *s) {
if (upb_fielddef_issubmsg(f)) {
bool hashandler = false;
- if (upb_handlers_gethandler(h, getsel(h, f, UPB_HANDLER_STARTSUBMSG)) ||
- upb_handlers_gethandler(h, getsel(h, f, UPB_HANDLER_ENDSUBMSG))) {
+ if (upb_handlers_gethandler(
+ h, handlers_getsel(h, f, UPB_HANDLER_STARTSUBMSG)) ||
+ upb_handlers_gethandler(
+ h, handlers_getsel(h, f, UPB_HANDLER_ENDSUBMSG))) {
hashandler = true;
}
if (upb_fielddef_isseq(f) &&
- (upb_handlers_gethandler(h, getsel(h, f, UPB_HANDLER_STARTSEQ)) ||
- upb_handlers_gethandler(h, getsel(h, f, UPB_HANDLER_ENDSEQ)))) {
+ (upb_handlers_gethandler(
+ h, handlers_getsel(h, f, UPB_HANDLER_STARTSEQ)) ||
+ upb_handlers_gethandler(
+ h, handlers_getsel(h, f, UPB_HANDLER_ENDSEQ)))) {
hashandler = true;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback