You are right. My new code:

class Browser
{
    public:
        Browser();
        void getContext();
        const char* execute(const char* data);
        int test;
    private:
        v8::Isolate* _isolate;
        v8::Persistent<v8::Context> _context;
};


Browser::Browser()
{
    v8::V8::InitializeICU();
    v8::V8::InitializeExternalStartupData("/opt/v8build/");
    v8::Platform* platform = v8::platform::CreateDefaultPlatform();
    v8::V8::InitializePlatform(platform);
    v8::V8::Initialize();

    ArrayBufferAllocator allocator;
    v8::Isolate::CreateParams create_params;
    create_params.array_buffer_allocator = &allocator;

    _isolate = v8::Isolate::New(create_params);
}

const char* Browser::execute(const char* data)
{
    v8::Isolate::Scope isolate_scope(_isolate);
    v8::HandleScope handle_scope(_isolate);

    const char* result;
    {
        v8::Local<v8::Context> context = v8::Local<v8::Context>::New(
_isolate, _context);

        v8::Context::Scope context_scope(context);

    v8::Local<v8::String> source =
    v8::String::NewFromUtf8(_isolate, data,
                            v8::NewStringType::kNormal).ToLocalChecked();

    v8::Local<v8::Script> script = v8::Script::Compile(context, source).
ToLocalChecked();
    v8::Local<v8::Value> result = script->Run(context).ToLocalChecked();
    v8::String::Utf8Value utf8(result);

    // Konwersja danych do char*
    int len = utf8.length() + 1;
    char *str = (char *) calloc(sizeof(char), len);
    strncpy(str, *utf8, len);

    return str;
    }

    return result;
}


Result is error

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5998d9e in v8::Context::Enter() () from /opt/v8build/hello.so




W dniu piątek, 18 marca 2016 09:22:21 UTC+1 użytkownik Ben Noordhuis 
napisał:
>
> On Wed, Mar 16, 2016 at 1:45 PM, Daniel Burchardt 
> <[email protected] <javascript:>> wrote: 
> > It's not posible because: 
> > 
> > error: no matching function for call to ‘v8::Context::New(v8::Isolate*&, 
> > v8::Persistent<v8::Context>&) 
> > 
> > V8::GetVersion - 4.10.0 (candidate) 
>
> It looks like you didn't copy Danny's example correctly.  It should be: 
>
>   v8::Local<v8::Context> context = 
>       v8::Local<v8::Context>::New(isolate, persistent_context); 
>
> Note that you call v8::Local<T>::New (with T=v8::Context), not 
> v8::Context::New. 
>

-- 
-- 
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.

Reply via email to