forked from electronifie/node-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpy_object_wrapper.h
More file actions
61 lines (38 loc) · 1.68 KB
/
py_object_wrapper.h
File metadata and controls
61 lines (38 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef PY_OBJECT_WRAPPER_H
#define PY_OBJECT_WRAPPER_H
#include <string>
#include <node.h>
#include <Python.h>
#include "utils.h"
using namespace v8;
using std::string;
class PyObjectWrapper : public node::ObjectWrap {
PyObject* mPyObject;
public:
static Persistent<FunctionTemplate> py_function_template;
PyObjectWrapper(PyObject* obj) : node::ObjectWrap(), mPyObject(obj) {};
virtual ~PyObjectWrapper() {
Py_XDECREF(mPyObject);
mPyObject = NULL;
}
static void Initialize();
static Handle<Value> New(PyObject* obj);
static Handle<Value> New(const Arguments& args);
static Handle<Value> Get(Local<String> key, const AccessorInfo& info);
static Handle<Value> Set(Local<String> key, Local<Value> value, const AccessorInfo& info);
static Handle<Value> CallAccessor(Local<String> property, const AccessorInfo& info);
static Handle<Value> ToStringAccessor(Local<String> property, const AccessorInfo& info);
static Handle<Value> ValueOfAccessor(Local<String> property, const AccessorInfo& info);
static Handle<Value> Call(const Arguments& args);
static Handle<Value> ToString(const Arguments& args);
static Handle<Value> ValueOf(const Arguments& args);
static PyObject* ConvertToPython(const Handle<Value>& value);
static Local<Value> ConvertToJavaScript(PyObject* obj);
PyObject* InstanceGetPyObject() {
return mPyObject;
};
Handle<Value> InstanceCall(const Arguments& args);
string InstanceToString(const Arguments& args);
PyObject* InstanceGet(const string& key);
};
#endif