[gjs] Revert "Drop the GJS_NATIVE_CONSTRUCTOR_VARIABLES macro"



commit f4b6d472853fe863f8ea082bd02e9b24384947b8
Author: Colin Walters <walters verbum org>
Date:   Thu Mar 10 16:40:48 2011 -0500

    Revert "Drop the GJS_NATIVE_CONSTRUCTOR_VARIABLES macro"
    
    This reverts commit e4ce5947b00cd73436d2a5e2305f919e8466b695.  It
    didn't actually work because in the old xulrunner 1.9 case, JSObject *
    comes from the prototype.

 gi/boxed.c                      |    3 +--
 gi/keep-alive.c                 |    2 +-
 gi/ns.c                         |    2 +-
 gi/object.c                     |    3 +--
 gi/param.c                      |    2 +-
 gi/repo.c                       |    2 +-
 gi/union.c                      |    2 +-
 gjs/byteArray.c                 |    3 +--
 gjs/compat.h                    |   11 +++++++++++
 gjs/importer.c                  |    2 +-
 modules/cairo-context.c         |    3 +--
 modules/cairo-image-surface.c   |    3 +--
 modules/cairo-linear-gradient.c |    3 +--
 modules/cairo-pdf-surface.c     |    3 +--
 modules/cairo-ps-surface.c      |    3 +--
 modules/cairo-radial-gradient.c |    3 +--
 modules/cairo-surface-pattern.c |    3 +--
 modules/cairo-svg-surface.c     |    3 +--
 modules/dbus-exports.c          |    2 +-
 19 files changed, 29 insertions(+), 29 deletions(-)
