2009-12-07 02:20:16 -05:00
|
|
|
#ifndef _RUBY_V8_REF_
|
|
|
|
#define _RUBY_V8_REF_
|
|
|
|
|
|
|
|
#include <v8.h>
|
|
|
|
|
2009-12-07 02:44:18 -05:00
|
|
|
//this is a non-template superclass so that the mark() and free() functions
|
|
|
|
//don't need to be templatized. Not sure if this is valid... are
|
|
|
|
// class destructors virtual?
|
|
|
|
|
2009-12-07 02:20:16 -05:00
|
|
|
class v8_ref_data {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2009-12-07 02:44:18 -05:00
|
|
|
//the v8_ref wraps a v8 handle so that ruby can hold a reference to it.
|
|
|
|
|
2009-12-07 02:20:16 -05:00
|
|
|
template <class T> class v8_ref : v8_ref_data {
|
|
|
|
public:
|
2009-12-07 02:44:18 -05:00
|
|
|
//takes a handle object and adds a new persistent handle for
|
2009-12-07 02:54:20 -05:00
|
|
|
//the referenced object
|
2009-12-07 02:20:16 -05:00
|
|
|
v8_ref(v8::Handle<T> object);
|
|
|
|
~v8_ref();
|
|
|
|
private:
|
|
|
|
v8::Persistent<T> handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//memory management
|
|
|
|
void v8_ref_mark(v8_ref_data* ref);
|
|
|
|
void v8_ref_free(v8_ref_data* ref);
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|