[gjs/wip/package: 76/83] Add basic versioning to public JS and native modules
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/package: 76/83] Add basic versioning to public JS and native modules
- Date: Tue, 7 May 2013 22:01:46 +0000 (UTC)
commit c0ca04b600ea352c8fca5382b41b97b995be1549
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Fri Feb 22 03:17:05 2013 +0100
Add basic versioning to public JS and native modules
Add the concept of "api version", which is tied to the module and
reflects API additions and removals. It will be used by the new
package system.
modules/lang.js | 4 ++++
modules/mainloop.js | 4 ++++
modules/signals.js | 4 ++++
modules/system.c | 10 ++++++++++
4 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/modules/lang.js b/modules/lang.js
index b88fe3c..bac87f0 100644
--- a/modules/lang.js
+++ b/modules/lang.js
@@ -23,6 +23,10 @@
const Gi = imports._gi;
+// Rules for versioning: bump major when making API incompatible changes,
+// bump minor when adding API
+var $API_VERSION = [1, 0];
+
function countProperties(obj) {
let count = 0;
for (let property in obj) {
diff --git a/modules/mainloop.js b/modules/mainloop.js
index 06458a3..15f01a9 100644
--- a/modules/mainloop.js
+++ b/modules/mainloop.js
@@ -24,6 +24,10 @@
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
+// Rules for versioning: bump major when making API incompatible changes,
+// bump minor when adding API
+var $API_VERSION = [1, 0];
+
var _mainLoops = {};
function run(name) {
diff --git a/modules/signals.js b/modules/signals.js
index 0905e53..4fa885a 100644
--- a/modules/signals.js
+++ b/modules/signals.js
@@ -20,6 +20,10 @@
* IN THE SOFTWARE.
*/
+// Rules for versioning: bump major when making API incompatible changes,
+// bump minor when adding API
+var $API_VERSION = [1, 0];
+
// A couple principals of this simple signal system:
// 1) should look just like our GObject signal binding
// 2) memory and safety matter more than speed of connect/disconnect/emit
diff --git a/modules/system.c b/modules/system.c
index 1626bb0..fa33768 100644
--- a/modules/system.c
+++ b/modules/system.c
@@ -31,6 +31,8 @@
#include <gi/object.h>
#include "system.h"
+static const int API_VERSION[] = { 1, 0 };
+
static JSBool
gjs_address_of(JSContext *context,
unsigned argc,
@@ -187,6 +189,14 @@ gjs_js_define_system_stuff(JSContext *context,
GJS_MODULE_PROP_FLAGS | JSPROP_READONLY))
goto out;
+ if (!gjs_define_int_array(context, module,
+ "$API_VERSION",
+ G_N_ELEMENTS(API_VERSION),
+ API_VERSION,
+ GJS_MODULE_PROP_FLAGS &
+ ~JSPROP_ENUMERATE))
+ goto out;
+
retval = JS_TRUE;
out:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]