Skip to content

Commit e5ed3a1

Browse files
author
Bruno da Silva de Oliveira
committed
Fixed bug where the code for wrappers of member functions were defined outside
the pyste namespace. Reported by Dan Haffey. [SVN r28479]
1 parent 2bbff71 commit e5ed3a1

File tree

8 files changed

+36
-18
lines changed

8 files changed

+36
-18
lines changed

pyste/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
25 April 2005
2+
- Fixed bug where the code for wrappers of member functions were defined outside
3+
the pyste namespace. Reported by Dan Haffey.
4+
15
9 October 2004
26
- Applied a patch by Christian Hudon that fixed an issue with files
37
that had a tail and relative includes.

pyste/src/Pyste/ClassExporter.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,11 @@ def init_code(cons):
253253
return init
254254

255255
constructors = [x for x in self.public_members if isinstance(x, Constructor)]
256+
# don't export copy constructors if the class is abstract
257+
# we could remove all constructors, but this will have the effect of
258+
# inserting no_init in the declaration, which would not allow
259+
# even subclasses to be instantiated.
256260
self.constructors = constructors[:]
257-
# don't export constructors if the class is abstract
258261
if self.class_.abstract:
259262
for cons in constructors:
260263
if cons.IsCopy():
@@ -277,6 +280,7 @@ def init_code(cons):
277280
for cons in constructors:
278281
code = '.def(%s)' % init_code(cons)
279282
self.Add('inside', code)
283+
280284
# check if the class is copyable
281285
if not self.class_.HasCopyConstructor() or self.class_.abstract:
282286
self.Add('template', namespaces.boost + 'noncopyable')
@@ -392,7 +396,7 @@ def IsExportable(m):
392396
# add wrapper code if this method has one
393397
wrapper = method_info.wrapper
394398
if wrapper and wrapper.code:
395-
self.Add('declaration-outside', wrapper.code)
399+
self.Add('declaration', wrapper.code)
396400

397401
# export staticmethod statements
398402
for name in staticmethods:

pyste/src/Pyste/GCCXMLParser.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
# http:#www.boost.org/LICENSE_1_0.txt)
55

66
from declarations import *
7-
from elementtree.ElementTree import ElementTree
7+
# try to use cElementTree if avaiable
8+
try:
9+
from cElementTree import ElementTree
10+
except ImportError:
11+
# fall back to the normal elementtree
12+
from elementtree.ElementTree import ElementTree
813
from xml.parsers.expat import ExpatError
914
from copy import deepcopy
1015
from utils import enumerate
@@ -403,12 +408,8 @@ def ParseConstructor(self, id, element):
403408
classname = self.GetDecl(element.get('context')).FullName()
404409
location = self.GetLocation(element.get('location'))
405410
params = self.GetArguments(element)
406-
artificial = element.get('artificial', False)
407-
if not artificial:
408-
ctor = Constructor(name, classname, params, visib)
409-
else:
410-
# we don't want artificial constructors
411-
ctor = Unknown('__Unknown_Element_%s' % id)
411+
artificial = element.get('artificial', False)
412+
ctor = Constructor(name, classname, params, visib)
412413
ctor.location = location
413414
self.Update(id, ctor)
414415

pyste/tests/.cvsignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
*.arg
66
*.dll
77
.sconsign
8+
cache
9+
*.cpp
10+
*.pch

pyste/tests/GCCXMLParserUT.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import unittest
99
import tempfile
1010
import os.path
11-
import GCCXMLParser
12-
from declarations import *
11+
from Pyste import GCCXMLParser
12+
from Pyste.declarations import *
1313

1414

1515
class Tester(unittest.TestCase):

pyste/tests/infosUT.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
# (See accompanying file LICENSE_1_0.txt or copy at
44
# http:#www.boost.org/LICENSE_1_0.txt)
55
import sys
6-
sys.path.append('../src')
7-
from infos import *
8-
from policies import *
9-
from exporterutils import *
6+
from Pyste.infos import *
7+
from Pyste.policies import *
8+
from Pyste.exporterutils import *
109
import unittest
1110

12-
11+
#================================================================================
12+
# InfosTest
13+
#================================================================================
1314
class InfosTest(unittest.TestCase):
1415

1516
def testFunctionInfo(self):

pyste/tests/inherit3.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace inherit3 {
88

99
struct A
1010
{
11+
A() { x = 0; }
1112
struct X { int y; };
1213
int x;
1314
virtual int foo() { return 0; }
@@ -24,6 +25,7 @@ struct A
2425

2526
struct B: A
2627
{
28+
B() { x = 0; }
2729
struct X { int y; };
2830
int x;
2931
int foo() { return 1; }

pyste/tests/policiesUT.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
# (See accompanying file LICENSE_1_0.txt or copy at
44
# http:#www.boost.org/LICENSE_1_0.txt)
55
import sys
6-
sys.path.append('../src')
76
import unittest
8-
from policies import *
7+
from Pyste.policies import *
98

9+
10+
#================================================================================
11+
# PolicicesTest
12+
#================================================================================
1013
class PoliciesTest(unittest.TestCase):
1114

1215
def testReturnInternal(self):

0 commit comments

Comments
 (0)