diff --git a/ext/v8/callbacks.cpp b/ext/v8/callbacks.cpp index f080b6b..091c691 100644 --- a/ext/v8/callbacks.cpp +++ b/ext/v8/callbacks.cpp @@ -1,4 +1,4 @@ -#include +#include "rr.h" #include "callbacks.h" #include "converters.h" @@ -90,7 +90,8 @@ Handle RacerRubyNamedPropertyGetter(Local property, const Accesso } VALUE object = unwrap(info); VALUE camel_name = V82RB((Local&)property); - VALUE perl_name = rb_funcall(V8_To, rb_intern("perl_case"), 1, camel_name); + VALUE perl_name = rr_str_to_perl_case(camel_name); + // VALUE perl_name = rb_funcall(V8_To, rb_intern("perl_case"), 1, camel_name); VALUE methods = CALLABLE_METHODS(object); if (RTEST(rb_ary_includes(methods, perl_name))) { @@ -116,7 +117,8 @@ Handle RacerRubyNamedPropertySetter(Local property, Local Local setter_name = String::New(setter.c_str()); VALUE object = unwrap(info); VALUE camel_name = V82RB((Local&)setter_name); - VALUE perl_name = rb_funcall(V8_To, rb_intern("perl_case"), 1, camel_name); + VALUE perl_name = rr_str_to_perl_case(camel_name); + // VALUE perl_name = rb_funcall(V8_To, rb_intern("perl_case"), 1, camel_name); VALUE methods = CALLABLE_METHODS(object); Local args = Array::New(1); args->Set(Integer::New(0), value); @@ -143,7 +145,8 @@ Handle RacerRubyNamedPropertyQuery(Local property, const Access VALUE object = unwrap(info); VALUE methods = CALLABLE_METHODS(object); VALUE attr_name = V82RB((Local&)property); - VALUE perl_name = rb_funcall(V8_To, rb_intern("perl_case"), 1, attr_name); + // VALUE perl_name = rb_funcall(V8_To, rb_intern("perl_case"), 1, attr_name); + VALUE perl_name = rr_str_to_perl_case(attr_name); if (RTEST(rb_ary_includes(methods, attr_name)) || RTEST(rb_ary_includes(methods, perl_name))) { return True(); @@ -171,7 +174,8 @@ Handle RacerRubyNamedPropertyEnumerator(const AccessorInfo& info) { int length = RARRAY_LEN(methods); Local 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)); + // 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)); } return properties; diff --git a/ext/v8/converters.cpp b/ext/v8/converters.cpp index cd88eb4..05c9632 100644 --- a/ext/v8/converters.cpp +++ b/ext/v8/converters.cpp @@ -12,8 +12,6 @@ namespace { std::string UNDEFINED_STR("undefined"); } -VALUE V8_To; - VALUE V82RB(Handle& value) { convert_v8_to_rb_t convert; VALUE result; diff --git a/ext/v8/converters.h b/ext/v8/converters.h index f43df98..c0f79cb 100644 --- a/ext/v8/converters.h +++ b/ext/v8/converters.h @@ -6,8 +6,6 @@ #include "convert_v8.h" #include -extern VALUE V8_To; - typedef RubyValueSource > convert_rb_to_v8_t; typedef V8HandleSource convert_v8_to_rb_t; diff --git a/ext/v8/rr.cpp b/ext/v8/rr.cpp index 811ad77..2334e5e 100644 --- a/ext/v8/rr.cpp +++ b/ext/v8/rr.cpp @@ -4,4 +4,16 @@ VALUE rr_define_class(const char *name, VALUE superclass) { VALUE V8 = rb_define_module("V8"); VALUE V8_C = rb_define_module_under(V8, "C"); return rb_define_class_under(V8_C, name, superclass); -} \ No newline at end of file +} + +VALUE rr_str_to_perl_case(VALUE str) { + VALUE V8 = rb_define_module("V8"); + VALUE to = rb_define_module_under(V8, "To"); + return rb_funcall(to, rb_intern("perl_case"), 1, str); +} + +VALUE rr_str_to_camel_case(VALUE str) { + VALUE V8 = rb_define_module("V8"); + VALUE to = rb_define_module_under(V8, "To"); + return rb_funcall(to, rb_intern("camel_case"), 1, str); +} diff --git a/ext/v8/rr.h b/ext/v8/rr.h index e49b2d3..355615f 100644 --- a/ext/v8/rr.h +++ b/ext/v8/rr.h @@ -7,5 +7,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_str_to_perl_case(VALUE str); +VALUE rr_str_to_camel_case(VALUE str); #endif \ No newline at end of file diff --git a/ext/v8/v8.cpp b/ext/v8/v8.cpp index feeae7d..0e6e5f2 100644 --- a/ext/v8/v8.cpp +++ b/ext/v8/v8.cpp @@ -13,11 +13,8 @@ extern "C" { void Init_v8(); } -VALUE rb_mModule; - extern "C" { - void Init_v8() { - V8_To = rb_define_module_under(rb_define_module("V8"), "To"); + void Init_v8() { rr_init_cxt(); rr_init_str(); rr_init_script();