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

- Added exception specifiers (patch by Gottfried).

[SVN r19645]
This commit is contained in:
Bruno da Silva de Oliveira
2003-08-16 18:21:44 +00:00
parent 7f3aceafd2
commit 06b8320815
7 changed files with 42 additions and 13 deletions

View File

@@ -1,3 +1,7 @@
16 August 2003
Applied a patch by Gottfried Ganssauge that adds exception specifiers to
wrapper functions and pointer declarations. Thanks a lot Gottfried!!
10 August 2003
Support for incremental generation of the code has been added. This changes
how --multiple works; documentation of this new feature will follow. Thanks

View File

@@ -695,7 +695,7 @@ class _VirtualWrapperGenerator(object):
constantness = ' const'
# call_method callback
decl = indent + '%s %s(%s)%s {\n' % (result, method.name, params, constantness)
decl = indent + '%s %s(%s)%s%s {\n' % (result, method.name, params, constantness, method.Exceptions())
param_names_str = ', '.join(param_names)
if param_names_str:
param_names_str = ', ' + param_names_str
@@ -804,7 +804,7 @@ class _VirtualWrapperGenerator(object):
# them.
def MethodSig(method):
if method.const:
const = 'const'
const = ' const'
else:
const = ''
if method.result:
@@ -812,7 +812,8 @@ class _VirtualWrapperGenerator(object):
else:
result = ''
params = ', '.join([x.FullName() for x in method.parameters])
return '%s %s(%s) %s' % (result, method.name, params, const)
return '%s %s(%s)%s%s' % (
result, method.name, params, const, method.Exceptions())
already_added = {}
self.virtual_methods = []

View File

@@ -44,7 +44,7 @@ class FunctionExporter(Exporter):
codeunit.Write('module', self.INDENT + defs + '\n')
# add the code of the wrapper
if wrapper and wrapper.code:
codeunit.Write('declaration', code + '\n')
codeunit.Write('declaration', wrapper.code + '\n')
def OverloadName(self, decl):

View File

@@ -193,6 +193,17 @@ class GCCXMLParser(object):
return args
def GetExceptions(self, exception_list):
if exception_list is None:
return None
exceptions = []
for t in exception_list.split():
exceptions.append(self.GetType(t))
return exceptions
def ParseFunction(self, id, element, functionType=Function):
'''functionType is used because a Operator is identical to a normal
function, only the type of the function changes.'''
@@ -202,7 +213,8 @@ class GCCXMLParser(object):
location = self.GetLocation(element.get('location'))
params = self.GetArguments(element)
incomplete = bool(int(element.get('incomplete', 0)))
function = functionType(name, namespace, returns, params)
throws = self.GetExceptions(element.get('throw', None))
function = functionType(name, namespace, returns, params, throws)
function.location = location
self.AddDecl(function)
self.Update(id, function)
@@ -366,9 +378,10 @@ class GCCXMLParser(object):
abstract = bool(int(element.get('pure_virtual', '0')))
const = bool(int(element.get('const', '0')))
location = self.GetLocation(element.get('location'))
throws = self.GetExceptions(element.get('throw', None))
params = self.GetArguments(element)
method = methodType(
name, classname, result, params, visib, virtual, abstract, static, const)
name, classname, result, params, visib, virtual, abstract, static, const, throws)
method.location = location
self.Update(id, method)

View File

@@ -50,7 +50,7 @@ class SingleCodeUnit:
return self.code[section]
def SetCurrent(self, current):
def SetCurrent(self, *args):
pass

View File

@@ -196,14 +196,24 @@ class Function(Declaration):
'''The declaration of a function.
@ivar _result: instance of L{Type} or None.
@ivar _parameters: list of L{Type} instances.
@ivar _throws: exception specifiers or None
'''
def __init__(self, name, namespace, result, params):
def __init__(self, name, namespace, result, params, throws=None):
Declaration.__init__(self, name, namespace)
# the result type: instance of Type, or None (constructors)
self.result = result
# the parameters: instances of Type
self.parameters = params
# the exception specification
self.throws = throws
def Exceptions(self):
if self.throws is None:
return ""
else:
return " throw(%s)" % ', '.join (self.throws)
def PointerDeclaration(self, force=False):
@@ -264,10 +274,11 @@ class Method(Function):
@ivar _static: if this method is static.
@ivar _class: the full name of the class where this method was declared.
@ivar _const: if this method is declared as const.
@ivar _throws: list of exception specificiers or None
'''
def __init__(self, name, class_, result, params, visib, virtual, abstract, static, const):
Function.__init__(self, name, None, result, params)
def __init__(self, name, class_, result, params, visib, virtual, abstract, static, const, throws=None):
Function.__init__(self, name, None, result, params, throws)
self.visibility = visib
self.virtual = virtual
self.abstract = abstract
@@ -296,8 +307,8 @@ class Method(Function):
const = ''
if self.const:
const = 'const'
return '(%s (%s::*)(%s) %s)&%s' %\
(result, self.class_, params, const, self.FullName())
return '(%s (%s::*)(%s) %s%s)&%s' %\
(result, self.class_, params, const, self.Exceptions(), self.FullName())
#==============================================================================

View File

@@ -43,7 +43,7 @@ from CppParser import CppParser, CppParserError
import time
from declarations import Typedef
__VERSION__ = '0.9.12'
__VERSION__ = '0.9.13'
def RecursiveIncludes(include):
'Return a list containg the include dir and all its subdirectories'