0 | |
From 117f200e97b85424f21ca837b5094370f0120192 Mon Sep 17 00:00:00 2001
|
1 | |
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <michel@daenzer.net>
|
2 | |
Date: Mon, 5 May 2014 11:46:44 +0900
|
3 | |
Subject: Fix JS types in callback signatures
|
4 | |
MIME-Version: 1.0
|
5 | |
Content-Type: text/plain; charset=UTF-8
|
6 | |
Content-Transfer-Encoding: 8bit
|
7 | |
|
8 | |
Fixes crashes in the testsuite and in gnome-shell on at least PPC, due
|
9 | |
to treating things like pointers which really aren't.
|
10 | |
|
11 | |
Signed-off-by: Michel Dänzer <michel@daenzer.net>
|
12 | |
|
13 | |
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
|
14 | |
index 497352f..0c8e6bd 100644
|
15 | |
--- a/gi/boxed.cpp
|
16 | |
+++ b/gi/boxed.cpp
|
17 | |
@@ -118,21 +118,19 @@ gjs_define_static_methods(JSContext *context,
|
18 | |
*/
|
19 | |
static JSBool
|
20 | |
boxed_new_resolve(JSContext *context,
|
21 | |
- JSObject **obj,
|
22 | |
- jsid *id,
|
23 | |
- unsigned flags,
|
24 | |
- JSObject **objp)
|
25 | |
+ JS::HandleObject obj,
|
26 | |
+ JS::HandleId id,
|
27 | |
+ unsigned flags,
|
28 | |
+ JS::MutableHandleObject objp)
|
29 | |
{
|
30 | |
Boxed *priv;
|
31 | |
char *name;
|
32 | |
JSBool ret = JS_FALSE;
|
33 | |
|
34 | |
- *objp = NULL;
|
35 | |
-
|
36 | |
- if (!gjs_get_string_id(context, *id, &name))
|
37 | |
+ if (!gjs_get_string_id(context, id, &name))
|
38 | |
return JS_TRUE; /* not resolved, but no error */
|
39 | |
|
40 | |
- priv = priv_from_js(context, *obj);
|
41 | |
+ priv = priv_from_js(context, obj);
|
42 | |
gjs_debug_jsprop(GJS_DEBUG_GBOXED, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
|
43 | |
|
44 | |
if (priv == NULL)
|
45 | |
@@ -161,7 +159,7 @@ boxed_new_resolve(JSContext *context,
|
46 | |
g_base_info_get_namespace( (GIBaseInfo*) priv->info),
|
47 | |
g_base_info_get_name( (GIBaseInfo*) priv->info));
|
48 | |
|
49 | |
- boxed_proto = *obj;
|
50 | |
+ boxed_proto = obj;
|
51 | |
|
52 | |
if (gjs_define_function(context, boxed_proto, priv->gtype,
|
53 | |
(GICallableInfo *)method_info) == NULL) {
|
54 | |
@@ -169,7 +167,7 @@ boxed_new_resolve(JSContext *context,
|
55 | |
goto out;
|
56 | |
}
|
57 | |
|
58 | |
- *objp = boxed_proto; /* we defined the prop in object_proto */
|
59 | |
+ objp.set(boxed_proto); /* we defined the prop in object_proto */
|
60 | |
}
|
61 | |
|
62 | |
g_base_info_unref( (GIBaseInfo*) method_info);
|
63 | |
diff --git a/gi/function.cpp b/gi/function.cpp
|
64 | |
index 792778c..6b55273 100644
|
65 | |
--- a/gi/function.cpp
|
66 | |
+++ b/gi/function.cpp
|
67 | |
@@ -1334,15 +1334,15 @@ function_finalize(JSFreeOp *fop,
|
68 | |
|
69 | |
static JSBool
|
70 | |
get_num_arguments (JSContext *context,
|
71 | |
- JSObject **obj,
|
72 | |
- jsid *id,
|
73 | |
- jsval *vp)
|
74 | |
+ JS::HandleObject obj,
|
75 | |
+ JS::HandleId id,
|
76 | |
+ JS::MutableHandleValue vp)
|
77 | |
{
|
78 | |
int n_args, n_jsargs, i;
|
79 | |
jsval retval;
|
80 | |
Function *priv;
|
81 | |
|
82 | |
- priv = priv_from_js(context, *obj);
|
83 | |
+ priv = priv_from_js(context, obj);
|
84 | |
|
85 | |
if (priv == NULL)
|
86 | |
return JS_FALSE;
|
87 | |
@@ -1362,7 +1362,7 @@ get_num_arguments (JSContext *context,
|
88 | |
}
|
89 | |
|
90 | |
retval = INT_TO_JSVAL(n_jsargs);
|
91 | |
- JS_SET_RVAL(context, vp, retval);
|
92 | |
+ JS_SET_RVAL(context, vp.address(), retval);
|
93 | |
return JS_TRUE;
|
94 | |
}
|
95 | |
|
96 | |
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
|
97 | |
index bdb2742..9ca8003 100644
|
98 | |
--- a/gi/fundamental.cpp
|
99 | |
+++ b/gi/fundamental.cpp
|
100 | |
@@ -233,8 +233,8 @@ find_fundamental_constructor(JSContext *context,
|
101 | |
|
102 | |
static JSBool
|
103 | |
fundamental_instance_new_resolve_interface(JSContext *context,
|
104 | |
- JSObject *obj,
|
105 | |
- JSObject **objp,
|
106 | |
+ JS::HandleObject obj,
|
107 | |
+ JS::MutableHandleObject objp,
|
108 | |
Fundamental *proto_priv,
|
109 | |
char *name)
|
110 | |
{
|
111 | |
@@ -271,7 +271,7 @@ fundamental_instance_new_resolve_interface(JSContext *context,
|
112 | |
if (gjs_define_function(context, obj,
|
113 | |
proto_priv->gtype,
|
114 | |
(GICallableInfo *) method_info)) {
|
115 | |
- *objp = obj;
|
116 | |
+ objp.set(obj);
|
117 | |
} else {
|
118 | |
ret = JS_FALSE;
|
119 | |
}
|
120 | |
@@ -300,21 +300,19 @@ fundamental_instance_new_resolve_interface(JSContext *context,
|
121 | |
*/
|
122 | |
static JSBool
|
123 | |
fundamental_instance_new_resolve(JSContext *context,
|
124 | |
- JSObject **obj,
|
125 | |
- jsid *id,
|
126 | |
- unsigned flags,
|
127 | |
- JSObject **objp)
|
128 | |
+ JS::HandleObject obj,
|
129 | |
+ JS::HandleId id,
|
130 | |
+ unsigned flags,
|
131 | |
+ JS::MutableHandleObject objp)
|
132 | |
{
|
133 | |
FundamentalInstance *priv;
|
134 | |
char *name;
|
135 | |
JSBool ret = JS_FALSE;
|
136 | |
|
137 | |
- *objp = NULL;
|
138 | |
-
|
139 | |
- if (!gjs_get_string_id(context, *id, &name))
|
140 | |
+ if (!gjs_get_string_id(context, id, &name))
|
141 | |
return JS_TRUE; /* not resolved, but no error */
|
142 | |
|
143 | |
- priv = priv_from_js(context, *obj);
|
144 | |
+ priv = priv_from_js(context, obj);
|
145 | |
gjs_debug_jsprop(GJS_DEBUG_GFUNDAMENTAL, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
|
146 | |
|
147 | |
if (priv == NULL)
|
148 | |
@@ -355,19 +353,19 @@ fundamental_instance_new_resolve(JSContext *context,
|
149 | |
g_base_info_get_namespace((GIBaseInfo *) proto_priv->info),
|
150 | |
g_base_info_get_name((GIBaseInfo *) proto_priv->info));
|
151 | |
|
152 | |
- if (gjs_define_function(context, *obj, proto_priv->gtype,
|
153 | |
+ if (gjs_define_function(context, obj, proto_priv->gtype,
|
154 | |
method_info) == NULL) {
|
155 | |
g_base_info_unref((GIBaseInfo *) method_info);
|
156 | |
goto out;
|
157 | |
}
|
158 | |
|
159 | |
- *objp = *obj;
|
160 | |
+ objp.set(obj);
|
161 | |
}
|
162 | |
|
163 | |
g_base_info_unref((GIBaseInfo *) method_info);
|
164 | |
}
|
165 | |
|
166 | |
- ret = fundamental_instance_new_resolve_interface(context, *obj, objp,
|
167 | |
+ ret = fundamental_instance_new_resolve_interface(context, obj, objp,
|
168 | |
proto_priv, name);
|
169 | |
} else {
|
170 | |
/* We are an instance, not a prototype, so look for
|
171 | |
diff --git a/gi/gerror.cpp b/gi/gerror.cpp
|
172 | |
index 891f99c..2384cd5 100644
|
173 | |
--- a/gi/gerror.cpp
|
174 | |
+++ b/gi/gerror.cpp
|
175 | |
@@ -150,25 +150,27 @@ error_finalize(JSFreeOp *fop,
|
176 | |
}
|
177 | |
|
178 | |
static JSBool
|
179 | |
-error_get_domain(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
|
180 | |
+error_get_domain(JSContext *context, JS::HandleObject obj,
|
181 | |
+ JS::HandleId id, JS::MutableHandleValue vp)
|
182 | |
{
|
183 | |
Error *priv;
|
184 | |
|
185 | |
- priv = priv_from_js(context, *obj);
|
186 | |
+ priv = priv_from_js(context, obj);
|
187 | |
|
188 | |
if (priv == NULL)
|
189 | |
return JS_FALSE;
|
190 | |
|
191 | |
- *vp = INT_TO_JSVAL(priv->domain);
|
192 | |
+ vp.set(INT_TO_JSVAL(priv->domain));
|
193 | |
return JS_TRUE;
|
194 | |
}
|
195 | |
|
196 | |
static JSBool
|
197 | |
-error_get_message(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
|
198 | |
+error_get_message(JSContext *context, JS::HandleObject obj,
|
199 | |
+ JS::HandleId id, JS::MutableHandleValue vp)
|
200 | |
{
|
201 | |
Error *priv;
|
202 | |
|
203 | |
- priv = priv_from_js(context, *obj);
|
204 | |
+ priv = priv_from_js(context, obj);
|
205 | |
|
206 | |
if (priv == NULL)
|
207 | |
return JS_FALSE;
|
208 | |
@@ -179,15 +181,16 @@ error_get_message(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
|
209 | |
return JS_FALSE;
|
210 | |
}
|
211 | |
|
212 | |
- return gjs_string_from_utf8(context, priv->gerror->message, -1, vp);
|
213 | |
+ return gjs_string_from_utf8(context, priv->gerror->message, -1, vp.address());
|
214 | |
}
|
215 | |
|
216 | |
static JSBool
|
217 | |
-error_get_code(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
|
218 | |
+error_get_code(JSContext *context, JS::HandleObject obj,
|
219 | |
+ JS::HandleId id, JS::MutableHandleValue vp)
|
220 | |
{
|
221 | |
Error *priv;
|
222 | |
|
223 | |
- priv = priv_from_js(context, *obj);
|
224 | |
+ priv = priv_from_js(context, obj);
|
225 | |
|
226 | |
if (priv == NULL)
|
227 | |
return JS_FALSE;
|
228 | |
@@ -198,7 +201,7 @@ error_get_code(JSContext *context, JSObject **obj, jsid *id, jsval *vp)
|
229 | |
return JS_FALSE;
|
230 | |
}
|
231 | |
|
232 | |
- *vp = INT_TO_JSVAL(priv->gerror->code);
|
233 | |
+ vp.set(INT_TO_JSVAL(priv->gerror->code));
|
234 | |
return JS_TRUE;
|
235 | |
}
|
236 | |
|
237 | |
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
|
238 | |
index c45698f..7ac2a38 100644
|
239 | |
--- a/gi/gtype.cpp
|
240 | |
+++ b/gi/gtype.cpp
|
241 | |
@@ -88,23 +88,23 @@ to_string_func(JSContext *context,
|
242 | |
|
243 | |
static JSBool
|
244 | |
get_name_func (JSContext *context,
|
245 | |
- JSObject **obj,
|
246 | |
- jsid *id,
|
247 | |
- jsval *vp)
|
248 | |
+ JS::HandleObject obj,
|
249 | |
+ JS::HandleId id,
|
250 | |
+ JS::MutableHandleValue vp)
|
251 | |
{
|
252 | |
GType gtype;
|
253 | |
JSBool ret;
|
254 | |
jsval retval;
|
255 | |
|
256 | |
- gtype = GPOINTER_TO_SIZE(priv_from_js(context, *obj));
|
257 | |
+ gtype = GPOINTER_TO_SIZE(priv_from_js(context, obj));
|
258 | |
|
259 | |
if (gtype == 0) {
|
260 | |
- JS_SET_RVAL(context, vp, JSVAL_NULL);
|
261 | |
+ JS_SET_RVAL(context, vp.address(), JSVAL_NULL);
|
262 | |
return TRUE;
|
263 | |
} else {
|
264 | |
ret = gjs_string_from_utf8(context, g_type_name(gtype), -1, &retval);
|
265 | |
if (ret)
|
266 | |
- JS_SET_RVAL(context, vp, retval);
|
267 | |
+ JS_SET_RVAL(context, vp.address(), retval);
|
268 | |
return ret;
|
269 | |
}
|
270 | |
}
|
271 | |
diff --git a/gi/interface.cpp b/gi/interface.cpp
|
272 | |
index 8fb1253..e13cf3a 100644
|
273 | |
--- a/gi/interface.cpp
|
274 | |
+++ b/gi/interface.cpp
|
275 | |
@@ -100,22 +100,20 @@ gjs_define_static_methods(JSContext *context,
|
276 | |
|
277 | |
static JSBool
|
278 | |
interface_new_resolve(JSContext *context,
|
279 | |
- JSObject **obj,
|
280 | |
- jsid *id,
|
281 | |
- unsigned flags,
|
282 | |
- JSObject **objp)
|
283 | |
+ JS::HandleObject obj,
|
284 | |
+ JS::HandleId id,
|
285 | |
+ unsigned flags,
|
286 | |
+ JS::MutableHandleObject objp)
|
287 | |
{
|
288 | |
Interface *priv;
|
289 | |
char *name;
|
290 | |
JSBool ret = JS_FALSE;
|
291 | |
GIFunctionInfo *method_info;
|
292 | |
|
293 | |
- *objp = NULL;
|
294 | |
-
|
295 | |
- if (!gjs_get_string_id(context, *id, &name))
|
296 | |
+ if (!gjs_get_string_id(context, id, &name))
|
297 | |
return JS_TRUE;
|
298 | |
|
299 | |
- priv = priv_from_js(context, *obj);
|
300 | |
+ priv = priv_from_js(context, obj);
|
301 | |
|
302 | |
if (priv == NULL)
|
303 | |
goto out;
|
304 | |
@@ -124,14 +122,14 @@ interface_new_resolve(JSContext *context,
|
305 | |
|
306 | |
if (method_info != NULL) {
|
307 | |
if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
|
308 | |
- if (gjs_define_function(context, *obj,
|
309 | |
+ if (gjs_define_function(context, obj,
|
310 | |
priv->gtype,
|
311 | |
(GICallableInfo*)method_info) == NULL) {
|
312 | |
g_base_info_unref((GIBaseInfo*)method_info);
|
313 | |
goto out;
|
314 | |
}
|
315 | |
|
316 | |
- *objp = *obj;
|
317 | |
+ objp.set(obj);
|
318 | |
}
|
319 | |
|
320 | |
g_base_info_unref((GIBaseInfo*)method_info);
|
321 | |
diff --git a/gi/ns.cpp b/gi/ns.cpp
|
322 | |
index f3d116b..5c84281 100644
|
323 | |
--- a/gi/ns.cpp
|
324 | |
+++ b/gi/ns.cpp
|
325 | |
@@ -57,10 +57,10 @@ GJS_DEFINE_PRIV_FROM_JS(Ns, gjs_ns_class)
|
326 | |
*/
|
327 | |
static JSBool
|
328 | |
ns_new_resolve(JSContext *context,
|
329 | |
- JSObject **obj,
|
330 | |
- jsid *id,
|
331 | |
- unsigned flags,
|
332 | |
- JSObject **objp)
|
333 | |
+ JS::HandleObject obj,
|
334 | |
+ JS::HandleId id,
|
335 | |
+ unsigned flags,
|
336 | |
+ JS::MutableHandleObject objp)
|
337 | |
{
|
338 | |
Ns *priv;
|
339 | |
char *name;
|
340 | |
@@ -68,9 +68,7 @@ ns_new_resolve(JSContext *context,
|
341 | |
GIBaseInfo *info;
|
342 | |
JSBool ret = JS_FALSE;
|
343 | |
|
344 | |
- *objp = NULL;
|
345 | |
-
|
346 | |
- if (!gjs_get_string_id(context, *id, &name))
|
347 | |
+ if (!gjs_get_string_id(context, id, &name))
|
348 | |
return JS_TRUE; /* not resolved, but no error */
|
349 | |
|
350 | |
/* let Object.prototype resolve these */
|
351 | |
@@ -80,7 +78,7 @@ ns_new_resolve(JSContext *context,
|
352 | |
goto out;
|
353 | |
}
|
354 | |
|
355 | |
- priv = priv_from_js(context, *obj);
|
356 | |
+ priv = priv_from_js(context, obj);
|
357 | |
gjs_debug_jsprop(GJS_DEBUG_GNAMESPACE, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
|
358 | |
|
359 | |
if (priv == NULL) {
|
360 | |
@@ -106,9 +104,9 @@ ns_new_resolve(JSContext *context,
|
361 | |
g_base_info_get_name(info),
|
362 | |
g_base_info_get_namespace(info));
|
363 | |
|
364 | |
- if (gjs_define_info(context, *obj, info)) {
|
365 | |
+ if (gjs_define_info(context, obj, info)) {
|
366 | |
g_base_info_unref(info);
|
367 | |
- *objp = *obj; /* we defined the property in this object */
|
368 | |
+ objp.set(obj); /* we defined the property in this object */
|
369 | |
ret = JS_TRUE;
|
370 | |
} else {
|
371 | |
gjs_debug(GJS_DEBUG_GNAMESPACE,
|
372 | |
diff --git a/gi/object.cpp b/gi/object.cpp
|
373 | |
index 5e74f63..1fb4de5 100644
|
374 | |
--- a/gi/object.cpp
|
375 | |
+++ b/gi/object.cpp
|
376 | |
@@ -267,7 +267,7 @@ object_instance_get_prop(JSContext *context,
|
377 | |
|
378 | |
priv = priv_from_js(context, obj);
|
379 | |
gjs_debug_jsprop(GJS_DEBUG_GOBJECT,
|
380 | |
- "Get prop '%s' hook obj %p priv %p", name, obj, priv);
|
381 | |
+ "Get prop '%s' hook obj %p priv %p", name, *obj, priv);
|
382 | |
|
383 | |
if (priv == NULL) {
|
384 | |
/* If we reach this point, either object_instance_new_resolve
|
385 | |
@@ -335,7 +335,7 @@ object_instance_set_prop(JSContext *context,
|
386 | |
|
387 | |
priv = priv_from_js(context, obj);
|
388 | |
gjs_debug_jsprop(GJS_DEBUG_GOBJECT,
|
389 | |
- "Set prop '%s' hook obj %p priv %p", name, obj, priv);
|
390 | |
+ "Set prop '%s' hook obj %p priv %p", name, *obj, priv);
|
391 | |
|
392 | |
if (priv == NULL) {
|
393 | |
/* see the comment in object_instance_get_prop() on this */
|
394 | |
@@ -435,8 +435,8 @@ find_vfunc_on_parents(GIObjectInfo *info,
|
395 | |
|
396 | |
static JSBool
|
397 | |
object_instance_new_resolve_no_info(JSContext *context,
|
398 | |
- JSObject *obj,
|
399 | |
- JSObject **objp,
|
400 | |
+ JS::HandleObject obj,
|
401 | |
+ JS::MutableHandleObject objp,
|
402 | |
ObjectInstance *priv,
|
403 | |
char *name)
|
404 | |
{
|
405 | |
@@ -472,7 +472,7 @@ object_instance_new_resolve_no_info(JSContext *context,
|
406 | |
if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
|
407 | |
if (gjs_define_function(context, obj, priv->gtype,
|
408 | |
(GICallableInfo *)method_info)) {
|
409 | |
- *objp = obj;
|
410 | |
+ objp.set(obj);
|
411 | |
} else {
|
412 | |
ret = JS_FALSE;
|
413 | |
}
|
414 | |
@@ -501,22 +501,20 @@ object_instance_new_resolve_no_info(JSContext *context,
|
415 | |
*/
|
416 | |
static JSBool
|
417 | |
object_instance_new_resolve(JSContext *context,
|
418 | |
- JSObject **obj,
|
419 | |
- jsid *id,
|
420 | |
- unsigned flags,
|
421 | |
- JSObject **objp)
|
422 | |
+ JS::HandleObject obj,
|
423 | |
+ JS::HandleId id,
|
424 | |
+ unsigned flags,
|
425 | |
+ JS::MutableHandleObject objp)
|
426 | |
{
|
427 | |
GIFunctionInfo *method_info;
|
428 | |
ObjectInstance *priv;
|
429 | |
char *name;
|
430 | |
JSBool ret = JS_FALSE;
|
431 | |
|
432 | |
- *objp = NULL;
|
433 | |
-
|
434 | |
- if (!gjs_get_string_id(context, *id, &name))
|
435 | |
+ if (!gjs_get_string_id(context, id, &name))
|
436 | |
return JS_TRUE; /* not resolved, but no error */
|
437 | |
|
438 | |
- priv = priv_from_js(context, *obj);
|
439 | |
+ priv = priv_from_js(context, obj);
|
440 | |
|
441 | |
gjs_debug_jsprop(GJS_DEBUG_GOBJECT,
|
442 | |
"Resolve prop '%s' hook obj %p priv %p (%s.%s) gobj %p %s",
|
443 | |
@@ -550,7 +548,7 @@ object_instance_new_resolve(JSContext *context,
|
444 | |
* we need to look at exposing interfaces. Look up our interfaces through
|
445 | |
* GType data, and then hope that *those* are introspectable. */
|
446 | |
if (priv->info == NULL) {
|
447 | |
- ret = object_instance_new_resolve_no_info(context, *obj, objp, priv, name);
|
448 | |
+ ret = object_instance_new_resolve_no_info(context, obj, objp, priv, name);
|
449 | |
goto out;
|
450 | |
}
|
451 | |
|
452 | |
@@ -583,8 +581,8 @@ object_instance_new_resolve(JSContext *context,
|
453 | |
goto out;
|
454 | |
}
|
455 | |
|
456 | |
- gjs_define_function(context, *obj, priv->gtype, vfunc);
|
457 | |
- *objp = *obj;
|
458 | |
+ gjs_define_function(context, obj, priv->gtype, vfunc);
|
459 | |
+ objp.set(obj);
|
460 | |
g_base_info_unref((GIBaseInfo *)vfunc);
|
461 | |
ret = JS_TRUE;
|
462 | |
goto out;
|
463 | |
@@ -615,7 +613,7 @@ object_instance_new_resolve(JSContext *context,
|
464 | |
* https://bugzilla.gnome.org/show_bug.cgi?id=632922
|
465 | |
*/
|
466 | |
if (method_info == NULL) {
|
467 | |
- ret = object_instance_new_resolve_no_info(context, *obj, objp,
|
468 | |
+ ret = object_instance_new_resolve_no_info(context, obj, objp,
|
469 | |
priv, name);
|
470 | |
goto out;
|
471 | |
} else {
|
472 | |
@@ -631,12 +629,12 @@ object_instance_new_resolve(JSContext *context,
|
473 | |
g_base_info_get_namespace( (GIBaseInfo*) priv->info),
|
474 | |
g_base_info_get_name( (GIBaseInfo*) priv->info));
|
475 | |
|
476 | |
- if (gjs_define_function(context, *obj, priv->gtype, method_info) == NULL) {
|
477 | |
+ if (gjs_define_function(context, obj, priv->gtype, method_info) == NULL) {
|
478 | |
g_base_info_unref( (GIBaseInfo*) method_info);
|
479 | |
goto out;
|
480 | |
}
|
481 | |
|
482 | |
- *objp = *obj; /* we defined the prop in obj */
|
483 | |
+ objp.set(obj); /* we defined the prop in obj */
|
484 | |
}
|
485 | |
|
486 | |
g_base_info_unref( (GIBaseInfo*) method_info);
|
487 | |
diff --git a/gi/repo.cpp b/gi/repo.cpp
|
488 | |
index 8037d5f..54a84d6 100644
|
489 | |
--- a/gi/repo.cpp
|
490 | |
+++ b/gi/repo.cpp
|
491 | |
@@ -173,18 +173,16 @@ resolve_namespace_object(JSContext *context,
|
492 | |
*/
|
493 | |
static JSBool
|
494 | |
repo_new_resolve(JSContext *context,
|
495 | |
- JSObject **obj,
|
496 | |
- jsid *id,
|
497 | |
- unsigned flags,
|
498 | |
- JSObject **objp)
|
499 | |
+ JS::HandleObject obj,
|
500 | |
+ JS::HandleId id,
|
501 | |
+ unsigned flags,
|
502 | |
+ JS::MutableHandleObject objp)
|
503 | |
{
|
504 | |
Repo *priv;
|
505 | |
char *name;
|
506 | |
JSBool ret = JS_TRUE;
|
507 | |
|
508 | |
- *objp = NULL;
|
509 | |
-
|
510 | |
- if (!gjs_get_string_id(context, *id, &name))
|
511 | |
+ if (!gjs_get_string_id(context, id, &name))
|
512 | |
return JS_TRUE; /* not resolved, but no error */
|
513 | |
|
514 | |
/* let Object.prototype resolve these */
|
515 | |
@@ -192,16 +190,16 @@ repo_new_resolve(JSContext *context,
|
516 | |
strcmp(name, "toString") == 0)
|
517 | |
goto out;
|
518 | |
|
519 | |
- priv = priv_from_js(context, *obj);
|
520 | |
- gjs_debug_jsprop(GJS_DEBUG_GREPO, "Resolve prop '%s' hook obj %p priv %p", name, obj, priv);
|
521 | |
+ priv = priv_from_js(context, obj);
|
522 | |
+ gjs_debug_jsprop(GJS_DEBUG_GREPO, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
|
523 | |
|
524 | |
if (priv == NULL) /* we are the prototype, or have the wrong class */
|
525 | |
goto out;
|
526 | |
|
527 | |
- if (!resolve_namespace_object(context, *obj, *id, name)) {
|
528 | |
+ if (!resolve_namespace_object(context, obj, id, name)) {
|
529 | |
ret = JS_FALSE;
|
530 | |
} else {
|
531 | |
- *objp = *obj; /* store the object we defined the prop in */
|
532 | |
+ objp.set(obj); /* store the object we defined the prop in */
|
533 | |
}
|
534 | |
|
535 | |
out:
|
536 | |
diff --git a/gi/union.cpp b/gi/union.cpp
|
537 | |
index 7ac58e3..718b991 100644
|
538 | |
--- a/gi/union.cpp
|
539 | |
+++ b/gi/union.cpp
|
540 | |
@@ -64,21 +64,19 @@ GJS_DEFINE_PRIV_FROM_JS(Union, gjs_union_class)
|
541 | |
*/
|
542 | |
static JSBool
|
543 | |
union_new_resolve(JSContext *context,
|
544 | |
- JSObject **obj,
|
545 | |
- jsid *id,
|
546 | |
- unsigned flags,
|
547 | |
- JSObject **objp)
|
548 | |
+ JS::HandleObject obj,
|
549 | |
+ JS::HandleId id,
|
550 | |
+ unsigned flags,
|
551 | |
+ JS::MutableHandleObject objp)
|
552 | |
{
|
553 | |
Union *priv;
|
554 | |
char *name;
|
555 | |
JSBool ret = JS_TRUE;
|
556 | |
|
557 | |
- *objp = NULL;
|
558 | |
-
|
559 | |
- if (!gjs_get_string_id(context, *id, &name))
|
560 | |
+ if (!gjs_get_string_id(context, id, &name))
|
561 | |
return JS_TRUE; /* not resolved, but no error */
|
562 | |
|
563 | |
- priv = priv_from_js(context, *obj);
|
564 | |
+ priv = priv_from_js(context, obj);
|
565 | |
gjs_debug_jsprop(GJS_DEBUG_GBOXED, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
|
566 | |
|
567 | |
if (priv == NULL) {
|
568 | |
@@ -109,7 +107,7 @@ union_new_resolve(JSContext *context,
|
569 | |
g_base_info_get_namespace( (GIBaseInfo*) priv->info),
|
570 | |
g_base_info_get_name( (GIBaseInfo*) priv->info));
|
571 | |
|
572 | |
- union_proto = *obj;
|
573 | |
+ union_proto = obj;
|
574 | |
|
575 | |
if (gjs_define_function(context, union_proto,
|
576 | |
g_registered_type_info_get_g_type(priv->info),
|
577 | |
@@ -119,7 +117,7 @@ union_new_resolve(JSContext *context,
|
578 | |
goto out;
|
579 | |
}
|
580 | |
|
581 | |
- *objp = union_proto; /* we defined the prop in object_proto */
|
582 | |
+ objp.set(union_proto); /* we defined the prop in object_proto */
|
583 | |
}
|
584 | |
|
585 | |
g_base_info_unref( (GIBaseInfo*) method_info);
|
586 | |
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
|
587 | |
index b5ff7a9..8f99f42 100644
|
588 | |
--- a/gjs/byteArray.cpp
|
589 | |
+++ b/gjs/byteArray.cpp
|
590 | |
@@ -40,14 +40,14 @@ extern struct JSClass gjs_byte_array_class;
|
591 | |
GJS_DEFINE_PRIV_FROM_JS(ByteArrayInstance, gjs_byte_array_class)
|
592 | |
|
593 | |
static JSBool byte_array_get_prop (JSContext *context,
|
594 | |
- JSObject **obj,
|
595 | |
- jsid *id,
|
596 | |
- jsval *value_p);
|
597 | |
+ JS::HandleObject obj,
|
598 | |
+ JS::HandleId id,
|
599 | |
+ JS::MutableHandleValue value_p);
|
600 | |
static JSBool byte_array_set_prop (JSContext *context,
|
601 | |
- JSObject **obj,
|
602 | |
- jsid *id,
|
603 | |
+ JS::HandleObject obj,
|
604 | |
+ JS::HandleId id,
|
605 | |
JSBool strict,
|
606 | |
- jsval *value_p);
|
607 | |
+ JS::MutableHandleValue value_p);
|
608 | |
GJS_NATIVE_CONSTRUCTOR_DECLARE(byte_array);
|
609 | |
static void byte_array_finalize (JSFreeOp *fop,
|
610 | |
JSObject *obj);
|
611 | |
@@ -81,13 +81,13 @@ gjs_typecheck_bytearray(JSContext *context,
|
612 | |
static JSBool
|
613 | |
gjs_value_from_gsize(JSContext *context,
|
614 | |
gsize v,
|
615 | |
- jsval *value_p)
|
616 | |
+ JS::MutableHandleValue value_p)
|
617 | |
{
|
618 | |
if (v > (gsize) JSVAL_INT_MAX) {
|
619 | |
- *value_p = INT_TO_JSVAL(v);
|
620 | |
+ value_p.set(INT_TO_JSVAL(v));
|
621 | |
return JS_TRUE;
|
622 | |
} else {
|
623 | |
- return JS_NewNumberValue(context, v, value_p);
|
624 | |
+ return JS_NewNumberValue(context, v, value_p.address());
|
625 | |
}
|
626 | |
}
|
627 | |
|
628 | |
@@ -170,10 +170,10 @@ gjs_value_to_byte(JSContext *context,
|
629 | |
|
630 | |
static JSBool
|
631 | |
byte_array_get_index(JSContext *context,
|
632 | |
- JSObject *obj,
|
633 | |
+ JS::HandleObject obj,
|
634 | |
ByteArrayInstance *priv,
|
635 | |
gsize idx,
|
636 | |
- jsval *value_p)
|
637 | |
+ JS::MutableHandleValue value_p)
|
638 | |
{
|
639 | |
gsize len;
|
640 | |
guint8 *data;
|
641 | |
@@ -188,7 +188,7 @@ byte_array_get_index(JSContext *context,
|
642 | |
return JS_FALSE;
|
643 | |
}
|
644 | |
|
645 | |
- *value_p = INT_TO_JSVAL(data[idx]);
|
646 | |
+ value_p.set(INT_TO_JSVAL(data[idx]));
|
647 | |
|
648 | |
return JS_TRUE;
|
649 | |
}
|
650 | |
@@ -198,19 +198,19 @@ byte_array_get_index(JSContext *context,
|
651 | |
*/
|
652 | |
static JSBool
|
653 | |
byte_array_get_prop(JSContext *context,
|
654 | |
- JSObject **obj,
|
655 | |
- jsid *id,
|
656 | |
- jsval *value_p)
|
657 | |
+ JS::HandleObject obj,
|
658 | |
+ JS::HandleId id,
|
659 | |
+ JS::MutableHandleValue value_p)
|
660 | |
{
|
661 | |
ByteArrayInstance *priv;
|
662 | |
jsval id_value;
|
663 | |
|
664 | |
- priv = priv_from_js(context, *obj);
|
665 | |
+ priv = priv_from_js(context, obj);
|
666 | |
|
667 | |
if (priv == NULL)
|
668 | |
return JS_TRUE; /* prototype, not an instance. */
|
669 | |
|
670 | |
- if (!JS_IdToValue(context, *id, &id_value))
|
671 | |
+ if (!JS_IdToValue(context, id, &id_value))
|
672 | |
return JS_FALSE;
|
673 | |
|
674 | |
/* First handle array indexing */
|
675 | |
@@ -218,7 +218,7 @@ byte_array_get_prop(JSContext *context,
|
676 | |
gsize idx;
|
677 | |
if (!gjs_value_to_gsize(context, id_value, &idx))
|
678 | |
return JS_FALSE;
|
679 | |
- return byte_array_get_index(context, *obj, priv, idx, value_p);
|
680 | |
+ return byte_array_get_index(context, obj, priv, idx, value_p);
|
681 | |
}
|
682 | |
|
683 | |
/* We don't special-case anything else for now. Regular JS arrays
|
684 | |
@@ -230,14 +230,14 @@ byte_array_get_prop(JSContext *context,
|
685 | |
|
686 | |
static JSBool
|
687 | |
byte_array_length_getter(JSContext *context,
|
688 | |
- JSObject **obj,
|
689 | |
- jsid *id,
|
690 | |
- jsval *value_p)
|
691 | |
+ JS::HandleObject obj,
|
692 | |
+ JS::HandleId id,
|
693 | |
+ JS::MutableHandleValue value_p)
|
694 | |
{
|
695 | |
ByteArrayInstance *priv;
|
696 | |
gsize len = 0;
|
697 | |
|
698 | |
- priv = priv_from_js(context, *obj);
|
699 | |
+ priv = priv_from_js(context, obj);
|
700 | |
|
701 | |
if (priv == NULL)
|
702 | |
return JS_TRUE; /* prototype, not an instance. */
|
703 | |
@@ -251,23 +251,22 @@ byte_array_length_getter(JSContext *context,
|
704 | |
|
705 | |
static JSBool
|
706 | |
byte_array_length_setter(JSContext *context,
|
707 | |
- JSObject **obj,
|
708 | |
- jsid *id,
|
709 | |
- JSBool strict,
|
710 | |
- jsval *value_p)
|
711 | |
+ JS::HandleObject obj,
|
712 | |
+ JS::HandleId id,
|
713 | |
+ JSBool strict,
|
714 | |
+ JS::MutableHandleValue value_p)
|
715 | |
{
|
716 | |
ByteArrayInstance *priv;
|
717 | |
gsize len = 0;
|
718 | |
|
719 | |
- priv = priv_from_js(context, *obj);
|
720 | |
+ priv = priv_from_js(context, obj);
|
721 | |
|
722 | |
if (priv == NULL)
|
723 | |
return JS_TRUE; /* prototype, not instance */
|
724 | |
|
725 | |
byte_array_ensure_array(priv);
|
726 | |
|
727 | |
- if (!gjs_value_to_gsize(context, *value_p,
|
728 | |
- &len)) {
|
729 | |
+ if (!gjs_value_to_gsize(context, value_p, &len)) {
|
730 | |
gjs_throw(context,
|
731 | |
"Can't set ByteArray length to non-integer");
|
732 | |
return JS_FALSE;
|
733 | |
@@ -278,15 +277,14 @@ byte_array_length_setter(JSContext *context,
|
734 | |
|
735 | |
static JSBool
|
736 | |
byte_array_set_index(JSContext *context,
|
737 | |
- JSObject *obj,
|
738 | |
+ JS::HandleObject obj,
|
739 | |
ByteArrayInstance *priv,
|
740 | |
gsize idx,
|
741 | |
- jsval *value_p)
|
742 | |
+ JS::MutableHandleValue value_p)
|
743 | |
{
|
744 | |
guint8 v;
|
745 | |
|
746 | |
- if (!gjs_value_to_byte(context, *value_p,
|
747 | |
- &v)) {
|
748 | |
+ if (!gjs_value_to_byte(context, value_p, &v)) {
|
749 | |
return JS_FALSE;
|
750 | |
}
|
751 | |
|
752 | |
@@ -301,7 +299,7 @@ byte_array_set_index(JSContext *context,
|
753 | |
g_array_index(priv->array, guint8, idx) = v;
|
754 | |
|
755 | |
/* Stop JS from storing a copy of the value */
|
756 | |
- *value_p = JSVAL_VOID;
|
757 | |
+ value_p.set(JSVAL_VOID);
|
758 | |
|
759 | |
return JS_TRUE;
|
760 | |
}
|
761 | |
@@ -311,20 +309,20 @@ byte_array_set_index(JSContext *context,
|
762 | |
*/
|
763 | |
static JSBool
|
764 | |
byte_array_set_prop(JSContext *context,
|
765 | |
- JSObject **obj,
|
766 | |
- jsid *id,
|
767 | |
- JSBool strict,
|
768 | |
- jsval *value_p)
|
769 | |
+ JS::HandleObject obj,
|
770 | |
+ JS::HandleId id,
|
771 | |
+ JSBool strict,
|
772 | |
+ JS::MutableHandleValue value_p)
|
773 | |
{
|
774 | |
ByteArrayInstance *priv;
|
775 | |
jsval id_value;
|
776 | |
|
777 | |
- priv = priv_from_js(context, *obj);
|
778 | |
+ priv = priv_from_js(context, obj);
|
779 | |
|
780 | |
if (priv == NULL)
|
781 | |
return JS_TRUE; /* prototype, not an instance. */
|
782 | |
|
783 | |
- if (!JS_IdToValue(context, *id, &id_value))
|
784 | |
+ if (!JS_IdToValue(context, id, &id_value))
|
785 | |
return JS_FALSE;
|
786 | |
|
787 | |
/* First handle array indexing */
|
788 | |
@@ -333,7 +331,7 @@ byte_array_set_prop(JSContext *context,
|
789 | |
if (!gjs_value_to_gsize(context, id_value, &idx))
|
790 | |
return JS_FALSE;
|
791 | |
|
792 | |
- return byte_array_set_index(context, *obj, priv, idx, value_p);
|
793 | |
+ return byte_array_set_index(context, obj, priv, idx, value_p);
|
794 | |
}
|
795 | |
|
796 | |
/* We don't special-case anything else for now */
|
797 | |
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
|
798 | |
index cccd6a9..5bf922f 100644
|
799 | |
--- a/gjs/importer.cpp
|
800 | |
+++ b/gjs/importer.cpp
|
801 | |
@@ -855,23 +855,21 @@ importer_new_enumerate(JSContext *context,
|
802 | |
*/
|
803 | |
static JSBool
|
804 | |
importer_new_resolve(JSContext *context,
|
805 | |
- JSObject **obj,
|
806 | |
- jsid *id,
|
807 | |
- unsigned flags,
|
808 | |
- JSObject **objp)
|
809 | |
+ JS::HandleObject obj,
|
810 | |
+ JS::HandleId id,
|
811 | |
+ unsigned flags,
|
812 | |
+ JS::MutableHandleObject objp)
|
813 | |
{
|
814 | |
Importer *priv;
|
815 | |
char *name;
|
816 | |
JSBool ret = JS_TRUE;
|
817 | |
jsid module_init_name;
|
818 | |
|
819 | |
- *objp = NULL;
|
820 | |
-
|
821 | |
module_init_name = gjs_context_get_const_string(context, GJS_STRING_MODULE_INIT);
|
822 | |
- if (*id == module_init_name)
|
823 | |
+ if (id == module_init_name)
|
824 | |
return JS_TRUE;
|
825 | |
|
826 | |
- if (!gjs_get_string_id(context, *id, &name))
|
827 | |
+ if (!gjs_get_string_id(context, id, &name))
|
828 | |
return JS_FALSE;
|
829 | |
|
830 | |
/* let Object.prototype resolve these */
|
831 | |
@@ -879,14 +877,14 @@ importer_new_resolve(JSContext *context,
|
832 | |
strcmp(name, "toString") == 0 ||
|
833 | |
strcmp(name, "__iterator__") == 0)
|
834 | |
goto out;
|
835 | |
- priv = priv_from_js(context, *obj);
|
836 | |
+ priv = priv_from_js(context, obj);
|
837 | |
|
838 | |
gjs_debug_jsprop(GJS_DEBUG_IMPORTER, "Resolve prop '%s' hook obj %p priv %p", name, *obj, priv);
|
839 | |
if (priv == NULL) /* we are the prototype, or have the wrong class */
|
840 | |
goto out;
|
841 | |
JS_BeginRequest(context);
|
842 | |
- if (do_import(context, *obj, priv, name)) {
|
843 | |
- *objp = *obj;
|
844 | |
+ if (do_import(context, obj, priv, name)) {
|
845 | |
+ objp.set(obj);
|
846 | |
} else {
|
847 | |
ret = JS_FALSE;
|
848 | |
}
|
849 | |
--
|
850 | |
cgit v0.10.1
|