Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Newer API in V8 version 7.6 #131

Closed
pmed opened this issue Dec 15, 2019 · 2 comments
Closed

Newer API in V8 version 7.6 #131

pmed opened this issue Dec 15, 2019 · 2 comments

Comments

@pmed
Copy link
Owner

pmed commented Dec 15, 2019

For example for v8::String::NewFromUtf8()

pmed added a commit that referenced this issue Dec 15, 2019
to support V8 version 7.6 and newer

See issue #131
@lemmel
Copy link

lemmel commented Apr 18, 2020

Hi !

I'm discovering your project (with no prior experience with the v8 engine) and I was making some wrapping when I tested something like this:

int f(int x) { return x * 2; }

v8::Isolate* isolate = v8::Isolate::GetCurrent();

v8::Local<v8::Function> v8_fun = v8pp::wrap_function(isolate, "f", &f);
isolate->GetCurrentContext()-> Global()->Set(v8pp::to_v8(isolate, "v8_fun"), v8_fun);

That is coming from the documentation: https://github.com/pmed/v8pp/blob/master/docs/wrapping.md

The problem is that the Set methods signatures are:

  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
                                        Local<Value> key, Local<Value> value);

  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
                                        Local<Value> value);

A context is required and I can't achieve to access to the context, and thus give it to v8.

Is that a result of the new version of v8 API, or am I missing something ?

@pmed
Copy link
Owner Author

pmed commented May 1, 2020

Hi,

the documentation seems to be outdated, because of the changes in V8 API. That deprecated method v8::Object::Set(key, value) was removed in the newer V8 releases. So you could try to use the newer one, with the additional context argument.

There is at least one context in a V8 Isolate, that could be accessed with a function named literally GetCurrentContext(). I would try to use it.

@pmed pmed closed this as completed Aug 15, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants