Permalink
Browse files

Naming and formatting nitpicks.

  • Loading branch information...
1 parent 145f24d commit 78f8bf92745f1a4d5fac8a22563ef909992afee1 @jbarnette committed Apr 18, 2008
Showing with 10 additions and 7 deletions.
  1. +3 −3 ext/spidermonkey/conversions.c
  2. +7 −4 ext/spidermonkey/js_land_proxy.c
@@ -94,14 +94,14 @@ jsval convert_to_js(OurContext* context, VALUE ruby)
static VALUE make_ruby_regexp(OurContext* context, jsval regexp)
{
- JSRegExp * re = (JSRegExp *)JS_GetPrivate(context->js, JSVAL_TO_OBJECT(regexp));
+ JSRegExp* re = (JSRegExp*)JS_GetPrivate(context->js, JSVAL_TO_OBJECT(regexp));
return rb_funcall(rb_cRegexp, rb_intern("new"), 2,
rb_str_new2(JS_GetStringBytes(re->source)),
INT2NUM(re->flags));
}
-static JSBool js_value_is_a_regexp(OurContext* context, jsval maybe_regexp)
+static JSBool js_value_is_regexp(OurContext* context, jsval maybe_regexp)
{
return JS_InstanceOf(context->js, JSVAL_TO_OBJECT(maybe_regexp), &js_RegExpClass, NULL);
}
@@ -149,7 +149,7 @@ VALUE convert_to_ruby(OurContext* context, jsval js)
if (js_value_is_proxy(context, js))
return unwrap_js_land_proxy(context, js);
- if (js_value_is_a_regexp(context, js))
+ if (js_value_is_regexp(context, js))
return make_ruby_regexp(context, js);
return make_ruby_land_proxy(context, js);
@@ -56,9 +56,9 @@ static JSBool get(JSContext* js_context, JSObject* obj, jsval id, jsval* retval)
// if the Ruby object has a dynamic js property with a key
// matching the property we're looking for, pull the value out of
// that map.
+
if (rb_funcall(ruby_context, rb_intern("autovivified?"), 2, self, ID2SYM(ruby_id)))
{
-
*retval = convert_to_js(context,
rb_funcall(ruby_context, rb_intern("autovivified"), 2, self, ID2SYM(ruby_id)));
}
@@ -137,8 +137,11 @@ static JSBool set(JSContext* js_context, JSObject* obj, jsval id, jsval* value)
// (it responds to "[]="), assign it by key
rb_funcall(self, rb_intern("[]="), 2, ruby_key, convert_to_ruby(context, *value));
- } else {
- rb_funcall(ruby_context, rb_intern("autovivify"), 3, self, ruby_key, convert_to_ruby(context, *value));
+ }
+ else
+ {
+ rb_funcall(ruby_context, rb_intern("autovivify"), 3, self,
+ ruby_key, convert_to_ruby(context, *value));
}
return JS_TRUE;
@@ -183,7 +186,7 @@ static JSBool method_missing(JSContext* js_context, JSObject* obj, uintN argc, j
VALUE ruby_id = rb_intern(key);
- // FIXME: this is horrible and lazy, to_a comes from enumerable on proxy
+ // FIXME: this is horrible and lazy, to_a comes from enumerable on proxy (argv[1] is a JSArray)
VALUE args = rb_funcall(convert_to_ruby(context, argv[1]), rb_intern("to_a"), 0);
// Context#jsend: if the last arg is a function, it'll get passed along as a &block

0 comments on commit 78f8bf9

Please sign in to comment.