Commit 14ec6047 authored by Felix Wu's avatar Felix Wu

Cython and C++ exceptions

parent fc317380
...@@ -1678,6 +1678,14 @@ class SimpleCallNode(ExprNode): ...@@ -1678,6 +1678,14 @@ class SimpleCallNode(ExprNode):
rhs = typecast(py_object_type, self.type, rhs) rhs = typecast(py_object_type, self.type, rhs)
else: else:
lhs = "" lhs = ""
# <fsw> added for generating C++ try/catch block
if func_type.exception_check == '+':
code.putln(
"try {%s%s;} catch(...) {CppExn2PyErr(); %s}" % (
lhs,
rhs,
code.error_goto(self.pos)))
return
code.putln( code.putln(
"%s%s; %s" % ( "%s%s; %s" % (
lhs, lhs,
......
...@@ -1645,6 +1645,9 @@ def p_exception_value_clause(s): ...@@ -1645,6 +1645,9 @@ def p_exception_value_clause(s):
if s.sy == '*': if s.sy == '*':
exc_check = 1 exc_check = 1
s.next() s.next()
elif s.sy == '+':
exc_check = '+'
s.next()
else: else:
if s.sy == '?': if s.sy == '?':
exc_check = 1 exc_check = 1
......
...@@ -747,8 +747,10 @@ class CFuncType(CType): ...@@ -747,8 +747,10 @@ class CFuncType(CType):
exc_clause = " except? %s" % self.exception_value exc_clause = " except? %s" % self.exception_value
elif self.exception_value: elif self.exception_value:
exc_clause = " except %s" % self.exception_value exc_clause = " except %s" % self.exception_value
elif self.exception_check: elif self.exception_check == '+':
exc_clause = " except *" exc_clause = " except +"
else:
" except *"
cc = self.calling_convention_prefix() cc = self.calling_convention_prefix()
if (not entity_code and cc) or entity_code.startswith("*"): if (not entity_code and cc) or entity_code.startswith("*"):
entity_code = "(%s%s)" % (cc, entity_code) entity_code = "(%s%s)" % (cc, entity_code)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment