GNOME Bugzilla – Bug 750983
lua-factory: Add inspect.lua helper
Last modified: 2015-07-09 14:43:19 UTC
.
Created attachment 305274 [details] [review] lua-factory: Add inspect.lua helper Which is very useful when developing new sources, to inspect the results of json parsing, etc.
Not sure if I understand how this should work. What should be the content of `inspect.lua` and how is connected to grl.inspect?
Created attachment 305278 [details] [review] lua-factory: Add inspect.lua helper Which is very useful when developing new sources, to inspect the results of json parsing, etc.
(In reply to Victor Toso from comment #2) > Not sure if I understand how this should work. > What should be the content of `inspect.lua` and how is connected to > grl.inspect? I've added inspect.lua to the patch now. I'm trying to make a "grl.inspect" call in one of our source modules call the "inspect.inspect" function in inspect.lua. Just can't figure out how...
Created attachment 307105 [details] [review] lua-factory: Add inspect.lua helper Which is very useful when developing new sources, to inspect the results of json parsing, etc.
Hey! Please double check if this works fine for you! (In reply to Bastien Nocera from comment #4) > I've added inspect.lua to the patch now. I'm trying to make a "grl.inspect" > call in one of our source modules call the "inspect.inspect" function in > inspect.lua. > Just can't figure out how... As inspect.lua returns the inspect table, by using luaL_dofile (load + run the file) we have the table in the top of the stack. My changes: * use grl.lua.inspect instead of grl.inspect -> This was a suggestion by Juan when lua-factory was created. The reason is to keep what belongs only to lua in grl.lua; * moved inspect.lua to lua-library -> I believe the libraries will increase a lot so this is an attempt to keep it organized. * inspect.lua as gresource
Review of attachment 307105 [details] [review]: Looks good otherwise. Thanks! ::: src/lua-factory/grl-lua-library.c @@ +1260,3 @@ + /* Top of the stack is inspect.inspect */ + lua_setfield (L, -4, GRILO_LUA_LIBRARY_INSPECT); + /* grl.lua.inspect points to inspect.inspect */ Is it really going to be called "grl.lua.inspect"? I'd prefer grl.inspect().
(In reply to Bastien Nocera from comment #7) > Review of attachment 307105 [details] [review] [review]: > > Looks good otherwise. Thanks! > > ::: src/lua-factory/grl-lua-library.c > @@ +1260,3 @@ > + /* Top of the stack is inspect.inspect */ > + lua_setfield (L, -4, GRILO_LUA_LIBRARY_INSPECT); > + /* grl.lua.inspect points to inspect.inspect */ > > Is it really going to be called "grl.lua.inspect"? I'd prefer grl.inspect(). Well, I don't mind it to be grl.inspect() but what about grl.lua.json.string_to_table ? Should we move it too in the future? I'll better test it again tomorrow and push it.
(In reply to Victor Toso from comment #8) > Well, I don't mind it to be grl.inspect() but what about > grl.lua.json.string_to_table ? Should we move it too in the future? Hmm, let's keep your grl.lua. prefix then. I guess we could move it in the future if/when we break the API. > I'll better test it again tomorrow and push it. Cool, thanks
The following fix has been pushed: 048ad86 lua-factory: Add inspect.lua helper
Created attachment 307149 [details] [review] lua-factory: Add inspect.lua helper Which is very useful when developing new sources, to inspect the results of json parsing, etc.