mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
reflect v8::External back into Ruby
This commit is contained in:
parent
4a372c2382
commit
1ae9f62e49
3 changed files with 10 additions and 1 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "v8_str.h"
|
||||
#include "v8_date.h"
|
||||
#include "v8_msg.h"
|
||||
#include "v8_external.h"
|
||||
|
||||
using namespace v8;
|
||||
|
||||
|
@ -29,9 +30,12 @@ VALUE rr_v82rb(Handle<Value> value) {
|
|||
if (value.IsEmpty()) {
|
||||
return rr_cV8_C_Empty;
|
||||
}
|
||||
if (value.IsEmpty() || value->IsUndefined() || value->IsNull()) {
|
||||
if (value->IsUndefined() || value->IsNull()) {
|
||||
return Qnil;
|
||||
}
|
||||
if (value->IsExternal()) {
|
||||
return rr_reflect_v8_external(value);
|
||||
}
|
||||
if (value->IsUint32()) {
|
||||
return UINT2NUM(value->Uint32Value());
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@ void rr_init_v8_external() {
|
|||
// rr_define_method(ExternalClass, "Value", _Value, 0);
|
||||
}
|
||||
|
||||
VALUE rr_reflect_v8_external(Handle<Value> external) {
|
||||
return rr_v8_ref_create(ExternalClass, external);
|
||||
}
|
||||
|
||||
Handle<Value> rr_v8_external_create(VALUE value) {
|
||||
rb_hash_aset(references, rb_obj_id(value), value);
|
||||
Local<Value> external(External::Wrap((void *)value));
|
||||
|
|
|
@ -4,5 +4,6 @@
|
|||
#include "rr.h"
|
||||
|
||||
void rr_init_v8_external();
|
||||
VALUE rr_reflect_v8_external(v8::Handle<v8::Value> value);
|
||||
v8::Handle<v8::Value> rr_v8_external_create(VALUE value);
|
||||
#endif
|
Loading…
Reference in a new issue