aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-23 06:41:55 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-23 06:41:55 +0000
commite544ea1c4ea59000f53582a4f1a52b89caa1db8f (patch)
tree6e0716a464b6fc4cd42cc63c793a7ec8a667f9f7
parent837ed5227bbe789d97eea6c323619706678b32ff (diff)
downloadpaludis-e544ea1c4ea59000f53582a4f1a52b89caa1db8f.tar.gz
paludis-e544ea1c4ea59000f53582a4f1a52b89caa1db8f.tar.xz
Add the start of a Ruby interface. Tidy up some of the makefiles.
-rw-r--r--Makefile.am4
-rw-r--r--configure.ac53
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/paludis.cc8
-rw-r--r--paludis/paludis.hh.m46
-rw-r--r--paludis/repositories/cran/Makefile.am10
-rw-r--r--paludis/repositories/fake/Makefile.am5
-rw-r--r--paludis/repositories/nothing/Makefile.am5
-rw-r--r--paludis/repositories/portage/Makefile.am12
-rw-r--r--paludis/repositories/vdb/Makefile.am10
-rw-r--r--paludis/repositories/virtuals/Makefile.am5
-rw-r--r--ruby/Makefile.am58
-rw-r--r--ruby/name.cc131
-rw-r--r--ruby/name_TEST.rb130
-rw-r--r--ruby/paludis_ruby.cc62
-rw-r--r--ruby/paludis_ruby.hh43
-rw-r--r--ruby/paludis_ruby_TEST.rb11
-rw-r--r--src/gtkpaludis/Makefile.am3
-rw-r--r--src/gtkpaludis/browse_tree.cc8
19 files changed, 545 insertions, 21 deletions
diff --git a/Makefile.am b/Makefile.am
index e7e001a..3f55630 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,9 +3,9 @@ MAINTAINERCLEANFILES = Makefile.in configure config/* aclocal.m4 \
config.h config.h.in INSTALL COPYING
AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip std-options
EXTRA_DIST = autogen.bash automake-deps-hack.tmp
-SUBDIRS = misc test paludis cran ebuild src doc hooks eselect
+SUBDIRS = misc test paludis cran ebuild ruby src doc hooks eselect
-DISTCHECK_CONFIGURE_FLAGS = --enable-qa
+DISTCHECK_CONFIGURE_FLAGS = --enable-qa --enable-ruby
automake-deps-hack.tmp :
make -C paludis/util
diff --git a/configure.ac b/configure.ac
index d189ddc..39b0e9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -253,6 +253,8 @@ fi
PALUDIS_CXXFLAGS=
PALUDIS_CXXFLAGS_NO_WOLD_STYLE_CAST=
PALUDIS_CXXFLAGS_NO_WREDUNDANT_DECLS=
+PALUDIS_CXXFLAGS_NO_WSHADOW=
+PALUDIS_CXXFLAGS_WITHOUT_PEDANTIC=
AC_MSG_CHECKING([whether our compiler is iccy])
AC_COMPILE_IFELSE([
#ifndef __ICC
@@ -293,6 +295,7 @@ if test "x${cxx_compiler_icc}" = "xyes" ; then
CHECK_CXXFLAG([-wd981])
CHECK_CXXFLAG([-wd1125])
CHECK_CXXFLAG([-wd1418])
+ PALUDIS_CXXFLAGS_WITHOUT_PEDANTIC=$PALUDIS_CXXFLAGS
elif test "x${ac_cv_cxx_compiler_gnu}" = "xyes" ; then
CHECK_CXXFLAG([-Wall])
CHECK_CXXFLAG([-Wextra])
@@ -315,13 +318,19 @@ elif test "x${ac_cv_cxx_compiler_gnu}" = "xyes" ; then
CHECK_CXXFLAG([-Wunreachable-code])
CHECK_CXXFLAG([-Wunused-function])
CHECK_CXXFLAG([-Wshadow])
+ if test "x$cxxflag_success" = "xyes" ; then
+ PALUDIS_CXXFLAGS_NO_WSHADOW=-Wno-shadow
+ fi
+ PALUDIS_CXXFLAGS_WITHOUT_PEDANTIC=$PALUDIS_CXXFLAGS
CHECK_CXXFLAG([-pedantic])
else
CHECK_CXXFLAG([-Wall])
fi
AC_MSG_RESULT([${cxxflags_message}])
AC_SUBST([PALUDIS_CXXFLAGS])
+AC_SUBST([PALUDIS_CXXFLAGS_WITHOUT_PEDANTIC])
AC_SUBST([PALUDIS_CXXFLAGS_NO_WOLD_STYLE_CAST])
+AC_SUBST([PALUDIS_CXXFLAGS_NO_WSHADOW])
AC_SUBST([PALUDIS_CXXFLAGS_NO_WREDUNDANT_DECLS])
dnl }}}
@@ -484,6 +493,49 @@ fi
AM_CONDITIONAL([ENABLE_GTK], test "x$enable_gtk" = "xyes")
dnl }}}
+dnl {{{ ruby interface
+AC_MSG_CHECKING([whether to build the ruby interface])
+AC_ARG_ENABLE([ruby],
+ AS_HELP_STRING([--enable-ruby], [Enable ruby interface (default: disable)]),
+ enable_ruby=$enableval,
+ enable_ruby=no)
+AC_MSG_RESULT($enable_ruby)
+
+if test "x$enable_ruby" = "xyes" ; then
+ AC_CHECK_PROGS(RUBY, ruby, )
+ if test "x$RUBY" = "x" ; then
+ AC_MSG_ERROR([Ruby is required for --enable-ruby])
+ fi
+
+ AC_MSG_CHECKING([for Ruby archdir])
+ RUBY_ARCHDIR=`ruby -r rbconfig -e 'puts Config::CONFIG@<:@"archdir"@:>@'`
+ if test "x$RUBY_ARCHDIR" = "x" ; then
+ AC_MSG_ERROR([Could not find Ruby archdir])
+ fi
+ AC_MSG_RESULT([$RUBY_ARCHDIR])
+ AC_SUBST([RUBY_ARCHDIR])
+
+ AC_MSG_CHECKING([for Ruby sitearchdir])
+ RUBY_SITEARCHDIR=`ruby -r rbconfig -e 'puts Config::CONFIG@<:@"sitearchdir"@:>@'`
+ if test "x$RUBY_SITEARCHDIR" = "x" ; then
+ AC_MSG_ERROR([Could not find Ruby sitearchdir])
+ fi
+ AC_MSG_RESULT([$RUBY_SITEARCHDIR])
+ AC_SUBST([RUBY_SITEARCHDIR])
+
+ AC_MSG_CHECKING([for Ruby soname])
+ RUBY_SONAME=`ruby -r rbconfig -e 'puts Config::CONFIG@<:@"RUBY_SO_NAME"@:>@'`
+ if test "x$RUBY_SONAME" = "x" ; then
+ AC_MSG_ERROR([Could not find Ruby soname])
+ fi
+ AC_MSG_RESULT([$RUBY_SONAME])
+ AC_SUBST([RUBY_SONAME])
+fi
+
+AM_CONDITIONAL([ENABLE_RUBY], test "x$enable_ruby" = "xyes")
+
+dnl }}}
+
dnl {{{ is sed gnu sed
AC_MSG_CHECKING([if we need a sed wrapper])
AC_SUBST([NEED_SED_WRAPPER])
@@ -547,6 +599,7 @@ AC_OUTPUT(
paludis/selinux/Makefile
paludis/tasks/Makefile
paludis/util/Makefile
+ ruby/Makefile
src/Makefile
src/paludis/Makefile
src/gtkpaludis/Makefile
diff --git a/paludis/files.m4 b/paludis/files.m4
index 3a2c0a0..11535b9 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -28,7 +28,7 @@ add(`match_package', `hh', `cc')
add(`name', `hh', `cc', `test')
add(`package_database', `hh', `cc', `test')
add(`package_database_entry', `hh', `sr')
-add(`paludis', `hh')
+add(`paludis', `hh', `cc')
add(`portage_dep_lexer', `hh', `cc', `test')
add(`portage_dep_parser', `hh', `cc', `test')
add(`qualified_package_name', `sr')
diff --git a/paludis/paludis.cc b/paludis/paludis.cc
new file mode 100644
index 0000000..47e119f
--- /dev/null
+++ b/paludis/paludis.cc
@@ -0,0 +1,8 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include "paludis.hh"
+
+void paludis_was_here()
+{
+}
+
diff --git a/paludis/paludis.hh.m4 b/paludis/paludis.hh.m4
index 16cdf27..847b5e6 100644
--- a/paludis/paludis.hh.m4
+++ b/paludis/paludis.hh.m4
@@ -37,5 +37,11 @@ addthis(`$1',`$5')addthis(`$1',`$6')')dnl
include(`paludis/files.m4')
+extern "C"
+{
+ /* for simplifying extconf.rb detection */
+ void paludis_was_here();
+}
+
#endif
diff --git a/paludis/repositories/cran/Makefile.am b/paludis/repositories/cran/Makefile.am
index 6257684..b67c1de 100644
--- a/paludis/repositories/cran/Makefile.am
+++ b/paludis/repositories/cran/Makefile.am
@@ -29,6 +29,11 @@ libpaludiscranrepository_la_SOURCES = \
cran_installed_repository.cc \
$(paludis_repositories_cran_include_HEADERS)
+libpaludiscranrepository_la_LIBADD = \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
+
TESTS = cran_dep_parser_TEST cran_repository_TEST
cran_dep_parser_TEST_SOURCES = cran_dep_parser_TEST.cc
@@ -36,10 +41,7 @@ cran_dep_parser_TEST_SOURCES = cran_dep_parser_TEST.cc
cran_dep_parser_TEST_LDADD= \
$(top_builddir)/paludis/util/test_extras.o \
$(top_builddir)/test/libtest.a \
- libpaludiscranrepository.la \
- $(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/util/libpaludisutil.la \
- $(DYNAMIC_LD_LIBS)
+ libpaludiscranrepository.la
cran_repository_TEST_SOURCES = cran_repository_TEST.cc
diff --git a/paludis/repositories/fake/Makefile.am b/paludis/repositories/fake/Makefile.am
index b0f0817..e7ef33d 100644
--- a/paludis/repositories/fake/Makefile.am
+++ b/paludis/repositories/fake/Makefile.am
@@ -15,6 +15,11 @@ libpaludisfakerepository_la_SOURCES = \
fake_repository.cc fake_repository.hh \
fake_installed_repository.cc fake_installed_repository.hh
+libpaludisfakerepository_la_LIBADD = \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
+
libpaludisfakerepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
paludis_repositories_fake_includedir = $(includedir)/paludis/repositories/fake/
diff --git a/paludis/repositories/nothing/Makefile.am b/paludis/repositories/nothing/Makefile.am
index 4035957..191a2c8 100644
--- a/paludis/repositories/nothing/Makefile.am
+++ b/paludis/repositories/nothing/Makefile.am
@@ -14,6 +14,11 @@ libpaludisnothingrepository_la_SOURCES = nothing_repository.cc nothing_repositor
libpaludisnothingrepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
paludis_repositories_nothing_includedir = $(includedir)/paludis/repositories/nothing/
+libpaludisnothingrepository_la_LIBADD = \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
+
paludis_repositories_nothing_include_HEADERS = \
nothing_repository.hh \
nothing_repository-sr.hh
diff --git a/paludis/repositories/portage/Makefile.am b/paludis/repositories/portage/Makefile.am
index c8932bf..ffeaebf 100644
--- a/paludis/repositories/portage/Makefile.am
+++ b/paludis/repositories/portage/Makefile.am
@@ -42,17 +42,19 @@ libpaludisportagerepository_la_SOURCES = \
make_ebin_repository.cc \
$(paludis_repositories_portage_include_HEADERS)
+libpaludisportagerepository_la_LIBADD = \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
+
TESTS = portage_repository_TEST
portage_repository_TEST_SOURCES = portage_repository_TEST.cc
portage_repository_TEST_LDADD = \
- $(top_builddir)/paludis/util/test_extras.o \
- $(top_builddir)/test/libtest.a \
libpaludisportagerepository.la \
- $(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/util/libpaludisutil.la \
- $(DYNAMIC_LD_LIBS)
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/test/libtest.a
portage_repository_TEST_CXXFLAGS = -I$(top_srcdir)
diff --git a/paludis/repositories/vdb/Makefile.am b/paludis/repositories/vdb/Makefile.am
index 835d204..8ced530 100644
--- a/paludis/repositories/vdb/Makefile.am
+++ b/paludis/repositories/vdb/Makefile.am
@@ -18,6 +18,11 @@ paludis_repositories_vdb_include_HEADERS = \
vdb_repository-sr.hh \
vdb_repository-sr.cc
+libpaludisvdbrepository_la_LIBADD = \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
+
TESTS = vdb_repository_TEST
vdb_repository_TEST_SOURCES = vdb_repository_TEST.cc
@@ -25,10 +30,7 @@ vdb_repository_TEST_SOURCES = vdb_repository_TEST.cc
vdb_repository_TEST_LDADD = \
$(top_builddir)/paludis/util/test_extras.o \
$(top_builddir)/test/libtest.a \
- libpaludisvdbrepository.la \
- $(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/util/libpaludisutil.la \
- $(DYNAMIC_LD_LIBS)
+ libpaludisvdbrepository.la
vdb_repository_TEST_CXXFLAGS = -I$(top_srcdir)
diff --git a/paludis/repositories/virtuals/Makefile.am b/paludis/repositories/virtuals/Makefile.am
index ac5116d..ae1f600 100644
--- a/paludis/repositories/virtuals/Makefile.am
+++ b/paludis/repositories/virtuals/Makefile.am
@@ -25,6 +25,11 @@ libpaludisvirtualsrepository_la_SOURCES = \
vr_entry.cc \
$(paludis_repositories_portage_include_HEADERS)
+libpaludisvirtualsrepository_la_LIBADD = \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(DYNAMIC_LD_LIBS)
+
EXTRA_DIST = \
vr_entry-sr.hh \
vr_entry-sr.cc \
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
new file mode 100644
index 0000000..28b2082
--- /dev/null
+++ b/ruby/Makefile.am
@@ -0,0 +1,58 @@
+SUBDIRS = .
+
+AM_CXXFLAGS = -I$(top_srcdir) -I$(srcdir)/ \
+ @PALUDIS_CXXFLAGS_WITHOUT_PEDANTIC@ \
+ @PALUDIS_CXXFLAGS_NO_WREDUNDANT_DECLS@ \
+ @PALUDIS_CXXFLAGS_NO_WOLD_STYLE_CAST@
+
+DEFS= \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DLIBDIR=\"$(libdir)\"
+
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda *.o *.so
+MAINTAINERCLEANFILES = Makefile.in
+
+IF_RUBY_TESTS = paludis_ruby_TEST.rb name_TEST.rb
+IF_RUBY_SOURCES = paludis_ruby.cc paludis_ruby.hh name.cc
+EXTRA_DIST = $(IF_RUBY_TESTS) $(IF_RUBY_SOURCES)
+
+TESTS_ENVIRONMENT = env \
+ PALUDIS_NO_GLOBAL_HOOKS="yes" \
+ PALUDIS_NO_XTERM_TITLES="yes" \
+ PALUDIS_EBUILD_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_srcdir)/ebuild/`" \
+ PALUDIS_EBUILD_DIR_FALLBACK="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/ebuild/`" \
+ PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
+ LD_LIBRARY_PATH="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/paludis/.libs`" \
+ ruby -I ./
+
+if ENABLE_RUBY
+
+TESTS = $(IF_RUBY_TESTS)
+OUR_OBJECTS = name.o paludis_ruby.o
+noinst_DATA = $(OUR_OBJECTS)
+rubylibdir = $(DESTDIR)/@RUBY_SITEARCHDIR@
+rubylib_DATA = Paludis.so
+
+OUR_CXXCOMPILE = $(CXX) -fPIC $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) \
+ -I. -I@RUBY_SITEARCHDIR@ -I@RUBY_ARCHDIR@ -c
+
+paludis_ruby.o : paludis_ruby.cc paludis_ruby.hh
+ $(OUR_CXXCOMPILE) -o $@ $(srcdir)/paludis_ruby.cc
+
+name.o : name.cc paludis_ruby.hh
+ $(OUR_CXXCOMPILE) -o $@ $(srcdir)/name.cc
+
+Paludis.so : $(OUR_OBJECTS)
+ $(CXX) -fPIC -shared $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -I@RUBY_SITEARCHDIR@ -l@RUBY_SONAME@ \
+ -L$(top_builddir)/paludis/.libs -lpaludis -o $@ $^
+
+clean-local :
+ rm -fr Paludis.so .checkimage || true
+
+endif
+
diff --git a/ruby/name.cc b/ruby/name.cc
new file mode 100644
index 0000000..928d5b1
--- /dev/null
+++ b/ruby/name.cc
@@ -0,0 +1,131 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include <paludis_ruby.hh>
+#include <paludis/name.hh>
+#include <paludis/util/compare.hh>
+#include <ruby.h>
+
+using namespace paludis;
+using namespace paludis::ruby;
+
+#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
+
+namespace
+{
+ template <typename T_, typename E_>
+ struct NameWrapper
+ {
+ static VALUE c_class;
+ static VALUE c_class_except;
+
+ static void
+ name_part_error_free(void * ptr)
+ {
+ delete static_cast<std::string *>(ptr);
+ }
+
+ static VALUE
+ name_part_error_new(VALUE the_class, VALUE value)
+ {
+ VALUE argv[1];
+ std::string * ptr(new std::string(STR2CSTR(value)));
+ VALUE tdata(Data_Wrap_Struct(the_class, 0, &name_part_error_free, ptr));
+ argv[0] = value;
+ rb_obj_call_init(tdata, 1, argv);
+ rb_call_super(1, &value);
+ return tdata;
+ }
+
+ static VALUE
+ name_part_error_init(VALUE self, VALUE)
+ {
+ return self;
+ }
+
+ static void
+ name_part_free(void * ptr)
+ {
+ delete static_cast<T_ *>(ptr);
+ }
+
+ static VALUE
+ name_part_new(VALUE the_class, VALUE value)
+ {
+ VALUE argv[1];
+ T_ * ptr(0);
+ try
+ {
+ ptr = new T_(std::string(STR2CSTR(value)));
+ VALUE tdata(Data_Wrap_Struct(the_class, 0, &name_part_free, ptr));
+ argv[0] = value;
+ rb_obj_call_init(tdata, 1, argv);
+ return tdata;
+ }
+ catch (const NameError & e)
+ {
+ delete ptr;
+ rb_raise(c_class_except, e.message().c_str());
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ static VALUE
+ name_part_compare(VALUE left, VALUE right)
+ {
+ T_ * left_ptr, * right_ptr;
+ Data_Get_Struct(left, T_, left_ptr);
+ Data_Get_Struct(right, T_, right_ptr);
+
+ return INT2FIX(compare(*left_ptr, *right_ptr));
+ }
+
+ static VALUE
+ name_part_to_s(VALUE left)
+ {
+ T_ * left_ptr;
+ Data_Get_Struct(left, T_, left_ptr);
+
+ return rb_str_new2(left_ptr->data().c_str());
+ }
+
+ static VALUE
+ name_part_init(VALUE self, VALUE)
+ {
+ return self;
+ }
+
+ static void do_register(const std::string & name)
+ {
+ c_class = rb_define_class(name.c_str(), rb_cObject);
+ rb_define_singleton_method(c_class, "new", RUBY_FUNC_CAST(&name_part_new), 1);
+ rb_define_method(c_class, "initialize", RUBY_FUNC_CAST(&name_part_init), 1);
+ rb_define_method(c_class, "<=>", RUBY_FUNC_CAST(&name_part_compare), 1);
+ rb_include_module(c_class, rb_mComparable);
+ rb_define_method(c_class, "to_s", RUBY_FUNC_CAST(&name_part_to_s), 0);
+
+ c_class_except = rb_define_class((name + "Error").c_str(), rb_eRuntimeError);
+ rb_define_singleton_method(c_class_except, "new", RUBY_FUNC_CAST(&name_part_error_new), 1);
+ rb_define_method(c_class_except, "initialize", RUBY_FUNC_CAST(&name_part_error_init), 1);
+ }
+ };
+
+ template <typename T_, typename E_> VALUE NameWrapper<T_, E_>::c_class;
+ template <typename T_, typename E_> VALUE NameWrapper<T_, E_>::c_class_except;
+
+ void do_register_names()
+ {
+ NameWrapper<PackageNamePart, PackageNamePartError>::do_register("PackageNamePart");
+ NameWrapper<CategoryNamePart, CategoryNamePartError>::do_register("CategoryNamePart");
+ NameWrapper<UseFlagName, UseFlagNameError>::do_register("UseFlagName");
+ NameWrapper<SlotName, SlotNameError>::do_register("SlotName");
+ NameWrapper<RepositoryName, RepositoryNameError>::do_register("RepositoryName");
+ NameWrapper<KeywordName, KeywordNameError>::do_register("KeywordName");
+ }
+}
+
+RegisterRubyClass::Register paludis_ruby_register_name PALUDIS_ATTRIBUTE((used)) (&do_register_names);
+
diff --git a/ruby/name_TEST.rb b/ruby/name_TEST.rb
new file mode 100644
index 0000000..6e35cc3
--- /dev/null
+++ b/ruby/name_TEST.rb
@@ -0,0 +1,130 @@
+#!/usr/bin/ruby
+# vim: set sw=4 sts=4 et tw=80 :
+
+require 'test/unit'
+require 'Paludis'
+
+module NameTestCaseBase
+ def valid_name_foo
+ return "foo"
+ end
+
+ def valid_name_bar
+ return "bar"
+ end
+
+ def bad_name
+ return "foo~"
+ end
+
+ def test_create
+ x = name_type().new(valid_name_foo())
+ end
+
+ def test_assign
+ x = name_type().new(valid_name_foo())
+ y = x
+ end
+
+ def test_compare
+ x = name_type().new(valid_name_foo())
+ y = name_type().new(valid_name_foo())
+ z = name_type().new(valid_name_bar())
+ assert x == y
+ assert y != z
+ assert z < x
+ assert x > z
+ assert_raise TypeError do
+ x < valid_name_foo()
+ end
+ end
+
+ def test_create_errors
+ assert_raise error_type() do
+ x = name_type().new(bad_name())
+ end
+ assert_raise error_type() do
+ x = name_type().new("")
+ end
+ end
+
+ def test_to_s
+ x = name_type().new(valid_name_foo())
+ y = name_type().new(valid_name_bar())
+ assert x.to_s == valid_name_foo()
+ assert y.to_s == valid_name_bar()
+ end
+end
+
+class TestCase_PackageNamePart < Test::Unit::TestCase
+ include NameTestCaseBase
+
+ def error_type
+ return PackageNamePartError
+ end
+
+ def name_type
+ return PackageNamePart
+ end
+end
+
+class TestCase_CategoryNamePart < Test::Unit::TestCase
+ include NameTestCaseBase
+
+ def error_type
+ return CategoryNamePartError
+ end
+
+ def name_type
+ return CategoryNamePart
+ end
+end
+
+class TestCase_UseFlagName < Test::Unit::TestCase
+ include NameTestCaseBase
+
+ def error_type
+ return UseFlagNameError
+ end
+
+ def name_type
+ return UseFlagName
+ end
+end
+
+class TestCase_RepositoryName < Test::Unit::TestCase
+ include NameTestCaseBase
+
+ def error_type
+ return RepositoryNameError
+ end
+
+ def name_type
+ return RepositoryName
+ end
+end
+
+class TestCase_SlotName < Test::Unit::TestCase
+ include NameTestCaseBase
+
+ def error_type
+ return SlotNameError
+ end
+
+ def name_type
+ return SlotName
+ end
+end
+
+class TestCase_KeywordName < Test::Unit::TestCase
+ include NameTestCaseBase
+
+ def error_type
+ return KeywordNameError
+ end
+
+ def name_type
+ return KeywordName
+ end
+end
+
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
new file mode 100644
index 0000000..d70e480
--- /dev/null
+++ b/ruby/paludis_ruby.cc
@@ -0,0 +1,62 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include <paludis/paludis.hh>
+#include <paludis_ruby.hh>
+#include <ruby.h>
+#include <list>
+
+using namespace paludis;
+using namespace paludis::ruby;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<RegisterRubyClass> :
+ InternalCounted<Implementation<RegisterRubyClass> >
+ {
+ std::list<void (*)()> funcs;
+ };
+}
+
+RegisterRubyClass::RegisterRubyClass() :
+ PrivateImplementationPattern<RegisterRubyClass>(new Implementation<RegisterRubyClass>)
+{
+}
+
+RegisterRubyClass::~RegisterRubyClass()
+{
+}
+
+void
+RegisterRubyClass::execute() const
+{
+ for (std::list<void (*)()>::const_iterator f(_imp->funcs.begin()), f_end(_imp->funcs.end()) ;
+ f != f_end ; ++f)
+ (*f)();
+}
+
+RegisterRubyClass::Register::Register(void (* f)())
+{
+ RegisterRubyClass::get_instance()->_imp->funcs.push_back(f);
+}
+
+void paludis::ruby::exception_to_ruby_exception(const std::exception & ee)
+{
+ if (0 != dynamic_cast<const paludis::InternalError *>(&ee))
+ rb_raise(rb_eRuntimeError, "Unexpected paludis::InternalError: %s (%s)",
+ dynamic_cast<const paludis::InternalError *>(&ee)->message().c_str(), ee.what());
+ else if (0 != dynamic_cast<const paludis::Exception *>(&ee))
+ rb_raise(rb_eRuntimeError, "Caught paludis::Exception: %s (%s)",
+ dynamic_cast<const paludis::Exception *>(&ee)->message().c_str(), ee.what());
+ else
+ rb_raise(rb_eRuntimeError, "Unexpected std::exception: (%s)", ee.what());
+}
+
+extern "C"
+{
+ void Init_Paludis()
+ {
+ RegisterRubyClass::get_instance()->execute();
+ }
+}
+
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
new file mode 100644
index 0000000..74e9296
--- /dev/null
+++ b/ruby/paludis_ruby.hh
@@ -0,0 +1,43 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#ifndef PALUDIS_GUARD_RUBY_RUBY_PALUDIS_RUBY_HH
+#define PALUDIS_GUARD_RUBY_RUBY_PALUDIS_RUBY_HH 1
+
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/exception.hh>
+
+namespace paludis
+{
+ namespace ruby
+ {
+ void exception_to_ruby_exception(const std::exception &) PALUDIS_ATTRIBUTE((noreturn));
+
+ class RegisterRubyClass :
+ public InstantiationPolicy<RegisterRubyClass, instantiation_method::SingletonAsNeededTag>,
+ private PrivateImplementationPattern<RegisterRubyClass>
+ {
+ friend class InstantiationPolicy<RegisterRubyClass, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ RegisterRubyClass();
+ ~RegisterRubyClass();
+
+ public:
+ class Register;
+ friend class Register;
+
+ void execute() const;
+ };
+
+ class RegisterRubyClass::Register :
+ public InstantiationPolicy<RegisterRubyClass, instantiation_method::NonCopyableTag>
+ {
+ public:
+ Register(void (* func)());
+ };
+ }
+}
+
+#endif
diff --git a/ruby/paludis_ruby_TEST.rb b/ruby/paludis_ruby_TEST.rb
new file mode 100644
index 0000000..77cdfc2
--- /dev/null
+++ b/ruby/paludis_ruby_TEST.rb
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+# vim: set sw=4 sts=4 et tw=80 :
+
+require 'test/unit'
+
+class TC_Basic < Test::Unit::TestCase
+ def test_require
+ require 'Paludis'
+ end
+end
+
diff --git a/src/gtkpaludis/Makefile.am b/src/gtkpaludis/Makefile.am
index 55cf6e0..23f08e3 100644
--- a/src/gtkpaludis/Makefile.am
+++ b/src/gtkpaludis/Makefile.am
@@ -1,7 +1,8 @@
AM_CXXFLAGS = -I$(top_srcdir) \
@PALUDIS_CXXFLAGS@ \
@PALUDIS_CXXFLAGS_NO_WOLD_STYLE_CAST@ \
- @PALUDIS_CXXFLAGS_NO_WREDUNDANT_DECLS@
+ @PALUDIS_CXXFLAGS_NO_WREDUNDANT_DECLS@ \
+ @PALUDIS_CXXFLAGS_NO_WSHADOW@
DEFS = \
-DSYSCONFDIR=\"$(sysconfdir)\" \
diff --git a/src/gtkpaludis/browse_tree.cc b/src/gtkpaludis/browse_tree.cc
index 9c5561d..c0aff35 100644
--- a/src/gtkpaludis/browse_tree.cc
+++ b/src/gtkpaludis/browse_tree.cc
@@ -421,12 +421,12 @@ BrowseTree::on_menu_sync()
}
bool
-BrowseTree::on_button_press_event(GdkEventButton * event)
+BrowseTree::on_button_press_event(GdkEventButton * our_event)
{
- bool result(TreeView::on_button_press_event(event));
+ bool result(TreeView::on_button_press_event(our_event));
- if (event->type == GDK_BUTTON_PRESS && event->button == 3)
- _imp->popup_menu.popup(event->button, event->time);
+ if (our_event->type == GDK_BUTTON_PRESS && our_event->button == 3)
+ _imp->popup_menu.popup(our_event->button, our_event->time);
return result;
}