Comments (13)
multiple context support are landed :-)
from lua-protobuf.
multiple context support are landed :-)
Thanks!
I see this initial version requires some dancing around to set the default context; make changes; then set the old context again.
In future, would you consider changing things to be methods so that this dance isn't required?
from lua-protobuf.
It may easy to add this function, but I wonder it's useful...
from lua-protobuf.
It may easy to add this function, but I wonder it's useful...
I have a use case where users of my server can upload .proto files; and then I use them to send messages on behalf of the user.
I'd like each user to have their own context (or even have ability to have multiple)
from lua-protobuf.
In this case, maybe users should be separated into different Lua state?
from lua-protobuf.
In this case, maybe users should be separated into different Lua state?
It's running inside of openresty; which has one lua state per worker process; so that's a no go :(
from lua-protobuf.
Okay, I will add plan to do this :-)
from lua-protobuf.
most usage use the global context, because this module is usually used in game engines. So people don’t like the method way to use it
from lua-protobuf.
most usage use the global context, because this module is usually used in game engines. So people don’t like the method way to use it
Can always have both options: methods available on the context object; or use a default object when called on the module itself.
from lua-protobuf.
It means we will prepare two version of functions: State as the first argument, or not. It may change a lot of code to retrieve state from argument, not from default_lstate(L) routine.
from lua-protobuf.
It may change a lot of code to retrieve state from argument, not from default_lstate(L) routine.
Should be easy to swap it to check_lstate(L, 1);
To get the non-method versions, you could add lua-side wrappers? e.g.
function pb.load(...)
return pb.get_default_context():load(...)
end
from lua-protobuf.
I don't really like to adding Lua wrapper, as a single C module may easier to deploy and use. But it's a way to think of.
and, check functions are relately slow. it will getfield from registry, using type name string as key. thus means to calculate the hash value of string. So maybe it's better to passing it from parameter.
I will try to change pb module into a metatable of state type. but it may take times.
from lua-protobuf.
and, check functions are relately slow. it will getfield from registry, using type name string as key. thus means to calculate the hash value of string. So maybe it's better to passing it from parameter.
For times when speed is critical, I've previously kept the metatable in an upvalue so that you can skip the lookup-by-string step:
void *ud = lua_touserdata(L, index);;
int eq;
if (!ud)
return NULL;
if (!lua_getmetatable(L, index))
return NULL;
int eq = lua_rawequal(L, -1, lua_upvalueindex(upvalue));
lua_pop(L, 1);
if (!eq)
return NULL;
from lua-protobuf.
Related Issues (20)
- Fix for embedded system HOT 2
- The struct type is not supported HOT 1
- Is lua-protobuf thread-safe / LuaLanes safe? HOT 7
- 关于pb.decode使用问题 HOT 1
- proto3怎么区分默认值和缺省值呢? HOT 1
- symbol not found in flat namespace '_luaL_checkversion_' HOT 1
- 您好,请问oneof支持吗?lua里面怎么使用呢 HOT 1
- 当include_imports和unknow_import都为true时,会出现错误
- 希望支持 oneof 的 DefaultMessageDecoding HOT 1
- bad argument #1 to 'encode' (type 'Person' does not exists) HOT 8
- pb.so causes nginx to segfault HOT 4
- 循环引用场景下会导致stack overflow HOT 1
- pb.decode() 导致 out of memory HOT 1
- pb中uint64过长, 在decode时会被科学计数法 HOT 1
- pb.decode 问题。 HOT 1
- Option name expected
- Proto - JSON transcoder HOT 2
- nested message with default values regression HOT 1
- protobuf3 optional: configurable "optional_" prefix HOT 3
- pb.encode double/float 类型数据,在C++里ParseFromString会有问题。 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-protobuf.