[gjs: 1/3] overrides: Add override for Cairo that merges in imports.cairo



commit 38f1b73f4d15b2a5d33401ef0c218006a6485f0b
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Mar 17 23:52:04 2018 -0700

    overrides: Add override for Cairo that merges in imports.cairo
    
    It's confusing to have two incompatible ways to import Cairo. This makes
    sure that when you use imports.gi.cairo, it merges in imports.cairo as
    well. (imports.gi.cairo is only needed in a few cases, so I'm not going
    to worry about the reverse right now.)
    
    Closes #126.

 installed-tests/js/testCairo.js | 13 +++++++++++++
 modules/modules.gresource.xml   |  1 +
 modules/overrides/cairo.js      |  6 ++++++
 3 files changed, 20 insertions(+)
---
diff --git a/installed-tests/js/testCairo.js b/installed-tests/js/testCairo.js
index 6ff759d..db20de0 100644
--- a/installed-tests/js/testCairo.js
+++ b/installed-tests/js/testCairo.js
@@ -228,3 +228,16 @@ describe('Cairo', function () {
         });
     });
 });
+
+describe('Cairo imported via GI', function () {
+    const giCairo = imports.gi.cairo;
+
+    it('has the same functionality as imports.cairo', function () {
+        const surface = new giCairo.ImageSurface(Cairo.Format.ARGB32, 1, 1);
+        void new giCairo.Context(surface);
+    });
+
+    it('has boxed types from the GIR file', function () {
+        void new giCairo.RectangleInt();
+    });
+});
diff --git a/modules/modules.gresource.xml b/modules/modules.gresource.xml
index 724adb4..72cad22 100644
--- a/modules/modules.gresource.xml
+++ b/modules/modules.gresource.xml
@@ -8,6 +8,7 @@
     <file>modules/tweener/tweener.js</file>
     <file>modules/tweener/tweenList.js</file>
 
+    <file>modules/overrides/cairo.js</file>
     <file>modules/overrides/GLib.js</file>
     <file>modules/overrides/Gio.js</file>
     <file>modules/overrides/GObject.js</file>
diff --git a/modules/overrides/cairo.js b/modules/overrides/cairo.js
new file mode 100644
index 0000000..0f366a8
--- /dev/null
+++ b/modules/overrides/cairo.js
@@ -0,0 +1,6 @@
+// This override adds the builtin Cairo bindings to imports.gi.cairo.
+// (It's confusing to have two incompatible ways to import Cairo.)
+
+function _init() {
+    Object.assign(this, imports.cairo);
+}


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