Skip to content

Commit

Permalink
Use NODE_MODULE to define extern and change Holder to This().
Browse files Browse the repository at this point in the history
  • Loading branch information
Kashif Rasul committed Mar 17, 2012
1 parent ed49f5a commit 471946d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
5 changes: 3 additions & 2 deletions src/bindings.cpp
Expand Up @@ -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);
14 changes: 7 additions & 7 deletions src/cuda_ctx.cpp
Expand Up @@ -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());
Expand All @@ -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));
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/cuda_device.cpp
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions src/cuda_mem.cpp
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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);

Expand Down

0 comments on commit 471946d

Please sign in to comment.