@@ -137,7 +137,7 @@ function getFoo(obj) {
137
137
}
138
138
```
139
139
140
- ``` c++
140
+ ``` cpp
141
141
v8::Local<v8::Value> GetFoo (v8::Local< v8::Context > context,
142
142
v8::Local< v8::Object > obj) {
143
143
v8::Isolate* isolate = context->GetIsolate();
@@ -168,7 +168,7 @@ See [exception handling][] for more information about the usage of `.To()`,
168
168
If it is known that a `Local<Value>` refers to a more specific type, it can
169
169
be cast to that type using `.As<...>()`:
170
170
171
- ```c++
171
+ ```cpp
172
172
v8::Local<v8::Value> some_value;
173
173
// CHECK() is a Node.js utilitity that works similar to assert().
174
174
CHECK(some_value->IsUint8Array());
@@ -201,7 +201,7 @@ alive even if no other objects refer to them. Weak global handles do not do
201
201
that, and instead optionally call a callback when the object they refer to
202
202
is garbage-collected.
203
203
204
- ``` c++
204
+ ``` cpp
205
205
v8::Global<v8::Object> reference;
206
206
207
207
void StoreReference (v8::Isolate* isolate, v8::Local< v8::Object > obj) {
@@ -329,7 +329,7 @@ The platform can be accessed through `isolate_data->platform()` given an
329
329
C++ functions exposed to JS follow a specific signature. The following example
330
330
is from `node_util.cc`:
331
331
332
- ```c++
332
+ ```cpp
333
333
void ArrayBufferViewHasBuffer(const FunctionCallbackInfo<Value>& args) {
334
334
CHECK(args[0]->IsArrayBufferView());
335
335
args.GetReturnValue().Set(args[0].As<ArrayBufferView>()->HasBuffer());
@@ -351,7 +351,7 @@ floating-point number or a `Local<Value>` to set the return value.
351
351
Node.js provides various helpers for building JS classes in C++ and/or attaching
352
352
C++ functions to the exports of a built-in module:
353
353
354
- ``` c++
354
+ ``` cpp
355
355
void Initialize (Local<Object > target,
356
356
Local<Value > unused,
357
357
Local<Context > context,
@@ -409,7 +409,7 @@ constant string, in order to disambiguate it from other classes of this type,
409
409
and which could e.g. match the binding’s name (in the example above, that would
410
410
be `cares_wrap`).
411
411
412
- ```c++
412
+ ```cpp
413
413
// In the HTTP parser source code file:
414
414
class BindingData : public BaseObject {
415
415
public:
@@ -523,7 +523,7 @@ to perform further calls to APIs that return `Maybe`s.
523
523
A typical pattern for dealing with APIs that return ` Maybe ` and ` MaybeLocal ` is
524
524
using ` .ToLocal() ` and ` .To() ` and returning early in case there is an error:
525
525
526
- ``` c++
526
+ ``` cpp
527
527
// This could also return a v8::MaybeLocal<v8::Number>, for example.
528
528
v8::Maybe<double > SumNumbers (v8::Local< v8::Context > context,
529
529
v8::Local< v8::Array > array_of_integers) {
@@ -692,7 +692,7 @@ A helper for this is the `ASSIGN_OR_RETURN_UNWRAP` macro that returns from the
692
692
current function if unwrapping fails (typically that means that the `BaseObject`
693
693
has been deleted earlier).
694
694
695
- ```c++
695
+ ```cpp
696
696
void Http2Session::Request(const FunctionCallbackInfo<Value>& args) {
697
697
Http2Session* session;
698
698
ASSIGN_OR_RETURN_UNWRAP(&session, args.Holder());
@@ -780,7 +780,7 @@ queues once it returns.
780
780
Before calling ` MakeCallback() ` , it is typically necessary to enter both a
781
781
` HandleScope ` and a ` Context::Scope ` .
782
782
783
- ``` c++
783
+ ``` cpp
784
784
void StatWatcher::Callback (uv_fs_poll_t* handle,
785
785
int status,
786
786
const uv_stat_t* prev,
@@ -872,7 +872,7 @@ The `Utf8Value`, `TwoByteValue` (i.e. UTF-16 value) and `BufferValue`
872
872
inherit from this class and allow accessing the characters in a JavaScript
873
873
string this way.
874
874
875
- ```c++
875
+ ```cpp
876
876
static void Chdir(const FunctionCallbackInfo<Value>& args) {
877
877
Environment* env = Environment::GetCurrent(args);
878
878
// ...
0 commit comments