From e6c6f4e04bb103922e6b1129bd08600d5738c59c Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Sat, 22 May 2010 09:15:00 +0300 Subject: [PATCH] add rr_define_const() --- ext/v8/rr.cpp | 10 ++++++++++ ext/v8/rr.h | 1 + 2 files changed, 11 insertions(+) diff --git a/ext/v8/rr.cpp b/ext/v8/rr.cpp index c76bb43..87675ed 100644 --- a/ext/v8/rr.cpp +++ b/ext/v8/rr.cpp @@ -17,6 +17,13 @@ VALUE rr_define_class(const char *name, VALUE superclass) { return klass; } +VALUE rr_define_const(const char *name, VALUE value) { + VALUE V8 = rb_define_module("V8"); + VALUE V8_C = rb_define_module_under(V8, "C"); + rb_define_const(V8_C, name, value); + return value; +} + VALUE rr_str_to_perl_case(VALUE str) { VALUE V8 = rb_define_module("V8"); VALUE to = rb_define_module_under(V8, "To"); @@ -30,6 +37,9 @@ VALUE rr_str_to_camel_case(VALUE str) { } VALUE rr_v82rb(Handle value) { + if (value.IsEmpty()) { + return rr_cV8_C_Empty; + } if (value.IsEmpty() || value->IsUndefined() || value->IsNull()) { return Qnil; } diff --git a/ext/v8/rr.h b/ext/v8/rr.h index cf4259f..c7ca3a2 100644 --- a/ext/v8/rr.h +++ b/ext/v8/rr.h @@ -8,6 +8,7 @@ #define rr_define_singleton_method(object, name, impl, argc) rb_define_singleton_method(object, name, (VALUE(*)(...))impl, argc) VALUE rr_define_class(const char *name, VALUE superclass = rb_cObject); +VALUE rr_define_const(const char *name, VALUE value); VALUE rr_str_to_perl_case(VALUE str); VALUE rr_str_to_camel_case(VALUE str);