Skip to content

Conversation

@MoonBall
Copy link
Contributor

@MoonBall MoonBall commented Jan 14, 2022

modify doc

@MoonBall MoonBall changed the title fix example fix doc Jan 14, 2022
```c++
V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(Local<Context> context) const;
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToNumber(Local<String> context) const;
V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(Local<Context> context) const;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contains a number of Local/Handle's (think pointers to objects but is managed
by V8) and will take care of deleting the Local/Handles for us. HandleScopes
are stack allocated
Contains a number of local handles (like pointers to objects but are managed
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In v8's source code, they use local handles rather than Local/Handles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Local is essentially equivalent to Handle. The difference of them is Local is an outer api and Handle is an inner api.

So we can simplify the doc by omitting the Local.

We can cast from a subtype to a supertype using Local::Cast:
```c++
v8::Local<v8::Number> nr = v8::Local<v8::Number>(v8::Number::New(isolate_, 12));
v8::Local<v8::Number> nr = v8::Number::New(isolate_, 12);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since v8::Number::New return v8::Local<v8::Number>, we can remove unnecessary type conversion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant