2012-05-02 19:15:11 -04:00
|
|
|
#include "rr.h"
|
|
|
|
|
|
|
|
namespace rr {
|
2012-05-03 03:24:15 -04:00
|
|
|
VALUE StringClass;
|
2012-05-02 19:15:11 -04:00
|
|
|
namespace {
|
|
|
|
VALUE New(VALUE StringClass, VALUE string) {
|
2012-05-03 03:24:15 -04:00
|
|
|
v8::HandleScope h;
|
|
|
|
return String::ToRuby(v8::String::New(RSTRING_PTR(string), (int)RSTRING_LEN(string)));
|
2012-05-02 19:15:11 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-03 03:24:15 -04:00
|
|
|
VALUE String::ToRuby(v8::Handle<v8::String> string) {
|
|
|
|
return String::create(string, StringClass);
|
|
|
|
}
|
|
|
|
|
2012-05-02 19:15:11 -04:00
|
|
|
void String::Init() {
|
2012-05-03 03:24:15 -04:00
|
|
|
rb_gc_register_address(&StringClass);
|
|
|
|
StringClass = defineClass("String");
|
2012-05-02 19:15:11 -04:00
|
|
|
RR_DEFINE_SINGLETON_METHOD(StringClass, "New", &New, 1);
|
|
|
|
}
|
|
|
|
}
|