From 256e3a467cf2beb6362c3c5a20e4543fadfc7f6f Mon Sep 17 00:00:00 2001 From: Bruno da Silva de Oliveira Date: Tue, 3 Jun 2003 20:58:22 +0000 Subject: [PATCH] - Appliced a patch from Giulio Eulisse that allows unnamed enumerations to be exported with an AllFromHeader construct [SVN r18657] --- pyste/NEWS | 4 ++++ pyste/src/EnumExporter.py | 6 +++++- pyste/src/pyste.py | 2 +- pyste/tests/enums.h | 5 +++++ pyste/tests/enums.pyste | 13 ++++++------- pyste/tests/enumsUT.py | 2 ++ pyste/tests/test_all.py | 5 ++++- 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/pyste/NEWS b/pyste/NEWS index 97ba5a86..43a1010c 100644 --- a/pyste/NEWS +++ b/pyste/NEWS @@ -1,3 +1,7 @@ +3 June 2003 +Appliced a patch from Giulio Eulisse that allows unnamed enumerations to be +exported with an AllFromHeader construct. Thanks a lot Giulio! + 2 June 2003 Added a new construct, add_method. See documentation. diff --git a/pyste/src/EnumExporter.py b/pyste/src/EnumExporter.py index 66a66a23..c36b8888 100644 --- a/pyste/src/EnumExporter.py +++ b/pyste/src/EnumExporter.py @@ -23,7 +23,11 @@ class EnumExporter(Exporter): in_indent = self.INDENT*2 rename = self.info.rename or self.enum.name full_name = self.enum.FullName() - code = indent + namespaces.python + 'enum_< %s >("%s")\n' % (full_name, rename) + if rename == "$_0" or rename == '._0': + full_name = "int" + rename = "unnamed" + code = indent + namespaces.python + code += 'enum_< %s >("%s")\n' % (full_name, rename) for name in self.enum.values: rename = self.info[name].rename or name value_fullname = self.enum.ValueFullName(name) diff --git a/pyste/src/pyste.py b/pyste/src/pyste.py index 59d524e4..17095333 100644 --- a/pyste/src/pyste.py +++ b/pyste/src/pyste.py @@ -37,7 +37,7 @@ from policies import * from CppParser import CppParser, CppParserError import time -__VERSION__ = '0.9.0' +__VERSION__ = '0.9.1' def RecursiveIncludes(include): 'Return a list containg the include dir and all its subdirectories' diff --git a/pyste/tests/enums.h b/pyste/tests/enums.h index 207001e0..e58a5c39 100644 --- a/pyste/tests/enums.h +++ b/pyste/tests/enums.h @@ -19,6 +19,11 @@ struct X } }; +enum { + x = 0, + y = 1 +}; + } #endif diff --git a/pyste/tests/enums.pyste b/pyste/tests/enums.pyste index a6cc740a..afb94316 100644 --- a/pyste/tests/enums.pyste +++ b/pyste/tests/enums.pyste @@ -1,8 +1,7 @@ -color = Enum('enums::color', 'enums.h') -rename(color.red, 'Red') -rename(color.blue, 'Blue') -X = Class('enums::X', 'enums.h') -rename(X.choices.bad, 'Bad') -rename(X.choices.good, 'Good') -rename(X.choices, 'Choices') +h = AllFromHeader('enums.h') +rename(h.color.red, 'Red') +rename(h.color.blue, 'Blue') +rename(h.X.choices.bad, 'Bad') +rename(h.X.choices.good, 'Good') +rename(h.X.choices, 'Choices') diff --git a/pyste/tests/enumsUT.py b/pyste/tests/enumsUT.py index ce29050d..4701f217 100644 --- a/pyste/tests/enumsUT.py +++ b/pyste/tests/enumsUT.py @@ -12,6 +12,8 @@ class EnumsTest(unittest.TestCase): x = X() self.assertEqual(x.set(x.Choices.Good), 1) self.assertEqual(x.set(x.Choices.Bad), 2) + self.assertEqual(unnamed.x, 0) + self.assertEqual(unnamed.y, 1) if __name__ == '__main__': diff --git a/pyste/tests/test_all.py b/pyste/tests/test_all.py index 23ab4ff0..f2dbee66 100644 --- a/pyste/tests/test_all.py +++ b/pyste/tests/test_all.py @@ -158,7 +158,10 @@ def main(multiple, module=None): compile_multiple(module) else: compile_single(module) - run_tests() + if len(modules) == 1: + os.system('python %sUT.py' % modules[0]) + else: + run_tests() cleanup()