summaryrefslogtreecommitdiff
path: root/weave/ext_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/ext_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/ext_tools.py')
-rw-r--r--weave/ext_tools.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/weave/ext_tools.py b/weave/ext_tools.py
index eae6ecfc3..436a068c5 100644
--- a/weave/ext_tools.py
+++ b/weave/ext_tools.py
@@ -41,7 +41,7 @@ class ext_function_from_specs:
"""
join = string.join
- declare_return = 'PyObject *return_val = NULL;\n' \
+ declare_return = 'py::object return_val;\n' \
'int exception_occured = 0;\n' \
'PyObject *py_local_dict = NULL;\n'
arg_string_list = self.arg_specs.variable_as_strings() + ['"local_dict"']
@@ -128,18 +128,17 @@ class ext_function_from_specs:
"\n} \n"
catch_code = "catch(...) \n" \
"{ \n" + \
- " return_val = NULL; \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() + \