After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 750983 - lua-factory: Add inspect.lua helper
lua-factory: Add inspect.lua helper
Status: RESOLVED FIXED
Product: grilo
Classification: Other
Component: lua
unspecified
Other All
: Normal normal
: ---
Assigned To: grilo-maint
grilo-maint
Depends on:
Blocks:
 
 
Reported: 2015-06-15 09:50 UTC by Bastien Nocera
Modified: 2015-07-09 14:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
lua-factory: Add inspect.lua helper (1.82 KB, patch)
2015-06-15 09:50 UTC, Bastien Nocera
none Details | Review
lua-factory: Add inspect.lua helper (11.41 KB, patch)
2015-06-15 11:33 UTC, Bastien Nocera
none Details | Review
lua-factory: Add inspect.lua helper (15.25 KB, patch)
2015-07-08 21:08 UTC, Victor Toso
committed Details | Review
lua-factory: Add inspect.lua helper (15.25 KB, patch)
2015-07-09 14:43 UTC, Victor Toso
committed Details | Review

Description Bastien Nocera 2015-06-15 09:50:56 UTC
.
Comment 1 Bastien Nocera 2015-06-15 09:50:59 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.
Comment 2 Victor Toso 2015-06-15 11:03:11 UTC
Not sure if I understand how this should work.
What should be the content of `inspect.lua` and how is connected to grl.inspect?
Comment 3 Bastien Nocera 2015-06-15 11:33:42 UTC
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.
Comment 4 Bastien Nocera 2015-07-06 11:06:08 UTC
(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...
Comment 5 Victor Toso 2015-07-08 21:08:20 UTC
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.
Comment 6 Victor Toso 2015-07-08 21:18:48 UTC
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
Comment 7 Bastien Nocera 2015-07-08 22:21:17 UTC
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().
Comment 8 Victor Toso 2015-07-08 22:28:48 UTC
(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.
Comment 9 Bastien Nocera 2015-07-08 22:46:58 UTC
(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
Comment 10 Victor Toso 2015-07-09 14:43:12 UTC
The following fix has been pushed:
048ad86 lua-factory: Add inspect.lua helper
Comment 11 Victor Toso 2015-07-09 14:43:19 UTC
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.