Hello,
I have a little problem with this code :
#include <exception>
#include <string>
#include <v8/v8.h>
using namespace v8;
class Engine
{
private:
Persistent<Context> context;
public:
Engine()
{
context = Context::New();
}
Handle<Value> Run(const std::string& scriptContent)
{
Context::Scope contextScope(context);
HandleScope handleScope;
Handle<String> source = String::New(scriptContent.c_str());
Handle<Script> script = Script::Compile(source);
TryCatch trycatch;
Handle<Value> result = script->Run();
if (result.IsEmpty())
{
Handle<Value> exception = trycatch.Exception();
String::AsciiValue exceptionString(exception);
throw std::exception(*exceptionString);
}
return handleScope.Close(result);
}
~Engine()
{
context.Dispose();
}
};
int main(int argc, char* argv[])
{
Engine engine;
HandleScope handleScope;
Handle<Value> str = engine.Run("42;");
String::AsciiValue ascii(str);
printf("%s", *ascii);
return 0;
}
I am using Visual Studio 2008 and this code crashes at the conversion
to AsciiValue and the debugger breaks at line 38 in contexts.cc inside
Context::builtins() : GlobalObject* object = global();
What I would like to create is a little class which would load
configuration scripts and keep the context so that I can retrieve the
config data for my application.
Thanks for any help!
Remi Gillig.
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users