UNPKG

1.73 kBtext/x-cView Raw
1/*********************************************************************
2 * NAN - Native Abstractions for Node.js
3 *
4 * Copyright (c) 2018 NAN contributors
5 *
6 * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
7 ********************************************************************/
8
9#ifndef NAN_CONVERTERS_43_INL_H_
10#define NAN_CONVERTERS_43_INL_H_
11
12#define X(TYPE) \
13imp::ToFactory<v8::TYPE>::return_t \
14imp::ToFactory<v8::TYPE>::convert(v8::Local<v8::Value> val) { \
15 v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
16 v8::EscapableHandleScope scope(isolate); \
17 return scope.Escape( \
18 val->To ## TYPE(isolate->GetCurrentContext()) \
19 .FromMaybe(v8::Local<v8::TYPE>())); \
20}
21
22X(Boolean)
23X(Number)
24X(String)
25X(Object)
26X(Integer)
27X(Uint32)
28X(Int32)
29
30#undef X
31
32#define X(TYPE, NAME) \
33imp::ToFactory<TYPE>::return_t \
34imp::ToFactory<TYPE>::convert(v8::Local<v8::Value> val) { \
35 v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
36 v8::HandleScope scope(isolate); \
37 return val->NAME ## Value(isolate->GetCurrentContext()); \
38}
39
40X(bool, Boolean)
41X(double, Number)
42X(int64_t, Integer)
43X(uint32_t, Uint32)
44X(int32_t, Int32)
45
46#undef X
47
48#endif // NAN_CONVERTERS_43_INL_H_