Je ne sais pas si c'est une bonne idée de maintenir des bindings ruby,
mais comme ca ne coute pas grand chose et que je l'ai fait, autant
l'ajouter, on pourra toujours l'enlever (en 10 minutes) si ca nous
disperse trop ...
Index: ChangeLog
from Nicolas Burrus <burrus_n(a)lrde.epita.fr>
* configure.ac: Add ruby support.
Index: tools/swilena/ChangeLog
from Nicolas Burrus <burrus_n(a)lrde.epita.fr>
* meta/swilena_ntg.i: Adjust for ruby.
* meta/swilena_describe.i: Tweak for ruby.
* expand.sh: Generate ruby source files.
+2003-09-21 Nicolas Burrus <burrus_n(a)lrde.epita.fr>
+
+ * meta/swilena_describe.i: Add __str__ function for python.
+
2003-09-15 Nicolas Burrus <burrus_n(a)lrde.epita.fr>
* meta/swilena_image.i: Copy constructor parameter is not const.
Index: configure.ac
--- configure.ac Mon, 15 Sep 2003 17:23:46 +0200 burrus_n (oln/3_configure.
1.47.1.1.1.1.1.4.1.15.1.10 640)
+++ configure.ac Sun, 21 Sep 2003 20:25:01 +0200 burrus_n (oln/3_configure.
1.47.1.1.1.1.1.4.1.15.1.11 640)
@@ -373,11 +373,31 @@
CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
AC_CHECK_HEADERS([Python.h],,
AC_MSG_ERROR(
- [You need Python development files to compile the Python interface. Specify
--with-python-includedir to set it manually or --without-swilena to disable it.]))
+ [You need Python development files to compile the Python interface. Specify
--with-python-includedir to set it manually or --without-pylena to disable it.]))
CPPFLAGS=$save_CPPFLAGS
], [python])dnl End of OLN_COMPONENT([tools/swilena/python])
+ OLN_COMPONENT([tools/swilena/ruby],
+ [rblena],
+ [oln_cv_build_rblena],
+ [the Ruby interface to Olena],
+ [OLN_SWILENA],
+ [tools/swilena/ruby/Makefile],
+ [
+ AC_ARG_VAR([RUBY_CPPFLAGS], [Path to ruby.h])
+ AC_ARG_WITH([python-includedir], [Include path for ruby.h],
+ [RUBY_CPPFLAGS="-I$withval"],
+ [RUBY_CPPFLAGS="-I/usr/lib/ruby/1.6/i386-linux"])
+
+ CPPFLAGS="$CPPFLAGS $RUBY_CPPFLAGS"
+ AC_CHECK_HEADERS([ruby.h],,
+ AC_MSG_ERROR(
+ [You need Ruby development files to compile the Ruby interface. Specify
--with-python-includedir to set it manually or --without-rblena to disable it.]))
+
+ CPPFLAGS=$save_CPPFLAGS
+ ], [ruby])dnl End of OLN_COMPONENT([tools/swilena/ruby])
+
])dnl End of OLN_COLLECTION([OLN_SWILENA])
], [swilena])dnl End of OLN_COMPONENT([tools/swilena])
Index: tools/swilena/expand.sh
--- tools/swilena/expand.sh Mon, 15 Sep 2003 17:50:05 +0200 burrus_n (oln/s/25_expand.sh
1.6 750)
+++ tools/swilena/expand.sh Sun, 21 Sep 2003 20:25:01 +0200 burrus_n (oln/s/25_expand.sh
1.7 750)
@@ -7,6 +7,7 @@
mkdir -p "$SWILENA/src"
mkdir -p "$SWILENA/python"
+mkdir -p "$SWILENA/ruby"
MODULES="$MODULES ntg ntg_cplx ntg_int_u ntg_int_s"
for dim in 1 2 3; do
@@ -40,7 +41,7 @@
float_s float_d # rgb_8 rgb_16 rgb_32
do
short=`echo $t | sed -e 's,int_,,g;s,_,,g'`
- echo "make_image(image${dim}d_$short, $dim, ntg::$t)" >>
"$SWILENA/src/swilena_image${dim}d.i"
+ echo "make_image(image${dim}d_$short, $dim, ntg_$t)" >>
"$SWILENA/src/swilena_image${dim}d.i"
done
done
@@ -105,6 +106,66 @@
done
}
+#################### Ruby stuff #######################
+
+header_ruby()
+{
+cat <<EOF
+## Process this file through Automake to produce Makefile.in -*- Makefile -*-
+##
+## Makefile.am for swilena/python
+## NOTE: this file was generated automatically by expand.sh
+##
+
+INCLUDES = \$(RUBY_CPPFLAGS) -I\$(srcdir)/../src
+AM_CPPFLAGS = -DOLN_EXCEPTIONS
+AM_CXXFLAGS = \$(CXXFLAGS_OPTIMIZE)
+AM_LDFLAGS = -shared -lswigrb \$(ZLIB_LDFLAGS)
+
+rubydir = \$(libdir)/ruby
+
+EOF
+}
+
+dump_ruby()
+{
+ echo -n "ruby_PROGRAMS ="
+ ilist=0
+ for mod in $MODULES; do
+ if [ `expr $ilist % 4` = 0 ]; then
+ echo " \\"; echo -ne "\t"
+ fi
+ echo -n " swilena_$mod.so"
+ ilist=`expr $ilist + 1`
+ done
+ echo; echo
+ echo -n "ruby_DATA ="
+ ilist=0
+ for mod in $MODULES; do
+ if [ `expr $ilist % 4` = 0 ]; then
+ echo " \\"; echo -ne "\t"
+ fi
+ echo -n " swilena_$mod.rb"
+ ilist=`expr $ilist + 1`
+ done
+ echo; echo
+ for mod in $MODULES; do
+ echo "swilena_${mod}_so_SOURCES = swilena_${mod}_wrap.cxx"
+ done
+ echo
+ ilist=0
+ for mod in $MODULES; do
+ if [ -r "$SWILENA/src/swilena_${mod}.i" ]; then
+ sdir=src
+ else
+ sdir=meta
+ fi
+ echo "swilena_${mod}_wrap.cxx swilena_${mod}.rb:
\$(srcdir)/../$sdir/swilena_${mod}.i"
+ echo -e "\t\$(SWIG) -c -c++ -ruby -I\$(srcdir)/../src -I\$(srcdir)/../meta
\$(CPPFLAGS) -o swilena_${mod}_wrap.cxx \$(srcdir)/../$sdir/swilena_${mod}.i"
+ echo
+ done
+}
+
############ Generic stuff ###########
header_src() {
@@ -140,3 +201,5 @@
dump_src >>"$SWILENA/src/Makefile.am"
header_python >"$SWILENA/python/Makefile.am"
dump_python >>"$SWILENA/python/Makefile.am"
+header_ruby >"$SWILENA/ruby/Makefile.am"
+dump_ruby >>"$SWILENA/ruby/Makefile.am"
Index: tools/swilena/meta/swilena_describe.i
--- tools/swilena/meta/swilena_describe.i Tue, 06 May 2003 06:56:14 +0200 raph
(oln/s/38_swilena_de 1.1 640)
+++ tools/swilena/meta/swilena_describe.i Sun, 21 Sep 2003 20:25:01 +0200 burrus_n
(oln/s/38_swilena_de 1.2 640)
@@ -12,6 +12,22 @@
os << # T1 "," # T2 "@" << self << " =
" << (*self);
return os.str();
}
+
+#if defined(SWIGPYTHON)
+ const char *__str__() {
+ std::ostringstream os;
+ os << (*self);
+ return os.str().c_str();
+ }
+#endif
+
+#if defined(SWIGRUBY)
+ std::string to_s() {
+ std::ostringstream os;
+ os << (*self);
+ return os.str();
+ }
+#endif
}
%enddef
%define EXTEND_DESCRIBE(T)
@@ -23,6 +39,21 @@
os << # T "@" << self << " = " <<
(*self);
return os.str();
}
+
+#if defined(SWIGPYTHON)
+ const char *__str__() {
+ std::ostringstream os;
+ os << (*self);
+ return os.str().c_str();
}
-%enddef
+#endif
+#if defined(SWIGRUBY)
+ std::string to_s() {
+ std::ostringstream os;
+ os << (*self);
+ return os.str();
+ }
+#endif
+}
+%enddef