summaryrefslogtreecommitdiff
path: root/weave/inline_tools.py
diff options
context:
space:
mode:
authorEric Jones <eric@enthought.com>2002-09-30 08:31:56 +0000
committerEric Jones <eric@enthought.com>2002-09-30 08:31:56 +0000
commit920b35a1c9a88595384d4ff0f4a90ddf594ffedd (patch)
treea51766420a2f1af289892b5c6f5f635dddec4712 /weave/inline_tools.py
parentc3ba22da35f011595b2643e894db1f797e7f2fec (diff)
downloadnumpy-920b35a1c9a88595384d4ff0f4a90ddf594ffedd.tar.gz
This checkin has quite a few changes. Most are augmentations to the
py::object class' capabilities and unit tests to check them and changes to test cases/examples to use the new features. There is also one other BIG change. return_val has been changed from a PyObject* to a py::object. This removes the need to handle reference counting almost completely from inline() code. I am very happy about this. :-) All tests pass on win32, but the examples still need some work.
Diffstat (limited to 'weave/inline_tools.py')
-rw-r--r--weave/inline_tools.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/weave/inline_tools.py b/weave/inline_tools.py
index 7ec290a74..38f22865b 100644
--- a/weave/inline_tools.py
+++ b/weave/inline_tools.py
@@ -29,7 +29,7 @@ class inline_ext_function(ext_tools.ext_function):
This code got a lot uglier when I added local_dict...
"""
- declare_return = 'PyObject *return_val = NULL;\n' \
+ declare_return = 'py::object return_val;\n' \
'int exception_occured = 0;\n' \
'PyObject *py__locals = NULL;\n' \
'PyObject *py__globals = NULL;\n'
@@ -96,19 +96,18 @@ class inline_ext_function(ext_tools.ext_function):
' /*I would like to fill in changed ' \
'locals and globals here...*/ \n' \
'\n} \n'
- catch_code = "catch(...) \n" \
- "{ \n" + \
- " return_val = NULL; \n" \
- " exception_occured = 1; \n" \
- "} \n"
+ catch_code = "catch(...) \n" \
+ "{ \n" + \
+ " return_val = py::object(); \n" \
+ " exception_occured = 1; \n" \
+ "} \n"
return_code = " /* cleanup code */ \n" + \
cleanup_code + \
- " if(!return_val && !exception_occured)\n" \
+ " if(!(PyObject*)return_val && !exception_occured)\n" \
" {\n \n" \
- " Py_INCREF(Py_None); \n" \
" return_val = Py_None; \n" \
" }\n \n" \
- " return return_val; \n" \
+ " return return_val.disown(); \n" \
"} \n"
all_code = self.function_declaration_code() + \