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

Commit

Permalink
reducing the iterator code
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Apr 21, 2008
1 parent d86c757 commit 63b6e8d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ext/spidermonkey/js_land_proxy.c
Expand Up @@ -123,6 +123,14 @@ static JSBool respond_to_p(JSContext* js_context, JSObject* obj, char* name)
|| has_key_p(self, name);
}

static jsval property_get(OurContext * context, char * property) {
jsval retval;
JSBool ok = JS_EvaluateScript(context->js, context->global,
property, strlen(property), NULL, 1,
&retval);
return retval;
}

static JSBool get(JSContext* js_context, JSObject* obj, jsval id, jsval* retval)
{
// pull out our Ruby context, which is embedded in js_context
Expand Down Expand Up @@ -161,15 +169,7 @@ static JSBool get(JSContext* js_context, JSObject* obj, jsval id, jsval* retval)
// FIXME: we should probably just JS_DefineProperty this, and it shouldn't be enumerable

if (!strcasecmp("__iterator__", name)) {
jsval nsJohnson;
assert(JS_GetProperty(context->js, context->global, "Johnson", &nsJohnson) || JSVAL_VOID == nsJohnson);

jsval nsGenerator;
assert(JS_GetProperty(context->js, JSVAL_TO_OBJECT(nsJohnson), "Generator", &nsGenerator) || JSVAL_VOID == nsGenerator);

jsval create;
assert(JS_GetProperty(context->js, JSVAL_TO_OBJECT(nsGenerator), "create", &create) || JSVAL_VOID == create);
*retval = create;
*retval = property_get(context, "Johnson.Generator.create");
return JS_TRUE;
}

Expand Down

0 comments on commit 63b6e8d

Please sign in to comment.