-
-
Save creationix/673906bbce33c8a1c67e to your computer and use it in GitHub Desktop.
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
#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(); | |
} |
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
#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