mirror of
https://github.com/vxcontrol/lualibs-protobuf.git
synced 2026-07-01 09:16:28 -04:00
fix the maintain of oneof_field in type.
This commit is contained in:
@@ -27,7 +27,7 @@ jobs:
|
||||
steps:
|
||||
- name: Install LCov
|
||||
run: |
|
||||
sudo apt install libperlio-gzip-perl libjson-perl
|
||||
sudo apt install libperlio-gzip-perl libjson-perl libcapture-tiny-perl
|
||||
wget "https://github.com/linux-test-project/lcov/archive/master.zip"
|
||||
unzip "master.zip"
|
||||
cd "lcov-master"
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*.pdb
|
||||
*.rock
|
||||
*.so
|
||||
*.o
|
||||
*.gc*
|
||||
google
|
||||
lua*/
|
||||
out*
|
||||
|
||||
@@ -1169,8 +1169,10 @@ typedef enum {USE_FIELD = 1, USE_REPEAT = 2, USE_MESSAGE = 4} lpb_DefFlags;
|
||||
|
||||
static void lpb_pushtypetable(lua_State *L, lpb_State *LS, const pb_Type *t);
|
||||
|
||||
static void lpb_newmsgtable(lua_State *L, const pb_Type *t)
|
||||
{ lua_createtable(L, 0, t->field_count - t->oneof_field + t->oneof_count*2); }
|
||||
static void lpb_newmsgtable(lua_State *L, const pb_Type *t) {
|
||||
int fieldcnt = t->field_count - t->oneof_field + t->oneof_count*2;
|
||||
lua_createtable(L, 0, fieldcnt > 0 ? fieldcnt : 0);
|
||||
}
|
||||
|
||||
LUALIB_API const pb_Type *lpb_type(lpb_State *LS, pb_Slice s) {
|
||||
const pb_Type *t;
|
||||
|
||||
@@ -1323,7 +1323,10 @@ PB_API void pb_delfield(pb_State *S, pb_Type *t, pb_Field *f) {
|
||||
tf = (pb_FieldEntry*)pb_gettable(&t->field_tags, (pb_Key)f->number);
|
||||
if (nf && nf->value == f) nf->entry.key = 0, nf->value = NULL, ++count;
|
||||
if (tf && tf->value == f) tf->entry.key = 0, tf->value = NULL, ++count;
|
||||
if (count) pbT_freefield(S, f), --t->field_count;
|
||||
if (count) {
|
||||
if (f->oneof_idx) --t->oneof_field;
|
||||
pbT_freefield(S, f), --t->field_count;
|
||||
}
|
||||
pb_delsort(t);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user