Commit f7614877 authored by Roland Levillain's avatar Roland Levillain
Browse files

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.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@4701 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent aec7da15
......@@ -6,6 +6,17 @@
../../swilena/run.in.
(modpath): Append @abs_top_builddir@/src/wrappers/.libs.
2009-11-02 Roland Levillain <roland@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@lrde.epita.fr>
Expose the Milena wrappers to SWIG.
......
......@@ -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)
......
......@@ -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)
......
#! /usr/bin/env python
# Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
#
# This file is part of Olena.
#
# Olena is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, version 2 of the License.
#
# Olena is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
# \file
# \brief A Python version of test/test_milena.cc using libdynmilena.
import ltihooks
import dyn
import mln
# We'd like to be able to write this:
#
# 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 = mln.cvar.mk_image2d_int(dyn.data(3), dyn.data(3))
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)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment