util-inl.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef SRC_UTIL_INL_H_
  2. #define SRC_UTIL_INL_H_
  3. #include "util.h"
  4. #include "v8.h"
  5. namespace node {
  6. inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
  7. const char* data,
  8. int length) {
  9. return v8::String::NewFromOneByte(isolate,
  10. reinterpret_cast<const uint8_t*>(data),
  11. v8::NewStringType::kNormal,
  12. length).ToLocalChecked();
  13. }
  14. inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
  15. const signed char* data,
  16. int length) {
  17. return v8::String::NewFromOneByte(isolate,
  18. reinterpret_cast<const uint8_t*>(data),
  19. v8::NewStringType::kNormal,
  20. length).ToLocalChecked();
  21. }
  22. inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
  23. const unsigned char* data,
  24. int length) {
  25. return v8::String::NewFromOneByte(isolate,
  26. reinterpret_cast<const uint8_t*>(data),
  27. v8::NewStringType::kNormal,
  28. length).ToLocalChecked();
  29. }
  30. } // namespace node
  31. #endif // SRC_UTIL_INL_H_