2009-12-18 02:48:06 -05:00
|
|
|
#include "v8_obj.h"
|
|
|
|
#include "v8_ref.h"
|
|
|
|
#include "converters.h"
|
|
|
|
|
|
|
|
using namespace v8;
|
|
|
|
|
2009-12-25 21:59:46 -05:00
|
|
|
#include <cstdio>
|
|
|
|
|
2009-12-18 02:48:06 -05:00
|
|
|
VALUE V8_C_Object;
|
|
|
|
|
|
|
|
VALUE v8_Object_New(VALUE clazz) {
|
|
|
|
HandleScope handles;
|
|
|
|
return V8_Ref_Create(clazz, Object::New());
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE v8_Object_Get(VALUE self, VALUE key) {
|
|
|
|
HandleScope handles;
|
|
|
|
Local<Object> obj = V8_Ref_Get<Object>(self);
|
|
|
|
VALUE keystr = rb_funcall(key,rb_intern("to_s"), 0);
|
2009-12-20 12:31:02 -05:00
|
|
|
Local<Value> value = obj->Get(RB2V8(keystr));
|
|
|
|
return V82RB(value);
|
2009-12-18 02:48:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE v8_Object_Set(VALUE self, VALUE key, VALUE value) {
|
|
|
|
HandleScope handles;
|
|
|
|
Local<Object> obj = V8_Ref_Get<Object>(self);
|
|
|
|
VALUE keystr = rb_funcall(key, rb_intern("to_s"), 0);
|
2009-12-25 21:59:46 -05:00
|
|
|
|
|
|
|
obj->Set(RB2V8(keystr), RB2V8(value));
|
2009-12-18 02:48:06 -05:00
|
|
|
return Qnil;
|
|
|
|
}
|