summaryrefslogtreecommitdiff
path: root/upb
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2019-01-15 06:54:54 -0800
committerJoshua Haberman <jhaberman@gmail.com>2019-01-15 06:54:54 -0800
commit9ae5a3af5be8650950c9647b121f23c3a8ae8e83 (patch)
tree8e6837bbeb38202d7591453ecf6fa22f1850761e /upb
parent1508648f30cbaf5a3590572b2313fb5b595a7946 (diff)
parent9ea6bb467810b958c8c2fb0bcf96d0af2b243801 (diff)
Merge branch 'arrayapi' into defcleanup
Diffstat (limited to 'upb')
-rw-r--r--upb/bindings/lua/def.c4
-rw-r--r--upb/bindings/lua/upb/pb.c2
-rw-r--r--upb/decode.c14
-rw-r--r--upb/decode.h2
-rw-r--r--upb/def.c38
-rw-r--r--upb/def.h2
-rw-r--r--upb/encode.c6
-rw-r--r--upb/msg.c2
-rw-r--r--upb/msg.h26
-rw-r--r--upb/msgfactory.c2
10 files changed, 49 insertions, 49 deletions
diff --git a/upb/bindings/lua/def.c b/upb/bindings/lua/def.c
index c38b6d1..e16d426 100644
--- a/upb/bindings/lua/def.c
+++ b/upb/bindings/lua/def.c
@@ -639,8 +639,8 @@ static int lupb_symtab_add(lua_State *L) {
lupb_arena_new(L);
arena = lupb_arena_check(L, -1);
- set = google_protobuf_FileDescriptorSet_parsenew(
- upb_stringview_make(str, len), arena);
+ set = google_protobuf_FileDescriptorSet_parsenew(upb_strview_make(str, len),
+ arena);
if (!set) {
luaL_argerror(L, 2, "failed to parse descriptor");
diff --git a/upb/bindings/lua/upb/pb.c b/upb/bindings/lua/upb/pb.c
index 2edefe0..e60dcde 100644
--- a/upb/bindings/lua/upb/pb.c
+++ b/upb/bindings/lua/upb/pb.c
@@ -16,7 +16,7 @@ static int lupb_pb_decode(lua_State *L) {
const upb_msglayout *layout;
upb_msg *msg = lupb_msg_checkmsg2(L, 1, &layout);
const char *pb = lua_tolstring(L, 2, &len);
- upb_stringview buf = upb_stringview_make(pb, len);
+ upb_strview buf = upb_strview_make(pb, len);
upb_decode(buf, msg, layout);
/* TODO(haberman): check for error. */
diff --git a/upb/decode.c b/upb/decode.c
index 0f62326..f43f18f 100644
--- a/upb/decode.c
+++ b/upb/decode.c
@@ -113,14 +113,14 @@ static int64_t upb_zzdecode_64(uint64_t n) {
}
static bool upb_decode_string(const char **ptr, const char *limit,
- upb_stringview *val) {
+ upb_strview *val) {
uint32_t len;
CHK(upb_decode_varint32(ptr, limit, &len) &&
len < INT32_MAX &&
limit - *ptr >= (int32_t)len);
- *val = upb_stringview_make(*ptr, len);
+ *val = upb_strview_make(*ptr, len);
*ptr += len;
return true;
}
@@ -151,7 +151,7 @@ static bool upb_skip_unknownfielddata(upb_decstate *d, upb_decframe *frame,
return upb_decode_64bit(&d->ptr, frame->limit, &val);
}
case UPB_WIRE_TYPE_DELIMITED: {
- upb_stringview val;
+ upb_strview val;
return upb_decode_string(&d->ptr, frame->limit, &val);
}
case UPB_WIRE_TYPE_START_GROUP:
@@ -375,7 +375,7 @@ static bool upb_decode_32bitfield(upb_decstate *d, upb_decframe *frame,
return true;
}
-static bool upb_decode_fixedpacked(upb_array *arr, upb_stringview data,
+static bool upb_decode_fixedpacked(upb_array *arr, upb_strview data,
int elem_size) {
int elements = data.size / elem_size;
void *field_mem;
@@ -390,7 +390,7 @@ static bool upb_decode_fixedpacked(upb_array *arr, upb_stringview data,
static bool upb_decode_toarray(upb_decstate *d, upb_decframe *frame,
const char *field_start,
const upb_msglayout_field *field,
- upb_stringview val) {
+ upb_strview val) {
upb_array *arr = upb_getorcreatearr(frame, field);
#define VARINT_CASE(ctype, decode) { \
@@ -471,7 +471,7 @@ static bool upb_decode_toarray(upb_decstate *d, upb_decframe *frame,
static bool upb_decode_delimitedfield(upb_decstate *d, upb_decframe *frame,
const char *field_start,
const upb_msglayout_field *field) {
- upb_stringview val;
+ upb_strview val;
CHK(upb_decode_string(&d->ptr, frame->limit, &val));
@@ -585,7 +585,7 @@ static bool upb_decode_message(upb_decstate *d, const char *limit,
return true;
}
-bool upb_decode(upb_stringview buf, void *msg, const upb_msglayout *l) {
+bool upb_decode(upb_strview buf, void *msg, const upb_msglayout *l) {
upb_decstate state;
state.ptr = buf.data;
diff --git a/upb/decode.h b/upb/decode.h
index 790d7ef..275f138 100644
--- a/upb/decode.h
+++ b/upb/decode.h
@@ -11,7 +11,7 @@
extern "C" {
#endif
-bool upb_decode(upb_stringview buf, upb_msg *msg, const upb_msglayout *l);
+bool upb_decode(upb_strview buf, upb_msg *msg, const upb_msglayout *l);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/upb/def.c b/upb/def.c
index c744138..ae2306f 100644
--- a/upb/def.c
+++ b/upb/def.c
@@ -143,7 +143,7 @@ static bool upb_isalphanum(char c) {
return upb_isletter(c) || upb_isbetween(c, '0', '9');
}
-static bool upb_isident(upb_stringview name, bool full, upb_status *s) {
+static bool upb_isident(upb_strview name, bool full, upb_status *s) {
const char *str = name.data;
size_t len = name.size;
bool start = true;
@@ -933,7 +933,7 @@ typedef struct {
upb_status *status; /* Record errors here. */
} symtab_addctx;
-static char* strviewdup(const symtab_addctx *ctx, upb_stringview view) {
+static char* strviewdup(const symtab_addctx *ctx, upb_strview view) {
if (view.size == 0) {
return NULL;
}
@@ -944,12 +944,12 @@ static bool streql2(const char *a, size_t n, const char *b) {
return n == strlen(b) && memcmp(a, b, n) == 0;
}
-static bool streql_view(upb_stringview view, const char *b) {
+static bool streql_view(upb_strview view, const char *b) {
return streql2(view.data, view.size, b);
}
static const char *makefullname(const symtab_addctx *ctx, const char *prefix,
- upb_stringview name) {
+ upb_strview name) {
if (prefix) {
/* ret = prefix + '.' + name; */
size_t n = strlen(prefix);
@@ -981,7 +981,7 @@ static bool symtab_add(const symtab_addctx *ctx, const char *name,
/* Given a symbol and the base symbol inside which it is defined, find the
* symbol's definition in t. */
static bool resolvename(const upb_strtable *t, const upb_fielddef *f,
- const char *base, upb_stringview sym,
+ const char *base, upb_strview sym,
upb_deftype_t type, upb_status *status,
const void **def) {
if(sym.size == 0) return NULL;
@@ -1013,7 +1013,7 @@ static bool resolvename(const upb_strtable *t, const upb_fielddef *f,
}
const void *symtab_resolve(const symtab_addctx *ctx, const upb_fielddef *f,
- const char *base, upb_stringview sym,
+ const char *base, upb_strview sym,
upb_deftype_t type) {
const void *ret;
if (!resolvename(ctx->addtab, f, base, sym, type, ctx->status, &ret) &&
@@ -1030,7 +1030,7 @@ static bool create_oneofdef(
const symtab_addctx *ctx, upb_msgdef *m,
const google_protobuf_OneofDescriptorProto *oneof_proto) {
upb_oneofdef *o;
- upb_stringview name = google_protobuf_OneofDescriptorProto_name(oneof_proto);
+ upb_strview name = google_protobuf_OneofDescriptorProto_name(oneof_proto);
upb_value v;
o = (upb_oneofdef*)&m->oneofs[m->oneof_count++];
@@ -1153,7 +1153,7 @@ static bool create_fielddef(
upb_alloc *alloc = ctx->alloc;
upb_fielddef *f;
const google_protobuf_FieldOptions *options;
- upb_stringview name;
+ upb_strview name;
const char *full_name;
const char *shortname;
uint32_t field_number;
@@ -1273,7 +1273,7 @@ static bool create_enumdef(
const google_protobuf_EnumDescriptorProto *enum_proto) {
upb_enumdef *e;
const google_protobuf_EnumValueDescriptorProto *const *values;
- upb_stringview name;
+ upb_strview name;
size_t i, n;
name = google_protobuf_EnumDescriptorProto_name(enum_proto);
@@ -1300,7 +1300,7 @@ static bool create_enumdef(
for (i = 0; i < n; i++) {
const google_protobuf_EnumValueDescriptorProto *value = values[i];
- upb_stringview name = google_protobuf_EnumValueDescriptorProto_name(value);
+ upb_strview name = google_protobuf_EnumValueDescriptorProto_name(value);
char *name2 = strviewdup(ctx, name);
int32_t num = google_protobuf_EnumValueDescriptorProto_number(value);
upb_value v = upb_value_int32(num);
@@ -1339,7 +1339,7 @@ static bool create_msgdef(const symtab_addctx *ctx, const char *prefix,
const google_protobuf_EnumDescriptorProto *const *enums;
const google_protobuf_DescriptorProto *const *msgs;
size_t i, n;
- upb_stringview name;
+ upb_strview name;
name = google_protobuf_DescriptorProto_name(msg_proto);
CHK(upb_isident(name, false, ctx->status));
@@ -1437,7 +1437,7 @@ static void count_types_in_file(
static bool resolve_fielddef(const symtab_addctx *ctx, const char *prefix,
upb_fielddef *f) {
- upb_stringview name;
+ upb_strview name;
const google_protobuf_FieldDescriptorProto *field_proto = f->sub.unresolved;
if (f->is_extension_) {
@@ -1473,7 +1473,7 @@ static bool resolve_fielddef(const symtab_addctx *ctx, const char *prefix,
/* Have to delay resolving of the default value until now because of the enum
* case, since enum defaults are specified with a label. */
if (google_protobuf_FieldDescriptorProto_has_default_value(field_proto)) {
- upb_stringview defaultval =
+ upb_strview defaultval =
google_protobuf_FieldDescriptorProto_default_value(field_proto);
if (f->file->syntax == UPB_SYNTAX_PROTO3) {
@@ -1492,9 +1492,9 @@ static bool resolve_fielddef(const symtab_addctx *ctx, const char *prefix,
if (!parse_default(ctx, defaultval.data, defaultval.size, f)) {
upb_status_seterrf(ctx->status,
- "couldn't parse default '" UPB_STRINGVIEW_FORMAT
+ "couldn't parse default '" UPB_STRVIEW_FORMAT
"' for field (%s)",
- UPB_STRINGVIEW_ARGS(defaultval), f->full_name);
+ UPB_STRVIEW_ARGS(defaultval), f->full_name);
return false;
}
} else {
@@ -1512,7 +1512,7 @@ static bool build_filedef(
const google_protobuf_DescriptorProto *const *msgs;
const google_protobuf_EnumDescriptorProto *const *enums;
const google_protobuf_FieldDescriptorProto *const *exts;
- const upb_stringview* strs;
+ const upb_strview* strs;
size_t i, n;
decl_counts counts = {0};
@@ -1542,7 +1542,7 @@ static bool build_filedef(
file->phpnamespace = NULL;
if (google_protobuf_FileDescriptorProto_has_package(file_proto)) {
- upb_stringview package =
+ upb_strview package =
google_protobuf_FileDescriptorProto_package(file_proto);
CHK(upb_isident(package, true, ctx->status));
file->package = strviewdup(ctx, package);
@@ -1551,7 +1551,7 @@ static bool build_filedef(
}
if (google_protobuf_FileDescriptorProto_has_syntax(file_proto)) {
- upb_stringview syntax =
+ upb_strview syntax =
google_protobuf_FileDescriptorProto_syntax(file_proto);
if (streql_view(syntax, "proto2")) {
@@ -1581,7 +1581,7 @@ static bool build_filedef(
CHK_OOM(n == 0 || file->deps);
for (i = 0; i < n; i++) {
- upb_stringview dep_name = strs[i];
+ upb_strview dep_name = strs[i];
upb_value v;
if (!upb_strtable_lookup2(&ctx->symtab->files, dep_name.data,
dep_name.size, &v)) {
diff --git a/upb/def.h b/upb/def.h
index b1cf275..4fd8509 100644
--- a/upb/def.h
+++ b/upb/def.h
@@ -796,7 +796,7 @@ bool upb_symtab_addfile(upb_symtab *s,
typedef struct upb_def_init {
struct upb_def_init **deps;
const char *filename;
- upb_stringview descriptor;
+ upb_strview descriptor;
} upb_def_init;
bool _upb_symtab_loaddefinit(upb_symtab *s, const upb_def_init *init);
diff --git a/upb/encode.c b/upb/encode.c
index c874281..18b35d9 100644
--- a/upb/encode.c
+++ b/upb/encode.c
@@ -208,8 +208,8 @@ do { ; } while(0)
VARINT_CASE(int64_t, upb_zzencode_64(*ptr));
case UPB_DESCRIPTOR_TYPE_STRING:
case UPB_DESCRIPTOR_TYPE_BYTES: {
- upb_stringview *start = arr->data;
- upb_stringview *ptr = start + arr->len;
+ upb_strview *start = arr->data;
+ upb_strview *ptr = start + arr->len;
do {
ptr--;
CHK(upb_put_bytes(e, ptr->data, ptr->size) &&
@@ -293,7 +293,7 @@ static bool upb_encode_scalarfield(upb_encstate *e, const char *field_mem,
CASE(int64_t, varint, UPB_WIRE_TYPE_VARINT, upb_zzencode_64(val));
case UPB_DESCRIPTOR_TYPE_STRING:
case UPB_DESCRIPTOR_TYPE_BYTES: {
- upb_stringview view = *(upb_stringview*)field_mem;
+ upb_strview view = *(upb_strview*)field_mem;
if (skip_zero_value && view.size == 0) {
return true;
}
diff --git a/upb/msg.c b/upb/msg.c
index 41260d6..20401f9 100644
--- a/upb/msg.c
+++ b/upb/msg.c
@@ -53,7 +53,7 @@ static size_t upb_msgval_sizeof(upb_fieldtype_t type) {
return sizeof(void*);
case UPB_TYPE_BYTES:
case UPB_TYPE_STRING:
- return sizeof(upb_stringview);
+ return sizeof(upb_strview);
}
UPB_UNREACHABLE();
}
diff --git a/upb/msg.h b/upb/msg.h
index 149b7ab..78c3633 100644
--- a/upb/msg.h
+++ b/upb/msg.h
@@ -79,32 +79,32 @@ typedef struct upb_msglayout {
bool extendable;
} upb_msglayout;
-/** upb_stringview ************************************************************/
+/** upb_strview ************************************************************/
typedef struct {
const char *data;
size_t size;
-} upb_stringview;
+} upb_strview;
-UPB_INLINE upb_stringview upb_stringview_make(const char *data, size_t size) {
- upb_stringview ret;
+UPB_INLINE upb_strview upb_strview_make(const char *data, size_t size) {
+ upb_strview ret;
ret.data = data;
ret.size = size;
return ret;
}
-UPB_INLINE upb_stringview upb_stringview_makez(const char *data) {
- return upb_stringview_make(data, strlen(data));
+UPB_INLINE upb_strview upb_strview_makez(const char *data) {
+ return upb_strview_make(data, strlen(data));
}
-UPB_INLINE bool upb_stringview_eql(upb_stringview a, upb_stringview b) {
+UPB_INLINE bool upb_strview_eql(upb_strview a, upb_strview b) {
return a.size == b.size && memcmp(a.data, b.data, a.size) == 0;
}
-#define UPB_STRINGVIEW_FORMAT "%.*s"
-#define UPB_STRINGVIEW_ARGS(view) (int)(view).size, (view).data
+#define UPB_STRVIEW_INIT(ptr, len) {ptr, len}
-#define UPB_STRINGVIEW_INIT(ptr, len) {ptr, len}
+#define UPB_STRVIEW_FORMAT "%.*s"
+#define UPB_STRVIEW_ARGS(view) (int)(view).size, (view).data
/** upb_msgval ****************************************************************/
@@ -123,7 +123,7 @@ typedef union {
const upb_msg* msg;
const upb_array* arr;
const void* ptr;
- upb_stringview str;
+ upb_strview str;
} upb_msgval;
#define ACCESSORS(name, membername, ctype) \
@@ -150,12 +150,12 @@ ACCESSORS(map, map, const upb_map*)
ACCESSORS(msg, msg, const upb_msg*)
ACCESSORS(ptr, ptr, const void*)
ACCESSORS(arr, arr, const upb_array*)
-ACCESSORS(str, str, upb_stringview)
+ACCESSORS(str, str, upb_strview)
#undef ACCESSORS
UPB_INLINE upb_msgval upb_msgval_makestr(const char *data, size_t size) {
- return upb_msgval_str(upb_stringview_make(data, size));
+ return upb_msgval_str(upb_strview_make(data, size));
}
/** upb_msg *******************************************************************/
diff --git a/upb/msgfactory.c b/upb/msgfactory.c
index 23dd79a..f082042 100644
--- a/upb/msgfactory.c
+++ b/upb/msgfactory.c
@@ -33,7 +33,7 @@ static size_t upb_msgval_sizeof2(upb_fieldtype_t type) {
return sizeof(void*);
case UPB_TYPE_BYTES:
case UPB_TYPE_STRING:
- return sizeof(upb_stringview);
+ return sizeof(upb_strview);
}
UPB_UNREACHABLE();
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback