Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-09-11 20:33:28 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2012-09-11 20:33:30 +0400
commitc8c638a84195e5571f4ece881375909e1f4b82a8 (patch)
treef9827b69c8f6a42ec214750665f87bce40c4efa6 /src/node_buffer.h
parenteaf13431003b92521e3277dd7fa5dd223407052f (diff)
buffer: change prototype of Data() and Length()
Make Buffer:Data() and Buffer::Length() accept a Value instead of an Object.
Diffstat (limited to 'src/node_buffer.h')
-rw-r--r--src/node_buffer.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/node_buffer.h b/src/node_buffer.h
index 38c1e2d29c1..a092faa756b 100644
--- a/src/node_buffer.h
+++ b/src/node_buffer.h
@@ -72,16 +72,21 @@ class NODE_EXTERN Buffer: public ObjectWrap {
static bool HasInstance(v8::Handle<v8::Value> val);
- static inline char* Data(v8::Handle<v8::Object> obj) {
- return (char*)obj->GetIndexedPropertiesExternalArrayData();
+ static inline char* Data(v8::Handle<v8::Value> val) {
+ assert(val->IsObject());
+ void* data = val.As<v8::Object>()->GetIndexedPropertiesExternalArrayData();
+ return reinterpret_cast<char*>(data);
}
static inline char* Data(Buffer *b) {
return Buffer::Data(b->handle_);
}
- static inline size_t Length(v8::Handle<v8::Object> obj) {
- return (size_t)obj->GetIndexedPropertiesExternalArrayDataLength();
+ static inline size_t Length(v8::Handle<v8::Value> val) {
+ assert(val->IsObject());
+ int len = val.As<v8::Object>()
+ ->GetIndexedPropertiesExternalArrayDataLength();
+ return static_cast<size_t>(len);
}
static inline size_t Length(Buffer *b) {