mirror of https://github.com/lukechilds/node.git
Browse Source
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: https://github.com/nodejs/node/issues/3107 PR-URL: https://github.com/nodejs/node/pull/3119 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>v5.x
Evan Lucas
9 years ago
4 changed files with 89 additions and 5 deletions
@ -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) |
Loading…
Reference in new issue