You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nan_scriptorigin.h 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*********************************************************************
  2. * NAN - Native Abstractions for Node.js
  3. *
  4. * Copyright (c) 2021 NAN contributors
  5. *
  6. * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
  7. ********************************************************************/
  8. #ifndef NAN_SCRIPTORIGIN_H_
  9. #define NAN_SCRIPTORIGIN_H_
  10. class ScriptOrigin : public v8::ScriptOrigin {
  11. public:
  12. #if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 9 || \
  13. (V8_MAJOR_VERSION == 9 && (defined(V8_MINOR_VERSION) && (V8_MINOR_VERSION > 0\
  14. || (V8_MINOR_VERSION == 0 && defined(V8_BUILD_NUMBER) \
  15. && V8_BUILD_NUMBER >= 1)))))
  16. explicit ScriptOrigin(v8::Local<v8::Value> name) :
  17. v8::ScriptOrigin(v8::Isolate::GetCurrent(), name) {}
  18. ScriptOrigin(v8::Local<v8::Value> name
  19. , v8::Local<v8::Integer> line) :
  20. v8::ScriptOrigin(v8::Isolate::GetCurrent()
  21. , name
  22. , To<int32_t>(line).FromMaybe(0)) {}
  23. ScriptOrigin(v8::Local<v8::Value> name
  24. , v8::Local<v8::Integer> line
  25. , v8::Local<v8::Integer> column) :
  26. v8::ScriptOrigin(v8::Isolate::GetCurrent()
  27. , name
  28. , To<int32_t>(line).FromMaybe(0)
  29. , To<int32_t>(column).FromMaybe(0)) {}
  30. #elif defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 8 || \
  31. (V8_MAJOR_VERSION == 8 && (defined(V8_MINOR_VERSION) && (V8_MINOR_VERSION > 9\
  32. || (V8_MINOR_VERSION == 9 && defined(V8_BUILD_NUMBER) \
  33. && V8_BUILD_NUMBER >= 45)))))
  34. explicit ScriptOrigin(v8::Local<v8::Value> name) : v8::ScriptOrigin(name) {}
  35. ScriptOrigin(v8::Local<v8::Value> name
  36. , v8::Local<v8::Integer> line) :
  37. v8::ScriptOrigin(name, To<int32_t>(line).FromMaybe(0)) {}
  38. ScriptOrigin(v8::Local<v8::Value> name
  39. , v8::Local<v8::Integer> line
  40. , v8::Local<v8::Integer> column) :
  41. v8::ScriptOrigin(name
  42. , To<int32_t>(line).FromMaybe(0)
  43. , To<int32_t>(column).FromMaybe(0)) {}
  44. #else
  45. explicit ScriptOrigin(v8::Local<v8::Value> name) : v8::ScriptOrigin(name) {}
  46. ScriptOrigin(v8::Local<v8::Value> name
  47. , v8::Local<v8::Integer> line) : v8::ScriptOrigin(name, line) {}
  48. ScriptOrigin(v8::Local<v8::Value> name
  49. , v8::Local<v8::Integer> line
  50. , v8::Local<v8::Integer> column) :
  51. v8::ScriptOrigin(name, line, column) {}
  52. #endif
  53. #if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 8 || \
  54. (V8_MAJOR_VERSION == 8 && (defined(V8_MINOR_VERSION) && (V8_MINOR_VERSION > 9\
  55. || (V8_MINOR_VERSION == 9 && defined(V8_BUILD_NUMBER) \
  56. && V8_BUILD_NUMBER >= 45)))))
  57. v8::Local<v8::Integer> ResourceLineOffset() const {
  58. return New(LineOffset());
  59. }
  60. v8::Local<v8::Integer> ResourceColumnOffset() const {
  61. return New(ColumnOffset());
  62. }
  63. #endif
  64. };
  65. #endif // NAN_SCRIPTORIGIN_H_