Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
View
8 ext/v8/converters.cpp
@@ -9,6 +9,8 @@ namespace {
std::string UNDEFINED_STR("undefined");
}
+VALUE V8_To;
+
VALUE V82RB(Handle<Value>& value) {
convert_v8_to_rb_t convert;
VALUE result;
@@ -42,9 +44,13 @@ Local<Value> RB2V8(VALUE value) {
int len = RARRAY(methods)->len;
for (int i = 0; i < len; i++) {
VALUE method_name = RARRAY(methods)->ptr[i];
+ VALUE camel_method_name = rb_funcall(V8_To, rb_intern("camelcase"), 1, method_name);
VALUE method = rb_funcall(value, rb_intern("method"), 1, method_name);
Local<String> keystr = (String *)*RB2V8(method_name);
- tmpl->Set(keystr, RB2V8(method));
+ Local<String> camelstr = (String *)*RB2V8(camel_method_name);
+ Local<Value> fun = RB2V8(method);
+ tmpl->Set(keystr, fun);
+ tmpl->Set(camelstr, fun);
}
return tmpl->NewInstance();
}
View
2  ext/v8/converters.h
@@ -6,6 +6,8 @@
#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;
View
3  ext/v8/v8.cpp
@@ -6,6 +6,7 @@
#include "v8_script.h"
#include "v8_template.h"
#include "v8_standalone.h"
+#include "converters.h"
#include <stdio.h>
@@ -29,6 +30,8 @@ extern "C" {
rb_mModule = rb_define_module("V8");
rb_define_singleton_method(rb_mModule, "what_is_this?", (VALUE(*)(...)) v8_what_is_this, 1);
+
+ V8_To = rb_define_module_under(rb_mModule, "To");
//native module setup
VALUE rb_mNative = rb_define_module_under(rb_mModule, "C");
View
4 lib/v8/to.rb
@@ -20,6 +20,10 @@ def v8(value)
value
end
end
+
+ def camelcase(str)
+ str.to_s.gsub(/_(\w)/) {$1.upcase}
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.