Permalink
Browse files

Use NODE_MODULE to define extern and change Holder to This().

  • Loading branch information...
1 parent ed49f5a commit 471946db905e175090d802730ad7808bef2a6a32 @kashif committed Mar 17, 2012
Showing with 17 additions and 16 deletions.
  1. +3 −2 src/bindings.cpp
  2. +7 −7 src/cuda_ctx.cpp
  3. +3 −3 src/cuda_device.cpp
  4. +4 −4 src/cuda_mem.cpp
View
@@ -3,10 +3,11 @@
#include "cuda_ctx.hpp"
#include "cuda_mem.hpp"
-extern "C"
void init (Handle<Object> target) {
HandleScope scope;
CudaDevice::Initialize(target);
CudaCtx::Initialize(target);
CudaMem::Initialize(target);
-}
+}
+
+NODE_MODULE(cuda, init);
View
@@ -26,7 +26,7 @@ Handle<Value> CudaCtx::New(const Arguments& args) {
HandleScope scope;
CudaCtx *pctx = new CudaCtx();
- pctx->Wrap(args.Holder());
+ pctx->Wrap(args.This());
unsigned int flags = args[0]->Uint32Value();
CudaDevice *pdev = ObjectWrap::Unwrap<CudaDevice>(args[1]->ToObject());
@@ -37,39 +37,39 @@ Handle<Value> CudaCtx::New(const Arguments& args) {
Handle<Value> CudaCtx::destroy(const Arguments& args) {
HandleScope scope;
- CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.Holder());
+ CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.This());
CUresult error = cuCtxDestroy(pctx->m_context);
return scope.Close(Number::New(error));
}
Handle<Value> CudaCtx::pushCurrent(const Arguments& args) {
HandleScope scope;
- CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.Holder());
+ CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.This());
CUresult error = cuCtxPushCurrent(pctx->m_context);
return scope.Close(Number::New(error));
}
Handle<Value> CudaCtx::popCurrent(const Arguments& args) {
HandleScope scope;
- CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.Holder());
+ CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.This());
CUresult error = cuCtxPopCurrent(&(pctx->m_context));
return scope.Close(Number::New(error));
}
Handle<Value> CudaCtx::setCurrent(const Arguments& args) {
HandleScope scope;
- CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.Holder());
+ CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.This());
CUresult error = cuCtxSetCurrent(pctx->m_context);
return scope.Close(Number::New(error));
}
Handle<Value> CudaCtx::getCurrent(const Arguments& args) {
HandleScope scope;
- CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.Holder());
+ CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.This());
CUresult error = cuCtxGetCurrent(&(pctx->m_context));
return scope.Close(Number::New(error));
@@ -84,7 +84,7 @@ Handle<Value> CudaCtx::synchronize(const Arguments& args) {
Handle<Value> CudaCtx::getApiVersion(const Arguments& args) {
HandleScope scope;
- CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.Holder());
+ CudaCtx *pctx = ObjectWrap::Unwrap<CudaCtx>(args.This());
unsigned int version;
CUresult error = cuCtxGetApiVersion(pctx->m_context, &version);
View
@@ -50,7 +50,7 @@ Handle<Value> CudaDevice::New(const Arguments& args) {
Handle<Value> CudaDevice::getName(const Arguments& args) {
HandleScope scope;
- CudaDevice *cu = ObjectWrap::Unwrap<CudaDevice>(args.Holder());
+ CudaDevice *cu = ObjectWrap::Unwrap<CudaDevice>(args.This());
char deviceName[256];
cuDeviceGetName(deviceName, 256, cu->m_device);
@@ -61,7 +61,7 @@ Handle<Value> CudaDevice::getName(const Arguments& args) {
Handle<Value> CudaDevice::computeCapability(const Arguments& args) {
HandleScope scope;
- CudaDevice *cu = ObjectWrap::Unwrap<CudaDevice>(args.Holder());
+ CudaDevice *cu = ObjectWrap::Unwrap<CudaDevice>(args.This());
int major = 0, minor = 0;
cuDeviceComputeCapability(&major, &minor, cu->m_device);
@@ -74,7 +74,7 @@ Handle<Value> CudaDevice::computeCapability(const Arguments& args) {
Handle<Value> CudaDevice::totalMem(const Arguments& args) {
HandleScope scope;
- CudaDevice *cu = ObjectWrap::Unwrap<CudaDevice>(args.Holder());
+ CudaDevice *cu = ObjectWrap::Unwrap<CudaDevice>(args.This());
size_t totalGlobalMem;
cuDeviceTotalMem(&totalGlobalMem, cu->m_device);
View
@@ -21,14 +21,14 @@ Handle<Value> CudaMem::New(const Arguments& args) {
HandleScope scope;
CudaMem *cuptr = new CudaMem();
- cuptr->Wrap(args.Holder());
+ cuptr->Wrap(args.This());
return args.This();
}
Handle<Value> CudaMem::alloc(const Arguments& args) {
HandleScope scope;
- CudaMem *cuptr = ObjectWrap::Unwrap<CudaMem>(args.Holder());
+ CudaMem *cuptr = ObjectWrap::Unwrap<CudaMem>(args.This());
size_t bytesize = args[0]->Uint32Value();
CUresult error = cuMemAlloc(&(cuptr->m_devicePtr), bytesize);
@@ -38,7 +38,7 @@ Handle<Value> CudaMem::alloc(const Arguments& args) {
Handle<Value> CudaMem::allocPitch(const Arguments& args) {
HandleScope scope;
- CudaMem *cuptr = ObjectWrap::Unwrap<CudaMem>(args.Holder());
+ CudaMem *cuptr = ObjectWrap::Unwrap<CudaMem>(args.This());
size_t bytesize = args[0]->Uint32Value();
size_t pPitch;
@@ -52,7 +52,7 @@ Handle<Value> CudaMem::allocPitch(const Arguments& args) {
Handle<Value> CudaMem::free(const Arguments& args) {
HandleScope scope;
- CudaMem *cuptr = ObjectWrap::Unwrap<CudaMem>(args.Holder());
+ CudaMem *cuptr = ObjectWrap::Unwrap<CudaMem>(args.This());
CUresult error = cuMemFree(cuptr->m_devicePtr);

0 comments on commit 471946d

Please sign in to comment.