Comments (1)
now ffpython has supported that case, i have update the ffpython.h and example.cpp, you can see the example.cpp how to call pyclass method. By the way, ffpython now can call python lamda function.
But you should pay more attention when using that api, because you should call Py_DECREF when you don't need the reference of the python handle.
example python code:
class pyclass_t:
def __init__(self):
print('pyclass_t init....')
def sayHi(self, a1, a2):
print('sayHi..', a1, a2)
def test_cpp_obj_return_py_obj():
return pyclass_t()
def test_cpp_obj_return_py_lambda():
def test_lambda(a1):
print('test_lambda....', a1)
return test_lambda
example c++ code:
void test_py_class_lambda(ffpython_t& ffpython)
{
PyObject* pobj = ffpython.call<PyObject*>("fftest", "test_cpp_obj_return_py_obj");
ffpython.obj_call<void>(pobj, "sayHi", 1, string("soNice"));
PyObject* pFunc= ffpython.call<PyObject*>("fftest", "test_cpp_obj_return_py_lambda");
ffpython.call_lambda<void>(pFunc, 112233);
Py_DECREF(pFunc);
Py_DECREF(pobj);
}
from ffpython.
Related Issues (12)
- can't compiled with vs2008/vs2010/gcc HOT 2
- NameError: name 'ffpython' is not defined HOT 1
- Is there a posibility to return a custom type to python HOT 1
- Calling from C++ a C++ reg function by name HOT 1
- several issues about the ffpython HOT 1
- string format issue HOT 2
- MFC引用不能多次include HOT 9
- windows上面 python27 编译后第 invalid type 错误 HOT 2
- linux下编译增加gcc选项-c -O2 -Wall 编译失败 HOT 1
- ffpython::add_path() file path changed support
- 内存泄漏 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ffpython.