Skip to content

Commit

Permalink
Configurably, always invoke for 0-arity methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewd committed Sep 19, 2009
1 parent 5692134 commit d61720e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ext/spidermonkey/js_land_proxy.c
Expand Up @@ -144,7 +144,7 @@ static bool attribute_p(VALUE self, char* name)
}

return RTEST(rb_funcall(Johnson_SpiderMonkey_JSLandProxy(),
rb_intern("js_property?"), 2, self, ID2SYM(rb_id)));
rb_intern("js_property?"), 3, self, ID2SYM(rb_id), rb_method));
}

static bool indexable_p(VALUE self)
Expand Down
5 changes: 3 additions & 2 deletions lib/johnson/spidermonkey/js_land_proxy.rb
Expand Up @@ -10,9 +10,10 @@ def self.treat_all_properties_as_methods(target)
def target.js_property?(name); true; end
end

def self.js_property?(target, name)
def self.js_property?(target, name, method)
# FIXME: that rescue is gross; handles, e.g., "name?"
(target.send(:instance_variable_defined?, "@#{name}") rescue false) ||
(Johnson::SpiderMonkey::Runtime.invoke_zero_arity? && method.arity == 0) ||
(target.send(:instance_variable_defined?, "@#{name}") rescue false) ||
(target.respond_to?(:js_property?) && target.__send__(:js_property?, name))
end

Expand Down
2 changes: 2 additions & 0 deletions lib/johnson/spidermonkey/runtime.rb
Expand Up @@ -19,6 +19,8 @@ def remove_gcthing(object_id)
@gcthings.delete(object_id) if defined? @gcthings
end

def self.invoke_zero_arity= v; @invoke_zero_arity = v; end
def self.invoke_zero_arity?; @invoke_zero_arity ||= false; end

def current_context
@context ||= Context.new(self)
Expand Down

0 comments on commit d61720e

Please sign in to comment.