Browse Source

src: move ParseArrayIndex() to src/node_buffer.cc

It's not used anywhere else so move it out of src/node_internals.h.

PR-URL: https://github.com/nodejs/node/pull/7497
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v4.x
Ben Noordhuis 9 years ago
committed by Myles Borins
parent
commit
e1f961d050
  1. 19
      src/node_buffer.cc
  2. 18
      src/node_internals.h

19
src/node_buffer.cc

@ -171,6 +171,25 @@ void CallbackInfo::WeakCallback(Isolate* isolate, Local<Object> object) {
}
// Parse index for external array data.
inline MUST_USE_RESULT bool ParseArrayIndex(Local<Value> arg,
size_t def,
size_t* ret) {
if (arg->IsUndefined()) {
*ret = def;
return true;
}
int64_t tmp_i = arg->IntegerValue();
if (tmp_i < 0)
return false;
*ret = static_cast<size_t>(tmp_i);
return true;
}
// Buffer methods
bool HasInstance(Local<Value> val) {

18
src/node_internals.h

@ -160,24 +160,6 @@ inline bool IsBigEndian() {
return GetEndianness() == kBigEndian;
}
// parse index for external array data
inline MUST_USE_RESULT bool ParseArrayIndex(v8::Local<v8::Value> arg,
size_t def,
size_t* ret) {
if (arg->IsUndefined()) {
*ret = def;
return true;
}
int32_t tmp_i = arg->Int32Value();
if (tmp_i < 0)
return false;
*ret = static_cast<size_t>(tmp_i);
return true;
}
void ThrowError(v8::Isolate* isolate, const char* errmsg);
void ThrowTypeError(v8::Isolate* isolate, const char* errmsg);
void ThrowRangeError(v8::Isolate* isolate, const char* errmsg);

Loading…
Cancel
Save