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

- Fixed bug where an union that was a class member crashed pyste (unions are still not exported)

- Added support for int, double, float and long operators


[SVN r17991]
This commit is contained in:
Bruno da Silva de Oliveira
2003-03-19 02:57:31 +00:00
parent d4b1b46e63
commit 08254b1fe7
3 changed files with 39 additions and 11 deletions

View File

@@ -366,10 +366,11 @@ class ClassExporter(Exporter):
}
# converters which has a special name in python
SPECIAL_CONVETERS = {
SPECIAL_CONVERTERS = {
'double' : '__float__',
'float' : '__float__',
'int' : '__int__',
'long' : '__long__',
}
@@ -480,12 +481,15 @@ class ClassExporter(Exporter):
# export them as simple functions with a pre-determined name
converters = [x for x in self.public_members if type(x) == ConverterOperator]
def ConverterMethodName(converter):
result_fullname = converter.result.name
# extract the last name from the full name
result_name = _ID(result_fullname.split('::')[-1])
return 'to_' + result_name
if result_fullname in self.SPECIAL_CONVERTERS:
return self.SPECIAL_CONVERTERS[result_fullname]
else:
# extract the last name from the full name
result_name = _ID(result_fullname.split('::')[-1])
return 'to_' + result_name
for converter in converters:
info = self.info['operator'][converter.result.name]

View File

@@ -358,12 +358,13 @@ class GCCXMLParser(object):
name = element.get('name')
location = self.GetLocation(element.get('location'))
context = self.GetDecl(element.get('context'))
if isinstance(context, Class):
if isinstance(context, str):
enum = Enumeration(name, context)
self.AddDecl(enum) # in this case, is a top level decl
else:
visib = element.get('access', Scope.public)
enum = ClassEnumeration(name, context.FullName(), visib)
else:
enum = Enumeration(name, context)
self.AddDecl(enum) # in this case, is a top level decl
enum.location = location
for child in element:
if child.tag == 'EnumValue':
@@ -379,7 +380,18 @@ class GCCXMLParser(object):
def ParseUnion(self, id, element):
self.Update(id, Declaration(element.get('name'), ''))
name = element.get('name')
context = self.GetDecl(element.get('context'))
location = self.GetLocation(element.get('location'))
if isinstance(context, str):
# a free union
union = Union(name, context)
self.AddDecl(union)
else:
visib = element.get('access', Scope.public)
union = ClassUnion(name, context.FullName(), visib)
union.location = location
self.Update(id, union)

View File

@@ -445,8 +445,20 @@ class Typedef(Declaration):
self.visibility = Scope.public
class Union(Declaration):
'Shallow declaration, because Unions are not supported yet'
def __init__(self, name, namespace):
Declaration.__init__(self, name, namespace)
class ClassUnion(Union):
def __init__(self, name, class_, visib):
Union.__init__(self, name, None)
self.class_ = class_
self.visibility = visib
def FullName(self):
return '%s::%s' % (self.class_, self.name)