Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 liveuser 1
/*********************************************************************
2
 * NAN - Native Abstractions for Node.js
3
 *
4
 * Copyright (c) 2016 NAN contributors
5
 *
6
 * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
7
 ********************************************************************/
8
 
9
#ifndef NAN_CONVERTERS_H_
10
#define NAN_CONVERTERS_H_
11
 
12
namespace imp {
13
template<typename T> struct ToFactoryBase {
14
  typedef MaybeLocal<T> return_t;
15
};
16
template<typename T> struct ValueFactoryBase { typedef Maybe<T> return_t; };
17
 
18
template<typename T> struct ToFactory;
19
 
20
#define X(TYPE)                                                                \
21
    template<>                                                                 \
22
    struct ToFactory<v8::TYPE> : ToFactoryBase<v8::TYPE> {                     \
23
      static inline return_t convert(v8::Local<v8::Value> val);                \
24
    };
25
 
26
X(Boolean)
27
X(Number)
28
X(String)
29
X(Object)
30
X(Integer)
31
X(Uint32)
32
X(Int32)
33
 
34
#undef X
35
 
36
#define X(TYPE)                                                                \
37
    template<>                                                                 \
38
    struct ToFactory<TYPE> : ValueFactoryBase<TYPE> {                          \
39
      static inline return_t convert(v8::Local<v8::Value> val);                \
40
    };
41
 
42
X(bool)
43
X(double)
44
X(int64_t)
45
X(uint32_t)
46
X(int32_t)
47
 
48
#undef X
49
}  // end of namespace imp
50
 
51
template<typename T>
52
inline
53
typename imp::ToFactory<T>::return_t To(v8::Local<v8::Value> val) {
54
  return imp::ToFactory<T>::convert(val);
55
}
56
 
57
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 ||                      \
58
  (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
59
# include "nan_converters_43_inl.h"
60
#else
61
# include "nan_converters_pre_43_inl.h"
62
#endif
63
 
64
#endif  // NAN_CONVERTERS_H_