mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
remove all global references from the main extension file
This commit is contained in:
parent
23771c070f
commit
b251a0b83a
6 changed files with 25 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
|||
#include <ruby.h>
|
||||
#include "rr.h"
|
||||
|
||||
#include "callbacks.h"
|
||||
#include "converters.h"
|
||||
|
@ -90,7 +90,8 @@ Handle<Value> RacerRubyNamedPropertyGetter(Local<String> property, const Accesso
|
|||
}
|
||||
VALUE object = unwrap(info);
|
||||
VALUE camel_name = V82RB((Local<Value>&)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<Value> RacerRubyNamedPropertySetter(Local<String> property, Local<Value>
|
|||
Local<String> setter_name = String::New(setter.c_str());
|
||||
VALUE object = unwrap(info);
|
||||
VALUE camel_name = V82RB((Local<Value>&)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<Array> args = Array::New(1);
|
||||
args->Set(Integer::New(0), value);
|
||||
|
@ -143,7 +145,8 @@ Handle<Boolean> RacerRubyNamedPropertyQuery(Local<String> property, const Access
|
|||
VALUE object = unwrap(info);
|
||||
VALUE methods = CALLABLE_METHODS(object);
|
||||
VALUE attr_name = V82RB((Local<Value>&)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<Array> RacerRubyNamedPropertyEnumerator(const AccessorInfo& info) {
|
|||
int length = RARRAY_LEN(methods);
|
||||
Local<Array> 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;
|
||||
|
|
|
@ -12,8 +12,6 @@ namespace {
|
|||
std::string UNDEFINED_STR("undefined");
|
||||
}
|
||||
|
||||
VALUE V8_To;
|
||||
|
||||
VALUE V82RB(Handle<Value>& value) {
|
||||
convert_v8_to_rb_t convert;
|
||||
VALUE result;
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
#include "convert_v8.h"
|
||||
#include <cstring>
|
||||
|
||||
extern VALUE V8_To;
|
||||
|
||||
typedef RubyValueSource<V8LocalDest, v8::Local<v8::Value> > convert_rb_to_v8_t;
|
||||
typedef V8HandleSource<RubyValueDest, VALUE> convert_v8_to_rb_t;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue