[gjs/ewlsh/nova-repl: 4/7] system: Add versionString
- From: Evan Welsh <ewlsh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/ewlsh/nova-repl: 4/7] system: Add versionString
- Date: Sun, 30 Jan 2022 05:16:44 +0000 (UTC)
commit 98de2102ea78434a572c8f1f0093e3931795096d
Author: Evan Welsh <contact evanwelsh com>
Date: Sun Jan 23 23:15:06 2022 -0800
system: Add versionString
installed-tests/js/testSystem.js | 6 ++++++
modules/system.cpp | 9 ++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/installed-tests/js/testSystem.js b/installed-tests/js/testSystem.js
index c7bab2ef2..17701bcba 100644
--- a/installed-tests/js/testSystem.js
+++ b/installed-tests/js/testSystem.js
@@ -23,6 +23,12 @@ describe('System.version', function () {
});
});
+describe('System.versionString', function () {
+ it('gives a correctly formatted string', function () {
+ expect(System.versionString).toMatch(/1.[0-9]{2}.[0-9]/);
+ });
+});
+
describe('System.refcount()', function () {
it('gives the correct number', function () {
let o = new GObject.Object({});
diff --git a/modules/system.cpp b/modules/system.cpp
index 9152cfe38..789a91843 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -328,6 +328,10 @@ gjs_js_define_system_stuff(JSContext *context,
return false;
}
+ JS::RootedValue v_gjs_version_string(context);
+ if (!gjs_string_from_utf8(context, VERSION, &v_gjs_version_string))
+ return false;
+
JS::RootedObject program_args_getter(
context,
JS_GetFunctionObject(js::NewFunctionByIdWithReserved(
@@ -350,5 +354,8 @@ gjs_js_define_system_stuff(JSContext *context,
GJS_MODULE_PROP_FLAGS) &&
JS_DefinePropertyById(context, module, gjs->atoms().version(),
GJS_VERSION,
- GJS_MODULE_PROP_FLAGS | JSPROP_READONLY);
+ GJS_MODULE_PROP_FLAGS | JSPROP_READONLY) &&
+ JS_DefineProperty(context, module, "versionString",
+ v_gjs_version_string,
+ GJS_MODULE_PROP_FLAGS | JSPROP_READONLY);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]