[gjs/wip/package: 4/8] 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: 4/8] Add basic versioning to public JS and native modules
- Date: Sun, 10 Mar 2013 18:18:22 +0000 (UTC)
commit 04a5d27e8b88a71f9ae1737e5da3eb7e217695f2
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 c650a8a..ebc3535 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,
@@ -151,5 +153,13 @@ gjs_js_define_system_stuff(JSContext *context,
0, GJS_MODULE_PROP_FLAGS))
return JS_FALSE;
+ if (!gjs_define_int_array(context, module,
+ "$API_VERSION",
+ G_N_ELEMENTS(API_VERSION),
+ API_VERSION,
+ GJS_MODULE_PROP_FLAGS &
+ ~JSPROP_ENUMERATE))
+ return JS_FALSE;
+
return JS_TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]