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

26 lines
670 B
C++
Raw Normal View History

2012-05-02 19:15:11 -04:00
#include "rr.h"
namespace rr {
void String::Init() {
ClassBuilder("String", Value::Class).
defineSingletonMethod("New", &New).
2012-05-09 14:12:44 -04:00
defineSingletonMethod("Concat", &Concat).
2012-05-08 17:04:47 -04:00
defineMethod("Utf8Value", &Utf8Value).
store(&Class);
}
VALUE String::New(VALUE StringClass, VALUE string) {
return String(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());
2012-05-02 19:15:11 -04:00
}
2012-05-09 14:12:44 -04:00
VALUE String::Concat(VALUE self, VALUE left, VALUE right) {
return String(v8::String::Concat(String(left), String(right)));
2012-05-09 14:12:44 -04:00
}
} //namespace rr