aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-03-01 12:59:21 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-03-01 12:59:21 +0000
commit0210b15ca5717535ee872703953820a1d13148b8 (patch)
tree6b9032af1be5f7281f11c929142c407f5e268cab
parent5c0e758c5cca7dfebeeef66c30c05c77365973f7 (diff)
downloadpaludis-0210b15ca5717535ee872703953820a1d13148b8.tar.gz
paludis-0210b15ca5717535ee872703953820a1d13148b8.tar.xz
Add PaludisEnvironment::config_dir to C++ and Ruby.
-rw-r--r--paludis/environments/paludis/paludis_environment.cc6
-rw-r--r--paludis/environments/paludis/paludis_environment.hh5
-rw-r--r--ruby/Makefile.am3
-rw-r--r--ruby/environment.cc73
4 files changed, 87 insertions, 0 deletions
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 8d46509..29c798a 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -838,3 +838,9 @@ PaludisEnvironment::clear_forced_use()
_imp->forced_use.clear();
}
+std::string
+PaludisEnvironment::config_dir() const
+{
+ return _imp->config->config_dir();
+}
+
diff --git a/paludis/environments/paludis/paludis_environment.hh b/paludis/environments/paludis/paludis_environment.hh
index 546cad2..15d7735 100644
--- a/paludis/environments/paludis/paludis_environment.hh
+++ b/paludis/environments/paludis/paludis_environment.hh
@@ -95,6 +95,11 @@ namespace paludis
const UseFlagState);
virtual void clear_forced_use();
+
+ /**
+ * The config directory.
+ */
+ std::string config_dir() const;
};
}
#endif
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index e0c7c76..4302f5e 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -88,6 +88,7 @@ TESTS_ENVIRONMENT = env \
LD_LIBRARY_PATH=`echo "\`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/.libs\`: \
\`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/util/.libs\`: \
\`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/.libs\`: \
+ \`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/.libs\`: \
\`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/no_config/.libs\`: \
\`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/dep_list/.libs\`: \
\`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/.libs\`: \
@@ -117,6 +118,7 @@ libpaludisruby_la_LIBADD = \
$(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
$(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/paludis/repositories/gentoo/libpaludisgentoorepository.la \
+ $(top_builddir)/paludis/environments/paludis/libpaludispaludisenvironment.la \
$(top_builddir)/paludis/environments/no_config/libpaludisnoconfigenvironment.la \
$(top_builddir)/paludis/environments/libpaludisenvironments.la \
$(top_builddir)/paludis/qa/libpaludisqa.la
@@ -132,6 +134,7 @@ libpaludisruby_la_LIBADD = \
$(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
$(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/paludis/repositories/gentoo/libpaludisgentoorepository.la \
+ $(top_builddir)/paludis/environments/paludis/libpaludispaludisenvironment.la \
$(top_builddir)/paludis/environments/no_config/libpaludisnoconfigenvironment.la \
$(top_builddir)/paludis/environments/libpaludisenvironments.la
diff --git a/ruby/environment.cc b/ruby/environment.cc
index c0e928c..df1be23 100644
--- a/ruby/environment.cc
+++ b/ruby/environment.cc
@@ -18,6 +18,7 @@
*/
#include <paludis_ruby.hh>
+#include <paludis/environments/paludis/paludis_environment.hh>
#include <paludis/environments/no_config/no_config_environment.hh>
#include <paludis/environments/environment_maker.hh>
#include <ruby.h>
@@ -30,6 +31,7 @@ using namespace paludis::ruby;
namespace
{
static VALUE c_environment;
+ static VALUE c_paludis_environment;
static VALUE c_no_config_environment;
static VALUE c_environment_maker;
@@ -263,6 +265,67 @@ namespace
}
+ PaludisEnvironment *
+ value_to_paludis_environment(VALUE v)
+ {
+ if (rb_obj_is_kind_of(v, c_paludis_environment))
+ {
+ return static_cast<PaludisEnvironment *>(value_to_environment_data(v)->env_ptr);
+ }
+ else
+ {
+ rb_raise(rb_eTypeError, "Can't convert %s into PaludisEnvironment", rb_obj_classname(v));
+ }
+ }
+
+ VALUE
+ paludis_environment_init(int, VALUE*, VALUE self)
+ {
+ return self;
+ }
+
+ /*
+ * call-seq:
+ * PaludisEnvironment.new -> PaludisEnvironment
+ * PaludisEnvironment.new(config_suffix) -> PaludisEnvironment
+ *
+ * Create a new PaludisEnvironment, with the specified config suffix if any, otherwise the empty suffix.
+ */
+ VALUE
+ paludis_environment_new(int argc, VALUE* argv, VALUE self)
+ {
+ try
+ {
+ std::string config_suffix;
+ if (1 == argc)
+ config_suffix = StringValuePtr(argv[0]);
+ else if (0 != argc)
+ rb_raise(rb_eArgError, "PaludisEnvironment.new expects one or zero arguments, but got %d", argc);
+
+ PaludisEnvironment * e(new PaludisEnvironment(config_suffix));
+ EnvironmentData * ptr(new EnvironmentData(e, e));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<EnvironmentData>::free, ptr));
+ rb_obj_call_init(tdata, argc, argv);
+ return tdata;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * config_dir -> String
+ *
+ * Configuration directory used by this PaludisEnvironment.
+ */
+ VALUE
+ paludis_environment_config_dir(VALUE self)
+ {
+ return rb_str_new2(value_to_paludis_environment(self)->config_dir().c_str());
+ }
+
VALUE
no_config_environment_init(int, VALUE*, VALUE self)
{
@@ -391,6 +454,16 @@ namespace
rb_define_method(c_environment, "default_destinations", RUBY_FUNC_CAST(&environment_default_destinations), 0);
/*
+ * Document-class: Paludis::PaludisEnvironment
+ *
+ * An Environment that corresponds to the normal operating evironment.
+ */
+ c_paludis_environment = rb_define_class_under(paludis_module(), "PaludisEnvironment", c_environment);
+ rb_define_singleton_method(c_paludis_environment, "new", RUBY_FUNC_CAST(&paludis_environment_new), -1);
+ rb_define_method(c_paludis_environment, "initialize", RUBY_FUNC_CAST(&paludis_environment_init), -1);
+ rb_define_method(c_paludis_environment, "config_dir", RUBY_FUNC_CAST(&paludis_environment_config_dir), 0);
+
+ /*
* Document-class: Paludis::NoConfigEnvironment
*
* An environment that uses a single repository, with no user configuration.