Well, like a said before, the std::ostream object is not the problem, if i change the method to:
v8::Handle<v8::Value> System::log(const v8::Arguments& args)
{
for(int i = 0, s = args.Length(); i < s; ++i) {
v8::String::AsciiValue ascii(args[i]);
std::cerr << "Length: " << ascii.length() << std::endl;
std::cerr.write(*ascii,ascii.length()) << std::endl;
}
return v8::Undefined();
}
Will it print out the length without any whitespaces, e.g javascript code: System.log(" "); prints "Length: 0". However, do anyone have any idea what I can have done wrong? I am adding the method by doing something like the following, if it helps:
Handlescope handle_scope;
Persistent<Context> context = context(Context::New());
Context::Scope context_scope(context);
Local<ObjectTemplate> env = ObjectTemplate::New();
env->Set(String::New("log"), FunctionTemplate::New(&System::log)); //System.log is a static method of course
context->Global()->Set(String::New("System"), env->NewInstance());