---
diff --git a/gi/boxed.c b/gi/boxed.c
index faff71e..268d629 100644
--- a/gi/boxed.c
+++ b/gi/boxed.c
@@ -416,8 +416,7 @@ boxed_init(JSContext   *context,
  */
 GJS_NATIVE_CONSTRUCTOR_DECLARE(boxed)
 {
-    JSObject *object = NULL;                            \
-    jsval *argv = JS_ARGV(context, vp);
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(boxed)
     Boxed *priv;
     Boxed *proto_priv;
     JSClass *obj_class;
diff --git a/gi/keep-alive.c b/gi/keep-alive.c
index dd59d17..028f900 100644
--- a/gi/keep-alive.c
+++ b/gi/keep-alive.c
@@ -90,7 +90,7 @@ child_free(void *data)
  */
 GJS_NATIVE_CONSTRUCTOR_DECLARE(keep_alive)
 {
-    JSObject *object = NULL;                            \
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(keep_alive)
     KeepAlive *priv;
 
     GJS_NATIVE_CONSTRUCTOR_PRELUDE(keep_alive);
diff --git a/gi/ns.c b/gi/ns.c
index 945b5d0..665af8a 100644
--- a/gi/ns.c
+++ b/gi/ns.c
@@ -156,7 +156,7 @@ ns_new_resolve(JSContext *context,
  */
 GJS_NATIVE_CONSTRUCTOR_DECLARE(ns)
 {
-    JSObject *object = NULL;                            \
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(ns)
     Ns *priv;
 
     GJS_NATIVE_CONSTRUCTOR_PRELUDE(ns);
diff --git a/gi/object.c b/gi/object.c
index 18afa79..e059228 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -620,8 +620,7 @@ wrapped_gobj_toggle_notify(gpointer      data,
  */
 GJS_NATIVE_CONSTRUCTOR_DECLARE(object_instance)
 {
-    JSObject *object = NULL;                            \
-    jsval *argv = JS_ARGV(context, vp);
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(object_instance)
     ObjectInstance *priv;
     ObjectInstance *proto_priv;
     JSObject *proto;
diff --git a/gi/param.c b/gi/param.c
index 6bbdad9..77b83af 100644
--- a/gi/param.c
+++ b/gi/param.c
@@ -150,7 +150,7 @@ param_new_resolve(JSContext *context,
  */
 GJS_NATIVE_CONSTRUCTOR_DECLARE(param)
 {
-    JSObject *object = NULL;                            \
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(param)
     Param *priv;
     Param *proto_priv;
     JSClass *obj_class;
diff --git a/gi/repo.c b/gi/repo.c
index db6905e..097ca67 100644
--- a/gi/repo.c
+++ b/gi/repo.c
@@ -169,7 +169,7 @@ repo_new_resolve(JSContext *context,
  */
 GJS_NATIVE_CONSTRUCTOR_DECLARE(repo)
 {
-    JSObject *object = NULL;                            \
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(repo)
     Repo *priv;
 
     GJS_NATIVE_CONSTRUCTOR_PRELUDE(repo);
diff --git a/gi/union.c b/gi/union.c
index cdf93dd..8d1ee6e 100644
--- a/gi/union.c
+++ b/gi/union.c
@@ -209,7 +209,7 @@ union_new(JSContext   *context,
  */
 GJS_NATIVE_CONSTRUCTOR_DECLARE(union)
 {
-    JSObject *object = NULL;                            \
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(union)
     Union *priv;
     Union *proto_priv;
     JSClass *obj_class;
diff --git a/gjs/byteArray.c b/gjs/byteArray.c
index 70a4203..02c627f 100644
--- a/gjs/byteArray.c
+++ b/gjs/byteArray.c
@@ -439,8 +439,7 @@ gjs_g_byte_array_new(int preallocated_length)
  */
 GJS_NATIVE_CONSTRUCTOR_DECLARE(byte_array)
 {
-    JSObject *object = NULL;                            \
-    jsval *argv = JS_ARGV(context, vp);
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(byte_array)
     ByteArrayInstance *priv;
     JSObject *proto;
     gboolean is_proto;
diff --git a/gjs/compat.h b/gjs/compat.h
index c3599b2..3ceeb1d 100644
--- a/gjs/compat.h
+++ b/gjs/compat.h
@@ -81,6 +81,15 @@ gjs_##name##_constructor(JSContext  *context,           \
                          jsval      *vp)
 
 /**
+ * GJS_NATIVE_CONSTRUCTOR_VARIABLES:
+ * Declare variables necessary for the constructor; should
+ * be at the very top.
+ */
+#define GJS_NATIVE_CONSTRUCTOR_VARIABLES(name)          \
+    JSObject *object = NULL;                            \
+    jsval *argv = JS_ARGV(context, vp);
+
+/**
  * GJS_NATIVE_CONSTRUCTOR_PRELUDE:
  * Call after the initial variable declaration.
  */
@@ -114,6 +123,8 @@ gjs_##name##_constructor(JSContext *context,            \
                          jsval     *argv,               \
                          jsval     *retval)
 
+#define GJS_NATIVE_CONSTRUCTOR_VARIABLES(name)
+
 #define GJS_NATIVE_CONSTRUCTOR_PRELUDE(name)            \
     if (!JS_IsConstructing(context)) {                  \
         gjs_throw_constructor_error(context);           \
diff --git a/gjs/importer.c b/gjs/importer.c
index 571d51f..7aa674e 100644
--- a/gjs/importer.c
+++ b/gjs/importer.c
@@ -967,7 +967,7 @@ importer_new_resolve(JSContext *context,
  */
 GJS_NATIVE_CONSTRUCTOR_DECLARE(importer)
 {
-    JSObject *object = NULL;                            \
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(importer)
     Importer *priv;
 
     GJS_NATIVE_CONSTRUCTOR_PRELUDE(importer);
diff --git a/modules/cairo-context.c b/modules/cairo-context.c
index bdb89ac..7b9575f 100644
--- a/modules/cairo-context.c
+++ b/modules/cairo-context.c
@@ -274,8 +274,7 @@ _gjs_cairo_context_construct_internal(JSContext *context,
 
 GJS_NATIVE_CONSTRUCTOR_DECLARE(cairo_context)
 {
-    JSObject *object = NULL;                            \
-    jsval *argv = JS_ARGV(context, vp);
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(cairo_context)
     JSObject *surface_wrapper;
     cairo_surface_t *surface;
     cairo_t *cr;
diff --git a/modules/cairo-image-surface.c b/modules/cairo-image-surface.c
index 30b0df2..c2e587f 100644
--- a/modules/cairo-image-surface.c
+++ b/modules/cairo-image-surface.c
@@ -31,8 +31,7 @@ GJS_DEFINE_PROTO("CairoImageSurface", cairo_image_surface)
 
 GJS_NATIVE_CONSTRUCTOR_DECLARE(cairo_image_surface)
 {
-    JSObject *object = NULL;                            \
-    jsval *argv = JS_ARGV(context, vp);
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(cairo_image_surface)
     int format, width, height;
     cairo_surface_t *surface;
 
diff --git a/modules/cairo-linear-gradient.c b/modules/cairo-linear-gradient.c
index 4132c96..74efc90 100644
--- a/modules/cairo-linear-gradient.c
+++ b/modules/cairo-linear-gradient.c
@@ -31,8 +31,7 @@ GJS_DEFINE_PROTO("CairoLinearGradient", cairo_linear_gradient)
 
 GJS_NATIVE_CONSTRUCTOR_DECLARE(cairo_linear_gradient)
 {
-    JSObject *object = NULL;                            \
-    jsval *argv = JS_ARGV(context, vp);
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(cairo_linear_gradient)
     double x0, y0, x1, y1;
     cairo_pattern_t *pattern;
 
diff --git a/modules/cairo-pdf-surface.c b/modules/cairo-pdf-surface.c
index 144d53b..6aca613 100644
--- a/modules/cairo-pdf-surface.c
+++ b/modules/cairo-pdf-surface.c
@@ -34,8 +34,7 @@ GJS_DEFINE_PROTO("CairoPDFSurface", cairo_pdf_surface)
 
 GJS_NATIVE_CONSTRUCTOR_DECLARE(cairo_pdf_surface)
 {
-    JSObject *object = NULL;                            \
-    jsval *argv = JS_ARGV(context, vp);
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(cairo_pdf_surface)
     char *filename;
     double width, height;
     cairo_surface_t *surface;
diff --git a/modules/cairo-ps-surface.c b/modules/cairo-ps-surface.c
index 6e86c1a..ca0fad4 100644
--- a/modules/cairo-ps-surface.c
+++ b/modules/cairo-ps-surface.c
@@ -34,8 +34,7 @@ GJS_DEFINE_PROTO("CairoPSSurface", cairo_ps_surface)
 
 GJS_NATIVE_CONSTRUCTOR_DECLARE(cairo_ps_surface)
 {
-    JSObject *object = NULL;                            \
-    jsval *argv = JS_ARGV(context, vp);
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(cairo_ps_surface)
     char *filename;
     double width, height;
     cairo_surface_t *surface;
diff --git a/modules/cairo-radial-gradient.c b/modules/cairo-radial-gradient.c
index 6b9a20c..48f8b0b 100644
--- a/modules/cairo-radial-gradient.c
+++ b/modules/cairo-radial-gradient.c
@@ -31,8 +31,7 @@ GJS_DEFINE_PROTO("CairoRadialGradient", cairo_radial_gradient)
 
 GJS_NATIVE_CONSTRUCTOR_DECLARE(cairo_radial_gradient)
 {
-    JSObject *object = NULL;                            \
-    jsval *argv = JS_ARGV(context, vp);
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(cairo_radial_gradient)
     double cx0, cy0, radius0, cx1, cy1, radius1;
     cairo_pattern_t *pattern;
 
diff --git a/modules/cairo-surface-pattern.c b/modules/cairo-surface-pattern.c
index 3f9cf3d..8791e32 100644
--- a/modules/cairo-surface-pattern.c
+++ b/modules/cairo-surface-pattern.c
@@ -31,8 +31,7 @@ GJS_DEFINE_PROTO("CairoSurfacePattern", cairo_surface_pattern)
 
 GJS_NATIVE_CONSTRUCTOR_DECLARE(cairo_surface_pattern)
 {
-    JSObject *object = NULL;                            \
-    jsval *argv = JS_ARGV(context, vp);
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(cairo_surface_pattern)
     JSObject *surface_wrapper;
     cairo_surface_t *surface;
     cairo_pattern_t *pattern;
diff --git a/modules/cairo-svg-surface.c b/modules/cairo-svg-surface.c
index 03880a4..6acc26c 100644
--- a/modules/cairo-svg-surface.c
+++ b/modules/cairo-svg-surface.c
@@ -34,8 +34,7 @@ GJS_DEFINE_PROTO("CairoSVGSurface", cairo_svg_surface)
 
 GJS_NATIVE_CONSTRUCTOR_DECLARE(cairo_svg_surface)
 {
-    JSObject *object = NULL;                            \
-    jsval *argv = JS_ARGV(context, vp);
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(cairo_svg_surface)
     char *filename;
     double width, height;
     cairo_surface_t *surface;
diff --git a/modules/dbus-exports.c b/modules/dbus-exports.c
index 3c1d8b4..d5c7198 100644
--- a/modules/dbus-exports.c
+++ b/modules/dbus-exports.c
@@ -1708,7 +1708,7 @@ exports_new_resolve(JSContext *context,
  */
 GJS_NATIVE_CONSTRUCTOR_DECLARE(js_exports)
 {
-    JSObject *object = NULL;                            \
+    GJS_NATIVE_CONSTRUCTOR_VARIABLES(js_exports)
     Exports *priv;
 
     GJS_NATIVE_CONSTRUCTOR_PRELUDE(js_exports);



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