-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: correctly inspect Map/Set Iterators
Previously, a MapIterator or SetIterator would not be inspected properly. This change makes it possible to inspect them by creating a Debug Mirror and previewing the iterators to not consume the actual iterator that we are trying to inspect. This change also adds a node_util binding that uses v8's Value::IsSetIterator and Value::IsMapIterator to verify that the values passed in are actual iterators. Fixes: #3107 PR-URL: #3119 Reviewed-By: Ben Noordhuis <[email protected]>
- Loading branch information
Showing
4 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "node.h" | ||
#include "v8.h" | ||
#include "env.h" | ||
#include "env-inl.h" | ||
|
||
namespace node { | ||
namespace util { | ||
|
||
using v8::Context; | ||
using v8::FunctionCallbackInfo; | ||
using v8::Local; | ||
using v8::Object; | ||
using v8::Value; | ||
|
||
static void IsMapIterator(const FunctionCallbackInfo<Value>& args) { | ||
CHECK_EQ(1, args.Length()); | ||
args.GetReturnValue().Set(args[0]->IsMapIterator()); | ||
} | ||
|
||
|
||
static void IsSetIterator(const FunctionCallbackInfo<Value>& args) { | ||
CHECK_EQ(1, args.Length()); | ||
args.GetReturnValue().Set(args[0]->IsSetIterator()); | ||
} | ||
|
||
|
||
void Initialize(Local<Object> target, | ||
Local<Value> unused, | ||
Local<Context> context) { | ||
Environment* env = Environment::GetCurrent(context); | ||
env->SetMethod(target, "isMapIterator", IsMapIterator); | ||
env->SetMethod(target, "isSetIterator", IsSetIterator); | ||
} | ||
|
||
} // namespace util | ||
} // namespace node | ||
|
||
NODE_MODULE_CONTEXT_AWARE_BUILTIN(util, node::util::Initialize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters