Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Siddharth Mahendraker
committed
Mar 3, 2012
0 parents
commit d205b77
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/build | ||
.lock-wscript | ||
/src/.lock-wscript | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var hashify = require("./build/Release/hashify"); | ||
|
||
module.exports = hashify.hashify; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"author": "Siddharth Mahendraker <siddharth_mahen@me.com>", | ||
"name": "hashify", | ||
"description": "Access native v8 object hashes", | ||
"keywords": [ | ||
"object", | ||
"hash" | ||
], | ||
"version": "0.0.1", | ||
"repository": { | ||
"url": "" | ||
}, | ||
"main": "index.js", | ||
"scripts": { | ||
"preinstall": "node-waf clean || true; node-waf configure build" | ||
}, | ||
"engines": { | ||
"node": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#define BUILDING_NODE_EXTENSION | ||
#include <node.h> | ||
|
||
using namespace v8; | ||
|
||
Handle<Value> hashify(const Arguments& args) { | ||
HandleScope scope; | ||
|
||
if(args.Length() < 1 || !args[0]->IsObject()){ | ||
ThrowException(Exception::TypeError(String::New("Invalid arguments"))); | ||
return scope.Close(Undefined()); | ||
} | ||
|
||
Local<Object> obj = Local<Object>::Cast(args[0]); | ||
Local<Number> num = Number::New(obj->GetIdentityHash()); | ||
|
||
return scope.Close(num); | ||
} | ||
|
||
void init(Handle<Object> target) { | ||
target->Set(String::NewSymbol("hashify"), | ||
FunctionTemplate::New(hashify)->GetFunction()); | ||
} | ||
|
||
NODE_MODULE(hashify, init) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
srcdir = 'src' | ||
blddir = 'build' | ||
VERSION = '0.0.1' | ||
|
||
def set_options(opt): | ||
opt.tool_options('compiler_cxx') | ||
|
||
def configure(conf): | ||
conf.check_tool('compiler_cxx') | ||
conf.check_tool('node_addon') | ||
|
||
def build(bld): | ||
obj = bld.new_task_gen('cxx', 'shlib', 'node_addon') | ||
obj.target = 'hashify' | ||
obj.source = [ srcdir+'/'+'hashify.cc'] |