← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] Add str() to Variable interface (in C++) and overload info()

 



Johan Hake wrote:
On Sunday 10 May 2009 12:20:24 Garth N. Wells wrote:
DOLFIN wrote:
One or more new changesets pushed to the primary dolfin repository.
A short summary of the last three changesets is included below.

changeset:   6112:1b2b19ddacfa92c80d36dc78a5bb4829605a10c0
tag:         tip
user:        Anders Logg <logg@xxxxxxxxx>
date:        Sun May 10 00:33:56 2009 +0200
files:       dolfin/common/Variable.cpp dolfin/common/Variable.h
dolfin/log/Logger.cpp dolfin/log/Table.cpp dolfin/log/Table.h
dolfin/log/log.cpp dolfin/log/log.h dolfin/parameter/NewParameters.cpp
dolfin/parameter/NewParameters.h sandbox/misc/cpp/main.cpp description:
Add str() to Variable interface (in C++) and overload info()
to accept a Variable, printing the output of str().
The function

     void info(const Variable& variable);

has caused a problem when compiling the Python wrappers,
dolfin/swig/cpp_wrap.cc: In function ‘PyObject* _wrap_info(PyObject*,
PyObject*)’:
dolfin/swig/cpp_wrap.cc:27939: error: invalid conversion from ‘int’ to
‘PyObject*’
dolfin/swig/cpp_wrap.cc:27791: error: too many arguments to function
‘PyObject* _wrap_info__SWIG_0(PyObject*, PyObject*)’
dolfin/swig/cpp_wrap.cc:27939: error: at this point in file
dolfin/swig/cpp_wrap.cc:27942: error: invalid conversion from ‘int’ to
‘PyObject*’
dolfin/swig/cpp_wrap.cc:27861: error: too many arguments to function
‘PyObject* _wrap_info__SWIG_1(PyObject*, PyObject*)’
dolfin/swig/cpp_wrap.cc:27942: error: at this point in file
scons: *** [dolfin/swig/cpp_wrap.os] Error 1

 From a quick inspection, I don't see what the problem is.

I think swig has some problems with overloading functions with variable number of parameters.

I don't particularly like the functions with a variable number of parameters (those using the ellipses (...)). Can we avoid using them? Can we make use of ostringstream instead?

Garth

I fixed it by ignoring the new info(Variable) function, and
renamed info to _info and added a python info() which check if the first argument is a Variable instance. If so it calls _info(variable.__str_()).

Johan

Garth

changeset:   6111:cb273268cb9be9f70ab2769e704491d623005baf
user:        "Johan Hake <hake@xxxxxxxxx>"
date:        Sat May 09 23:04:49 2009 +0200
files:       dolfin/swig/dolfin.i dolfin/swig/dolfin_shared_ptr_classes.i
description:
A swig fix for member functions of Variables, when called from dervied
classes that are also declared shared_ptr stored in the swig interface

I just reimplemented the Variable interface in the c++ proxy classes for
both Mesh and Function. This is done using a macro making further fixes
straightforward. Thansk to Ola for this fix.


changeset:   6110:aab1ba963d5b7284c0014f5c64089744eea26501
parent:      6106:05785f70d30b2e1719773263d9f6d4800a292ce6
parent:      6109:9f0a8f3cf506bde1d1649c826bd164f52b3da601
user:        "Garth N. Wells <gnw20@xxxxxxxxx>"
date:        Sat May 09 17:39:37 2009 +0100
files:       demo/pde/sym-dirichlet-bc/cpp/main.cpp dolfin/la/enums_la.h
description:
merge.

----------------------------------------------------------------------
For more details, visit http://www.fenics.org/hg/dolfin
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev





Follow ups

References