Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix some operator= and memory issues, add GestureGenerator.create()

  • Loading branch information...
commit 414162dc690a851e2075f80ca6c0c3f11000f47c 1 parent e1c6aaf
@jmendeth authored
View
10 src/Context.cpp
@@ -26,10 +26,8 @@ namespace node_xn {
using namespace v8;
using namespace node;
- Context Context::Init() {
- XnContextPtr ptr;
- xnInit(&ptr);
- return Context(ptr);
+ void Context::Init(XnContextPtr& handle) {
+ xnInit(&handle);//TODO: check status
}
void Context::OnConstruct() {
@@ -73,7 +71,9 @@ namespace node_xn {
HandleScope scope;
Handle<Object> instH = ((Function*)(*args.Data()))->NewInstance();
- (new Context(Init()))->Wrap(instH);
+ XnContextPtr handle;
+ Init(handle);
+ (new Context(handle))->Wrap(instH);
return instH;
}
View
11 src/Context.h
@@ -29,10 +29,15 @@ namespace node_xn {
using namespace v8;
using namespace node;
+ /* Root class, so forward declarations go here */
+ class ProductionNode;
+ class Generator;
+ class GestureGenerator;
+
class Context: public ObjectWrap {
public:
/* Factory method(s) */
- static Context Init();
+ static void Init(XnContextPtr& handle);
/* Core methods */
inline Context(XnContextPtr const handle) : ptr(handle) {OnConstruct();}
@@ -46,6 +51,10 @@ namespace node_xn {
private:
XnContextPtr const ptr;
void OnConstruct();
+
+ friend class ProductionNode;
+ friend class Generator;
+ friend class GestureGenerator;
};
/* Initializer */
View
20 src/GestureGenerator.cpp
@@ -25,7 +25,11 @@ namespace node_xn {
using namespace v8;
using namespace node;
-
+
+ void GestureGenerator::create(const Context& ctx, XnNodeHandle& handle, XnNodeQuery* query) {
+ xnCreateGestureGenerator(ctx.ptr, &handle, query, NULL); //TODO: check status
+ }
+
Persistent<FunctionTemplate> INIT_GestureGenerator(Handle<Object> ctx, Persistent<FunctionTemplate> parent) {
HandleScope scope;
@@ -44,5 +48,19 @@ namespace node_xn {
ctx->Set(v8::String::NewSymbol("GestureGenerator"), proto->GetFunction());
return proto;
}
+
+ Handle<Value> GestureGenerator::createGestureGeneratorSync(const Arguments& args) {
+ HandleScope scope;
+
+ //Extract arguments
+ Context& ctx = *(Context::Unwrap<Context>(args[0]->ToObject()));
+
+ Handle<Object> instH = ((Function*)(*args.Data()))->NewInstance();
+ XnNodeHandle handle;
+ create(ctx, handle, NULL);
+ (new GestureGenerator(handle))->Wrap(instH); //FIXME: should we use wrap()?
+
+ return instH;
+ }
}
View
4 src/GestureGenerator.h
@@ -33,10 +33,14 @@ namespace node_xn {
class GestureGenerator: public Generator {
public:
+ /* Factory method(s) */
+ static void create(const Context& ctx, XnNodeHandle& handle, XnNodeQuery* query);
+
/* Copy ctor. */
inline GestureGenerator(const GestureGenerator& orig) : Generator(orig) {}
/** WRAPPED METHODS **/
+ static Handle<Value> createGestureGeneratorSync(const Arguments& args);
protected:
/* Supertype constructors */
inline GestureGenerator(XnNodeHandle handle) : Generator(handle) {}
View
7 src/ProductionNode.h
@@ -24,6 +24,8 @@
#include "wrapperUtils.h"
+#include "Context.h"
+
namespace node_xn {
using namespace v8;
@@ -42,6 +44,11 @@ namespace node_xn {
private:
void OnConstruct();
XnNodeHandle const ptr;
+
+ friend class Context;
+
+ friend class Generator;
+ friend class GestureGenerator;
};
/* Initializer */

0 comments on commit 414162d

Please sign in to comment.
Something went wrong with that request. Please try again.