2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-31 08:22:18 +00:00

- Appliced a patch from Giulio Eulisse that allows unnamed enumerations to be

exported with an AllFromHeader construct


[SVN r18657]
This commit is contained in:
Bruno da Silva de Oliveira
2003-06-03 20:58:22 +00:00
parent 4477fe4dd6
commit 256e3a467c
7 changed files with 27 additions and 10 deletions

View File

@@ -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.

View File

@@ -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)

View File

@@ -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'

View File

@@ -19,6 +19,11 @@ struct X
}
};
enum {
x = 0,
y = 1
};
}
#endif

View File

@@ -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')

View File

@@ -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__':

View File

@@ -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()