1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/ext/v8/string.cc
Charles Lowell 356b47a86f massively simplify reference creation.
make the template class define the RubyClass for
a given reference class. That way, it can define
the wrapping logic.
2012-05-15 11:46:14 -05:00

26 lines
No EOL
674 B
C++

#include "rr.h"
namespace rr {
void String::Init() {
ClassBuilder("String", "Value").
defineSingletonMethod("New", &New).
defineSingletonMethod("Concat", &Concat).
defineMethod("Utf8Value", &Utf8Value).
store(&Class);
}
VALUE String::New(VALUE StringClass, VALUE string) {
return String::create(v8::String::New(RSTRING_PTR(string), (int)RSTRING_LEN(string)));
}
VALUE String::Utf8Value(VALUE self) {
String str(self);
return rb_str_new(*v8::String::Utf8Value(str.GetHandle()), str->Utf8Length());
}
VALUE String::Concat(VALUE self, VALUE left, VALUE right) {
return Convert(v8::String::Concat(String(left), String(right)));
}
} //namespace rr