Attempt to finish off araq cpp exceptions (#13695)

* config update
* disable a questionable test
* remove c++ exception handling IDs, new impl doesn't require it anymore
* C++ based exceptions finally work
* fixes bootstrapping problem in C++ mode
* teach GCC it's 2020 now
* more bugfixes for C++ based exception handling
* apply cooldome's patch
* another attempt to enable C++11
* bug fix

Co-authored-by: Araq <rumpf_a@web.de>
Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
cooldome 2020-03-19 19:38:25 +00:00 • committed by GitHub
commit b3176b8817
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 233 additions and 74 deletions

View file

@ -14,7 +14,7 @@ cpp exception caught
'''
"""
type
type
std_exception* {.importcpp: "std::exception", header: "<exception>".} = object
std_runtime_error* {.importcpp: "std::runtime_error", header: "<stdexcept>".} = object
std_string* {.importcpp: "std::string", header: "<string>".} = object
@ -25,7 +25,7 @@ proc constructRuntimeError(s: stdstring): std_runtime_error {.importcpp: "std::r
proc what(ex: std_runtime_error): cstring {.importcpp: "((char *)#.what())".}
proc myexception =
proc myexception =
raise constructRuntimeError(constructStdString("cpp_exception"))
try:
@ -41,17 +41,17 @@ except std_exception:
doAssert(getCurrentException() == nil)
proc earlyReturn =
proc earlyReturn =
try:
try:
myexception()
myexception()
finally:
echo "finally1"
except:
return
finally:
echo "finally2"
earlyReturn()
doAssert(getCurrentException() == nil)
@ -118,16 +118,15 @@ try:
echo "finally 2"
except:
echo "expected"
doAssert(getCurrentException() == nil)
try:
try:
myexception()
except std_runtime_error as ex:
echo "cpp exception caught"
raise newException(ValueError, "rewritten " & $ex.what())
try:
myexception()
except std_runtime_error as ex:
echo "cpp exception caught"
raise newException(ValueError, "rewritten " & $ex.what())
except:
doAssert(getCurrentExceptionMsg() == "rewritten cpp_exception")