-
Notifications
You must be signed in to change notification settings - Fork 0
/
class_test.cpp
76 lines (55 loc) · 1.34 KB
/
class_test.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <Python/Python.h>
class Book {
public:
Book(int num_levels) {
num_levels = num_levels
levels = int* [num_levels]
};
void update();
private:
int num_levels;
int* levels;
int* bids, asks;
}
class FeatureSet {
public:
float*
}
class
int main(int argc, char *argv[])
{
PyObject *pName, *pModule, *pDict, *pFunc;
PyObject *pArgs, *pValue;
int i;
Py_Initialize();
PyObject *sys = PyImport_ImportModule("sys");
PyObject *path = PyObject_GetAttrString(sys, "path");
PyList_Append(path, PyString_FromString("."));
pName = PyString_FromString("class_test");
pModule = PyImport_Import(pName);
Py_DECREF(pName);
pFunc = PyObject_GetAttrString(pModule, "incrementer");
Py_DECREF(pModule);
PyObject *pObject = PyObject_CallObject(pFunc, NULL);
Py_DECREF(pFunc);
for (i = 0; i < 3; ++i) {
PyObject_CallMethod(pObject, "next", NULL);
}
Py_DECREF(pObject);
Py_Finalize();
return 0;
}
/*
#include </usr/include/python2.7/Python.h>
int main(int, char **) {
Py_Initialize();
PyObject *sys = PyImport_ImportModule("sys");
PyObject *path = PyObject_GetAttrString(sys, "path");
PyList_Append(path, PyString_FromString("."));
PyRun_SimpleString("import os,hello");
PyRun_SimpleString("print os.getcwd()");
PyRun_SimpleString("hello.hello()");
Py_Finalize();
return 0;
}
*/