1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

Enumerate ruby properties in javascript.

This commit is contained in:
Charles Lowell 2010-01-18 01:12:23 +02:00
parent ec985a9fc5
commit 1dd55ffa77
4 changed files with 12 additions and 4 deletions

View file

@ -148,5 +148,13 @@ Handle<Boolean> RacerRubyNamedPropertyDeleter(Local<String> property, const Acce
* property getter intercepts.
*/
Handle<Array> RacerRubyNamedPropertyEnumerator(const AccessorInfo& info) {
return Local<Array>();
VALUE object = unwrap(info);
VALUE methods = rb_funcall(object, rb_intern("public_methods"), 1, Qfalse);
int length = RARRAY_LEN(methods);
Local<Array> properties = Array::New(length);
for (int i = 0; i < length; i++) {
VALUE camel_name = rb_funcall(V8_To, rb_intern("camel_case"), 1, rb_ary_entry(methods, i));
properties->Set(Integer::New(i), RB2V8(camel_name));
}
return properties;
}

View file

@ -16,7 +16,7 @@ Local<ObjectTemplate> Racer_Create_V8_ObjectTemplate(VALUE value) {
RacerRubyNamedPropertySetter,
0, // RacerRubyNamedPropertyQuery,
0, // RacerRubyNamedPropertyDeleter,
0, // RacerRubyNamedPropertyEnumerator,
RacerRubyNamedPropertyEnumerator,
External::Wrap((void *)value)
);
return tmpl;

View file

@ -21,7 +21,7 @@ module V8
end
end
def camelcase(str)
def camel_case(str)
str.to_s.gsub(/_(\w)/) {$1.upcase}
end

@ -1 +1 @@
Subproject commit 26e3054452beb85bdb5ab6f42f1d9531f654a7d8
Subproject commit 9e8d547fc7b217f9cab0192c04753499f47fdb38