nan_converters_43_inl.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #ifndef NAN_CONVERTERS_43_INL_H_
  9. #define NAN_CONVERTERS_43_INL_H_
  10. #define X(TYPE) \
  11. imp::ToFactory<v8::TYPE>::return_t \
  12. imp::ToFactory<v8::TYPE>::convert(v8::Local<v8::Value> val) { \
  13. v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
  14. v8::EscapableHandleScope scope(isolate); \
  15. return scope.Escape( \
  16. val->To ## TYPE(v8::Isolate::GetCurrent()->GetCurrentContext()) \
  17. .FromMaybe(v8::Local<v8::TYPE>())); \
  18. }
  19. X(Boolean)
  20. X(Number)
  21. X(String)
  22. X(Object)
  23. X(Integer)
  24. X(Uint32)
  25. X(Int32)
  26. #undef X
  27. #define X(TYPE, NAME) \
  28. imp::ToFactory<TYPE>::return_t \
  29. imp::ToFactory<TYPE>::convert(v8::Local<v8::Value> val) { \
  30. v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
  31. v8::HandleScope scope(isolate); \
  32. return val->NAME ## Value(isolate->GetCurrentContext()); \
  33. }
  34. X(bool, Boolean)
  35. X(double, Number)
  36. X(int64_t, Integer)
  37. X(uint32_t, Uint32)
  38. X(int32_t, Int32)
  39. #undef X
  40. #endif // NAN_CONVERTERS_43_INL_H_