fix typecheck for INPUT* type
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6902 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
275031b938
commit
e5ce468853
2 changed files with 11 additions and 16 deletions
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
%apply int *INPUT {int *bar};
|
||||
|
||||
%typemap(out) int * Foo::foo {
|
||||
%typemap(out, fragment=SWIG_From_frag(int)) int * Foo::foo {
|
||||
if ($1) {
|
||||
$result = PyInt_FromLong(*$1);
|
||||
$result = SWIG_From(int)(*$1);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
$result = Py_None;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
%inline
|
||||
{
|
||||
struct Foo {
|
||||
int *foo(int *bar) {
|
||||
int *foo(int *bar = 0) {
|
||||
if (bar) {
|
||||
*bar *= 2;
|
||||
}
|
||||
|
|
@ -23,20 +23,10 @@
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
%include std_string.i
|
||||
%apply std::string *INPUT {std::string *bar};
|
||||
%typemap(out) int * sfoo {
|
||||
if ($1) {
|
||||
$result = PyInt_FromLong(*$1);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
$result = Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(out, fragment=SWIG_From_frag(std::string)) std::string * sfoo {
|
||||
%typemap(out, fragment=SWIG_From_frag(std::string)) std::string *sfoo {
|
||||
if ($1) {
|
||||
$result = SWIG_From(std::string)(*$1);
|
||||
} else {
|
||||
|
|
@ -46,7 +36,7 @@
|
|||
}
|
||||
|
||||
%inline %{
|
||||
std::string *sfoo(std::string *bar) {
|
||||
std::string *sfoo(std::string *bar = 0) {
|
||||
if (bar) *bar += " world";
|
||||
return (bar) ? bar : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,14 @@ if f.foo(2) != 4:
|
|||
if f.foo(None)!= None:
|
||||
raise RuntimeError
|
||||
|
||||
if f.foo()!= None:
|
||||
raise RuntimeError
|
||||
|
||||
if sfoo("Hello") != "Hello world":
|
||||
raise RuntimeError
|
||||
|
||||
if sfoo(None) != None:
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
if sfoo() != None:
|
||||
raise RuntimeError
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue