2009-12-07 16:06:06 +02:00
|
|
|
|
|
|
|
#include "v8_str.h"
|
|
|
|
#include "v8.h"
|
|
|
|
#include "v8_ref.h"
|
|
|
|
|
|
|
|
using namespace v8;
|
|
|
|
|
2010-05-10 07:56:52 -05:00
|
|
|
void rr_init_str() {
|
|
|
|
VALUE String = rr_define_class("String");
|
2010-05-10 10:16:26 -05:00
|
|
|
rr_define_singleton_method(String, "new", v8_str_new, 1);
|
|
|
|
rr_define_method(String, "to_s", v8_str_to_s, 0);
|
2010-05-10 07:56:52 -05:00
|
|
|
}
|
|
|
|
|
2009-12-07 16:06:06 +02:00
|
|
|
VALUE v8_str_new(VALUE clazz, VALUE str) {
|
|
|
|
HandleScope handles;
|
2010-02-11 17:14:47 -06:00
|
|
|
return V8_Ref_Create(clazz, String::New(RSTRING_PTR(str)));
|
2009-12-07 16:06:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VALUE v8_str_to_s(VALUE self){
|
|
|
|
HandleScope handles;
|
2009-12-13 17:08:55 +02:00
|
|
|
Local<String> str = V8_Ref_Get<String>(self);
|
2009-12-07 16:06:06 +02:00
|
|
|
return rb_str_new2(*String::AsciiValue(str));
|
|
|
|
}
|