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

begin converting Arguments class.

This commit is contained in:
Charles Lowell 2010-05-18 20:50:59 +03:00
parent 7cf117adf3
commit 2057383dfe
5 changed files with 11 additions and 9 deletions

View file

@ -51,6 +51,7 @@ namespace {
if (FIX2INT(rb_funcall(method, rb_intern("arity"), 0)) == 0) {
return Racer_Call_Ruby_Method(object, name, Array::New(0));
} else {
//causes out of memory if we use rr_rb2v8
return RB2V8(method);
}
}
@ -64,6 +65,7 @@ Handle<Value> RacerRubyInvocationCallback(const Arguments& args) {
VALUE* arguments = new VALUE[args.Length()];
for(int c=0;c<args.Length(); ++c) {
Handle<Value> val = args[c];
// arguments[c] = rr_v82rb(val); // segfaults... why?
arguments[c] = V82RB(val);
}
@ -89,6 +91,7 @@ Handle<Value> RacerRubyNamedPropertyGetter(Local<String> property, const Accesso
return Handle<Value>();
}
VALUE object = unwrap(info);
// VALUE camel_name = rr_v82rb(property); //segfaults. why??
VALUE camel_name = V82RB((Local<Value>&)property);
VALUE perl_name = rr_str_to_perl_case(camel_name);
// VALUE perl_name = rb_funcall(V8_To, rb_intern("perl_case"), 1, camel_name);
@ -176,7 +179,7 @@ Handle<Array> RacerRubyNamedPropertyEnumerator(const AccessorInfo& info) {
for (int i = 0; i < length; i++) {
// VALUE camel_name = rb_funcall(V8_To, rb_intern("camel_case"), 1, rb_ary_entry(methods, i));
VALUE camel_name = rr_str_to_camel_case(rb_ary_entry(methods, i));
properties->Set(Integer::New(i), RB2V8(camel_name));
properties->Set(Integer::New(i), rr_rb2v8(camel_name));
}
return properties;
}

View file

@ -28,7 +28,7 @@ VALUE rr_str_to_camel_case(VALUE str) {
}
VALUE rr_v82rb(Handle<Value> value) {
if (value->IsUndefined() || value->IsNull()) {
if (value.IsEmpty() || value->IsUndefined() || value->IsNull()) {
return Qnil;
}
if (value->IsUint32()) {

View file

@ -8,6 +8,7 @@
#include "v8_script.h"
#include "v8_template.h"
#include "v8_try_catch.h"
#include "v8_arguments.h"
#include "converters.h"
#include <stdio.h>
@ -27,6 +28,7 @@ extern "C" {
rr_init_func();
rr_init_v8_array();
rr_init_msg();
rr_init_v8_try_catch();
rr_init_v8_try_catch();
rr_init_v8_arguments();
}
}

View file

@ -56,9 +56,6 @@ v8::Handle<v8::Value> rr_reflect_rb_object(VALUE value) {
return o;
}
namespace {
}
VALUE v8_Object_New(VALUE clazz) {
HandleScope handles;
return V8_Ref_Create(clazz, Object::New());
@ -69,7 +66,7 @@ VALUE v8_Object_Set(VALUE self, VALUE key, VALUE value) {
Local<Object> obj = unwrap(self);
VALUE keystr = rb_funcall(key, rb_intern("to_s"), 0);
obj->Set(RB2V8(keystr), RB2V8(value));
obj->Set(rr_rb2v8(keystr), RB2V8(value));
return Qnil;
}
@ -77,7 +74,7 @@ VALUE v8_Object_GetPropertyNames(VALUE self) {
HandleScope handles;
Local<Object> object = unwrap(self);
Local<Value> names = object->GetPropertyNames();
return V82RB(names);
return rr_v82rb(names);
}
VALUE v8_Object_ToString(VALUE self) {

View file

@ -28,7 +28,7 @@ module V8
end
def each
for prop in @native.GetPropertyNames()
for prop in To.ruby(@native.GetPropertyNames())
yield prop, self[prop]
end
end