summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.current6
-rw-r--r--Doc/Devel/tree.html18
-rw-r--r--Examples/test-suite/php/catches_strings_runme.php4
-rw-r--r--Examples/test-suite/php/li_std_string_runme.php26
-rw-r--r--Lib/csharp/std_wstring.i12
-rw-r--r--Lib/ocaml/std_string.i14
-rw-r--r--Lib/php/std_string.i5
7 files changed, 61 insertions, 24 deletions
diff --git a/CHANGES.current b/CHANGES.current
index 15398ef7c..1b5b8dfef 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.2.0 (in progress)
===========================
+2023-04-26: mmomtchev
+ [Javascript] Take into account numinputs when counting arguments.
+
+2023-04-24: olly
+ [PHP] Add throws typemaps for std:string* and const std::string*.
+
2023-04-23: olly
[Javascript] #2453 The testsuite and examples now select which
Javascript engine to test based on what was detected by configure.
diff --git a/Doc/Devel/tree.html b/Doc/Devel/tree.html
index 2b9ac75dd..6ccfd6380 100644
--- a/Doc/Devel/tree.html
+++ b/Doc/Devel/tree.html
@@ -241,17 +241,17 @@ This function is called by the <tt>-debug-tags</tt> option to SWIG.
<pre>
% swig -debug-tags -python example.i
- . top (:1)
- . top . include (/Users/beazley/Projects/share/swig/1.3.31/swig.swg:0)
- . top . include . include (/Users/beazley/Projects/share/swig/1.3.31/swigwarnings.swg:0)
- . top . include . include . include (/Users/beazley/Projects/share/swig/1.3.31/swigwarn.swg:0)
+:1: . top
+:1: . top . include
+/usr/share/swig/swig.swg:320: . top . include . include
+/usr/share/swig/swigwarnings.swg:39: . top . include . include . include
...
...
- . top . include (example.i:0)
- . top . include . module (example.i:2)
- . top . include . insert (example.i:7)
- . top . include . cdecl (example.i:5)
- . top . include . cdecl (example.i:6)
+:4: . top . include
+example.i:2: . top . include . module
+example.i:7: . top . include . insert
+example.i:5: . top . include . cdecl
+example.i:6: . top . include . cdecl
</pre>
Since many language modules include hundreds of typemaps and other information, the output of this can be significantly more complicated than you might expect.
diff --git a/Examples/test-suite/php/catches_strings_runme.php b/Examples/test-suite/php/catches_strings_runme.php
index f727ea26a..758c3f618 100644
--- a/Examples/test-suite/php/catches_strings_runme.php
+++ b/Examples/test-suite/php/catches_strings_runme.php
@@ -6,7 +6,7 @@ $exception_thrown = false;
try {
StringsThrower::charstring();
} catch (Exception $e) {
- check::str_contains($e->getMessage(), "charstring message", "incorrect exception message: {$e->getMessage()}");
+ check::equal($e->getMessage(), "charstring message", "incorrect exception message: {$e->getMessage()}");
$exception_thrown = true;
}
check::equal($exception_thrown, true, "Should have thrown an exception");
@@ -15,7 +15,7 @@ $exception_thrown = false;
try {
StringsThrower::stdstring();
} catch (Exception $e) {
- check::str_contains($e->getMessage(), "stdstring message", "incorrect exception message: {$e->getMessage()}");
+ check::equal($e->getMessage(), "stdstring message", "incorrect exception message: {$e->getMessage()}");
$exception_thrown = true;
}
check::equal($exception_thrown, true, "Should have thrown an exception");
diff --git a/Examples/test-suite/php/li_std_string_runme.php b/Examples/test-suite/php/li_std_string_runme.php
index 169f947a7..390b7e17b 100644
--- a/Examples/test-suite/php/li_std_string_runme.php
+++ b/Examples/test-suite/php/li_std_string_runme.php
@@ -67,6 +67,32 @@ $s = "byref";
check::equal(li_std_string::test_reference_php($s), null);
check::equal($s, "byref.php");
+// Test throwing strings:
+try {
+ test_throw();
+ check::fail("test_throw() didn't throw");
+} catch (Exception $s) {
+ check::equal($s->getMessage(), "test_throw message");
+}
+try {
+ test_const_reference_throw();
+ check::fail("test_const_reference_throw() didn't throw");
+} catch (Exception $s) {
+ check::equal($s->getMessage(), "test_const_reference_throw message");
+}
+try {
+ test_pointer_throw();
+ check::fail("test_pointer_throw() didn't throw");
+} catch (Exception $s) {
+ check::equal($s->getMessage(), "foo");
+}
+try {
+ test_const_pointer_throw();
+ check::fail("test_const_pointer_throw() didn't throw");
+} catch (Exception $s) {
+ check::equal($s->getMessage(), "foo");
+}
+
// This used to give "Undefined variable: r"
li_std_string::test_const_reference_returning_void("foo");
diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i
index 1d10ca808..c7fef41a5 100644
--- a/Lib/csharp/std_wstring.i
+++ b/Lib/csharp/std_wstring.i
@@ -63,7 +63,7 @@ class wstring;
return $null;
}
$1 = Swig_csharp_UTF16ToWString($input); %}
-%typemap(out) wstring %{ $result = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1.size()); %}
+%typemap(out) wstring %{ $result = SWIG_csharp_wstring_with_length_callback($1.data(), (int)$1.size()); %}
%typemap(directorout, canthrow=1) wstring
%{ if (!$input) {
@@ -72,7 +72,7 @@ class wstring;
}
$result = Swig_csharp_UTF16ToWString($input); %}
-%typemap(directorin) wstring %{ $input = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1.size()); %}
+%typemap(directorin) wstring %{ $input = SWIG_csharp_wstring_with_length_callback($1.data(), (int)$1.size()); %}
%typemap(csin) wstring "$csinput"
%typemap(csout, excode=SWIGEXCODE) wstring {
@@ -83,7 +83,7 @@ class wstring;
%typemap(typecheck) wstring = wchar_t *;
%typemap(throws, canthrow=1) wstring
-%{ SWIG_csharp_ApplicationException_callback($1.c_str(), (int)$1.size());
+%{ SWIG_csharp_ApplicationException_callback($1.data(), (int)$1.size());
return $null; %}
// const wstring &
@@ -106,7 +106,7 @@ class wstring;
}
std::wstring $1_str(Swig_csharp_UTF16ToWString($input));
$1 = &$1_str; %}
-%typemap(out) const wstring & %{ $result = SWIG_csharp_wstring_with_length_callback($1->c_str(), (int)$1->size()); %}
+%typemap(out) const wstring & %{ $result = SWIG_csharp_wstring_with_length_callback($1->data(), (int)$1->size()); %}
%typemap(csin) const wstring & "$csinput"
%typemap(csout, excode=SWIGEXCODE) const wstring & {
@@ -124,7 +124,7 @@ class wstring;
$1_str = Swig_csharp_UTF16ToWString($input);
$result = &$1_str; %}
-%typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1.size()); %}
+%typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_with_length_callback($1.data(), (int)$1.size()); %}
%typemap(csvarin, excode=SWIGEXCODE2) const wstring & %{
set {
@@ -139,7 +139,7 @@ class wstring;
%typemap(typecheck) const wstring & = wchar_t *;
%typemap(throws, canthrow=1) const wstring &
-%{ SWIG_csharp_ApplicationException_callback($1.c_str(), (int)$1.size());
+%{ SWIG_csharp_ApplicationException_callback($1.data(), (int)$1.size());
return $null; %}
}
diff --git a/Lib/ocaml/std_string.i b/Lib/ocaml/std_string.i
index 08e304911..6cf918c6f 100644
--- a/Lib/ocaml/std_string.i
+++ b/Lib/ocaml/std_string.i
@@ -51,11 +51,11 @@ class wstring;
}
%typemap(out) const string & {
- $result = caml_val_string_len((*$1).c_str(), (*$1).size());
+ $result = caml_val_string_len((*$1).data(), (*$1).size());
}
%typemap(directorin) string {
- swig_result = caml_val_string_len($1.c_str(), $1.size());
+ swig_result = caml_val_string_len($1.data(), $1.size());
args = caml_list_append(args, swig_result);
}
@@ -64,19 +64,19 @@ class wstring;
}
%typemap(out) string {
- $result = caml_val_string_len($1.c_str(),$1.size());
+ $result = caml_val_string_len($1.data(),$1.size());
}
%typemap(varout) string {
- $result = caml_val_string_len($1.c_str(),$1.size());
+ $result = caml_val_string_len($1.data(),$1.size());
}
%typemap(out) string * {
- $result = caml_val_string_len((*$1).c_str(),(*$1).size());
+ $result = caml_val_string_len((*$1).data(),(*$1).size());
}
%typemap(varout) string * {
- $result = caml_val_string_len((*$1).c_str(),(*$1).size());
+ $result = caml_val_string_len((*$1).data(),(*$1).size());
}
%typemap(typecheck) string, const string & = char *;
@@ -87,7 +87,7 @@ class wstring;
%typemap(in, numinputs=0) string &OUTPUT ($*1_ltype temp)
%{ $1 = &temp; %}
%typemap(argout) string &OUTPUT {
- swig_result = caml_list_append(swig_result, caml_val_string_len((*$1).c_str(), (*$1).size()));
+ swig_result = caml_list_append(swig_result, caml_val_string_len((*$1).data(), (*$1).size()));
}
%typemap(in) string &INOUT = const string &;
%typemap(argout) string &INOUT = string &OUTPUT;
diff --git a/Lib/php/std_string.i b/Lib/php/std_string.i
index 0e2e1faff..5abbbbbef 100644
--- a/Lib/php/std_string.i
+++ b/Lib/php/std_string.i
@@ -56,6 +56,11 @@ namespace std {
goto fail;
%}
+ %typemap(throws) string*, const string* %{
+ zend_throw_exception(NULL, $1->c_str(), 0);
+ goto fail;
+ %}
+
%typemap(in, phptype="string") const string& ($*1_ltype temp) %{
convert_to_string(&$input);
temp.assign(Z_STRVAL($input), Z_STRLEN($input));