MCPcopy Create free account
hub / github.com/Tencent/UnLua / pbL_loadField

Function pbL_loadField

Plugins/UnLuaExtensions/LuaProtobuf/Source/src/pb.h:1665–1682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1663}
1664
1665static int pbL_loadField(pb_State *S, pbL_FieldInfo *info, pb_Loader *L, pb_Type *t) {
1666 pb_Type *ft = NULL;
1667 pb_Field *f;
1668 if (info->type == PB_Tmessage || info->type == PB_Tenum)
1669 pbCE(ft = pb_newtype(S, pb_newname(S, info->type_name, NULL)));
1670 if (t == NULL)
1671 pbCE(t = pb_newtype(S, pb_newname(S, info->extendee, NULL)));
1672 pbCE(f = pb_newfield(S, t, pb_newname(S, info->name, NULL), info->number));
1673 f->default_value = pb_newname(S, info->default_value, NULL);
1674 f->type = ft;
1675 if ((f->oneof_idx = info->oneof_index)) ++t->oneof_field;
1676 f->type_id = info->type;
1677 f->repeated = info->label == 3; /* repeated */
1678 f->packed = info->packed >= 0 ? info->packed : L->is_proto3 && f->repeated;
1679 if (f->type_id >= 9 && f->type_id <= 12) f->packed = 0;
1680 f->scalar = (f->type == NULL);
1681 return PB_OK;
1682}
1683
1684static int pbL_loadType(pb_State *S, pbL_TypeInfo *info, pb_Loader *L) {
1685 size_t i, count, curr;

Callers 2

pbL_loadTypeFunction · 0.85
pbL_loadFileFunction · 0.85

Calls 3

pb_newtypeFunction · 0.85
pb_newnameFunction · 0.85
pb_newfieldFunction · 0.85

Tested by

no test coverage detected