Skip to content

Instantly share code, notes, and snippets.

@creationix
Created March 22, 2012 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creationix/673906bbce33c8a1c67e to your computer and use it in GitHub Desktop.
Save creationix/673906bbce33c8a1c67e to your computer and use it in GitHub Desktop.
#include "luv.h"
#include "candor.h"
#include "uv.h"
#include <stdlib.h>
using namespace candor;
uvHandle::uvHandle(size_t size, Object* prototype) {
if (prototype) {
objHandle.Wrap(prototype->Clone());
} else {
objHandle.Wrap(Object::New());
}
objHandle->Set("cdata", Wrap());
handle = (uv_handle_t*)malloc(size);
}
// TODO: this is a ref cycle, we always hold obj, and obj holds us
uvHandle::~uvHandle() {
free(handle);
objHandle.Unwrap();
}
#ifndef LUV_H
#define LUV_H
#include "candor.h"
#include "uv.h"
class uvHandle: public candor::CWrapper {
candor::Handle<candor::Object> objHandle;
public:
uv_handle_t* handle;
uvHandle(size_t size, candor::Object* prototype);
~uvHandle();
inline candor::Object* obj() { return *objHandle; }
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment