Reputation: 647
I was reading NodeJS and V8 source, particulary node_contextify.cc
file, and I could not understand the following line:
Context::Scope context_scope(debug_context);
I don't understand what is that Context::Scope
before what seems to be a function call. I don't think it is a declaration because it is a function code, together with an if
and other calls.
Complete relevant code:
...
if (debug_context.IsEmpty()) {
// [... lines removed for brevity ...]
}
Context::Scope context_scope(debug_context);
MaybeLocal<Script> script = Script::Compile(debug_context, script_source);
if (script.IsEmpty())
return; // Exception pending.
args.GetReturnValue().Set(script.ToLocalChecked()->Run());
}
...
What is the meaning of that Context::Scope
?
Further information:
File: node/node_contextify.cc (the line 268 is highlighted).
While I understand it is a basic question about syntax, I don't even know how to call it, so I was not able to find any result in Google, StackOverflow or C++ reference.
The question title is one of my attempts when searching for it.
Upvotes: 1
Views: 484
Reputation: 6647
Context::Scope context_scope(debug_context);
You are declaring an object context_scope
of type Context::Scope
and initializing it with debug_context
Context::Scope
could be a type defined in a class or struct, for example:
class Context {
public:
using Scope = int;
....
}
or, Context::Scope
could be a type defined inside a namespace, such as:
namespace Context {
using Scope = int;
...
}
Upvotes: 3
Reputation: 12276
It's initializing the context_scope variable with debug_context. Context::Scope is the type (here's one ref page http://bespin.cz/~ondras/html/classv8_1_1Context_1_1Scope.html)
Here's another article on using Context::Scope How to correctly use Context::Scope ?
BTW, even if you don't know what to call it, searching for "v8 Context::Scope" will turn up information.
Upvotes: 3