How we can pass the readed content of a file(as a string variable) to a
javascript funcrion ??
#include <v8.h>
#include <stdio.h>
#include <stdlib.h>>
#include <iostream>
#include <fstream>
#include <string>
using namespace v8;
int main(int argc, char* argv[])
{
HandleScope handle_scope;
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
Local<String> source;
Local<Script> script;
Local<Value> result;
source = String::New("function test_function() { var
ans=arguments[0];return ans;}");
script = Script::Compile(source);
result = script->Run();
context.Dispose();
Handle<v8::Object> global = context->Global();
Handle<v8::Value> value = global->Get(String::New("test_function"));
Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(value);
Handle<Value> args[1];
Handle<Value> js_result;
// Code to read file
std::ifstream file("flare.json");
std::string str;
std::string file_contents;
while (std::getline(file, str))
{
file_contents += str;
file_contents.push_back('\n');
}
std::cout<<file_contents;
// End of Code to read file
args[0] = v8::String::New(file_contents);
std::string final_result;
js_result = func->Call(global, 1, args); * // it showing the error hear
: no matching function for call to ‘v8::String::New(std::string&)’\\*
String::AsciiValue ascii(js_result);
printf("This is the out put of JAVASCRIPT FUNCTION:%s\n\n", *ascii);
return 0;
}
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.