mirror of https://github.com/swig/swig
C++ reference errors when passing in a 'NULL' change of behaviour.
Most languages now use "NullReferenceError" in the error message where they previously used "ValueError". Also exception changes: Guile: "swig-null-reference-error" instead of "swig-value-error" MzScheme: "swig-null-reference-error" instead of "swig-value-error" PHP: zend_ce_type_error instead of zend_ce_value_error Python: Consistently raises TypeError instead of a mix of ValueError and TypeError. Ruby: Consistently raises NullReferenceError instead of a mix of ArgumentError and NullReferenceErrorError. The consistent raising of a TypeError instead of ValueError for Python ensures that incorrectly passing 'None' into a C++ reference argument will correctly convert the error into a NotImplemented error for the rich comparisons implementations per PEP 207. Fixes #2987 Note that the li_constraints checking implementation for the NONNULL typemap for pointers also makes the same error change from SWIG_ValueError to SWIG_NullReferenceError. The D typemaps use SWIG_DNullReferenceException instead of SWIG_DIllegalArgumentException, although this ultimately has no change as the same D Exception is still thrown.
This commit is contained in:
parent
acbaa3a757
commit
9bf4842002
|
@ -7,6 +7,26 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.3.0 (in progress)
|
||||
===========================
|
||||
|
||||
2024-09-14: wsfulton
|
||||
C++ reference errors when passing in a 'NULL' change of behaviour.
|
||||
Most languages now use "NullReferenceError" in the error message
|
||||
where they previously used "ValueError". Also exception changes:
|
||||
|
||||
Guile: "swig-null-reference-error" instead of "swig-value-error"
|
||||
MzScheme: "swig-null-reference-error" instead of "swig-value-error"
|
||||
PHP: zend_ce_type_error instead of zend_ce_value_error
|
||||
Python: Consistently raises TypeError instead of a mix of ValueError
|
||||
and TypeError.
|
||||
Ruby: Consistently raises NullReferenceError instead of a mix of
|
||||
ArgumentError and NullReferenceErrorError.
|
||||
|
||||
The consistent raising of a TypeError instead of ValueError for Python
|
||||
ensures that incorrectly passing 'None' into a C++ reference argument
|
||||
will correctly convert the error into a NotImplemented error for
|
||||
the rich comparisons implementations per PEP 207. Fixes #2987
|
||||
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2024-09-13: vadz
|
||||
[C] #2086 Add support for C as a target language. This support is
|
||||
currently experimental.
|
||||
|
|
|
@ -456,16 +456,17 @@ mapping:
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
MAP(SWIG_MemoryError, "swig-memory-error");
|
||||
MAP(SWIG_IOError, "swig-io-error");
|
||||
MAP(SWIG_RuntimeError, "swig-runtime-error");
|
||||
MAP(SWIG_IndexError, "swig-index-error");
|
||||
MAP(SWIG_TypeError, "swig-type-error");
|
||||
MAP(SWIG_DivisionByZero, "swig-division-by-zero");
|
||||
MAP(SWIG_OverflowError, "swig-overflow-error");
|
||||
MAP(SWIG_SyntaxError, "swig-syntax-error");
|
||||
MAP(SWIG_ValueError, "swig-value-error");
|
||||
MAP(SWIG_SystemError, "swig-system-error");
|
||||
MAP(SWIG_MemoryError, "swig-memory-error");
|
||||
MAP(SWIG_IOError, "swig-io-error");
|
||||
MAP(SWIG_RuntimeError, "swig-runtime-error");
|
||||
MAP(SWIG_IndexError, "swig-index-error");
|
||||
MAP(SWIG_TypeError, "swig-type-error");
|
||||
MAP(SWIG_DivisionByZero, "swig-division-by-zero");
|
||||
MAP(SWIG_OverflowError, "swig-overflow-error");
|
||||
MAP(SWIG_SyntaxError, "swig-syntax-error");
|
||||
MAP(SWIG_ValueError, "swig-value-error");
|
||||
MAP(SWIG_SystemError, "swig-system-error");
|
||||
MAP(SWIG_NullReferenceError, "swig-null-reference-error");
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -2399,6 +2399,7 @@ SWIG_OverflowError
|
|||
SWIG_SyntaxError
|
||||
SWIG_ValueError
|
||||
SWIG_SystemError
|
||||
SWIG_NullReferenceError
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ function check_func(except, f, val, name)
|
|||
actual, err = pcall(f, val);
|
||||
assert(actual == except, 'function perform exception wrongly');
|
||||
if name == nil then
|
||||
r = 'SWIG_ValueError:Received a NULL pointer.';
|
||||
r = 'SWIG_NullReferenceError:Received a NULL pointer.';
|
||||
else
|
||||
r = 'SWIG_ValueError:Expected a ' .. name .. ' value.';
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ try
|
|||
# Empty matrix translate to null pointer
|
||||
li_constraints.test_nonnull([]);
|
||||
catch
|
||||
have_exception = strcmp("Received a NULL pointer. (SWIG_ValueError)", lasterr) == 1;
|
||||
have_exception = strcmp("Received a NULL pointer. (SWIG_NullReferenceError)", lasterr) == 1;
|
||||
end
|
||||
if (!have_exception)
|
||||
error("test_nonnull should perform exception with 'null' value");
|
||||
|
|
|
@ -24,7 +24,7 @@ is(cpp17_string_view::test_const_reference("Fum"), "Fum", "Test 3");
|
|||
|
||||
# Verify type-checking for %typemap(in) const std::string_view & {}
|
||||
eval { cpp17_string_view::test_const_reference(undef) };
|
||||
like($@, qr/\bValueError\b/, "Test 4");
|
||||
like($@, qr/\bNullReferenceError\b/, "Test 4");
|
||||
|
||||
#
|
||||
# Input and output typemaps for pointers and non-const references to
|
||||
|
|
|
@ -49,7 +49,7 @@ check_double(1, $nonzero, "nonzero", -10);
|
|||
my $ret = eval { li_constraints::test_nonnull(undef); 1; };
|
||||
my $err = $@;
|
||||
is($ret, undef, "li_constraints::test_nonnull throw exception with null");
|
||||
ok($err =~ "^ValueError Received a NULL pointer.", "li_constraints::test_nonnull throw proper exception");
|
||||
ok($err =~ "^NullReferenceError Received a NULL pointer.", "li_constraints::test_nonnull throw proper exception");
|
||||
my $ptr = li_constraints::get_nonnull();
|
||||
# There should be no exception, we can use Perl lambda function
|
||||
$ret = (sub { li_constraints::test_nonnull($ptr); 1; })->();
|
||||
|
|
|
@ -24,7 +24,7 @@ is(li_std_string::test_const_reference("Fum"), "Fum", "Test 3");
|
|||
|
||||
# Verify type-checking for %typemap(in) const std::string & {}
|
||||
eval { li_std_string::test_const_reference(undef) };
|
||||
like($@, qr/\bValueError\b/, "Test 4");
|
||||
like($@, qr/\bNullReferenceError\b/, "Test 4");
|
||||
|
||||
#
|
||||
# Input and output typemaps for pointers and non-const references to
|
||||
|
|
|
@ -56,7 +56,7 @@ check_double(true, $nonzero, "nonzero", -10);
|
|||
$have_exception = false;
|
||||
try {
|
||||
test_nonnull(null);
|
||||
} catch(ValueError $e) {
|
||||
} catch(TypeError $e) {
|
||||
$msg = $e->getMessage();
|
||||
$have_exception = strcmp($msg, "Received a NULL pointer.") === 0;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ Counter.reset_counts()
|
|||
exception_thrown = False
|
||||
try:
|
||||
MovableCopyable.movein(None)
|
||||
except ValueError as e:
|
||||
except TypeError as e:
|
||||
if "invalid null reference" not in str(e):
|
||||
raise RuntimeError("incorrect exception message:" + str(e))
|
||||
exception_thrown = True
|
||||
|
|
|
@ -156,7 +156,7 @@ class li_boost_shared_ptr_runme:
|
|||
try:
|
||||
li_boost_shared_ptr.valuetest(k)
|
||||
raise RuntimeError("Failed to catch null pointer")
|
||||
except ValueError:
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
if (li_boost_shared_ptr.pointertest(k) != None):
|
||||
|
@ -165,7 +165,7 @@ class li_boost_shared_ptr_runme:
|
|||
try:
|
||||
li_boost_shared_ptr.reftest(k)
|
||||
raise RuntimeError("Failed to catch null pointer")
|
||||
except ValueError:
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
# test null pointers emitted from C++
|
||||
|
@ -476,7 +476,7 @@ class li_boost_shared_ptr_runme:
|
|||
try:
|
||||
m.MemberValue = None
|
||||
raise RuntimeError("Failed to catch null pointer")
|
||||
except ValueError:
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
# ////////////////////////////////// Global variables /////////////////
|
||||
|
@ -514,7 +514,7 @@ class li_boost_shared_ptr_runme:
|
|||
try:
|
||||
li_boost_shared_ptr.cvar.GlobalValue = None
|
||||
raise RuntimeError("Failed to catch null pointer")
|
||||
except ValueError:
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
# plain pointer
|
||||
|
@ -548,7 +548,7 @@ class li_boost_shared_ptr_runme:
|
|||
try:
|
||||
li_boost_shared_ptr.cvar.GlobalReference = None
|
||||
raise RuntimeError("Failed to catch null pointer")
|
||||
except ValueError:
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
# ////////////////////////////////// Templates ////////////////////////
|
||||
|
|
|
@ -46,7 +46,7 @@ check_double(True, nonzero, "nonzero", -10)
|
|||
have_exception = False
|
||||
try:
|
||||
li_constraints.test_nonnull(None)
|
||||
except ValueError as e:
|
||||
except TypeError as e:
|
||||
have_exception = "Received a NULL pointer." == "%s"%(e)
|
||||
if not have_exception:
|
||||
raise Exception("test_nonnull should perform exception with 'null' value")
|
||||
|
|
|
@ -27,13 +27,13 @@ except TypeError as e:
|
|||
try:
|
||||
li_std_wstring.test_reference(None)
|
||||
raise RuntimeError("NULL check failed")
|
||||
except ValueError as e:
|
||||
except TypeError as e:
|
||||
if "invalid null reference" not in str(e):
|
||||
raise RuntimeError("Missing text {}".format(e))
|
||||
try:
|
||||
li_std_wstring.test_const_reference(None)
|
||||
raise RuntimeError("NULL check failed")
|
||||
except ValueError as e:
|
||||
except TypeError as e:
|
||||
if "invalid null reference" not in str(e):
|
||||
raise RuntimeError("Missing text {}".format(e))
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ Cpp11_rvalue_reference_move::Counter.reset_counts()
|
|||
exception_thrown = false
|
||||
begin
|
||||
Cpp11_rvalue_reference_move::MovableCopyable.movein(nil)
|
||||
rescue ArgumentError => e
|
||||
rescue NullReferenceError => e
|
||||
if (!e.to_s.include? "invalid null reference")
|
||||
raise RuntimeError, "incorrect exception message: #{e.to_s}"
|
||||
end
|
||||
|
|
|
@ -184,7 +184,7 @@ class Li_boost_shared_ptr_runme
|
|||
begin
|
||||
Li_boost_shared_ptr::valuetest(k)
|
||||
raise RuntimeError, "Failed to catch null pointer"
|
||||
rescue ArgumentError
|
||||
rescue NullReferenceError
|
||||
end
|
||||
|
||||
if (Li_boost_shared_ptr::pointertest(k) != nil)
|
||||
|
@ -194,7 +194,7 @@ class Li_boost_shared_ptr_runme
|
|||
begin
|
||||
Li_boost_shared_ptr::reftest(k)
|
||||
raise RuntimeError, "Failed to catch null pointer"
|
||||
rescue ArgumentError
|
||||
rescue NullReferenceError
|
||||
end
|
||||
|
||||
# $owner
|
||||
|
@ -508,7 +508,7 @@ class Li_boost_shared_ptr_runme
|
|||
begin
|
||||
m.MemberValue = nil
|
||||
raise RuntimeError, "Failed to catch null pointer"
|
||||
rescue ArgumentError
|
||||
rescue NullReferenceError
|
||||
end
|
||||
|
||||
# ////////////////////////////////// Global variables /////////////////
|
||||
|
@ -547,7 +547,7 @@ class Li_boost_shared_ptr_runme
|
|||
begin
|
||||
Li_boost_shared_ptr.GlobalValue = nil
|
||||
raise RuntimeError, "Failed to catch null pointer"
|
||||
rescue ArgumentError
|
||||
rescue NullReferenceError
|
||||
end
|
||||
|
||||
# plain pointer
|
||||
|
@ -582,7 +582,7 @@ class Li_boost_shared_ptr_runme
|
|||
begin
|
||||
Li_boost_shared_ptr.GlobalReference = nil
|
||||
raise RuntimeError, "Failed to catch null pointer"
|
||||
rescue ArgumentError
|
||||
rescue NullReferenceError
|
||||
end
|
||||
|
||||
# ////////////////////////////////// Templates ////////////////////////
|
||||
|
|
|
@ -54,7 +54,7 @@ have_exception = false
|
|||
begin
|
||||
test_nonnull(nil)
|
||||
rescue => e
|
||||
have_exception = e.class == ArgumentError && e.message == "Received a NULL pointer."
|
||||
have_exception = e.class == NullReferenceError && e.message == "Received a NULL pointer."
|
||||
end
|
||||
if not have_exception
|
||||
raise RuntimeError, "test_nonnull should perform exception with 'null' value"
|
||||
|
|
|
@ -24,13 +24,13 @@ end
|
|||
begin
|
||||
Li_std_wstring.test_reference(nil)
|
||||
raise RuntimeError, "NULL check failed"
|
||||
rescue ArgumentError => e
|
||||
rescue NullReferenceError => e
|
||||
swig_assert_simple(e.message.include? "invalid null reference")
|
||||
end
|
||||
begin
|
||||
Li_std_wstring.test_const_reference(nil)
|
||||
raise RuntimeError, "NULL check failed"
|
||||
rescue ArgumentError => e
|
||||
rescue NullReferenceError => e
|
||||
swig_assert_simple(e.message.include? "invalid null reference")
|
||||
end
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ check_double 0 nonzero "nonzero" -10
|
|||
|
||||
set actual [ catch { test_nonnull NULL } err_msg ]
|
||||
if { ($actual != 1) ||
|
||||
([ string equal $err_msg "ValueError Received a NULL pointer." ] != 1) } {
|
||||
([ string equal $err_msg "NullReferenceError Received a NULL pointer." ] != 1) } {
|
||||
error "Test 'test_nonnull' with null value fail"
|
||||
}
|
||||
set nonnull [ get_nonnull ]
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
Pointer NONNULL
|
||||
{
|
||||
if (!$1) {
|
||||
SWIG_exception(SWIG_ValueError,"Received a NULL pointer.");
|
||||
SWIG_exception(SWIG_NullReferenceError,"Received a NULL pointer.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
|
||||
argp = ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0;
|
||||
if (!argp) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
$1 = *argp; %}
|
||||
|
@ -30,7 +30,7 @@
|
|||
|
||||
%typemap(directorout) CONST TYPE
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input;
|
||||
|
@ -56,7 +56,7 @@
|
|||
%typemap(in, canthrow=1) CONST TYPE & %{
|
||||
$1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0);
|
||||
if (!$1) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type reference is null");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "$1_type reference is null");
|
||||
return $null;
|
||||
} %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
|
||||
|
|
|
@ -24,7 +24,8 @@ typedef enum {
|
|||
SWIG_DIllegalArgumentException,
|
||||
SWIG_DIllegalElementException,
|
||||
SWIG_DIOException,
|
||||
SWIG_DNoSuchElementException
|
||||
SWIG_DNoSuchElementException,
|
||||
SWIG_DNullReferenceException
|
||||
} SWIG_DExceptionCodes;
|
||||
|
||||
typedef void (* SWIG_DExceptionCallback_t)(const char *);
|
||||
|
@ -39,7 +40,8 @@ static SWIG_DException_t SWIG_d_exceptions[] = {
|
|||
{ SWIG_DIllegalArgumentException, NULL },
|
||||
{ SWIG_DIllegalElementException, NULL },
|
||||
{ SWIG_DIOException, NULL },
|
||||
{ SWIG_DNoSuchElementException, NULL }
|
||||
{ SWIG_DNoSuchElementException, NULL },
|
||||
{ SWIG_DNullReferenceException, NULL }
|
||||
};
|
||||
|
||||
static void SWIGUNUSED SWIG_DSetPendingException(SWIG_DExceptionCodes code, const char *msg) {
|
||||
|
@ -58,12 +60,14 @@ SWIGEXPORT void SWIGRegisterExceptionCallbacks_$module(
|
|||
SWIG_DExceptionCallback_t illegalArgumentCallback,
|
||||
SWIG_DExceptionCallback_t illegalElementCallback,
|
||||
SWIG_DExceptionCallback_t ioCallback,
|
||||
SWIG_DExceptionCallback_t noSuchElementCallback) {
|
||||
SWIG_DExceptionCallback_t noSuchElementCallback,
|
||||
SWIG_DExceptionCallback_t nullReferenceCallback) {
|
||||
SWIG_d_exceptions[SWIG_DException].callback = exceptionCallback;
|
||||
SWIG_d_exceptions[SWIG_DIllegalArgumentException].callback = illegalArgumentCallback;
|
||||
SWIG_d_exceptions[SWIG_DIllegalElementException].callback = illegalElementCallback;
|
||||
SWIG_d_exceptions[SWIG_DIOException].callback = ioCallback;
|
||||
SWIG_d_exceptions[SWIG_DNoSuchElementException].callback = noSuchElementCallback;
|
||||
SWIG_d_exceptions[SWIG_DNullReferenceException].callback = nullReferenceCallback;
|
||||
}
|
||||
%}
|
||||
|
||||
|
@ -80,6 +84,7 @@ private class SwigExceptionHelper {
|
|||
&setException,
|
||||
&setException,
|
||||
&setException,
|
||||
&setException,
|
||||
&setException
|
||||
);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
%typemap(in, canthrow=1) SWIGTYPE ($&1_type argp)
|
||||
%{ argp = ($&1_ltype)$input;
|
||||
if (!argp) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
$1 = *argp; %}
|
||||
|
@ -65,7 +65,7 @@
|
|||
"$input = (void *)new $1_ltype(SWIG_STD_MOVE($1));"
|
||||
%typemap(directorout) SWIGTYPE
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "Unexpected null return for type $1_type");
|
||||
return $null;
|
||||
}
|
||||
$result = *($&1_ltype)$input; %}
|
||||
|
@ -122,7 +122,7 @@
|
|||
|
||||
%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
|
||||
if (!$1) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type is null");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "$1_type is null");
|
||||
return $null;
|
||||
} %}
|
||||
%typemap(out) SWIGTYPE & "$result = (void *)$1;"
|
||||
|
@ -131,7 +131,7 @@
|
|||
"$input = ($1_ltype) &$1;"
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "Unexpected null return for type $1_type");
|
||||
return $null;
|
||||
}
|
||||
$result = ($1_ltype)$input; %}
|
||||
|
@ -159,7 +159,7 @@
|
|||
|
||||
%typemap(in, canthrow=1, fragment="<memory>") SWIGTYPE && (std::unique_ptr<$*1_ltype> rvrdeleter) %{ $1 = ($1_ltype)$input;
|
||||
if (!$1) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type is null");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "$1_type is null");
|
||||
return $null;
|
||||
}
|
||||
rvrdeleter.reset($1); %}
|
||||
|
@ -169,7 +169,7 @@
|
|||
"$input = ($1_ltype) &$1;"
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &&
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "Unexpected null return for type $1_type");
|
||||
return $null;
|
||||
}
|
||||
$result = ($1_ltype)$input; %}
|
||||
|
|
|
@ -27,13 +27,13 @@ class string;
|
|||
|
||||
%typemap(in, canthrow=1) string, const string &
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "null string");
|
||||
return $null;
|
||||
}
|
||||
$1.assign($input); %}
|
||||
%typemap(in, canthrow=1) const string &
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "null string");
|
||||
return $null;
|
||||
}
|
||||
$*1_ltype $1_str($input);
|
||||
|
@ -52,14 +52,14 @@ class string;
|
|||
|
||||
%typemap(directorout, canthrow=1) string
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "null string");
|
||||
return $null;
|
||||
}
|
||||
$result.assign($input); %}
|
||||
|
||||
%typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
|
||||
%{ if (!$input) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "null string");
|
||||
return $null;
|
||||
}
|
||||
/* possible thread/reentrant code problem */
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
%typemap(in, canthrow=1) SWIGTYPE MOVE ($&1_type argp)
|
||||
%{ argp = ($&1_ltype)$input;
|
||||
if (!argp) {
|
||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type");
|
||||
SWIG_DSetPendingException(SWIG_DNullReferenceException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
SwigValueWrapper< $1_ltype >::reset($1, argp); %}
|
||||
|
|
|
@ -292,7 +292,8 @@ extern(C) void function(
|
|||
SwigExceptionCallback illegalArgumentCallback,
|
||||
SwigExceptionCallback illegalElementCallback,
|
||||
SwigExceptionCallback ioCallback,
|
||||
SwigExceptionCallback noSuchElementCallback) swigRegisterExceptionCallbacks$module;
|
||||
SwigExceptionCallback noSuchElementCallback,
|
||||
SwigExceptionCallback nullReferenceCallback) swigRegisterExceptionCallbacks$module;
|
||||
|
||||
extern(C) void function(SwigStringCallback callback) swigRegisterStringCallback$module;
|
||||
%}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
code == SWIG_DivisionByZero ? zend_ce_division_by_zero_error : \
|
||||
code == SWIG_SyntaxError ? zend_ce_parse_error : \
|
||||
code == SWIG_OverflowError ? zend_ce_arithmetic_error : \
|
||||
code == SWIG_NullReferenceError ? zend_ce_type_error : \
|
||||
NULL, msg, code); SWIG_fail; } while (0)
|
||||
%}
|
||||
#endif
|
||||
|
@ -36,16 +37,17 @@
|
|||
ERROR(scmerr); \
|
||||
break
|
||||
switch (code) {
|
||||
MAP(SWIG_MemoryError, "swig-memory-error");
|
||||
MAP(SWIG_IOError, "swig-io-error");
|
||||
MAP(SWIG_RuntimeError, "swig-runtime-error");
|
||||
MAP(SWIG_IndexError, "swig-index-error");
|
||||
MAP(SWIG_TypeError, "swig-type-error");
|
||||
MAP(SWIG_DivisionByZero, "swig-division-by-zero");
|
||||
MAP(SWIG_OverflowError, "swig-overflow-error");
|
||||
MAP(SWIG_SyntaxError, "swig-syntax-error");
|
||||
MAP(SWIG_ValueError, "swig-value-error");
|
||||
MAP(SWIG_SystemError, "swig-system-error");
|
||||
MAP(SWIG_MemoryError, "swig-memory-error");
|
||||
MAP(SWIG_IOError, "swig-io-error");
|
||||
MAP(SWIG_RuntimeError, "swig-runtime-error");
|
||||
MAP(SWIG_IndexError, "swig-index-error");
|
||||
MAP(SWIG_TypeError, "swig-type-error");
|
||||
MAP(SWIG_DivisionByZero, "swig-division-by-zero");
|
||||
MAP(SWIG_OverflowError, "swig-overflow-error");
|
||||
MAP(SWIG_SyntaxError, "swig-syntax-error");
|
||||
MAP(SWIG_ValueError, "swig-value-error");
|
||||
MAP(SWIG_SystemError, "swig-system-error");
|
||||
MAP(SWIG_NullReferenceError, "swig-null-reference-error");
|
||||
default:
|
||||
ERROR("swig-error");
|
||||
}
|
||||
|
@ -68,16 +70,17 @@ SWIGINTERN void SWIG_exception_ (int code, const char *msg) {
|
|||
ERROR(errname); \
|
||||
break
|
||||
switch (code) {
|
||||
MAP(SWIG_MemoryError, "swig-memory-error");
|
||||
MAP(SWIG_IOError, "swig-io-error");
|
||||
MAP(SWIG_RuntimeError, "swig-runtime-error");
|
||||
MAP(SWIG_IndexError, "swig-index-error");
|
||||
MAP(SWIG_TypeError, "swig-type-error");
|
||||
MAP(SWIG_DivisionByZero, "swig-division-by-zero");
|
||||
MAP(SWIG_OverflowError, "swig-overflow-error");
|
||||
MAP(SWIG_SyntaxError, "swig-syntax-error");
|
||||
MAP(SWIG_ValueError, "swig-value-error");
|
||||
MAP(SWIG_SystemError, "swig-system-error");
|
||||
MAP(SWIG_MemoryError, "swig-memory-error");
|
||||
MAP(SWIG_IOError, "swig-io-error");
|
||||
MAP(SWIG_RuntimeError, "swig-runtime-error");
|
||||
MAP(SWIG_IndexError, "swig-index-error");
|
||||
MAP(SWIG_TypeError, "swig-type-error");
|
||||
MAP(SWIG_DivisionByZero, "swig-division-by-zero");
|
||||
MAP(SWIG_OverflowError, "swig-overflow-error");
|
||||
MAP(SWIG_SyntaxError, "swig-syntax-error");
|
||||
MAP(SWIG_ValueError, "swig-value-error");
|
||||
MAP(SWIG_SystemError, "swig-system-error");
|
||||
MAP(SWIG_NullReferenceError, "swig-null-reference-error");
|
||||
default:
|
||||
ERROR("swig-error");
|
||||
}
|
||||
|
@ -116,6 +119,9 @@ SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) {
|
|||
case SWIG_TypeError:
|
||||
exception_code = SWIG_JavaIllegalArgumentException;
|
||||
break;
|
||||
case SWIG_NullReferenceError:
|
||||
exception_code = SWIG_JavaNullPointerException;
|
||||
break;
|
||||
case SWIG_UnknownError:
|
||||
default:
|
||||
exception_code = SWIG_JavaUnknownError;
|
||||
|
@ -160,6 +166,9 @@ SWIGINTERN void SWIG_OCamlException(int code, const char *msg) {
|
|||
case SWIG_ValueError:
|
||||
exception_code = SWIG_OCamlIllegalArgumentException;
|
||||
break;
|
||||
case SWIG_NullReferenceError:
|
||||
exception_code = SWIG_OCamlNullReferenceException;
|
||||
break;
|
||||
case SWIG_UnknownError:
|
||||
default:
|
||||
exception_code = SWIG_OCamlUnknownError;
|
||||
|
@ -197,6 +206,9 @@ SWIGINTERN void SWIG_CSharpException(int code, const char *msg) {
|
|||
case SWIG_OverflowError:
|
||||
exception_code = SWIG_CSharpOverflowException;
|
||||
break;
|
||||
case SWIG_NullReferenceError:
|
||||
exception_code = SWIG_CSharpNullReferenceException;
|
||||
break;
|
||||
case SWIG_RuntimeError:
|
||||
case SWIG_TypeError:
|
||||
case SWIG_SyntaxError:
|
||||
|
@ -238,6 +250,9 @@ SWIGINTERN void SWIG_DThrowException(int code, const char *msg) {
|
|||
case SWIG_ValueError:
|
||||
exception_code = SWIG_DIllegalArgumentException;
|
||||
break;
|
||||
case SWIG_NullReferenceError:
|
||||
exception_code = SWIG_DNullReferenceException;
|
||||
break;
|
||||
case SWIG_DivisionByZero:
|
||||
case SWIG_MemoryError:
|
||||
case SWIG_OverflowError:
|
||||
|
|
|
@ -49,6 +49,7 @@ SWIGINTERN void SWIG_NAPI_Raise(Napi::Env env, int type, const char *msg) {
|
|||
throw Napi::RangeError::New(env, msg);
|
||||
case SWIG_ValueError:
|
||||
case SWIG_TypeError:
|
||||
case SWIG_NullReferenceError:
|
||||
throw Napi::TypeError::New(env, msg);
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +91,7 @@ SWIGINTERN void SWIG_NAPI_Raise(Napi::Env env, int type, const char *msg) {
|
|||
return;
|
||||
case SWIG_ValueError:
|
||||
case SWIG_TypeError:
|
||||
case SWIG_NullReferenceError:
|
||||
Napi::TypeError::New(env, msg).ThrowAsJavaScriptException();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ typedef enum {
|
|||
SWIG_OCamlIndexOutOfBoundsException,
|
||||
SWIG_OCamlRuntimeException,
|
||||
SWIG_OCamlSystemException,
|
||||
SWIG_OCamlNullReferenceException,
|
||||
SWIG_OCamlUnknownError
|
||||
} SWIG_OCamlExceptionCodes;
|
||||
|
||||
|
@ -54,6 +55,7 @@ SWIGINTERN void SWIG_OCamlThrowException(SWIG_OCamlExceptionCodes code, const ch
|
|||
|
||||
switch (code) {
|
||||
case SWIG_OCamlIllegalArgumentException:
|
||||
case SWIG_OCamlNullReferenceException:
|
||||
caml_invalid_argument(msg);
|
||||
break;
|
||||
case SWIG_OCamlSystemException:
|
||||
|
|
|
@ -43,6 +43,8 @@ SWIGRUNTIME octave_value SWIG_ErrorType(int code) {
|
|||
return "SWIG_SystemError";
|
||||
case SWIG_AttributeError:
|
||||
return "SWIG_AttributeError";
|
||||
case SWIG_NullReferenceError:
|
||||
return "SWIG_NullReferenceError";
|
||||
}
|
||||
return "SWIG unknown error";
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ SWIG_Perl_ErrorType(int code) {
|
|||
return "SystemError";
|
||||
case SWIG_AttributeError:
|
||||
return "AttributeError";
|
||||
case SWIG_NullReferenceError:
|
||||
return "NullReferenceError";
|
||||
default:
|
||||
return "RuntimeError";
|
||||
}
|
||||
|
|
|
@ -39,6 +39,9 @@ SWIG_Python_ErrorType(int code) {
|
|||
case SWIG_AttributeError:
|
||||
type = PyExc_AttributeError;
|
||||
break;
|
||||
case SWIG_NullReferenceError:
|
||||
type = PyExc_TypeError;
|
||||
break;
|
||||
default:
|
||||
type = PyExc_RuntimeError;
|
||||
}
|
||||
|
|
|
@ -131,6 +131,8 @@ SWIG_Scilab_ErrorType(int code) {
|
|||
return "SystemError";
|
||||
case SWIG_AttributeError:
|
||||
return "AttributeError";
|
||||
case SWIG_NullReferenceError:
|
||||
return "NullReferenceError";
|
||||
default:
|
||||
return "RuntimeError";
|
||||
}
|
||||
|
|
|
@ -39,6 +39,9 @@ SWIG_Tcl_ErrorType(int code) {
|
|||
case SWIG_AttributeError:
|
||||
type = "AttributeError";
|
||||
break;
|
||||
case SWIG_NullReferenceError:
|
||||
type = "NullReferenceError";
|
||||
break;
|
||||
default:
|
||||
type = "RuntimeError";
|
||||
}
|
||||
|
|
|
@ -137,14 +137,14 @@
|
|||
#define %error_block(Block...) %block(Block)
|
||||
#define %default_code(code) SWIG_ArgError(code)
|
||||
#define %argument_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %argfail_fmt(type, name, argn))
|
||||
#define %argument_nullref(type, name, argn) SWIG_exception_fail(SWIG_ValueError, %argnullref_fmt(type, name, argn))
|
||||
#define %argument_nullref(type, name, argn) SWIG_exception_fail(SWIG_NullReferenceError, %argnullref_fmt(type, name, argn))
|
||||
#define %variable_fail(code, type, name) SWIG_exception_fail(%default_code(code), %varfail_fmt(type, name))
|
||||
#define %variable_nullref(type, name) SWIG_exception_fail(SWIG_ValueError, %varnullref_fmt(type, name))
|
||||
#define %variable_nullref(type, name) SWIG_exception_fail(SWIG_NullReferenceError, %varnullref_fmt(type, name))
|
||||
#define %releasenotowned_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %releasenotownedfail_fmt(type, name, argn))
|
||||
|
||||
#if defined(SWIG_DIRECTOR_TYPEMAPS)
|
||||
#define %dirout_fail(code, type) SWIG_DirOutFail(%default_code(code), %outfail_fmt(type))
|
||||
#define %dirout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, %outnullref_fmt(type))
|
||||
#define %dirout_nullref(type) SWIG_DirOutFail(SWIG_NullReferenceError, %outnullref_fmt(type))
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue