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 699784 - Allow inspecting the run program from a module
Allow inspecting the run program from a module
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2013-05-06 21:47 UTC by Giovanni Campagna
Modified: 2013-05-07 16:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Expose the launched binary to JS (6.34 KB, patch)
2013-05-06 21:47 UTC, Giovanni Campagna
committed Details | Review
Add some versioning properties to System (4.41 KB, patch)
2013-05-06 21:47 UTC, Giovanni Campagna
reviewed Details | Review
Add a version property to System (4.03 KB, patch)
2013-05-07 10:15 UTC, Giovanni Campagna
reviewed Details | Review
Add a version property to System (3.85 KB, patch)
2013-05-07 15:49 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2013-05-06 21:47:06 UTC
While fixing bug 699432, I noticed that ARGV[0] does not include the filename as it would be expected by the usual meaning of ARGV, so the trick of looking at the spawned program to see if it lies in the current directory is broken.

So I thought that, like C has program_invocation_name, gjs could have System.programInvocationName, containing the filename of the launched script.

See patches.
Comment 1 Giovanni Campagna 2013-05-06 21:47:24 UTC
Created attachment 243428 [details] [review]
Expose the launched binary to JS

Usually in various languages the launched program is available
as ARGV[0], but in the gjs case, ARGV only contains command line
arguments, so we need a separate property to retrieve the launched
script.
This is now exposed as System.programInvocationName.
The use case is allowing package.js to determine if the app is
launched from the source without hacks.
Comment 2 Giovanni Campagna 2013-05-06 21:47:41 UTC
Created attachment 243429 [details] [review]
Add some versioning properties to System

To allow dynamic checks for new API and features, expose the GJS
and JS version on the System module. For additional convenience,
the gjs version is provided as a number that can be directly
comparated to a reference value.
Comment 3 Jasper St. Pierre (not reading bugmail) 2013-05-06 21:54:11 UTC
Review of attachment 243428 [details] [review]:

OK.

::: gjs/console.c
@@ +98,2 @@
     if (js_version != NULL)
         source_js_version = js_version;

We should probably remove js-version support at some point.

::: modules/system.c
@@ +161,3 @@
+    g_object_get(gjs_context,
+                 "program-name", &program_name,
+                 NULL);

Hm, not the biggest fan of this, but OK.
Comment 4 Jasper St. Pierre (not reading bugmail) 2013-05-06 21:54:51 UTC
Review of attachment 243429 [details] [review]:

I don't think JS version is a great idea. It's API that we really should be removing, as upstream is removing it too.
Comment 5 Giovanni Campagna 2013-05-07 10:15:44 UTC
Created attachment 243465 [details] [review]
Add a version property to System

To allow dynamic checks for new API and features, expose the GJS
version in the System module. For additional convenience,
it is provided as a number (major * 10000 + minor * 100 + micro)
that can be directly comparated to a reference value.
Comment 6 Jasper St. Pierre (not reading bugmail) 2013-05-07 15:42:50 UTC
Review of attachment 243465 [details] [review]:

::: installed-tests/test/js/testSystem.js
@@ +13,3 @@
 
+function testVersion() {
+    JSUnit.assertEquals("1.8", System.jsVersion);

Did you not run the tests?
Comment 7 Giovanni Campagna 2013-05-07 15:49:59 UTC
Created attachment 243502 [details] [review]
Add a version property to System

To allow dynamic checks for new API and features, expose the GJS
version in the System module. For additional convenience,
it is provided as a number (major * 10000 + minor * 100 + micro)
that can be directly comparated to a reference value.

I did run the test suite, but only after a number of other changes,
so I forgot to submit the fixed version. Sorry.
Comment 8 Jasper St. Pierre (not reading bugmail) 2013-05-07 16:02:07 UTC
Review of attachment 243502 [details] [review]:

OK.
Comment 9 Giovanni Campagna 2013-05-07 16:15:51 UTC
Attachment 243428 [details] pushed as 47e06c7 - Expose the launched binary to JS
Attachment 243502 [details] pushed as aab113e - Add a version property to System