[gjs] Use interned jsid for "prototype"
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] Use interned jsid for "prototype"
- Date: Tue, 23 Apr 2013 20:54:40 +0000 (UTC)
commit f3ccf49654422b123f4da551c07757ebcfdd7b8c
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Mon Apr 8 20:23:54 2013 +0200
Use interned jsid for "prototype"
Replace all accesses to the prototype property with the jsid variant.
This involves one path, which is object construction.
https://bugzilla.gnome.org/show_bug.cgi?id=697592
gi/boxed.c | 6 +++++-
gi/gerror.c | 6 +++++-
gi/interface.c | 6 +++++-
gi/object.c | 5 ++++-
gi/param.c | 7 ++++++-
gi/union.c | 7 ++++++-
gjs/jsapi-dynamic-class.c | 8 ++++++--
gjs/jsapi-util.c | 8 ++++++--
8 files changed, 43 insertions(+), 10 deletions(-)
---
diff --git a/gi/boxed.c b/gi/boxed.c
index 071a940..5ce62e9 100644
--- a/gi/boxed.c
+++ b/gi/boxed.c
@@ -30,6 +30,7 @@
#include "object.h"
#include <gjs/gjs-module.h>
#include <gjs/compat.h>
+#include <gjs/runtime.h>
#include "repo.h"
#include "proxyutils.h"
#include "function.h"
@@ -1187,6 +1188,7 @@ gjs_define_boxed_class(JSContext *context,
if (gjs_object_get_property(context, in_object, constructor_name, &value)) {
JSObject *constructor;
+ jsid prototype_name;
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "Existing property '%s' does not look like a constructor",
@@ -1196,7 +1198,9 @@ gjs_define_boxed_class(JSContext *context,
constructor = JSVAL_TO_OBJECT(value);
- gjs_object_get_property(context, constructor, "prototype", &value);
+ prototype_name = gjs_runtime_get_const_string(JS_GetRuntime(context),
+ GJS_STRING_PROTOTYPE);
+ JS_GetPropertyById(context, constructor, prototype_name, &value);
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "boxed %s prototype property does not appear to exist or has wrong type",
constructor_name);
return JS_FALSE;
diff --git a/gi/gerror.c b/gi/gerror.c
index b6a3bad..e8fda70 100644
--- a/gi/gerror.c
+++ b/gi/gerror.c
@@ -27,6 +27,7 @@
#include <gjs/gjs-module.h>
#include <gjs/compat.h>
+#include <gjs/runtime.h>
#include "boxed.h"
#include "enumeration.h"
#include "repo.h"
@@ -417,6 +418,7 @@ gjs_define_error_class(JSContext *context,
if (gjs_object_get_property(context, in_object, constructor_name, &value)) {
JSObject *constructor;
+ jsid prototype_name;
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "Existing property '%s' does not look like a constructor",
@@ -426,7 +428,9 @@ gjs_define_error_class(JSContext *context,
constructor = JSVAL_TO_OBJECT(value);
- gjs_object_get_property(context, constructor, "prototype", &value);
+ prototype_name = gjs_runtime_get_const_string(JS_GetRuntime(context),
+ GJS_STRING_PROTOTYPE);
+ JS_GetPropertyById(context, constructor, prototype_name, &value);
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "error %s prototype property does not appear to exist or has wrong type",
constructor_name);
return JS_FALSE;
diff --git a/gi/interface.c b/gi/interface.c
index 92b0999..a63962a 100644
--- a/gi/interface.c
+++ b/gi/interface.c
@@ -30,6 +30,7 @@
#include <gjs/gjs-module.h>
#include <gjs/compat.h>
+#include <gjs/runtime.h>
#include <util/log.h>
#include <girepository.h>
@@ -183,6 +184,7 @@ gjs_define_interface_class(JSContext *context,
gjs_object_get_property(context, in_object, constructor_name, &value);
if (!JSVAL_IS_VOID(value)) {
JSObject *constructor;
+ jsid prototype_name;
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "Existing property '%s' does not look like a constructor",
@@ -192,7 +194,9 @@ gjs_define_interface_class(JSContext *context,
constructor = JSVAL_TO_OBJECT(value);
- gjs_object_get_property(context, constructor, "prototype", &value);
+ prototype_name = gjs_runtime_get_const_string(JS_GetRuntime(context),
+ GJS_STRING_PROTOTYPE);
+ JS_GetPropertyById(context, constructor, prototype_name, &value);
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "prototype property does not appear to exist or has wrong type");
return JS_FALSE;
diff --git a/gi/object.c b/gi/object.c
index ea8bfed..608236f 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -1920,6 +1920,7 @@ gjs_define_object_class(JSContext *context,
}
if (gjs_object_get_property(context, in_object, constructor_name, &value)) {
+ jsid prototype_name;
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "Existing property '%s' does not look like a constructor",
@@ -1930,7 +1931,9 @@ gjs_define_object_class(JSContext *context,
constructor = JSVAL_TO_OBJECT(value);
- gjs_object_get_property(context, constructor, "prototype", &value);
+ prototype_name = gjs_runtime_get_const_string(JS_GetRuntime(context),
+ GJS_STRING_PROTOTYPE);
+ JS_GetPropertyById(context, constructor, prototype_name, &value);
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "prototype property does not appear to exist or has wrong type");
g_base_info_unref((GIBaseInfo*)info);
diff --git a/gi/param.c b/gi/param.c
index 871f6c0..5034900 100644
--- a/gi/param.c
+++ b/gi/param.c
@@ -32,6 +32,7 @@
#include "gtype.h"
#include <gjs/gjs-module.h>
#include <gjs/compat.h>
+#include <gjs/runtime.h>
#include <util/log.h>
@@ -486,6 +487,8 @@ gjs_define_param_class(JSContext *context,
gjs_object_get_property(context, in_object, constructor_name, &value);
if (!JSVAL_IS_VOID(value)) {
+ jsid prototype_name;
+
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "Existing property '%s' does not look like a constructor",
constructor_name);
@@ -494,7 +497,9 @@ gjs_define_param_class(JSContext *context,
constructor = JSVAL_TO_OBJECT(value);
- gjs_object_get_property(context, constructor, "prototype", &value);
+ prototype_name = gjs_runtime_get_const_string(JS_GetRuntime(context),
+ GJS_STRING_PROTOTYPE);
+ JS_GetPropertyById(context, constructor, prototype_name, &value);
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "prototype property does not appear to exist or has wrong type");
return JS_FALSE;
diff --git a/gi/union.c b/gi/union.c
index a8799e7..7472c99 100644
--- a/gi/union.c
+++ b/gi/union.c
@@ -33,6 +33,7 @@
#include "object.h"
#include <gjs/gjs-module.h>
#include <gjs/compat.h>
+#include <gjs/runtime.h>
#include "repo.h"
#include "proxyutils.h"
#include "function.h"
@@ -413,6 +414,8 @@ gjs_define_union_class(JSContext *context,
constructor_name = g_base_info_get_name( (GIBaseInfo*) info);
if (gjs_object_get_property(context, in_object, constructor_name, &value)) {
+ jsid prototype_name;
+
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "Existing property '%s' does not look like a constructor",
constructor_name);
@@ -421,7 +424,9 @@ gjs_define_union_class(JSContext *context,
constructor = JSVAL_TO_OBJECT(value);
- gjs_object_get_property(context, constructor, "prototype", &value);
+ prototype_name = gjs_runtime_get_const_string(JS_GetRuntime(context),
+ GJS_STRING_PROTOTYPE);
+ JS_GetPropertyById(context, constructor, prototype_name, &value);
if (!JSVAL_IS_OBJECT(value)) {
gjs_throw(context, "union %s prototype property does not appear to exist or has wrong type",
constructor_name);
return JS_FALSE;
diff --git a/gjs/jsapi-dynamic-class.c b/gjs/jsapi-dynamic-class.c
index ab8c530..35bf713 100644
--- a/gjs/jsapi-dynamic-class.c
+++ b/gjs/jsapi-dynamic-class.c
@@ -31,6 +31,7 @@
#include "jsapi-util.h"
#include "compat.h"
#include "jsapi-private.h"
+#include "runtime.h"
#include <string.h>
#include <math.h>
@@ -50,12 +51,15 @@ gjs_new_object_for_constructor(JSContext *context,
jsval callee;
JSObject *parent;
jsval prototype;
+ jsid prototype_name;
callee = JS_CALLEE(context, vp);
parent = JS_GetParent(JSVAL_TO_OBJECT (callee));
- if (!gjs_object_get_property(context, JSVAL_TO_OBJECT (callee), "prototype",
- &prototype))
+ prototype_name = gjs_runtime_get_const_string(JS_GetRuntime(context),
+ GJS_STRING_PROTOTYPE);
+ if (!JS_GetPropertyById(context, JSVAL_TO_OBJECT(callee), prototype_name,
+ &prototype))
return NULL;
return JS_NewObjectWithGivenProto(context, clasp,
diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
index 35a9000..fe1083c 100644
--- a/gjs/jsapi-util.c
+++ b/gjs/jsapi-util.c
@@ -31,6 +31,7 @@
#include "jsapi-util.h"
#include "compat.h"
#include "jsapi-private.h"
+#include "runtime.h"
#include <string.h>
#include <math.h>
@@ -204,14 +205,17 @@ gjs_throw_abstract_constructor_error(JSContext *context,
{
jsval callee;
jsval prototype;
+ jsid prototype_name;
JSClass *proto_class;
const char *name = "anonymous";
callee = JS_CALLEE(context, vp);
if (JSVAL_IS_OBJECT(callee)) {
- if (gjs_object_get_property(context, JSVAL_TO_OBJECT(callee),
- "prototype", &prototype)) {
+ prototype_name = gjs_runtime_get_const_string(JS_GetRuntime(context),
+ GJS_STRING_PROTOTYPE);
+ if (JS_GetPropertyById(context, JSVAL_TO_OBJECT(callee),
+ prototype_name, &prototype)) {
proto_class = JS_GetClass(JSVAL_TO_OBJECT(prototype));
name = proto_class->name;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]