Mercurial > pytave
changeset 204:61df785bd8b0
pyeval creates pyobj direction
pyeval uses an feval call to create a pyobj. Thanks to Mike Miller.
* pyeval.cc: create pyobj
author | Colin Macdonald <cbm@m.fsf.org> |
---|---|
date | Fri, 20 May 2016 22:12:32 -0700 |
parents | 7d03df51d6e8 |
children | 98cde0dcf09f |
files | @pyobj/dummy.m pyeval.cc |
diffstat | 2 files changed, 6 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/@pyobj/dummy.m Fri May 20 10:21:04 2016 -0700 +++ b/@pyobj/dummy.m Fri May 20 22:12:32 2016 -0700 @@ -46,7 +46,7 @@ %% @example %% @group %% % x.keys() % FIXME: should be this but its broken -%% ddotkeys = pyobj(x.keys); +%% ddotkeys = x.keys; %% ddotkeys() %% @result{} ans = %% @{ @@ -56,11 +56,11 @@ %% @end group %% @end example %% -%% @code{pyeval} should return a @@pyobj for things it cannot convert to +%% @code{pyeval} returns a @@pyobj for things it cannot convert to %% Octave-native objects: %% @example %% @group -%% pyexec('import sys') % doctest: +XFAIL +%% pyexec('import sys') %% sysmodule = pyeval('sys') %% @result{} sysmodule = %% [PyObject id ...] @@ -68,19 +68,6 @@ %% @end group %% @end example %% -%% But it doesn't work yet, for now you have to do: -%% @example -%% @group -%% pyexec('import sys') -%% key = pyeval('sys') -%% @result{} key = ... -%% sysmodule = pyobj(key) -%% @result{} sysmodule = -%% [PyObject id ...] -%% <module 'sys' (built-in)> -%% @end group -%% @end example -%% %% After you have the object, you can access its properties: %% @example %% @group
--- a/pyeval.cc Fri May 20 10:21:04 2016 -0700 +++ b/pyeval.cc Fri May 20 22:12:32 2016 -0700 @@ -29,6 +29,7 @@ #include <boost/python/numeric.hpp> #include <oct.h> +#include <octave/parse.h> #define PYTAVE_DO_DECLARE_SYMBOL #include "arrayobjectdefs.h" @@ -96,9 +97,8 @@ " __InOct__ = dict()\n", main_namespace, main_namespace); main_namespace["__InOct__"][id] = res; - //retval(0) = pyobj(id); - // FIXME: how to do the above? For now, just return the string - retval(0) = id; + // Create @pyobj + retval = feval ("pyobj", ovl (id), 1); } catch (error_already_set const &) {