diff --git a/pyste/NEWS b/pyste/NEWS index 1b8f768a..ab1c5bcb 100644 --- a/pyste/NEWS +++ b/pyste/NEWS @@ -7,6 +7,11 @@ Fixed a bug where the macro BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID was being called multiple times for the same type. Thanks to Gottfried Ganßauge for reporting this! +Fixed bug where using AllFromHeader didn't use bases<> when exporting +hierarchies. + +Fixed the staticmethod bug. + 5 July 2003 Changed how --multiple works: now it generates one cpp file for each pyste file, makeing easier to integrate Pyste with build systems. diff --git a/pyste/TODO b/pyste/TODO index fa2207f2..de588b14 100644 --- a/pyste/TODO +++ b/pyste/TODO @@ -8,7 +8,3 @@ instance) - Virtual operators - -- staticmethod bug - -- opaque pointers bug diff --git a/pyste/install/setup.py b/pyste/install/setup.py index fff6db87..6c156536 100644 --- a/pyste/install/setup.py +++ b/pyste/install/setup.py @@ -4,7 +4,7 @@ from distutils.core import setup import sys setup (name = "Pyste", - version = "0.9.9", + version = "0.9.10", description = "Pyste - Python Semi-Automatic Exporter", maintainer = "Bruno da Silva de Oliveira", maintainer_email = "nicodemus@globalite.com.br", diff --git a/pyste/src/Pyste/ClassExporter.py b/pyste/src/Pyste/ClassExporter.py index 05b1e3b9..3ecf7729 100644 --- a/pyste/src/Pyste/ClassExporter.py +++ b/pyste/src/Pyste/ClassExporter.py @@ -97,10 +97,11 @@ class ClassExporter(Exporter): self.ExportMethods() self.ExportOperators() self.ExportNestedClasses(exported_names) - self.ExportNestedEnums() + self.ExportNestedEnums(exported_names) self.ExportSmartPointer() self.ExportOpaquePointerPolicies() self.Write(codeunit) + exported_names[self.class_.FullName()] = 1 def InheritMethods(self, exported_names): @@ -341,6 +342,8 @@ class ClassExporter(Exporter): methods = [x for x in self.public_members if IsExportable(x)] methods.extend(self.GetAddedMethods()) + staticmethods = {} + for method in methods: method_info = self.info[method.name] @@ -375,14 +378,19 @@ class ClassExporter(Exporter): self.Add('inside', code) # static method if isinstance(method, Method) and method.static: - code = '.staticmethod("%s")' % name - self.Add('inside', code) + staticmethods[name] = 1 # add wrapper code if this method has one wrapper = method_info.wrapper if wrapper and wrapper.code: self.Add('declaration', wrapper.code) + + # export staticmethod statements + for name in staticmethods: + code = '.staticmethod("%s")' % name + self.Add('inside', code) + def MakeNonVirtual(self): '''Make all methods that the user indicated to no_override no more virtual, delegating their export to the ExportMethods routine''' @@ -583,7 +591,7 @@ class ClassExporter(Exporter): self.nested_codeunits.append(codeunit) - def ExportNestedEnums(self): + def ExportNestedEnums(self, exported_names): nested_enums = [x for x in self.public_members if isinstance(x, ClassEnumeration)] for enum in nested_enums: enum_info = self.info[enum.name] @@ -592,7 +600,7 @@ class ClassExporter(Exporter): exporter = EnumExporter(enum_info) exporter.SetDeclarations(self.declarations) codeunit = SingleCodeUnit(None, None) - exporter.Export(codeunit, None) + exporter.Export(codeunit, exported_names) self.nested_codeunits.append(codeunit) diff --git a/pyste/src/Pyste/EnumExporter.py b/pyste/src/Pyste/EnumExporter.py index c36b8888..4e469db1 100644 --- a/pyste/src/Pyste/EnumExporter.py +++ b/pyste/src/Pyste/EnumExporter.py @@ -17,7 +17,7 @@ class EnumExporter(Exporter): self.enum = self.GetDeclaration(self.info.name) - def Export(self, codeunit, expoted_names): + def Export(self, codeunit, exported_names): if not self.info.exclude: indent = self.INDENT in_indent = self.INDENT*2 @@ -34,6 +34,7 @@ class EnumExporter(Exporter): code += in_indent + '.value("%s", %s)\n' % (rename, value_fullname) code += indent + ';\n\n' codeunit.Write('module', code) + exported_names[self.enum.FullName()] = 1 def Unit(self): diff --git a/pyste/src/Pyste/Exporter.py b/pyste/src/Pyste/Exporter.py index ff28ecef..c7de9072 100644 --- a/pyste/src/Pyste/Exporter.py +++ b/pyste/src/Pyste/Exporter.py @@ -3,7 +3,7 @@ import os.path #============================================================================== # Exporter #============================================================================== -class Exporter: +class Exporter(object): 'Base class for objects capable to generate boost.python code.' INDENT = ' ' * 4 diff --git a/pyste/src/Pyste/FunctionExporter.py b/pyste/src/Pyste/FunctionExporter.py index 25c004e3..53dea144 100644 --- a/pyste/src/Pyste/FunctionExporter.py +++ b/pyste/src/Pyste/FunctionExporter.py @@ -24,6 +24,7 @@ class FunctionExporter(Exporter): self.ExportDeclaration(decl, len(decls) == 1, codeunit) self.ExportOpaquePointer(decl, codeunit) self.GenerateOverloads(decls, codeunit) + exported_names[decl.FullName()] = 1 def ExportDeclaration(self, decl, unique, codeunit): diff --git a/pyste/src/Pyste/pyste.py b/pyste/src/Pyste/pyste.py index a16a8e37..394f17fc 100644 --- a/pyste/src/Pyste/pyste.py +++ b/pyste/src/Pyste/pyste.py @@ -39,7 +39,7 @@ from policies import * from CppParser import CppParser, CppParserError import time -__VERSION__ = '0.9.9' +__VERSION__ = '0.9.10' def RecursiveIncludes(include): 'Return a list containg the include dir and all its subdirectories' @@ -221,7 +221,6 @@ def Begin(): if multiple: codeunit.SetCurrent(export.interface_file, export.Unit()) export.GenerateCode(codeunit, exported_names) - exported_names[export.Name()] = 1 # force collect of cyclic references gc.collect() # finally save the code unit diff --git a/pyste/tests/basic.h b/pyste/tests/basic.h index f3d0f241..08286593 100644 --- a/pyste/tests/basic.h +++ b/pyste/tests/basic.h @@ -33,7 +33,10 @@ public: const int const_value; // test static functions - static int mul(int x=2, int y=3) { return x*y; } + static int mul(int x, int y) { return x*y; } + static double mul(double x, double y) { return x*y; } + + static int square(int x=2) { return x*x; } }; inline int call_f(C& c) diff --git a/pyste/tests/basicUT.py b/pyste/tests/basicUT.py index 23cd8655..4600e9e4 100644 --- a/pyste/tests/basicUT.py +++ b/pyste/tests/basicUT.py @@ -57,9 +57,12 @@ class BasicExampleTest(unittest.TestCase): def test_mul(result, *args): self.assertEqual(C.mul(*args), result) self.assertEqual(c.mul(*args), result) - test_mul(6) - test_mul(3, 1) test_mul(16, 8, 2) + test_mul(6.0, 2.0, 3.0) + self.assertEqual(C.square(), 4) + self.assertEqual(c.square(), 4) + self.assertEqual(C.square(3), 9) + self.assertEqual(c.square(3), 9) if __name__ == '__main__': diff --git a/pyste/tests/inherit2.pyste b/pyste/tests/inherit2.pyste index 38082139..df7d7454 100644 --- a/pyste/tests/inherit2.pyste +++ b/pyste/tests/inherit2.pyste @@ -1,2 +1,3 @@ -Class('inherit2::B', 'inherit2.h') -Class('inherit2::D', 'inherit2.h') +header = AllFromHeader('inherit2.h') +exclude(header.A) +exclude(header.C)