Call by reference in SWIG?

2008-12-10 Thread Nok
I can't get call-by-reference functions to work in SWIG...

Even when wrapping a trivial example like this:

/* File : trivial.i */
%module trivial
%inline
%{
  class test
  {
  public:
void foo(int *t)
{
  *t=42;
}
  };
%}

I get a TypeError when trying to use it:

import trivial

x=10
c=trivial.test()
c.foo(x)

The error is:

def foo(*args): return _trivial.test_foo(*args)
TypeError: in method 'test_foo', argument 2 of type 'int &'
--
http://mail.python.org/mailman/listinfo/python-list


Call by reference in SWIG?

2008-12-10 Thread Nok
I can't get call-by-reference functions to work in SWIG...

Even when wrapping a trivial example like this:

/* File : trivial.i */
%module trivial
%inline
%{
  class test
  {
  public:
void foo(int *t)
{
  *t=42;
}
  };
%}

I get a TypeError when trying to use it:

import trivial

x=10
c=trivial.test()
c.foo(x)

The error is:

def foo(*args): return _trivial.test_foo(*args)
TypeError: in method 'test_foo', argument 2 of type 'int &'
--
http://mail.python.org/mailman/listinfo/python-list