2012-05-02 19:15:11 -04:00
|
|
|
#include "rr.h"
|
|
|
|
|
|
|
|
namespace rr {
|
2012-05-03 18:21:25 -04:00
|
|
|
|
|
|
|
VALUE String::Class;
|
|
|
|
|
|
|
|
void String::Init() {
|
2012-05-08 17:04:47 -04:00
|
|
|
ClassBuilder("String", "Value").
|
2012-05-03 18:21:25 -04:00
|
|
|
defineSingletonMethod("New", &New).
|
2012-05-08 17:04:47 -04:00
|
|
|
defineMethod("Utf8Value", &Utf8Value).
|
|
|
|
store(&Class);
|
2012-05-03 18:21:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE String::New(VALUE StringClass, VALUE string) {
|
2012-05-08 17:17:25 -04:00
|
|
|
return String::convert(v8::String::New(RSTRING_PTR(string), (int)RSTRING_LEN(string)));
|
2012-05-03 18:21:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE String::Utf8Value(VALUE self) {
|
|
|
|
String str(self);
|
2012-05-03 18:48:49 -04:00
|
|
|
return rb_str_new(*v8::String::Utf8Value(str.GetHandle()), str->Utf8Length());
|
2012-05-02 19:15:11 -04:00
|
|
|
}
|
|
|
|
|
2012-05-08 17:17:25 -04:00
|
|
|
VALUE String::convert(v8::Handle<v8::String> string) {
|
|
|
|
return String::create(string, Class);
|
2012-05-03 03:24:15 -04:00
|
|
|
}
|
|
|
|
|
2012-05-03 17:34:51 -04:00
|
|
|
} //namespace rr
|