* swig/python/milena-libdynmilena.py: New.
* swig/python/milena.py: Rename as...
* swig/python/milena-libdyn.py: ...this.
Add comments.
* swig/python/Makefile.am (TESTS): s/milena.py/milena-libdyn.py/
Add milena-libdynmilena.py.
---
dynamic-use-of-static-c++/ChangeLog | 11 +++++++
dynamic-use-of-static-c++/swig/python/Makefile.am | 2 +-
.../swig/python/{milena.py => milena-libdyn.py} | 6 +++-
.../python/{milena.py => milena-libdynmilena.py} | 30 +++++++------------
4 files changed, 28 insertions(+), 21 deletions(-)
copy dynamic-use-of-static-c++/swig/python/{milena.py => milena-libdyn.py} (90%)
rename dynamic-use-of-static-c++/swig/python/{milena.py => milena-libdynmilena.py}
(61%)
diff --git a/dynamic-use-of-static-c++/ChangeLog b/dynamic-use-of-static-c++/ChangeLog
index 81c90c3..400c9bb 100644
--- a/dynamic-use-of-static-c++/ChangeLog
+++ b/dynamic-use-of-static-c++/ChangeLog
@@ -8,6 +8,17 @@
2009-11-02 Roland Levillain <roland(a)lrde.epita.fr>
+ Exercise the SWIG (Python) Milena wrappers.
+
+ * swig/python/milena-libdynmilena.py: New.
+ * swig/python/milena.py: Rename as...
+ * swig/python/milena-libdyn.py: ...this.
+ Add comments.
+ * swig/python/Makefile.am (TESTS): s/milena.py/milena-libdyn.py/
+ Add milena-libdynmilena.py.
+
+2009-11-02 Roland Levillain <roland(a)lrde.epita.fr>
+
Expose the Milena wrappers to SWIG.
* swig/mln.i: New.
diff --git a/dynamic-use-of-static-c++/swig/python/Makefile.am
b/dynamic-use-of-static-c++/swig/python/Makefile.am
index 86611e3..f704065 100644
--- a/dynamic-use-of-static-c++/swig/python/Makefile.am
+++ b/dynamic-use-of-static-c++/swig/python/Makefile.am
@@ -119,7 +119,7 @@ $(srcdir)/run.stamp: $(RUN_IN)
# and a test. Alas, the script `run' expects a file name with an
# extension as argument. We could improve this by adding options such
# as `--python' to `run'.
-TESTS = milena.py
+TESTS = milena-libdyn.py milena-libdynmilena.py
# FIXME: Is this really needed?
EXTRA_DIST += $(TESTS)
diff --git a/dynamic-use-of-static-c++/swig/python/milena.py
b/dynamic-use-of-static-c++/swig/python/milena-libdyn.py
similarity index 90%
copy from dynamic-use-of-static-c++/swig/python/milena.py
copy to dynamic-use-of-static-c++/swig/python/milena-libdyn.py
index 93c384b..65e6fe9 100644
--- a/dynamic-use-of-static-c++/swig/python/milena.py
+++ b/dynamic-use-of-static-c++/swig/python/milena-libdyn.py
@@ -17,24 +17,28 @@
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
# \file
-# \brief A Python version of test/test_olena.cc.
+# \brief A Python version of test/test_milena.cc using libdyn (directly).
import ltihooks
import dyn
import config
+# Set up paths.
dyn.include_dir(config.abs_milena_dir)
dyn.include("mln/core/image/image2d.hh")
dyn.include("mln/data/fill.hh")
dyn.include("mln/debug/iota.hh")
dyn.include("mln/debug/println.hh")
+# Instantiate functors.
mk_image2d_int = dyn.ctor("mln::image2d<int>")
fill = dyn.fun("mln::data::fill")
iota = dyn.fun("mln::debug::iota")
println = dyn.fun("mln::debug::println")
+# Use them (by compiling them on-the-fly).
+
# We'd like to be able to write this:
#
# ima = mk_image2d_int(3, 3)
diff --git a/dynamic-use-of-static-c++/swig/python/milena.py
b/dynamic-use-of-static-c++/swig/python/milena-libdynmilena.py
similarity index 61%
rename from dynamic-use-of-static-c++/swig/python/milena.py
rename to dynamic-use-of-static-c++/swig/python/milena-libdynmilena.py
index 93c384b..037a429 100644
--- a/dynamic-use-of-static-c++/swig/python/milena.py
+++ b/dynamic-use-of-static-c++/swig/python/milena-libdynmilena.py
@@ -17,35 +17,27 @@
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
# \file
-# \brief A Python version of test/test_olena.cc.
+# \brief A Python version of test/test_milena.cc using libdynmilena.
import ltihooks
import dyn
-import config
-
-dyn.include_dir(config.abs_milena_dir)
-dyn.include("mln/core/image/image2d.hh")
-dyn.include("mln/data/fill.hh")
-dyn.include("mln/debug/iota.hh")
-dyn.include("mln/debug/println.hh")
-
-mk_image2d_int = dyn.ctor("mln::image2d<int>")
-fill = dyn.fun("mln::data::fill")
-iota = dyn.fun("mln::debug::iota")
-println = dyn.fun("mln::debug::println")
+import mln
# We'd like to be able to write this:
#
-# ima = mk_image2d_int(3, 3)
+# ima = mln.mk_image2d_int(3, 3)
#
# but we just can't. `mk_image2d_int' only accept `dyn.data' as
# arguments, so we have to encapsulate integers in `dyn.data' objects
# (likewise for strings).
+#
+# Moreover, mk_image2d_int is a global object (functor), registered as
+# an attribute of the `mln.cvar' object.
-ima = mk_image2d_int(dyn.data(3), dyn.data(3))
+ima = mln.cvar.mk_image2d_int(dyn.data(3), dyn.data(3))
-fill(ima, dyn.data(0))
-println(dyn.data("ima (before) ="), ima)
-iota(ima)
-println(dyn.data("ima (after) ="), ima)
+mln.cvar.fill(ima, dyn.data(0))
+mln.cvar.println(dyn.data("ima (before) ="), ima)
+mln.cvar.iota(ima)
+mln.cvar.println(dyn.data("ima (after) ="), ima)
--
1.6.5
Show replies by date