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

- Bug where the full name of the operator wasn't used in the declaration

- Now converter operators that return char* or string are automatically named __str__ in Python
- Update documentation with info about Psyco


[SVN r18127]
This commit is contained in:
Bruno da Silva de Oliveira
2003-03-28 21:02:24 +00:00
parent bf696026bd
commit 0fd503d6af
7 changed files with 35 additions and 13 deletions

View File

@@ -123,6 +123,10 @@ which for Visual C++ 6 is normally located at:
with that, you should have little trouble setting up the flags.
[blurb [$theme/note.gif][*A note about Psyco][br][br]
Although you don't have to install [@http://psyco.sourceforge.net/ Psyco] to use Pyste, if you do, Pyste will make use of it to speed up the wrapper generation. Speed ups of 30% can be achieved, so it's highly recommended.
]
[page The Interface Files]
The interface files are the heart of Pyste. The user creates one or more

View File

@@ -95,6 +95,15 @@ which for Visual C++ 6 is normally located at:</p>
</span></pre></code>
<p>
with that, you should have little trouble setting up the flags.</p>
<table width="80%" border="0" align="center">
<tr>
<td class="note_box">
<img src="theme/note.gif"></img><b>A note about Psyco</b><br><br>
Although you don't have to install <a href="http://psyco.sourceforge.net/">
Psyco</a> to use Pyste, if you do, Pyste will make use of it to speed up the wrapper generation. Speed ups of 30% can be achieved, so it's highly recommended.
</td>
</tr>
</table>
<table border="0">
<tr>
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>

View File

@@ -28,7 +28,7 @@ struct C
return C::x + other;
}
operator const char*() { return "C"; }
};
double C::x = 10;
@@ -40,4 +40,5 @@ const C operator*(const C& lhs, const C& rhs)
return c;
}
}

View File

@@ -8,6 +8,7 @@ from EnumExporter import EnumExporter
from makeid import makeid
from copy import deepcopy
import exporterutils
import re
#==============================================================================
# ClassExporter
@@ -357,12 +358,16 @@ class ClassExporter(Exporter):
'()' : '__call__',
}
# converters which has a special name in python
# converters which have a special name in python
# it's a map of a regular expression of the converter's result to the
# appropriate python name
SPECIAL_CONVERTERS = {
'double' : '__float__',
'float' : '__float__',
'int' : '__int__',
'long' : '__long__',
re.compile(r'(const)?\s*double$') : '__float__',
re.compile(r'(const)?\s*float$') : '__float__',
re.compile(r'(const)?\s*int$') : '__int__',
re.compile(r'(const)?\s*long$') : '__long__',
re.compile(r'(const)?\s*char\s*\*?$') : '__str__',
re.compile(r'(const)?.*::basic_string<.*>\s*(\*|\&)?$') : '__str__',
}
@@ -475,16 +480,18 @@ class ClassExporter(Exporter):
converters = [x for x in self.public_members if type(x) == ConverterOperator]
def ConverterMethodName(converter):
result_fullname = converter.result.name
if result_fullname in self.SPECIAL_CONVERTERS:
return self.SPECIAL_CONVERTERS[result_fullname]
result_fullname = converter.result.FullName()
result_name = converter.result.name
for regex, method_name in self.SPECIAL_CONVERTERS.items():
if regex.match(result_fullname):
return method_name
else:
# extract the last name from the full name
result_name = makeid(result_fullname.split('::')[-1])
result_name = makeid(result_name)
return 'to_' + result_name
for converter in converters:
info = self.info['operator'][converter.result.name]
info = self.info['operator'][converter.result.FullName()]
# check if this operator should be excluded
if info.exclude:
continue

View File

@@ -258,7 +258,7 @@ class ConverterOperator(ClassOperator):
'An operator in the form "operator OtherClass()".'
def FullName(self):
return self.class_ + '::operator ' + self.result.name
return self.class_ + '::operator ' + self.result.FullName()

View File

@@ -27,7 +27,7 @@ from policies import *
from CppParser import CppParser, CppParserError
import time
__VERSION__ = '0.6.3'
__VERSION__ = '0.6.4'
def GetDefaultIncludes():
if 'INCLUDE' in os.environ:

View File

@@ -19,6 +19,7 @@ class OperatorTest(unittest.TestCase):
self.assertEqual(d(), 10)
self.assertEqual(c(3.0), 13.0)
self.assertEqual(d(6.0), 16.0)
self.assertEqual(str(c), "C")
if __name__ == '__main__':