From 184832d8cc25877ba22f9d0c4aae9100d2e5214e Mon Sep 17 00:00:00 2001 From: Gang Chen Date: Fri, 14 Jan 2022 22:24:41 +0800 Subject: [PATCH 1/8] fix example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index df06815..43719c9 100644 --- a/README.md +++ b/README.md @@ -392,7 +392,7 @@ is of a certain type, like `IsUndefined()`, `IsNull`, `IsNumber` etc. It also has useful methods to convert to a Local, for example: ```c++ V8_WARN_UNUSED_RESULT MaybeLocal ToNumber(Local context) const; -V8_WARN_UNUSED_RESULT MaybeLocal ToNumber(Local context) const; +V8_WARN_UNUSED_RESULT MaybeLocal ToString(Local context) const; ... ``` From b78e7ac63f2598d22fe01a1e6e9a7b273ec5c7cd Mon Sep 17 00:00:00 2001 From: Gang Chen Date: Fri, 14 Jan 2022 23:39:45 +0800 Subject: [PATCH 2/8] use local handles rather than Local/Handles --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 43719c9..9b07be7 100644 --- a/README.md +++ b/README.md @@ -452,9 +452,9 @@ $19 = 0x5 See [handle_test.cc](./test/handle_test.cc) for an example. ### HandleScope -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 +by V8) and will take care of deleting the local handles for us. HandleScopes +are stack allocated. When ~HandleScope is called all handles created within that scope are removed from the stack maintained by the HandleScope which makes objects to which the From 18a3c67dea86c12c220501a215c854a4acdce2a8 Mon Sep 17 00:00:00 2001 From: Gang Chen Date: Sat, 15 Jan 2022 09:25:10 +0800 Subject: [PATCH 3/8] fix doc --- README.md | 2 +- test/handlescope_test.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9b07be7..e431e85 100644 --- a/README.md +++ b/README.md @@ -521,7 +521,7 @@ being created: ```c++ Handle str = handle(Struct::cast(result), isolate()); ``` -This will land in the constructor Handlesrc/handles/handles-inl.h +This will land in the constructor `Handle` in `src/handles/handles-inl.h`: ```c++ template Handle::Handle(T object, Isolate* isolate): HandleBase(object.ptr(), isolate) {} diff --git a/test/handlescope_test.cc b/test/handlescope_test.cc index baa4526..bc058f6 100644 --- a/test/handlescope_test.cc +++ b/test/handlescope_test.cc @@ -39,7 +39,7 @@ TEST_F(HandleScopeTest, Create) { TEST_F(HandleScopeTest, HandleScopeImplementer) { i::Isolate* i_isolate = asInternal(isolate_); i::HandleScopeImplementer implementer{i_isolate}; - // Context is just a HeapObject so we can construct using the default not + // Context is just a HeapObject, so we can construct using the default not // args constructor. i::Context context{}; From 36add4788f0f195aab4c3d59e2011cfde6a0d002 Mon Sep 17 00:00:00 2001 From: Gang Chen Date: Sat, 15 Jan 2022 10:26:27 +0800 Subject: [PATCH 4/8] add link of escapable_handlescope_test example --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e431e85..5e40eca 100644 --- a/README.md +++ b/README.md @@ -684,6 +684,8 @@ Local handles should be cleaned up. its local handles, and then gives back the new handle copy which can safely be returned. +See [escapable_handlescope_test.cc](./test/escapable_handlescope_test.cc) for an example. + ### HeapObject TODO: From 8e5bc72e7cfd9c4f1323c53942a0c4d07409cd4c Mon Sep 17 00:00:00 2001 From: Gang Chen Date: Sun, 16 Jan 2022 02:28:36 +0800 Subject: [PATCH 5/8] fix doc --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e40eca..eb6656a 100644 --- a/README.md +++ b/README.md @@ -583,8 +583,8 @@ Local handles are located on the stack and are deleted when the appropriate destructor is called. If there is a local HandleScope then it will take care of this when the scope returns. When there are no references left to a handle it can be garbage collected. This means if a function has a HandleScope and -wants to return a handle/local it will not be available after the function -returns. This is what EscapableHandleScope is for, it enable the value to be +wants to return a local handle it will not be available after the function +returns. This is what EscapableHandleScope is for, it enables the value to be placed in the enclosing handle scope to allow it to survive. When the enclosing HandleScope goes out of scope it will be cleaned up. From b2e57734cda6308c16ea7af590e40aa47d53eabd Mon Sep 17 00:00:00 2001 From: Gang Chen Date: Sun, 16 Jan 2022 20:54:42 +0800 Subject: [PATCH 6/8] fix doc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb6656a..f3926cf 100644 --- a/README.md +++ b/README.md @@ -680,7 +680,7 @@ Next, we take a look at what happens when the EscapableHandleScope goes out of scope. This will call HandleScope::~HandleScope which makes sense as any other Local handles should be cleaned up. -`Escape` copies the value of its argument into the enclosing scope, deletes alli +`Escape` copies the value of its argument into the enclosing scope, deletes all its local handles, and then gives back the new handle copy which can safely be returned. From a93e2c529938f479410299d13548cb9a7f827b35 Mon Sep 17 00:00:00 2001 From: Gang Chen Date: Sun, 16 Jan 2022 22:42:11 +0800 Subject: [PATCH 7/8] remove unnecessary type conversion --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f3926cf..5116b7c 100644 --- a/README.md +++ b/README.md @@ -708,7 +708,7 @@ So a Local contains a pointer to type T. We can access this pointer using We can cast from a subtype to a supertype using Local::Cast: ```c++ -v8::Local nr = v8::Local(v8::Number::New(isolate_, 12)); +v8::Local nr = v8::Number::New(isolate_, 12); v8::Local val = v8::Local::Cast(nr); ``` And there is also the From 29745492b17d4dfffdb45d2c6085c36c49b4cd10 Mon Sep 17 00:00:00 2001 From: Gang Chen Date: Sun, 16 Jan 2022 22:58:22 +0800 Subject: [PATCH 8/8] fix doc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5116b7c..6141239 100644 --- a/README.md +++ b/README.md @@ -736,7 +736,7 @@ Lets take a closer look at the above: v8::internal::Object** gl = ((v8::internal::Object**)(*global)); ``` We use the dereference operator to get the value of a Local (*global), which is -just of type `T*`, a pointer to the type the Local: +just of type `T*`, a pointer to the type of the Local: ```c++ template class Local {