Skip to content
This repository has been archived by the owner on Aug 18, 2018. It is now read-only.

Commit

Permalink
Make JSLandProxyClass more easily parameterizable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarnette committed Apr 16, 2008
1 parent 510f1b5 commit 109858e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ext/spidermonkey/js_land_proxy.c
Expand Up @@ -31,7 +31,7 @@ static JSBool get(JSContext* js_context, JSObject* obj, jsval id, jsval* retval)
// get the Ruby object that backs this proxy

VALUE self;
assert(self = (VALUE)JS_GetInstancePrivate(context->js, obj, &JSLandProxyClass, NULL));
assert(self = (VALUE)JS_GetInstancePrivate(context->js, obj, JS_GET_CLASS(context->js, obj), NULL));

char* key = JS_GetStringBytes(JSVAL_TO_STRING(id));
VALUE ruby_id = rb_intern(key);
Expand Down Expand Up @@ -92,7 +92,7 @@ static JSBool set(JSContext* js_context, JSObject* obj, jsval id, jsval* value)
Data_Get_Struct(ruby_context, OurContext, context);

VALUE self;
assert(self = (VALUE)JS_GetInstancePrivate(context->js, obj, &JSLandProxyClass, NULL));
assert(self = (VALUE)JS_GetInstancePrivate(context->js, obj, JS_GET_CLASS(context->js, obj), NULL));

char* key = JS_GetStringBytes(JSVAL_TO_STRING(id));
VALUE ruby_key = rb_str_new2(key);
Expand Down Expand Up @@ -137,7 +137,7 @@ static JSBool method_missing(JSContext* js_context, JSObject* obj, uintN argc, j
Data_Get_Struct(ruby_context, OurContext, context);

VALUE self;
assert(self = (VALUE)JS_GetInstancePrivate(context->js, obj, &JSLandProxyClass, NULL));
assert(self = (VALUE)JS_GetInstancePrivate(context->js, obj, JS_GET_CLASS(context->js, obj), NULL));

char* key = JS_GetStringBytes(JSVAL_TO_STRING(argv[0]));

Expand All @@ -162,7 +162,11 @@ JSBool js_value_is_proxy(OurContext* context, jsval maybe_proxy)
VALUE unwrap_js_land_proxy(OurContext* context, jsval proxy)
{
VALUE value;
assert(value = (VALUE)JS_GetInstancePrivate(context->js, JSVAL_TO_OBJECT(proxy), &JSLandProxyClass, NULL));
JSObject *proxy_object = JSVAL_TO_OBJECT(proxy);

assert(value = (VALUE)JS_GetInstancePrivate(context->js, proxy_object,
JS_GET_CLASS(context->js, proxy_object), NULL));

return value;
}

Expand All @@ -176,7 +180,8 @@ static void finalize(JSContext* js_context, JSObject* obj)
Data_Get_Struct(ruby_context, OurContext, context);

VALUE self;
assert(self = (VALUE)JS_GetInstancePrivate(context->js, obj, &JSLandProxyClass, NULL));
assert(self = (VALUE)JS_GetInstancePrivate(context->js, obj,
JS_GET_CLASS(context->js, obj), NULL));

// remove the proxy OID from the id map
JS_HashTableRemove(context->rbids, (void *)rb_obj_id(self));
Expand Down

0 comments on commit 109858e

Please sign in to comment.