[gjs/split-argv: 2/2] Add system.fileName




commit b5e93d724ec2fb3aa3bf9cb1688fe3506f802a91
Author: Evan Welsh <noreply evanwelsh com>
Date:   Mon Jun 1 09:36:28 2020 -0500

    Add system.fileName

 modules/system.cpp | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/modules/system.cpp b/modules/system.cpp
index 6195fe34..3def97db 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -203,13 +203,21 @@ gjs_js_define_system_stuff(JSContext              *context,
 
     GjsContextPrivate* gjs = GjsContextPrivate::from_cx(context);
     const char* program_name = gjs->program_name();
-
-    JS::RootedValue value(context);
-    return gjs_string_from_utf8(context, program_name, &value) &&
+    const char* file_name = gjs->file_name();
+
+    JS::RootedValue program_invocation_value(context);
+    JS::RootedValue file_value(context);
+    return gjs_string_from_utf8(context, program_name,
+                                &program_invocation_value) &&
+           gjs_string_from_utf8(context, file_name, &file_value) &&
+           JS_DefinePropertyById(context, module, gjs->atoms().file_name(),
+                                 file_value,
+                                 GJS_MODULE_PROP_FLAGS | JSPROP_READONLY) &&
            /* The name is modeled after program_invocation_name, part of glibc
             */
            JS_DefinePropertyById(context, module,
-                                 gjs->atoms().program_invocation_name(), value,
+                                 gjs->atoms().program_invocation_name(),
+                                 program_invocation_value,
                                  GJS_MODULE_PROP_FLAGS | JSPROP_READONLY) &&
            JS_DefinePropertyById(context, module, gjs->atoms().version(),
                                  GJS_VERSION,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]