node-gtk 0.8.1 → 0.11.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 CHANGED
@@ -19,7 +19,7 @@ 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: **12**, **14**, **15** (other versions should work but are untested)
22
+ Supported Node.js versions: **12**, **14**, **15**, **16** (other versions should work but are untested)
23
23
  Pre-built binaries available for: **Linux**, **macOS**
24
24
 
25
25
  ### Table of contents
@@ -40,8 +40,10 @@ Pre-built binaries available for: **Linux**, **macOS**
40
40
 
41
41
  ## Usage
42
42
 
43
- You can use the [Gtk+ API](https://developer.gnome.org/gtk3/stable) directly, or you can
44
- use [react-gtk](https://github.com/codejamninja/react-gtk) if your prefer to use React.
43
+ Below is a minimal example of how to use the code, but take a look at
44
+ our [template](https://github.com/romgrk/node-gtk-template) or at
45
+ [react-gtk](https://github.com/codejamninja/react-gtk) to bootstrap your
46
+ project.
45
47
 
46
48
  ```javascript
47
49
  const gi = require('node-gtk')
@@ -216,6 +218,13 @@ cd ~/oss
216
218
  git clone https://github.com/romgrk/node-gtk
217
219
  cd node-gtk
218
220
 
221
+ # don't include /mingw64/include directly since it conflicts with
222
+ # Windows SDK headers. we copy needed headers to __extra__ directory:
223
+ ./windows/mingw_include_extra.sh
224
+
225
+ # if MSYS2 is NOT installed in C:/msys64 run:
226
+ export MINGW_WINDOWS_PATH=$(./windows/mingw_windows_path.sh)
227
+
219
228
  # first run might take a while
220
229
  GYP_MSVS_VERSION=2015 npm install
221
230
  ```
package/binding.gyp CHANGED
@@ -39,19 +39,20 @@
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 != "linux"', {
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": [
@@ -69,16 +70,34 @@
69
70
  }],
70
71
  ['OS == "win"', {
71
72
  "defines": [
72
- "uint=unsigned int",
73
73
  "PLATFORM_WIN=1",
74
74
  ],
75
+ "variables": {
76
+ # If MSYS2 is NOT installed in C:/msys64 run:
77
+ # $ export MINGW_WINDOWS_PATH=$(./windows/mingw_windows_path.sh)
78
+ # before compiling
79
+ "MINGW_PREFIX": "<!(bash -c 'echo ${MINGW_WINDOWS_PATH:-/msys64}')",
80
+ },
75
81
  "include_dirs": [
76
- "include",
77
- "/msys64/mingw64/include/gobject-introspection-1.0",
78
- "/msys64/mingw64/lib/libffi-3.2.1/include",
79
- "/msys64/mingw64/include/glib-2.0",
80
- "/msys64/mingw64/lib/glib-2.0/include",
81
- "/msys64/mingw64/include/cairo"
82
+ # Don't include /mingw64/include directly.
83
+ # To make extra include dir run:
84
+ # $ ./windows/mingw_include_extra.sh
85
+ # before compiling
86
+ "<(MINGW_PREFIX)/mingw64/include/__extra__",
87
+
88
+ "<(MINGW_PREFIX)/mingw64/include/gobject-introspection-1.0",
89
+ "<(MINGW_PREFIX)/mingw64/include/glib-2.0",
90
+ "<(MINGW_PREFIX)/mingw64/lib/glib-2.0/include",
91
+ "<(MINGW_PREFIX)/mingw64/include/cairo",
92
+ "<(MINGW_PREFIX)/mingw64/include/freetype2",
93
+ ],
94
+ "libraries": [
95
+ "<(MINGW_PREFIX)/mingw64/lib/libglib-2.0.dll.a",
96
+ "<(MINGW_PREFIX)/mingw64/lib/libgmodule-2.0.dll.a",
97
+ "<(MINGW_PREFIX)/mingw64/lib/libgobject-2.0.dll.a",
98
+ "<(MINGW_PREFIX)/mingw64/lib/libffi.dll.a",
99
+ "<(MINGW_PREFIX)/mingw64/lib/libgirepository-1.0.dll.a",
100
+ "<(MINGW_PREFIX)/mingw64/lib/libcairo.dll.a",
82
101
  ]
83
102
  }]
84
103
  ]
package/lib/bootstrap.js CHANGED
@@ -156,20 +156,6 @@ function addFunction(object, info) {
156
156
  define(object, getFunctionDescription(info))
157
157
  }
158
158
 
159
- function addVirtualFunction(object, info, implementor) {
160
- const fn = internal.MakeVirtualFunction(info, implementor);
161
- const name = getInfoName(info);
162
- const flags = GI.function_info_get_flags(info);
163
- const isMethod = ((flags & GI.FunctionInfoFlags.IS_METHOD) != 0 &&
164
- (flags & GI.FunctionInfoFlags.IS_CONSTRUCTOR) == 0);
165
- const target = (isMethod) ? object.prototype : object;
166
- Object.defineProperty(target, name, {
167
- configurable: true,
168
- writable: true,
169
- value: fn
170
- })
171
- }
172
-
173
159
  function fieldGetter(fieldInfo) {
174
160
  return function () {
175
161
  return internal.StructFieldGetter(this, fieldInfo);
@@ -227,10 +213,6 @@ function makeFunction(info) {
227
213
  return internal.MakeFunction(info)
228
214
  }
229
215
 
230
- function makeVirtualFunction(info, implementor) {
231
- return internal.MakeVirtualFunction(info, implementor)
232
- }
233
-
234
216
  function makeEnum(info) {
235
217
  const object = {}
236
218
 
@@ -395,9 +377,6 @@ function makeInfo(info) {
395
377
  case GI.InfoType.FUNCTION:
396
378
  return makeFunction(info);
397
379
 
398
- // case GI.InfoType.VFUNC:
399
- // return makeVirtualFunction(info, ...args);
400
-
401
380
  case GI.InfoType.STRUCT:
402
381
  if (GI.struct_info_is_gtype_struct(info))
403
382
  return undefined;
package/package.json CHANGED
@@ -1,15 +1,8 @@
1
1
  {
2
2
  "name": "node-gtk",
3
- "version": "0.8.1",
3
+ "version": "0.11.0",
4
4
  "description": "GNOME Gtk+ bindings for NodeJS",
5
5
  "main": "lib/index.js",
6
- "scripts": {
7
- "install": "if [ \"$(uname)\" = \"Darwin\" ] && [ \"$(which brew)\" != \"\" ]; then export PKG_CONFIG_PATH=$(brew --prefix libffi)/lib/pkgconfig; fi; node-pre-gyp install --fallback-to-build",
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"
12
- },
13
6
  "repository": {
14
7
  "type": "git",
15
8
  "url": "git+https://github.com/romgrk/node-gtk.git"
@@ -62,5 +55,12 @@
62
55
  "remote_path": "./{module_name}/v{version}/",
63
56
  "package_name": "{module_name}-{node_abi}-{platform}-{arch}.tar.gz",
64
57
  "host": "https://node-gtk-1.s3.amazonaws.com"
58
+ },
59
+ "scripts": {
60
+ "install": "npx node-pre-gyp install --fallback-to-build",
61
+ "test": "mocha tests/__run__.js",
62
+ "build": "npx node-pre-gyp build",
63
+ "build:full": "npx node-pre-gyp rebuild",
64
+ "configure": "npx node-pre-gyp configure --debug"
65
65
  }
66
- }
66
+ }
package/scripts/ci.sh CHANGED
File without changes
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 = malloc(size);
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 = calloc(1, size);
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
- free(box->data);
270
+ g_free(box->data);
271
271
  }
272
272
  else if (box->data != NULL) {
273
273
  /*
package/src/callback.cc CHANGED
@@ -22,7 +22,7 @@ using Nan::TryCatch;
22
22
 
23
23
  namespace GNodeJS {
24
24
 
25
- static uint callbackLevel = 0;
25
+ static guint callbackLevel = 0;
26
26
  static GSList* notifiedCallbacks = NULL;
27
27
 
28
28
  static Local<Object> GetSelfInstance(GIArgument **args) {
@@ -91,10 +91,10 @@ void Callback::Execute (GIArgument *result, GIArgument **args, Callback *callbac
91
91
 
92
92
  /* Skip the object instance in first place */
93
93
  int args_offset = isVFunc ? 1 : 0;
94
- uint n_native_args = (uint) g_callable_info_get_n_args(callback->info);
95
- uint n_return_values = 1;
94
+ guint n_native_args = (guint) g_callable_info_get_n_args(callback->info);
95
+ guint n_return_values = 1;
96
96
 
97
- uint primitive_out_arguments_mask = 0;
97
+ guint primitive_out_arguments_mask = 0;
98
98
 
99
99
  #ifndef __linux__
100
100
  Local<Value>* js_args = new Local<Value>[n_native_args];
@@ -102,7 +102,7 @@ void Callback::Execute (GIArgument *result, GIArgument **args, Callback *callbac
102
102
  Local<Value> js_args[n_native_args];
103
103
  #endif
104
104
 
105
- for (uint i = 0; i < n_native_args; i++) {
105
+ for (guint i = 0; i < n_native_args; i++) {
106
106
  GIArgInfo arg_info;
107
107
  GITypeInfo arg_type;
108
108
  g_callable_info_load_arg (callback->info, i, &arg_info);
@@ -144,12 +144,11 @@ void Callback::Execute (GIArgument *result, GIArgument **args, Callback *callbac
144
144
  auto jsReturnValue = maybeReturnValue.ToLocalChecked();
145
145
  auto jsRealReturnValue = jsReturnValue;
146
146
  Local<Array> jsReturnArray;
147
- uint returnIndex = 0;
147
+ guint returnIndex = 0;
148
148
  bool success;
149
149
  bool isOutPrimitive;
150
- uint n_js_return_values = n_return_values - (hasVoidReturn ? 1 : 0);
150
+ guint n_js_return_values = n_return_values - (hasVoidReturn ? 1 : 0);
151
151
 
152
- uint i;
153
152
  GIArgInfo arg_info;
154
153
  GITypeInfo arg_type;
155
154
 
@@ -172,7 +171,7 @@ void Callback::Execute (GIArgument *result, GIArgument **args, Callback *callbac
172
171
  else
173
172
  jsRealReturnValue = Nan::Get(jsReturnArray, returnIndex++).ToLocalChecked();
174
173
 
175
- for (i = 0; i < n_native_args; i++) {
174
+ for (guint i = 0; i < n_native_args; i++) {
176
175
  isOutPrimitive = (primitive_out_arguments_mask & (1 << i)) != 0;
177
176
  if (!isOutPrimitive)
178
177
  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, uint n_param_values,
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
- uint n_js_args = n_param_values - 1;
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 (uint i = 1; i < n_param_values; i++) {
61
+ for (guint i = 1; i < n_param_values; i++) {
62
62
  memcpy(&argument, &param_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 (uint i = 1; i < n_param_values; i++) {
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
- uint n_param_values,
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, uint n_param_values,
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
- uint argc, const GValue *g_argv,
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
- free(typeName);
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
- free(typeName);
171
+ g_free(typeName);
172
172
  if (i < n_args - 1)
173
173
  printf(", ");
174
174
  }