Skip to content

Commit

Permalink
unwrapBufferToPointer supports noe::Buffer object
Browse files Browse the repository at this point in the history
  • Loading branch information
jiahansu committed Sep 11, 2015
1 parent 65d1430 commit be63274
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bridjs",
"version": "0.3.4-1",
"version": "0.3.4-2",
"description": "V8 bindings for dyncall, and BridJ-like API for nodejs.",
"keywords": [
"dyncall",
Expand Down
12 changes: 10 additions & 2 deletions src/dyncall_v8_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,17 @@ Local<Value> bridjs::Utils::wrapPointerToBuffer(Isolate* isolate, const void* pt

void* bridjs::Utils::unwrapBufferToPointer(v8::Local<v8::Value> value){
void* ptr;
v8::Local<v8::ArrayBuffer> ab = value.As<v8::ArrayBuffer>();
void* bufferPtr;

if(node::Buffer::HasInstance(value)){
bufferPtr = node::Buffer::Data(value);
}else{
v8::Local<v8::ArrayBuffer> ab = value.As<v8::ArrayBuffer>();

bufferPtr = ab->GetContents().Data();
}

std::memcpy(&ptr, ab->GetContents().Data(), sizeof(void*));
std::memcpy(&ptr, bufferPtr, sizeof(void*));

return ptr;
}
Expand Down

0 comments on commit be63274

Please sign in to comment.