[PATCH 05/19] box2d.i: Add a ctor taking two `int's as argument.

--- swilena/ChangeLog | 4 ++++ swilena/box2d.i | 23 ++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/swilena/ChangeLog b/swilena/ChangeLog index 391d3e3..917269e 100644 --- a/swilena/ChangeLog +++ b/swilena/ChangeLog @@ -1,5 +1,9 @@ 2009-05-26 Roland Levillain <roland@lrde.epita.fr> + * box2d.i: Add a ctor taking two `int's as argument. + +2009-05-26 Roland Levillain <roland@lrde.epita.fr> + * python/sps-local.in (PYTHONPATH): Fix paths. 2009-05-14 Roland Levillain <roland@lrde.epita.fr> diff --git a/swilena/box2d.i b/swilena/box2d.i index 00e91e1..e24f016 100644 --- a/swilena/box2d.i +++ b/swilena/box2d.i @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -42,8 +42,11 @@ %include "mln/core/site_set/box.hh"; %include "mln/core/alias/box2d.hh"; -// Swig tries to wrap everything by default; prevent it from wrapping -// invalid methods (1D and 3D ctors for a box2d). +/* Swig tries to wrap everything by default; prevent it from wrapping + invalid methods (1D and 3D ctors for an mln::box2d). Moreover, as + Python does not automatically convert `int's to `short's, we cannot + use the ctor taking two `mln::def::coord's (i.e. `short's) + either. */ /* FIXME: Can't we simplify these directives, i.e. use `point2d' directly? Maybe we could use mln_coord()? */ %ignore mln::box< mln::point<mln::grid::square, mln::def::coord> > @@ -51,11 +54,22 @@ %ignore mln::box< mln::point<mln::grid::square, mln::def::coord> > ::box(typename mln::point<mln::grid::square, mln::def::coord>::coord, + typename mln::point<mln::grid::square, mln::def::coord>::coord); + +%ignore mln::box< mln::point<mln::grid::square, mln::def::coord> > +::box(typename mln::point<mln::grid::square, mln::def::coord>::coord, typename mln::point<mln::grid::square, mln::def::coord>::coord, typename mln::point<mln::grid::square, mln::def::coord>::coord); -%extend mln::box +%extend mln::box< mln::point<mln::grid::square, mln::def::coord> > { + // Provide a ctor creating an `mln::box2d' from two `int's. + mln::box< mln::point< mln::grid::square, mln::def::coord> > (int nrows, + int ncols) + { + return new mln::box<mln::point2d>(nrows, ncols); + } + unsigned nrows() const { // FIXME: This is the exact content of box_impl_<2, C, E>::nrows. @@ -69,5 +83,4 @@ } } - %template(box2d) mln::box< mln::point<mln::grid::square, mln::def::coord> >; -- 1.6.1.2
participants (1)
-
Roland Levillain