# HG changeset patch # User Colin Macdonald # Date 1463807552 25200 # Node ID 61df785bd8b0c2d3d08c22ac0535cb2c7327f75a # Parent 7d03df51d6e8fe65fabaeca1b5af68738d28ca44 pyeval creates pyobj direction pyeval uses an feval call to create a pyobj. Thanks to Mike Miller. * pyeval.cc: create pyobj diff -r 7d03df51d6e8 -r 61df785bd8b0 @pyobj/dummy.m --- 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 ...] -%% -%% @end group -%% @end example -%% %% After you have the object, you can access its properties: %% @example %% @group diff -r 7d03df51d6e8 -r 61df785bd8b0 pyeval.cc --- 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 #include +#include #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 &) {