Initial commit
[yaffs-website] / node_modules / nan / nan_converters_43_inl.h
1 /*********************************************************************
2  * NAN - Native Abstractions for Node.js
3  *
4  * Copyright (c) 2017 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)                                                                \
13 imp::ToFactory<v8::TYPE>::return_t                                             \
14 imp::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(v8::Isolate::GetCurrent()->GetCurrentContext())          \
19           .FromMaybe(v8::Local<v8::TYPE>()));                                  \
20 }
21
22 X(Boolean)
23 X(Number)
24 X(String)
25 X(Object)
26 X(Integer)
27 X(Uint32)
28 X(Int32)
29
30 #undef X
31
32 #define X(TYPE, NAME)                                                          \
33 imp::ToFactory<TYPE>::return_t                                                 \
34 imp::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
40 X(bool, Boolean)
41 X(double, Number)
42 X(int64_t, Integer)
43 X(uint32_t, Uint32)
44 X(int32_t, Int32)
45
46 #undef X
47
48 #endif  // NAN_CONVERTERS_43_INL_H_