diff --git a/src/node_api.cc b/src/node_api.cc index 22be3647ea86dd..ef4ec29708c0d4 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -2173,11 +2173,11 @@ static napi_status set_error_code(napi_env env, } } name_string = v8::String::Concat( - isolate, name_string, FIXED_ONE_BYTE_STRING(isolate, " [")); + isolate, name_string, node::FIXED_ONE_BYTE_STRING(isolate, " [")); name_string = v8::String::Concat(isolate, name_string, code_value.As()); name_string = v8::String::Concat( - isolate, name_string, FIXED_ONE_BYTE_STRING(isolate, "]")); + isolate, name_string, node::FIXED_ONE_BYTE_STRING(isolate, "]")); set_maybe = err_object->Set(context, name_key, name_string); RETURN_STATUS_IF_FALSE(env, diff --git a/src/util.h b/src/util.h index 057346a2d04fca..4036383dee92de 100644 --- a/src/util.h +++ b/src/util.h @@ -89,9 +89,6 @@ NO_RETURN void Abort(); NO_RETURN void Assert(const char* const (*args)[4]); void DumpBacktrace(FILE* fp); -#define FIXED_ONE_BYTE_STRING(isolate, string) \ - (node::OneByteString((isolate), (string), sizeof(string) - 1)) - #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ void operator=(const TypeName&) = delete; \ void operator=(TypeName&&) = delete; \ @@ -248,6 +245,15 @@ inline v8::Local OneByteString(v8::Isolate* isolate, const unsigned char* data, int length = -1); +// Used to be a macro, hence the uppercase name. +template +inline v8::Local FIXED_ONE_BYTE_STRING( + v8::Isolate* isolate, + const char(&data)[N]) { + return OneByteString(isolate, data, N - 1); +} + + // Swaps bytes in place. nbytes is the number of bytes to swap and must be a // multiple of the word size (checked by function). inline void SwapBytes16(char* data, size_t nbytes);