diff --git a/pyste/NEWS b/pyste/NEWS index edcda974..aaa8e3b3 100644 --- a/pyste/NEWS +++ b/pyste/NEWS @@ -1,3 +1,7 @@ +25 April 2005 +- Fixed bug where the code for wrappers of member functions were defined outside +the pyste namespace. Reported by Dan Haffey. + 9 October 2004 - Applied a patch by Christian Hudon that fixed an issue with files that had a tail and relative includes. diff --git a/pyste/src/Pyste/ClassExporter.py b/pyste/src/Pyste/ClassExporter.py index 883cea12..f79cc792 100644 --- a/pyste/src/Pyste/ClassExporter.py +++ b/pyste/src/Pyste/ClassExporter.py @@ -253,8 +253,11 @@ class ClassExporter(Exporter): return init constructors = [x for x in self.public_members if isinstance(x, Constructor)] + # don't export copy constructors if the class is abstract + # we could remove all constructors, but this will have the effect of + # inserting no_init in the declaration, which would not allow + # even subclasses to be instantiated. self.constructors = constructors[:] - # don't export constructors if the class is abstract if self.class_.abstract: for cons in constructors: if cons.IsCopy(): @@ -277,6 +280,7 @@ class ClassExporter(Exporter): for cons in constructors: code = '.def(%s)' % init_code(cons) self.Add('inside', code) + # check if the class is copyable if not self.class_.HasCopyConstructor() or self.class_.abstract: self.Add('template', namespaces.boost + 'noncopyable') @@ -392,7 +396,7 @@ class ClassExporter(Exporter): # add wrapper code if this method has one wrapper = method_info.wrapper if wrapper and wrapper.code: - self.Add('declaration-outside', wrapper.code) + self.Add('declaration', wrapper.code) # export staticmethod statements for name in staticmethods: diff --git a/pyste/src/Pyste/GCCXMLParser.py b/pyste/src/Pyste/GCCXMLParser.py index 31ba39cd..fbc40022 100644 --- a/pyste/src/Pyste/GCCXMLParser.py +++ b/pyste/src/Pyste/GCCXMLParser.py @@ -4,7 +4,12 @@ # http:#www.boost.org/LICENSE_1_0.txt) from declarations import * -from elementtree.ElementTree import ElementTree +# try to use cElementTree if avaiable +try: + from cElementTree import ElementTree +except ImportError: + # fall back to the normal elementtree + from elementtree.ElementTree import ElementTree from xml.parsers.expat import ExpatError from copy import deepcopy from utils import enumerate @@ -403,12 +408,8 @@ class GCCXMLParser(object): classname = self.GetDecl(element.get('context')).FullName() location = self.GetLocation(element.get('location')) params = self.GetArguments(element) - artificial = element.get('artificial', False) - if not artificial: - ctor = Constructor(name, classname, params, visib) - else: - # we don't want artificial constructors - ctor = Unknown('__Unknown_Element_%s' % id) + artificial = element.get('artificial', False) + ctor = Constructor(name, classname, params, visib) ctor.location = location self.Update(id, ctor) diff --git a/pyste/tests/.cvsignore b/pyste/tests/.cvsignore index 8fe21f06..88bbcf87 100644 --- a/pyste/tests/.cvsignore +++ b/pyste/tests/.cvsignore @@ -5,3 +5,6 @@ *.arg *.dll .sconsign +cache +*.cpp +*.pch \ No newline at end of file diff --git a/pyste/tests/GCCXMLParserUT.py b/pyste/tests/GCCXMLParserUT.py index f4140af5..7cfb6af7 100644 --- a/pyste/tests/GCCXMLParserUT.py +++ b/pyste/tests/GCCXMLParserUT.py @@ -8,8 +8,8 @@ sys.path.append('../src') import unittest import tempfile import os.path -import GCCXMLParser -from declarations import * +from Pyste import GCCXMLParser +from Pyste.declarations import * class Tester(unittest.TestCase): diff --git a/pyste/tests/infosUT.py b/pyste/tests/infosUT.py index 045841f4..899f43dc 100644 --- a/pyste/tests/infosUT.py +++ b/pyste/tests/infosUT.py @@ -3,13 +3,14 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http:#www.boost.org/LICENSE_1_0.txt) import sys -sys.path.append('../src') -from infos import * -from policies import * -from exporterutils import * +from Pyste.infos import * +from Pyste.policies import * +from Pyste.exporterutils import * import unittest - +#================================================================================ +# InfosTest +#================================================================================ class InfosTest(unittest.TestCase): def testFunctionInfo(self): diff --git a/pyste/tests/inherit3.h b/pyste/tests/inherit3.h index eb399a6c..d3d55f21 100644 --- a/pyste/tests/inherit3.h +++ b/pyste/tests/inherit3.h @@ -8,6 +8,7 @@ namespace inherit3 { struct A { + A() { x = 0; } struct X { int y; }; int x; virtual int foo() { return 0; } @@ -24,6 +25,7 @@ struct A struct B: A { + B() { x = 0; } struct X { int y; }; int x; int foo() { return 1; } diff --git a/pyste/tests/policiesUT.py b/pyste/tests/policiesUT.py index 8d3f618e..9f259e01 100644 --- a/pyste/tests/policiesUT.py +++ b/pyste/tests/policiesUT.py @@ -3,10 +3,13 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http:#www.boost.org/LICENSE_1_0.txt) import sys -sys.path.append('../src') import unittest -from policies import * +from Pyste.policies import * + +#================================================================================ +# PolicicesTest +#================================================================================ class PoliciesTest(unittest.TestCase): def testReturnInternal(self):