node-gtk 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -53
- package/binding.gyp +36 -18
- package/lib/binding/node-v102-linux-x64/node_gtk.node +0 -0
- package/lib/binding/node-v108-linux-x64/node_gtk.node +0 -0
- package/lib/binding/node-v115-linux-x64/node_gtk.node +0 -0
- package/lib/binding/node-v93-linux-x64/node_gtk.node +0 -0
- package/lib/overrides/Gtk-3.0.js +8 -0
- package/lib/overrides/Gtk-4.0.js +16 -0
- package/package.json +8 -8
- package/scripts/ci.sh +5 -1
- package/src/boxed.cc +3 -3
- package/src/callback.cc +10 -12
- package/src/closure.cc +5 -5
- package/src/closure.h +2 -2
- package/src/debug.cc +2 -2
- package/src/function.cc +41 -26
- package/src/function.h +1 -1
- package/src/gi.cc +17 -17
- package/src/gobject.cc +9 -5
- package/src/loop.cc +5 -0
- package/src/modules/cairo/context.cc +102 -106
- package/src/modules/cairo/generator.js +1 -5
- package/src/type.cc +5 -5
- package/src/util.h +1 -3
- package/src/value.cc +108 -35
- package/src/value.h +1 -1
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ Node-Gtk is a [gobject-introspection](https://gi.readthedocs.io/en/latest) libra
|
|
|
19
19
|
use any introspected library, such as Gtk+, usable. It is similar in essence to [GJS](https://wiki.gnome.org/action/show/Projects/Gjs) or [PyGObject](https://pygobject.readthedocs.io). Please note this project is currently in a _beta_ state and is being developed. Any contributors willing to help
|
|
20
20
|
will be welcomed.
|
|
21
21
|
|
|
22
|
-
Supported Node.js versions: **
|
|
23
|
-
Pre-built binaries available for: **Linux**, **macOS**
|
|
22
|
+
Supported Node.js versions: **16**, **18** (other versions should work but are untested)<br>
|
|
23
|
+
Pre-built binaries available for: **Linux**, **macOS** (all supported versions except 18)
|
|
24
24
|
|
|
25
25
|
### Table of contents
|
|
26
26
|
|
|
@@ -32,8 +32,8 @@ Pre-built binaries available for: **Linux**, **macOS**
|
|
|
32
32
|
- [How to build on Ubuntu](#how-to-build-on-ubuntu)
|
|
33
33
|
- [How to build on Fedora](#how-to-build-on-fedora)
|
|
34
34
|
- [How to build on ArchLinux](#how-to-build-on-archlinux)
|
|
35
|
-
- [How to build on macOS](#how-to-build-on-
|
|
36
|
-
- [
|
|
35
|
+
- [How to build on macOS](#how-to-build-on-macos)
|
|
36
|
+
- [How to build on Windows](#how-to-build-on-windows)
|
|
37
37
|
- [Testing the project](#testing-the-project)
|
|
38
38
|
- [Browser demo](#browser-demo)
|
|
39
39
|
- [Contributing](#contributing)
|
|
@@ -88,17 +88,15 @@ Note that prebuilt binaries are available for common systems, in those cases bui
|
|
|
88
88
|
|
|
89
89
|
- **Linux**: prebuilt binaries available
|
|
90
90
|
- **macOS**: prebuilt binaries available
|
|
91
|
-
- **Windows**:
|
|
91
|
+
- **Windows**: no prebuilt binaries
|
|
92
92
|
|
|
93
93
|
### Requirements
|
|
94
94
|
|
|
95
95
|
- `git`
|
|
96
96
|
- `nodejs@10` or higher
|
|
97
|
-
- `
|
|
97
|
+
- `python3` (for `node-gyp`)
|
|
98
98
|
- C compiler (`gcc@8` or higher, or `clang`)
|
|
99
99
|
|
|
100
|
-
In the _not-working-yet_ Windows platform, all dependencies must be available under [MSYS2 shell](https://msys2.github.io).
|
|
101
|
-
|
|
102
100
|
### How to build on Ubuntu
|
|
103
101
|
|
|
104
102
|
Install basic dependencies.
|
|
@@ -155,48 +153,11 @@ brew install git node gobject-introspection gtk+3 cairo
|
|
|
155
153
|
|
|
156
154
|
At this point `npm install node-gtk` should already install, fallback and build `node-gtk` without problems.
|
|
157
155
|
|
|
158
|
-
###
|
|
159
|
-
|
|
160
|
-
If you'd like to test everything builds and work properly, after installing and building you can run any of the
|
|
161
|
-
examples:
|
|
162
|
-
|
|
163
|
-
```sh
|
|
164
|
-
node ./examples/hello-gtk.js
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
If you'll see a little window saying hello that's it: it works!
|
|
168
|
-
|
|
169
|
-
Please note in macOS the window doesn't automatically open above other windows.
|
|
170
|
-
Try <kbd>Cmd</kbd> + <kbd>Tab</kbd> if you don't see it.
|
|
171
|
-
|
|
172
|
-
#### Browser demo
|
|
173
|
-
|
|
174
|
-
If you'd like to test `./examples/browser.js` you'll need [WebKit2 GTK+](http://webkitgtk.org/) libary.
|
|
175
|
-
|
|
176
|
-
- in **Ubuntu**, you can `apt-get install libwebkit2gtk-3.0` (`4.0` works too) and try it out.
|
|
177
|
-
- in **Fedora**, you should run `sudo dnf install webkit2gtk3`
|
|
178
|
-
- in **ArchLinux**, you can `pacman -S --needed webkitgtk` and try it out.
|
|
179
|
-
- in **macOS**, there is no way to run it right now because `webkitgtk` was removed from homebrew
|
|
180
|
-
|
|
181
|
-
Once installed, you can `./examples/browser.js google.com` or any other page, and you might try the _dark theme_ out too:
|
|
182
|
-
|
|
183
|
-
```sh
|
|
184
|
-
# macOS needs to have the Adwaita theme installed
|
|
185
|
-
# brew install adwaita-icon-theme
|
|
186
|
-
|
|
187
|
-
# Usage: ./examples/browser.js <url> [theme]
|
|
188
|
-
./examples/browser.js google.com dark
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Experimental platforms
|
|
192
|
-
|
|
193
|
-
Following how to setup the configuration to at least try building this project.
|
|
156
|
+
### How to build on Windows
|
|
194
157
|
|
|
195
|
-
|
|
158
|
+
Mandatory dependency is Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio Community (using the "Desktop development with C++" workload).
|
|
196
159
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
The easiest/tested way to at least try building this repository is within a _MinGW shell_ provided by the [MSYS2 installer](https://msys2.github.io/).
|
|
160
|
+
The easiest/tested way to build this repository is within a _MinGW shell_ provided by the [MSYS2 installer](https://msys2.github.io/).
|
|
200
161
|
|
|
201
162
|
Once VS and its C++ compiler is available and MSYS2 installed, launch the MinGW shell.
|
|
202
163
|
|
|
@@ -218,13 +179,26 @@ cd ~/oss
|
|
|
218
179
|
git clone https://github.com/romgrk/node-gtk
|
|
219
180
|
cd node-gtk
|
|
220
181
|
|
|
182
|
+
# don't include /mingw64/include directly since it conflicts with
|
|
183
|
+
# Windows SDK headers. we copy needed headers to __extra__ directory:
|
|
184
|
+
./windows/mingw_include_extra.sh
|
|
185
|
+
|
|
186
|
+
# if MSYS2 is NOT installed in C:/msys64 run:
|
|
187
|
+
export MINGW_WINDOWS_PATH=$(./windows/mingw_windows_path.sh)
|
|
188
|
+
|
|
221
189
|
# first run might take a while
|
|
222
|
-
GYP_MSVS_VERSION=
|
|
190
|
+
GYP_MSVS_VERSION=2017 npm install
|
|
223
191
|
```
|
|
224
192
|
|
|
225
|
-
The `GYP_MSVS_VERSION` could be
|
|
193
|
+
The `GYP_MSVS_VERSION` could be 2017 or above.
|
|
226
194
|
Please verify [which version you should use](https://github.com/nodejs/node-gyp#installation)
|
|
227
195
|
|
|
196
|
+
The below blog post series will help you get started:
|
|
197
|
+
|
|
198
|
+
1. [Node.js GTK Hello World on Windows](https://ten0s.github.io/blog/2022/07/22/nodejs-gtk-hello-world-on-windows)
|
|
199
|
+
2. [Find DLLs and Typelibs dependencies for Node.js GTK Application on Windows](https://ten0s.github.io/blog/2022/07/25/find-dlls-and-typelibs-dependencies-for-nodejs-gtk-application-on-windows)
|
|
200
|
+
3. [Package Node.js GTK Application on Windows](https://ten0s.github.io/blog/2022/07/27/package-nodejs-gtk-application-on-windows)
|
|
201
|
+
|
|
228
202
|
#### Possible issue on MinGW shell
|
|
229
203
|
|
|
230
204
|
In case you are launching the general executable without knowing the correct platform,
|
|
@@ -242,11 +216,38 @@ npm run install
|
|
|
242
216
|
|
|
243
217
|
This should do the trick. You can also check if there is any python at all via `pacman -Qs python`.
|
|
244
218
|
|
|
245
|
-
|
|
219
|
+
### Testing the project
|
|
220
|
+
|
|
221
|
+
If you'd like to test everything builds and work properly, after installing and building you can run any of the
|
|
222
|
+
examples:
|
|
223
|
+
|
|
224
|
+
```sh
|
|
225
|
+
node ./examples/hello-gtk.js
|
|
226
|
+
```
|
|
246
227
|
|
|
247
|
-
|
|
228
|
+
If you'll see a little window saying hello that's it: it works!
|
|
248
229
|
|
|
249
|
-
|
|
230
|
+
Please note in macOS the window doesn't automatically open above other windows.
|
|
231
|
+
Try <kbd>Cmd</kbd> + <kbd>Tab</kbd> if you don't see it.
|
|
232
|
+
|
|
233
|
+
#### Browser demo
|
|
234
|
+
|
|
235
|
+
If you'd like to test `./examples/browser.js` you'll need [WebKit2 GTK+](http://webkitgtk.org/) libary.
|
|
236
|
+
|
|
237
|
+
- in **Ubuntu**, you can `apt-get install libwebkit2gtk-3.0` (`4.0` works too) and try it out.
|
|
238
|
+
- in **Fedora**, you should run `sudo dnf install webkit2gtk3`
|
|
239
|
+
- in **ArchLinux**, you can `pacman -S --needed webkitgtk` and try it out.
|
|
240
|
+
- in **macOS**, there is no way to run it right now because `webkitgtk` was removed from homebrew
|
|
241
|
+
|
|
242
|
+
Once installed, you can `./examples/browser.js google.com` or any other page, and you might try the _dark theme_ out too:
|
|
243
|
+
|
|
244
|
+
```sh
|
|
245
|
+
# macOS needs to have the Adwaita theme installed
|
|
246
|
+
# brew install adwaita-icon-theme
|
|
247
|
+
|
|
248
|
+
# Usage: ./examples/browser.js <url> [theme]
|
|
249
|
+
./examples/browser.js google.com dark
|
|
250
|
+
```
|
|
250
251
|
|
|
251
252
|
## Contributing
|
|
252
253
|
|
package/binding.gyp
CHANGED
|
@@ -39,23 +39,23 @@
|
|
|
39
39
|
"include_dirs" : [
|
|
40
40
|
"<!(node -e \"require('nan')\")"
|
|
41
41
|
],
|
|
42
|
-
"cflags": [
|
|
43
|
-
"<!@(pkg-config --cflags gobject-introspection-1.0 cairo) -Wall -g",
|
|
44
|
-
],
|
|
45
|
-
"ldflags": [
|
|
46
|
-
"-Wl,-no-as-needed",
|
|
47
|
-
"<!@(pkg-config --libs gobject-introspection-1.0 cairo)",
|
|
48
|
-
],
|
|
49
42
|
"conditions": [
|
|
50
|
-
['OS
|
|
43
|
+
['OS == "linux"', {
|
|
51
44
|
"defines": [
|
|
52
|
-
"ulong=unsigned long",
|
|
53
45
|
"PLATFORM_LINUX=1",
|
|
54
|
-
]
|
|
46
|
+
],
|
|
47
|
+
"cflags": [
|
|
48
|
+
"<!@(pkg-config --cflags gobject-introspection-1.0 cairo)",
|
|
49
|
+
"-Wall",
|
|
50
|
+
"-g",
|
|
51
|
+
],
|
|
52
|
+
"ldflags": [
|
|
53
|
+
"-Wl,-no-as-needed",
|
|
54
|
+
"<!@(pkg-config --libs gobject-introspection-1.0 cairo)",
|
|
55
|
+
],
|
|
55
56
|
}],
|
|
56
57
|
['OS == "mac"', {
|
|
57
58
|
"defines": [
|
|
58
|
-
"ulong=unsigned long",
|
|
59
59
|
"PLATFORM_MAC=1",
|
|
60
60
|
],
|
|
61
61
|
"xcode_settings": {
|
|
@@ -69,16 +69,34 @@
|
|
|
69
69
|
}],
|
|
70
70
|
['OS == "win"', {
|
|
71
71
|
"defines": [
|
|
72
|
-
"uint=unsigned int",
|
|
73
72
|
"PLATFORM_WIN=1",
|
|
74
73
|
],
|
|
74
|
+
"variables": {
|
|
75
|
+
# If MSYS2 is NOT installed in C:/msys64 run:
|
|
76
|
+
# $ export MINGW_WINDOWS_PATH=$(./windows/mingw_windows_path.sh)
|
|
77
|
+
# before compiling
|
|
78
|
+
"MINGW_PREFIX": "<!(bash -c 'echo ${MINGW_WINDOWS_PATH:-/msys64}')",
|
|
79
|
+
},
|
|
75
80
|
"include_dirs": [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"/
|
|
81
|
-
|
|
81
|
+
# Don't include /mingw64/include directly.
|
|
82
|
+
# To make extra include dir run:
|
|
83
|
+
# $ ./windows/mingw_include_extra.sh
|
|
84
|
+
# before compiling
|
|
85
|
+
"<(MINGW_PREFIX)/mingw64/include/__extra__",
|
|
86
|
+
|
|
87
|
+
"<(MINGW_PREFIX)/mingw64/include/gobject-introspection-1.0",
|
|
88
|
+
"<(MINGW_PREFIX)/mingw64/include/glib-2.0",
|
|
89
|
+
"<(MINGW_PREFIX)/mingw64/lib/glib-2.0/include",
|
|
90
|
+
"<(MINGW_PREFIX)/mingw64/include/cairo",
|
|
91
|
+
"<(MINGW_PREFIX)/mingw64/include/freetype2",
|
|
92
|
+
],
|
|
93
|
+
"libraries": [
|
|
94
|
+
"<(MINGW_PREFIX)/mingw64/lib/libglib-2.0.dll.a",
|
|
95
|
+
"<(MINGW_PREFIX)/mingw64/lib/libgmodule-2.0.dll.a",
|
|
96
|
+
"<(MINGW_PREFIX)/mingw64/lib/libgobject-2.0.dll.a",
|
|
97
|
+
"<(MINGW_PREFIX)/mingw64/lib/libffi.dll.a",
|
|
98
|
+
"<(MINGW_PREFIX)/mingw64/lib/libgirepository-1.0.dll.a",
|
|
99
|
+
"<(MINGW_PREFIX)/mingw64/lib/libcairo.dll.a",
|
|
82
100
|
]
|
|
83
101
|
}]
|
|
84
102
|
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/overrides/Gtk-3.0.js
CHANGED
|
@@ -32,6 +32,14 @@ exports.apply = (Gtk) => {
|
|
|
32
32
|
process._tickCallback()
|
|
33
33
|
|
|
34
34
|
const loopStack = internal.GetLoopStack()
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* To keep the nodejs event loop alive, we need to have something running.
|
|
38
|
+
*/
|
|
39
|
+
if (placeholderIntervalID === undefined) {
|
|
40
|
+
placeholderIntervalID = setInterval(() => { /* noop */ }, 60 * 60 * 1000)
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
loopStack.push(originalQuit)
|
|
36
44
|
|
|
37
45
|
originalMain()
|
package/lib/overrides/Gtk-4.0.js
CHANGED
|
@@ -11,6 +11,22 @@ exports.apply = (Gtk) => {
|
|
|
11
11
|
Gtk.EVENT_CONTINUE = false
|
|
12
12
|
Gtk.EVENT_STOP = true
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Gtk.Widget.prototype.containsChild
|
|
16
|
+
* @param {Gtk.Widget} child
|
|
17
|
+
* @returns {bool}
|
|
18
|
+
*/
|
|
19
|
+
Gtk.Widget.prototype.containsChild = function containsChild(child) {
|
|
20
|
+
let current = child
|
|
21
|
+
while (current) {
|
|
22
|
+
if (current === this)
|
|
23
|
+
return true
|
|
24
|
+
current = current.getParent()
|
|
25
|
+
}
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
14
30
|
Gtk.Widget.prototype._addCssClass = Gtk.Widget.prototype.addCssClass
|
|
15
31
|
Gtk.Widget.prototype._removeCssClass = Gtk.Widget.prototype.removeCssClass
|
|
16
32
|
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-gtk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "GNOME Gtk+ bindings for NodeJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"install": "
|
|
7
|
+
"install": "npx node-pre-gyp install --fallback-to-build",
|
|
8
8
|
"test": "mocha tests/__run__.js",
|
|
9
|
-
"build": "node-pre-gyp build",
|
|
10
|
-
"build:full": "node-pre-gyp rebuild",
|
|
11
|
-
"configure": "node-pre-gyp configure --debug"
|
|
9
|
+
"build": "npx node-pre-gyp build",
|
|
10
|
+
"build:full": "npx node-pre-gyp rebuild",
|
|
11
|
+
"configure": "npx node-pre-gyp configure --debug"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/romgrk/node-gtk#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@mapbox/node-pre-gyp": "^1.0.
|
|
35
|
+
"@mapbox/node-pre-gyp": "^1.0.10",
|
|
36
36
|
"lodash.camelcase": "4.3.0",
|
|
37
37
|
"lodash.isequal": "4.5.0",
|
|
38
38
|
"lodash.snakecase": "^4.1.1",
|
|
39
|
-
"nan": "2.
|
|
40
|
-
"node-gyp": "^
|
|
39
|
+
"nan": "^2.17.0",
|
|
40
|
+
"node-gyp": "^9.3.1",
|
|
41
41
|
"remove-trailing-spaces": "^1.0.7",
|
|
42
42
|
"unindent": "^2.0.0"
|
|
43
43
|
},
|
package/scripts/ci.sh
CHANGED
|
@@ -41,7 +41,11 @@ function npm_test() {
|
|
|
41
41
|
echo "### Running tests ###";
|
|
42
42
|
|
|
43
43
|
if [[ $(uname -s) == 'Darwin' ]]; then
|
|
44
|
-
|
|
44
|
+
export GST_PLUGIN_SYSTEM_PATH=/usr/local/lib/gstreamer-1.0;
|
|
45
|
+
npx mocha \
|
|
46
|
+
--skip=callback \
|
|
47
|
+
--skip=error \
|
|
48
|
+
tests/__run__.js
|
|
45
49
|
else
|
|
46
50
|
xvfb-run -a npm test;
|
|
47
51
|
fi;
|
package/src/boxed.cc
CHANGED
|
@@ -183,7 +183,7 @@ static void BoxedConstructor(const Nan::FunctionCallbackInfo<Value> &info) {
|
|
|
183
183
|
boxed = g_boxed_copy (gtype, boxed);
|
|
184
184
|
}
|
|
185
185
|
else if ((size = Boxed::GetSize(gi_info)) != 0) {
|
|
186
|
-
void *boxedCopy =
|
|
186
|
+
void *boxedCopy = g_malloc(size);
|
|
187
187
|
memcpy(boxedCopy, boxed, size);
|
|
188
188
|
boxed = boxedCopy;
|
|
189
189
|
}
|
|
@@ -223,7 +223,7 @@ static void BoxedConstructor(const Nan::FunctionCallbackInfo<Value> &info) {
|
|
|
223
223
|
boxed = return_value.v_pointer;
|
|
224
224
|
|
|
225
225
|
} else if ((size = Boxed::GetSize(gi_info)) != 0) {
|
|
226
|
-
boxed =
|
|
226
|
+
boxed = g_malloc0(size);
|
|
227
227
|
|
|
228
228
|
} else {
|
|
229
229
|
Nan::ThrowError("Boxed allocation failed: no constructor found");
|
|
@@ -267,7 +267,7 @@ static void BoxedDestroyed(const Nan::WeakCallbackInfo<Boxed> &info) {
|
|
|
267
267
|
}
|
|
268
268
|
else if (box->size != 0) {
|
|
269
269
|
// Allocated in ./function.cc @ AllocateArgument
|
|
270
|
-
|
|
270
|
+
g_free(box->data);
|
|
271
271
|
}
|
|
272
272
|
else if (box->data != NULL) {
|
|
273
273
|
/*
|
package/src/callback.cc
CHANGED
|
@@ -18,11 +18,10 @@ using v8::Isolate;
|
|
|
18
18
|
using v8::Local;
|
|
19
19
|
using v8::Object;
|
|
20
20
|
using v8::Value;
|
|
21
|
-
using Nan::TryCatch;
|
|
22
21
|
|
|
23
22
|
namespace GNodeJS {
|
|
24
23
|
|
|
25
|
-
static
|
|
24
|
+
static guint callbackLevel = 0;
|
|
26
25
|
static GSList* notifiedCallbacks = NULL;
|
|
27
26
|
|
|
28
27
|
static Local<Object> GetSelfInstance(GIArgument **args) {
|
|
@@ -33,13 +32,13 @@ static Local<Object> GetSelfInstance(GIArgument **args) {
|
|
|
33
32
|
Callback::Callback(Local<Function> fn, GICallableInfo* callback_info, GIScopeType scope_type_) {
|
|
34
33
|
persistent.Reset(fn);
|
|
35
34
|
info = g_base_info_ref (callback_info);
|
|
36
|
-
closure =
|
|
35
|
+
closure = g_callable_info_create_closure(info, &cif, Callback::Call, this);
|
|
37
36
|
scope_type = scope_type_;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
Callback::~Callback() {
|
|
41
40
|
persistent.Reset();
|
|
42
|
-
|
|
41
|
+
g_callable_info_destroy_closure (this->info, this->closure);
|
|
43
42
|
g_base_info_unref (this->info);
|
|
44
43
|
}
|
|
45
44
|
|
|
@@ -91,10 +90,10 @@ void Callback::Execute (GIArgument *result, GIArgument **args, Callback *callbac
|
|
|
91
90
|
|
|
92
91
|
/* Skip the object instance in first place */
|
|
93
92
|
int args_offset = isVFunc ? 1 : 0;
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
guint n_native_args = (guint) g_callable_info_get_n_args(callback->info);
|
|
94
|
+
guint n_return_values = 1;
|
|
96
95
|
|
|
97
|
-
|
|
96
|
+
guint primitive_out_arguments_mask = 0;
|
|
98
97
|
|
|
99
98
|
#ifndef __linux__
|
|
100
99
|
Local<Value>* js_args = new Local<Value>[n_native_args];
|
|
@@ -102,7 +101,7 @@ void Callback::Execute (GIArgument *result, GIArgument **args, Callback *callbac
|
|
|
102
101
|
Local<Value> js_args[n_native_args];
|
|
103
102
|
#endif
|
|
104
103
|
|
|
105
|
-
for (
|
|
104
|
+
for (guint i = 0; i < n_native_args; i++) {
|
|
106
105
|
GIArgInfo arg_info;
|
|
107
106
|
GITypeInfo arg_type;
|
|
108
107
|
g_callable_info_load_arg (callback->info, i, &arg_info);
|
|
@@ -144,12 +143,11 @@ void Callback::Execute (GIArgument *result, GIArgument **args, Callback *callbac
|
|
|
144
143
|
auto jsReturnValue = maybeReturnValue.ToLocalChecked();
|
|
145
144
|
auto jsRealReturnValue = jsReturnValue;
|
|
146
145
|
Local<Array> jsReturnArray;
|
|
147
|
-
|
|
146
|
+
guint returnIndex = 0;
|
|
148
147
|
bool success;
|
|
149
148
|
bool isOutPrimitive;
|
|
150
|
-
|
|
149
|
+
guint n_js_return_values = n_return_values - (hasVoidReturn ? 1 : 0);
|
|
151
150
|
|
|
152
|
-
uint i;
|
|
153
151
|
GIArgInfo arg_info;
|
|
154
152
|
GITypeInfo arg_type;
|
|
155
153
|
|
|
@@ -172,7 +170,7 @@ void Callback::Execute (GIArgument *result, GIArgument **args, Callback *callbac
|
|
|
172
170
|
else
|
|
173
171
|
jsRealReturnValue = Nan::Get(jsReturnArray, returnIndex++).ToLocalChecked();
|
|
174
172
|
|
|
175
|
-
for (i = 0; i < n_native_args; i++) {
|
|
173
|
+
for (guint i = 0; i < n_native_args; i++) {
|
|
176
174
|
isOutPrimitive = (primitive_out_arguments_mask & (1 << i)) != 0;
|
|
177
175
|
if (!isOutPrimitive)
|
|
178
176
|
continue;
|
package/src/closure.cc
CHANGED
|
@@ -35,7 +35,7 @@ GClosure *Closure::New (Local<Function> function, GICallableInfo* info, guint si
|
|
|
35
35
|
|
|
36
36
|
void Closure::Execute(GICallableInfo *info, guint signal_id,
|
|
37
37
|
const Nan::Persistent<v8::Function> &persFn,
|
|
38
|
-
GValue *g_return_value,
|
|
38
|
+
GValue *g_return_value, guint n_param_values,
|
|
39
39
|
const GValue *param_values) {
|
|
40
40
|
Nan::HandleScope scope;
|
|
41
41
|
auto func = Nan::New<Function>(persFn);
|
|
@@ -45,7 +45,7 @@ void Closure::Execute(GICallableInfo *info, guint signal_id,
|
|
|
45
45
|
g_signal_query(signal_id, &signal_query);
|
|
46
46
|
|
|
47
47
|
// We don't pass the implicit instance as first argument
|
|
48
|
-
|
|
48
|
+
auto n_js_args = n_param_values - 1;
|
|
49
49
|
|
|
50
50
|
#ifndef __linux__
|
|
51
51
|
Local<Value>* js_args = new Local<Value>[n_js_args];
|
|
@@ -58,7 +58,7 @@ void Closure::Execute(GICallableInfo *info, guint signal_id,
|
|
|
58
58
|
GIArgument argument;
|
|
59
59
|
GIArgInfo arg_info;
|
|
60
60
|
GITypeInfo type_info;
|
|
61
|
-
for (
|
|
61
|
+
for (guint i = 1; i < n_param_values; i++) {
|
|
62
62
|
memcpy(&argument, ¶m_values[i].data[0], sizeof(GIArgument));
|
|
63
63
|
g_callable_info_load_arg(info, i - 1, &arg_info);
|
|
64
64
|
g_arg_info_load_type(&arg_info, &type_info);
|
|
@@ -76,7 +76,7 @@ void Closure::Execute(GICallableInfo *info, guint signal_id,
|
|
|
76
76
|
}
|
|
77
77
|
} else {
|
|
78
78
|
/* CallableInfo is not available: use GValueToV8 */
|
|
79
|
-
for (
|
|
79
|
+
for (guint i = 1; i < n_param_values; i++) {
|
|
80
80
|
bool mustCopy = true;
|
|
81
81
|
|
|
82
82
|
if (signal_query.signal_id) {
|
|
@@ -123,7 +123,7 @@ throw_exception:
|
|
|
123
123
|
|
|
124
124
|
void Closure::Marshal(GClosure *base,
|
|
125
125
|
GValue *g_return_value,
|
|
126
|
-
|
|
126
|
+
guint n_param_values,
|
|
127
127
|
const GValue *param_values,
|
|
128
128
|
gpointer invocation_hint,
|
|
129
129
|
gpointer marshal_data) {
|
package/src/closure.h
CHANGED
|
@@ -30,12 +30,12 @@ struct Closure {
|
|
|
30
30
|
|
|
31
31
|
static void Execute(GICallableInfo *info, guint signal_id,
|
|
32
32
|
const Nan::Persistent<v8::Function> &persFn,
|
|
33
|
-
GValue *g_return_value,
|
|
33
|
+
GValue *g_return_value, guint n_param_values,
|
|
34
34
|
const GValue *param_values);
|
|
35
35
|
|
|
36
36
|
static void Marshal(GClosure *closure,
|
|
37
37
|
GValue *g_return_value,
|
|
38
|
-
|
|
38
|
+
guint argc, const GValue *g_argv,
|
|
39
39
|
gpointer invocation_hint,
|
|
40
40
|
gpointer marshal_data);
|
|
41
41
|
|
package/src/debug.cc
CHANGED
|
@@ -158,7 +158,7 @@ void print_callable_info (GICallableInfo *info) {
|
|
|
158
158
|
g_callable_info_load_return_type(info, &return_info);
|
|
159
159
|
auto typeName = GetTypeName(&return_info);
|
|
160
160
|
printf("%s %s (", typeName, g_base_info_get_name(info));
|
|
161
|
-
|
|
161
|
+
g_free(typeName);
|
|
162
162
|
|
|
163
163
|
int n_args = g_callable_info_get_n_args(info);
|
|
164
164
|
for (int i = 0; i < n_args; i++) {
|
|
@@ -168,7 +168,7 @@ void print_callable_info (GICallableInfo *info) {
|
|
|
168
168
|
g_arg_info_load_type(&arg_info, &type_info);
|
|
169
169
|
auto typeName = GetTypeName(&type_info);
|
|
170
170
|
printf("%s %s", typeName, g_base_info_get_name(&arg_info));
|
|
171
|
-
|
|
171
|
+
g_free(typeName);
|
|
172
172
|
if (i < n_args - 1)
|
|
173
173
|
printf(", ");
|
|
174
174
|
}
|