tag的作用和map的实现上面不太理解
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 982
- Forks
- 254
- PR merge metrics
- No merged PRs in 30d
Description
感谢你的建议我也看了你5.3的中文文档,对我这个初学者很有帮助
另外sproto源码我看了然后昨天做了一次改版,里面有几个不太理解
1.tag的作用?除了实现option的功能外,是否还有其他用途?
2.map支持的局限性,是否考虑增加通用类型map?
目前我是改版支持任意类型的map结构不一定依赖于struct,以及里面的key定义(我们的项目中很多定义是 key 到 基础类型 的map)
另外修改lpeg使用C的struct定义,这样我觉得更能表示他和c的关系(其实也是为了偷懒,复制粘贴二进制的协议定义,支持字节对齐1,2,4,8,string,vt和map)
主要了解下map的以后发展,另外如果可以的话是否这样实现的通用类型map是否会有其他问题
encode{
...
if (args->index > 0) {
...
if (args->m_pMapKeyType > 0) {
...
lua_pushvalue(L, self->iter_index);
--根据类型读取key值
lua_pop(L, 1);
}
}
...
}
decode{
...
if (args->index != 0) {
...
if (args->m_pMapKeyType > 0){
//map,先压入key
lua_Integer v = *args->m_pMapKeyValue;
lua_pushinteger(L, v);
}
}
...
if (args->index > 0) {
if (args->m_pMapKeyType > 0)
{
//map
lua_settable(L, self->array_index);
}
else
{
//array
lua_seti(L, self->array_index, args->index);
}
} else {
lua_setfield(L, self->result_index, args->tagname);
}
}
主要是lua这里实现是否会引发其他问题?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing encode and decode paths referenced in the issue, especially the tag and map branches and their Lua table operations. Compare the current map constraints with the proposed arbitrary key and value types. Done would require a clear maintainer-approved design and defined compatibility and correctness criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100