aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-11-14 16:33:55 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-11-14 16:33:55 +0000
commit379066d3b475da76f4e549b3c53426c5fec26dc4 (patch)
tree4d61ce4b8cbc764c628dbb3686628b8d81bb61fe
parent19cdc245b2e1d3076060ddd7def5aee33f83b174 (diff)
downloadpaludis-379066d3b475da76f4e549b3c53426c5fec26dc4.tar.gz
paludis-379066d3b475da76f4e549b3c53426c5fec26dc4.tar.xz
(python) StringifyFormatter and PythonFormatter are now convertible to other Formatters.
-rw-r--r--python/additional_tests.cc51
-rw-r--r--python/formatter.cc21
-rwxr-xr-xpython/formatter_TEST.py50
3 files changed, 121 insertions, 1 deletions
diff --git a/python/additional_tests.cc b/python/additional_tests.cc
index 5cdc1ae..8781d60 100644
--- a/python/additional_tests.cc
+++ b/python/additional_tests.cc
@@ -287,6 +287,46 @@ namespace formatter
f.newline();
f.indent(1);
}
+
+ void test_formatter_string(const Formatter<std::string> &)
+ {
+ }
+
+ void test_formmater_keyword_name(const Formatter<KeywordName> &)
+ {
+ }
+
+ void test_formatter_use_flag_name(const Formatter<UseFlagName> &)
+ {
+ }
+
+ void test_formatter_iuse_flag(const Formatter<IUseFlag> &)
+ {
+ }
+
+ void test_formatter_license_spec_tree(const LicenseSpecTree::ItemFormatter &)
+ {
+ }
+
+ void test_formatter_provide_spec_tree(const ProvideSpecTree::ItemFormatter &)
+ {
+ }
+
+ void test_formatter_dependency_spec_tree(const DependencySpecTree::ItemFormatter &)
+ {
+ }
+
+ void test_formatter_restrict_spec_tree(const RestrictSpecTree::ItemFormatter &)
+ {
+ }
+
+ void test_formatter_simple_uri_spec_tree(const SimpleURISpecTree::ItemFormatter &)
+ {
+ }
+
+ void test_formatter_fetchable_uri_spec_tree(const FetchableURISpecTree::ItemFormatter &)
+ {
+ }
}
void expose_additional_tests()
@@ -334,5 +374,16 @@ void expose_additional_tests()
bp::def("test_iuse_roles", &formatter::test_iuse_roles);
bp::def("test_package_roles", &formatter::test_package_roles);
bp::def("test_can_space", &formatter::test_can_space);
+
+ bp::def("test_formatter_string", &formatter::test_formatter_string);
+ bp::def("test_formmater_keyword_name", &formatter::test_formmater_keyword_name);
+ bp::def("test_formatter_use_flag_name", &formatter::test_formatter_use_flag_name);
+ bp::def("test_formatter_iuse_flag", &formatter::test_formatter_iuse_flag);
+ bp::def("test_formatter_license_spec_tree", &formatter::test_formatter_license_spec_tree);
+ bp::def("test_formatter_provide_spec_tree", &formatter::test_formatter_provide_spec_tree);
+ bp::def("test_formatter_dependency_spec_tree", &formatter::test_formatter_dependency_spec_tree);
+ bp::def("test_formatter_restrict_spec_tree", &formatter::test_formatter_restrict_spec_tree);
+ bp::def("test_formatter_simple_uri_spec_tree", &formatter::test_formatter_simple_uri_spec_tree);
+ bp::def("test_formatter_fetchable_uri_spec_tree", &formatter::test_formatter_fetchable_uri_spec_tree);
}
diff --git a/python/formatter.cc b/python/formatter.cc
index b81bdb9..fdc1e13 100644
--- a/python/formatter.cc
+++ b/python/formatter.cc
@@ -343,6 +343,7 @@ struct PythonCanSpaceWrapper :
};
class PythonFormatterWrapper :
+ public PythonCanFormat<std::string>,
public PythonCanFormat<UseFlagName>,
public PythonCanFormat<IUseFlag>,
public PythonCanFormat<KeywordName>,
@@ -713,6 +714,16 @@ void expose_formatter()
/**
* StringifyFormatter
*/
+ bp::implicitly_convertible<StringifyFormatter, Formatter<std::string> >();
+ bp::implicitly_convertible<StringifyFormatter, Formatter<KeywordName> >();
+ bp::implicitly_convertible<StringifyFormatter, Formatter<UseFlagName> >();
+ bp::implicitly_convertible<StringifyFormatter, Formatter<IUseFlag> >();
+ bp::implicitly_convertible<StringifyFormatter, LicenseSpecTree::ItemFormatter>();
+ bp::implicitly_convertible<StringifyFormatter, ProvideSpecTree::ItemFormatter>();
+ bp::implicitly_convertible<StringifyFormatter, DependencySpecTree::ItemFormatter>();
+ bp::implicitly_convertible<StringifyFormatter, RestrictSpecTree::ItemFormatter>();
+ bp::implicitly_convertible<StringifyFormatter, SimpleURISpecTree::ItemFormatter>();
+ bp::implicitly_convertible<StringifyFormatter, FetchableURISpecTree::ItemFormatter>();
bp::class_<StringifyFormatter,
bp::bases<
CanFormat<std::string>,
@@ -747,6 +758,16 @@ void expose_formatter()
/**
* PythonFormatter
*/
+ bp::implicitly_convertible<PythonFormatterWrapper, Formatter<std::string> >();
+ bp::implicitly_convertible<PythonFormatterWrapper, Formatter<KeywordName> >();
+ bp::implicitly_convertible<PythonFormatterWrapper, Formatter<UseFlagName> >();
+ bp::implicitly_convertible<PythonFormatterWrapper, Formatter<IUseFlag> >();
+ bp::implicitly_convertible<PythonFormatterWrapper, LicenseSpecTree::ItemFormatter>();
+ bp::implicitly_convertible<PythonFormatterWrapper, ProvideSpecTree::ItemFormatter>();
+ bp::implicitly_convertible<PythonFormatterWrapper, DependencySpecTree::ItemFormatter>();
+ bp::implicitly_convertible<PythonFormatterWrapper, RestrictSpecTree::ItemFormatter>();
+ bp::implicitly_convertible<PythonFormatterWrapper, SimpleURISpecTree::ItemFormatter>();
+ bp::implicitly_convertible<PythonFormatterWrapper, FetchableURISpecTree::ItemFormatter>();
bp::class_<PythonFormatterWrapper,
bp::bases<
CanFormat<std::string>,
diff --git a/python/formatter_TEST.py b/python/formatter_TEST.py
index 4756949..6833fb3 100755
--- a/python/formatter_TEST.py
+++ b/python/formatter_TEST.py
@@ -25,7 +25,43 @@ import unittest
Log.instance.log_level = LogLevel.WARNING
-class TestCase_01_Formatters_suclassing(unittest.TestCase):
+class TestCase_01_StringifyFormatter(unittest.TestCase):
+ def test_01_create(self):
+ StringifyFormatter()
+
+ def test_02_passing_to_cpp(self):
+ f = StringifyFormatter()
+
+ test_formatter_string(f)
+ test_formmater_keyword_name(f)
+ test_formatter_use_flag_name(f)
+ test_formatter_iuse_flag(f)
+ test_formatter_license_spec_tree(f)
+ test_formatter_provide_spec_tree(f)
+ test_formatter_dependency_spec_tree(f)
+ test_formatter_restrict_spec_tree(f)
+ test_formatter_simple_uri_spec_tree(f)
+ test_formatter_fetchable_uri_spec_tree(f)
+
+class TestCase_02_PythonFormatter(unittest.TestCase):
+ def test_01_create(self):
+ PythonFormatter()
+
+ def test_02_passing_to_cpp(self):
+ f = PythonFormatter()
+
+ test_formatter_string(f)
+ test_formmater_keyword_name(f)
+ test_formatter_use_flag_name(f)
+ test_formatter_iuse_flag(f)
+ test_formatter_license_spec_tree(f)
+ test_formatter_provide_spec_tree(f)
+ test_formatter_dependency_spec_tree(f)
+ test_formatter_restrict_spec_tree(f)
+ test_formatter_simple_uri_spec_tree(f)
+ test_formatter_fetchable_uri_spec_tree(f)
+
+class TestCase_03_Formatters_suclassing(unittest.TestCase):
def test_python_can_formats(self):
class TestCanFormatPlain(CanFormatPlainTextDepSpec):
@@ -182,5 +218,17 @@ class TestCase_01_Formatters_suclassing(unittest.TestCase):
test_package_roles(f)
test_can_space(f)
+ test_formatter_string(f)
+ test_formmater_keyword_name(f)
+ test_formatter_use_flag_name(f)
+ test_formatter_iuse_flag(f)
+ test_formatter_license_spec_tree(f)
+ test_formatter_provide_spec_tree(f)
+ test_formatter_dependency_spec_tree(f)
+ test_formatter_restrict_spec_tree(f)
+ test_formatter_simple_uri_spec_tree(f)
+ test_formatter_fetchable_uri_spec_tree(f)
+
+
if __name__ == "__main__":
unittest.main()