[C++-sig] pyste - integration

Jason.Sibthorpe at aculab.com Jason.Sibthorpe at aculab.com
Thu Sep 11 18:36:27 CEST 2003


Synopsis :

I want to know how/if I can integrate my code
with pyste to take advantage of its knowledge of function
arguments so they don't have to be passed to  wrap_out_arg

Detail :

I have written a noddy code generator that takes

wrap_out_arg("test.h", "foo", "char *I, int *O")

(for any number of input args where 'O' indicates
that it is an output argument, and the type is simple
- the type need not be simple but if it aint then the result 
might not compile)

and generates

tuple return_args_wrapper(char * in0)
        	int * out0;
        	return make_tuple(foo(in0, out0), 

as a wrapper for
const char *foo(char *str, int *num)

where num is an output argument.

It is based on the example supplied by Nicodemus.

foo_wrapper = Wrapper('foo_wrapper',
tuple foo_wrapper(in_type in)
    out_type2 out2;
    out_type1 out1 = foo(in, out2);
    return make_tuple(out1, out2);
foo = Function(...)
set_wrapper(foo, foo_wrapper)


I found that I had to have my code in the .pyste file (I could not
import my module).  When attempting the import I got the following

    set_wrapper(Function(self.func, self.header),
TypeError: __init__() takes at least 5 arguments (3 given)

Which is bizarre.  If I add None, None I get a bit further.

    Wrapper(wrapper_name, code))
NameError: global name 'Wrapper' is not defined

even though I explicitly import exporterutils
from exporterutils import *

Changing the name from Wrapper to FunctionWrapper results in
"/home/jason/src/boost_cvs/boost/libs/python/pyste/src/Pyste/infos.py", line
212, in set_wrap
    info._Attribute('wrapper', wrapper)
AttributeError: 'Function' object has no attribute '_Attribute'

At this point I give up.  I suppose my question is, is this related to
the execfile(interface, context) call in ExecuteInterface?  I assume it
is something to do with the context in which my module is imported, mmm...
I don't know enough python.


I would like to integrate this code with pyste to take advantage
of its knowledge of the declaration so users of wrap_out_arg
need only specify the out args.  Is this possible?

Daniel Wallin mentions Lua 
Is what I am attempting going to be soon unnecessary?

Jason Sibthorpe
Software Engineer
Tel: +44 (0) 1908 273 869
Fax: +44 (0) 1908 273 801
Email: jason.sibthorpe at aculab.com
Website: <http://www.aculab.com>

More information about the Cplusplus-sig mailing list