From c8c638a84195e5571f4ece881375909e1f4b82a8 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 11 Sep 2012 18:33:28 +0200 Subject: buffer: change prototype of Data() and Length() Make Buffer:Data() and Buffer::Length() accept a Value instead of an Object. --- src/node_buffer.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/node_buffer.h') 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 val); - static inline char* Data(v8::Handle obj) { - return (char*)obj->GetIndexedPropertiesExternalArrayData(); + static inline char* Data(v8::Handle val) { + assert(val->IsObject()); + void* data = val.As()->GetIndexedPropertiesExternalArrayData(); + return reinterpret_cast(data); } static inline char* Data(Buffer *b) { return Buffer::Data(b->handle_); } - static inline size_t Length(v8::Handle obj) { - return (size_t)obj->GetIndexedPropertiesExternalArrayDataLength(); + static inline size_t Length(v8::Handle val) { + assert(val->IsObject()); + int len = val.As() + ->GetIndexedPropertiesExternalArrayDataLength(); + return static_cast(len); } static inline size_t Length(Buffer *b) { -- cgit v1.2.3