diff --git a/ruby_data.h b/ruby_data.h index b450b82..0e2a3e8 100644 --- a/ruby_data.h +++ b/ruby_data.h @@ -2,6 +2,8 @@ #define __ruby_data_h__ #include +#include +#include template class RubyDataSource { @@ -36,8 +38,8 @@ class RubyDest { RubyDest(); ~RubyDest(); - VALUE pushString(const char* value, const char* name=0) { - return Qnil; + VALUE pushString(std::string value, const char* name=0) { + return rb_str_new2(value.c_str()); } VALUE pushInt(int64_t value, const char* name=0) { diff --git a/v8_data.h b/v8_data.h index b492cb7..bc2e93b 100644 --- a/v8_data.h +++ b/v8_data.h @@ -4,6 +4,7 @@ #include "v8.h" #include "stdint.h" #include +#include template class V8HandleSource { @@ -30,8 +31,16 @@ template class V8HandleSource { } if(value->IsString()) { - //v8::Local strValue(value->ToString()); - return dest.pushString("", name); + v8::Local str = value->ToString(); + char buffer[1024]; + int strlen = str->Length(); + std::string output; + for (int total = 0; total < strlen;) { + int written = str->WriteAscii(buffer, 0, 1024); + output.append(buffer, written); + total += written; + } + return dest.pushString(output, name); } if(value->IsInt32()) {