Merge pull request #1398 from swig-fortran/missing-includes
Add missing includes to library and test cases
This commit is contained in:
commit
3e019977c5
25 changed files with 106 additions and 50 deletions
|
|
@ -11,6 +11,7 @@ below.
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define OTHERLAND_MSG "Little message from the safe world."
|
#define OTHERLAND_MSG "Little message from the safe world."
|
||||||
#define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible."
|
#define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible."
|
||||||
|
|
@ -150,11 +151,11 @@ const char global_const_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG;
|
||||||
%inline {
|
%inline {
|
||||||
struct Formatpos;
|
struct Formatpos;
|
||||||
struct OBFormat;
|
struct OBFormat;
|
||||||
|
|
||||||
static int GetNextFormat(Formatpos& itr, const char*& str,OBFormat*& pFormat) {
|
static int GetNextFormat(Formatpos& itr, const char*& str,OBFormat*& pFormat) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
%{
|
%{
|
||||||
#define TESTCASE_THROW1(T1)
|
#define TESTCASE_THROW1(T1)
|
||||||
#define TESTCASE_THROW2(T1, T2)
|
#define TESTCASE_THROW2(T1, T2)
|
||||||
|
#include <string.h>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include <std_string.i>
|
%include <std_string.i>
|
||||||
|
|
@ -71,7 +72,7 @@
|
||||||
class EnumClass {
|
class EnumClass {
|
||||||
public:
|
public:
|
||||||
enum speed { FAST, SLOW };
|
enum speed { FAST, SLOW };
|
||||||
// Note: default values should be EnumClass::FAST and SWEET
|
// Note: default values should be EnumClass::FAST and SWEET
|
||||||
bool blah(speed s = FAST, flavor f = SWEET) { return (s == FAST && f == SWEET); };
|
bool blah(speed s = FAST, flavor f = SWEET) { return (s == FAST && f == SWEET); };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -83,16 +84,16 @@
|
||||||
|
|
||||||
// casts
|
// casts
|
||||||
const char * casts1(const char *m = (const char *) NULL) {
|
const char * casts1(const char *m = (const char *) NULL) {
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
if (m) {
|
if (m) {
|
||||||
ret = new char[strlen(m)+1];
|
ret = new char[strlen(m)+1];
|
||||||
strcpy(ret, m);
|
strcpy(ret, m);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
const char * casts2(const char *m = (const char *) "Hello") {
|
const char * casts2(const char *m = (const char *) "Hello") {
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
if (m) {
|
if (m) {
|
||||||
ret = new char[strlen(m)+1];
|
ret = new char[strlen(m)+1];
|
||||||
strcpy(ret, m);
|
strcpy(ret, m);
|
||||||
}
|
}
|
||||||
|
|
@ -108,16 +109,16 @@
|
||||||
char chartest6(char c = '\x43') { return c; } // 'C'
|
char chartest6(char c = '\x43') { return c; } // 'C'
|
||||||
|
|
||||||
// namespaces
|
// namespaces
|
||||||
namespace AType {
|
namespace AType {
|
||||||
enum AType { NoType };
|
enum AType { NoType };
|
||||||
}
|
}
|
||||||
void dummy(AType::AType aType = AType::NoType) {}
|
void dummy(AType::AType aType = AType::NoType) {}
|
||||||
namespace A {
|
namespace A {
|
||||||
namespace B {
|
namespace B {
|
||||||
int CONST_NUM = 10;
|
int CONST_NUM = 10;
|
||||||
}
|
}
|
||||||
int afunction(int i = B::CONST_NUM) { return i; }
|
int afunction(int i = B::CONST_NUM) { return i; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// references
|
// references
|
||||||
int reftest1(const int &x = 42) { return x; }
|
int reftest1(const int &x = 42) { return x; }
|
||||||
|
|
@ -131,7 +132,7 @@
|
||||||
void test(int x = Oak + Fir + Cedar) {}
|
void test(int x = Oak + Fir + Cedar) {}
|
||||||
};
|
};
|
||||||
enum Tree::types chops(enum Tree::types type) { return type; }
|
enum Tree::types chops(enum Tree::types type) { return type; }
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
// Rename a class member
|
// Rename a class member
|
||||||
|
|
@ -155,11 +156,11 @@
|
||||||
static int spam;
|
static int spam;
|
||||||
|
|
||||||
Foo(){}
|
Foo(){}
|
||||||
|
|
||||||
Foo(int x, int y = 0, int z = 0){}
|
Foo(int x, int y = 0, int z = 0){}
|
||||||
|
|
||||||
void meth(int x, int y = 0, int z = 0){}
|
void meth(int x, int y = 0, int z = 0){}
|
||||||
|
|
||||||
// Use a renamed member as a default argument. SWIG has to resolve
|
// Use a renamed member as a default argument. SWIG has to resolve
|
||||||
// bar to Foo::bar and not Foo::spam. SWIG-1.3.11 got this wrong.
|
// bar to Foo::bar and not Foo::spam. SWIG-1.3.11 got this wrong.
|
||||||
// (Different default parameter wrapping in SWIG-1.3.23 ensures SWIG doesn't have to resolve these symbols).
|
// (Different default parameter wrapping in SWIG-1.3.23 ensures SWIG doesn't have to resolve these symbols).
|
||||||
|
|
@ -189,20 +190,20 @@
|
||||||
// tests valuewrapper
|
// tests valuewrapper
|
||||||
%feature("compactdefaultargs") MyClass2::set;
|
%feature("compactdefaultargs") MyClass2::set;
|
||||||
%inline %{
|
%inline %{
|
||||||
enum MyType { Val1, Val2 };
|
enum MyType { Val1, Val2 };
|
||||||
|
|
||||||
class MyClass1
|
class MyClass1
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyClass1(MyType myType) {}
|
MyClass1(MyType myType) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyClass2
|
class MyClass2
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
void set(MyClass1 cl1 = Val1) {}
|
void set(MyClass1 cl1 = Val1) {}
|
||||||
// This could have been written : set(MyClass1 cl1 = MyClass1(Val1))
|
// This could have been written : set(MyClass1 cl1 = MyClass1(Val1))
|
||||||
// But it works in C++ since there is a "conversion" constructor in MyClass1.
|
// But it works in C++ since there is a "conversion" constructor in MyClass1.
|
||||||
void set2(MyClass1 cl1 = Val1) {}
|
void set2(MyClass1 cl1 = Val1) {}
|
||||||
};
|
};
|
||||||
%}
|
%}
|
||||||
|
|
@ -281,7 +282,7 @@ struct ConstMethods {
|
||||||
};
|
};
|
||||||
%}
|
%}
|
||||||
|
|
||||||
// const methods
|
// const methods
|
||||||
// runtime test needed to check that the const method is called
|
// runtime test needed to check that the const method is called
|
||||||
struct ConstMethods {
|
struct ConstMethods {
|
||||||
int coo(double d = 0.0) const;
|
int coo(double d = 0.0) const;
|
||||||
|
|
@ -305,8 +306,8 @@ struct ConstMethods {
|
||||||
return(x+p);
|
return(x+p);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct Pointf {
|
typedef struct Pointf {
|
||||||
double x,y;
|
double x,y;
|
||||||
} Pointf;
|
} Pointf;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <stdio.h>
|
|
||||||
#else
|
#else
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
@ -30,6 +29,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include "swig_examples_lock.h"
|
#include "swig_examples_lock.h"
|
||||||
|
|
||||||
class Foo;
|
class Foo;
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,8 @@
|
||||||
%cdata(int);
|
%cdata(int);
|
||||||
%cdata(double);
|
%cdata(double);
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <stdlib.h>
|
||||||
|
%}
|
||||||
|
|
||||||
void *malloc(size_t size);
|
void *malloc(size_t size);
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,8 @@
|
||||||
%cdata(int);
|
%cdata(int);
|
||||||
%cdata(double);
|
%cdata(double);
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <stdlib.h>
|
||||||
|
%}
|
||||||
|
|
||||||
void *malloc(size_t size);
|
void *malloc(size_t size);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <typeinfo>
|
||||||
struct E1 : public std::exception
|
struct E1 : public std::exception
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ struct ExtendMe {
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string.h>
|
||||||
std::map<ExtendMe*, char *> ExtendMeStringMap;
|
std::map<ExtendMe*, char *> ExtendMeStringMap;
|
||||||
void ExtendMe_thing_set(ExtendMe *self, const char *val) {
|
void ExtendMe_thing_set(ExtendMe *self, const char *val) {
|
||||||
char *old_val = ExtendMeStringMap[self];
|
char *old_val = ExtendMeStringMap[self];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
class C;
|
class C;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
%module namespace_typemap
|
%module namespace_typemap
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#include <string.h>
|
||||||
namespace test {
|
namespace test {
|
||||||
/* A minimalistic string class */
|
/* A minimalistic string class */
|
||||||
class string_class {
|
class string_class {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include "stdlib.h"
|
||||||
|
%}
|
||||||
|
|
||||||
#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8)
|
#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8)
|
||||||
%extend hiA {
|
%extend hiA {
|
||||||
hiA() {
|
hiA() {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <stdlib.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma warning(disable: 4996) // 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
|
#pragma warning(disable: 4996) // 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
|
||||||
#endif
|
#endif
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%rename(AsCharStarRef) operator char*&;
|
%rename(AsCharStarRef) operator char*&;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@
|
||||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) Bar::operator->; // Overloaded method Bar::operator ->() ignored
|
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) Bar::operator->; // Overloaded method Bar::operator ->() ignored
|
||||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) Bar2::operator->; // Overloaded method Bar2::operator ->() ignored
|
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) Bar2::operator->; // Overloaded method Bar2::operator ->() ignored
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <stdlib.h>
|
||||||
|
%}
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
int CONST_ACCESS = 1;
|
int CONST_ACCESS = 1;
|
||||||
int MUTABLE_ACCESS = 2;
|
int MUTABLE_ACCESS = 2;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma warning(disable: 4996) // 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
|
#pragma warning(disable: 4996) // 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%ignore Name::operator=;
|
%ignore Name::operator=;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
%newobject copy_str;
|
%newobject copy_str;
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
const char* copy_str(const char* str) {
|
const char* copy_str(const char* str) {
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
%{
|
%{
|
||||||
typedef char * TypedefString;
|
typedef char * TypedefString;
|
||||||
|
#include <string.h>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string.h>
|
||||||
struct Kerfuffle {
|
struct Kerfuffle {
|
||||||
std::string StdString(std::string str) {
|
std::string StdString(std::string str) {
|
||||||
return str;
|
return str;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#include <string.h>
|
||||||
struct A {};
|
struct A {};
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#define MS_NOOVERRIDE -1111
|
#define MS_NOOVERRIDE -1111
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
// Default handling of varargs
|
// Default handling of varargs
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <string.h>
|
||||||
|
%}
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
char *test(const char *fmt, ...) {
|
char *test(const char *fmt, ...) {
|
||||||
return (char *) fmt;
|
return (char *) fmt;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,12 @@
|
||||||
* pointers as arrays.
|
* pointers as arrays.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
// C uses free/calloc/malloc
|
||||||
|
%include "swigfragments.swg"
|
||||||
|
%fragment("<stdlib.h>");
|
||||||
|
#endif
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* %array_functions(TYPE,NAME)
|
* %array_functions(TYPE,NAME)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
* SWIG library file containing macros for manipulating raw C data as strings.
|
* SWIG library file containing macros for manipulating raw C data as strings.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
%include <swigfragments.swg>
|
||||||
|
|
||||||
%{
|
%{
|
||||||
typedef struct SWIGCDATA {
|
typedef struct SWIGCDATA {
|
||||||
char *data;
|
char *data;
|
||||||
|
|
@ -60,7 +62,7 @@ static jbyteArray SWIG_JavaArrayOutCDATA(JNIEnv *jenv, char *result, jsize sz) {
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* %cdata(TYPE [, NAME])
|
* %cdata(TYPE [, NAME])
|
||||||
*
|
*
|
||||||
* Convert raw C data to a binary string.
|
* Convert raw C data to a binary string.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
@ -99,6 +101,8 @@ SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements);
|
||||||
|
|
||||||
%cdata(void);
|
%cdata(void);
|
||||||
|
|
||||||
|
%fragment("<string.h>");
|
||||||
|
|
||||||
/* Memory move function. Due to multi-argument typemaps this appears to be wrapped as
|
/* Memory move function. Due to multi-argument typemaps this appears to be wrapped as
|
||||||
void memmove(void *data, const char *s); */
|
void memmove(void *data, const char *s); */
|
||||||
void memmove(void *data, const void *indata, int inlen);
|
void memmove(void *data, const void *indata, int inlen);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,12 @@
|
||||||
* pointer objects.
|
* pointer objects.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
// C uses free/calloc/malloc
|
||||||
|
%include "swigfragments.swg"
|
||||||
|
%fragment("<stdlib.h>");
|
||||||
|
#endif
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* %pointer_class(type,name)
|
* %pointer_class(type,name)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
32
Lib/swig.swg
32
Lib/swig.swg
|
|
@ -453,7 +453,7 @@ namespace std {
|
||||||
/* Default typemap for handling char * members */
|
/* Default typemap for handling char * members */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
%typemap(memberin) char * {
|
%typemap(memberin,fragment="<string.h>") char * {
|
||||||
delete [] $1;
|
delete [] $1;
|
||||||
if ($input) {
|
if ($input) {
|
||||||
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
|
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
|
||||||
|
|
@ -462,7 +462,7 @@ namespace std {
|
||||||
$1 = 0;
|
$1 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
|
%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG,fragment="<string.h>") const char * {
|
||||||
if ($input) {
|
if ($input) {
|
||||||
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
|
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
|
||||||
strcpy((char *)$1, (const char *)$input);
|
strcpy((char *)$1, (const char *)$input);
|
||||||
|
|
@ -470,7 +470,7 @@ namespace std {
|
||||||
$1 = 0;
|
$1 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%typemap(globalin) char * {
|
%typemap(globalin,fragment="<string.h>") char * {
|
||||||
delete [] $1;
|
delete [] $1;
|
||||||
if ($input) {
|
if ($input) {
|
||||||
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
|
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
|
||||||
|
|
@ -479,7 +479,7 @@ namespace std {
|
||||||
$1 = 0;
|
$1 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
|
%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG,fragment="<string.h>") const char * {
|
||||||
if ($input) {
|
if ($input) {
|
||||||
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
|
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
|
||||||
strcpy((char *)$1, (const char *)$input);
|
strcpy((char *)$1, (const char *)$input);
|
||||||
|
|
@ -488,7 +488,7 @@ namespace std {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
%typemap(memberin) char * {
|
%typemap(memberin,fragment="<string.h>") char * {
|
||||||
free($1);
|
free($1);
|
||||||
if ($input) {
|
if ($input) {
|
||||||
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
|
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
|
||||||
|
|
@ -497,7 +497,7 @@ namespace std {
|
||||||
$1 = 0;
|
$1 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
|
%typemap(memberin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG,fragment="<string.h>") const char * {
|
||||||
if ($input) {
|
if ($input) {
|
||||||
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
|
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
|
||||||
strcpy((char *)$1, (const char *)$input);
|
strcpy((char *)$1, (const char *)$input);
|
||||||
|
|
@ -505,7 +505,7 @@ namespace std {
|
||||||
$1 = 0;
|
$1 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%typemap(globalin) char * {
|
%typemap(globalin,fragment="<string.h>") char * {
|
||||||
free($1);
|
free($1);
|
||||||
if ($input) {
|
if ($input) {
|
||||||
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
|
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
|
||||||
|
|
@ -514,7 +514,7 @@ namespace std {
|
||||||
$1 = 0;
|
$1 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const char * {
|
%typemap(globalin,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG,fragment="<string.h>") const char * {
|
||||||
if ($input) {
|
if ($input) {
|
||||||
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
|
$1 = ($1_type) malloc(strlen((const char *)$input)+1);
|
||||||
strcpy((char *)$1, (const char *)$input);
|
strcpy((char *)$1, (const char *)$input);
|
||||||
|
|
@ -527,7 +527,7 @@ namespace std {
|
||||||
|
|
||||||
/* Character array handling */
|
/* Character array handling */
|
||||||
|
|
||||||
%typemap(memberin) char [ANY] {
|
%typemap(memberin,fragment="<string.h>") char [ANY] {
|
||||||
if($input) {
|
if($input) {
|
||||||
strncpy((char*)$1, (const char *)$input, $1_dim0-1);
|
strncpy((char*)$1, (const char *)$input, $1_dim0-1);
|
||||||
$1[$1_dim0-1] = 0;
|
$1[$1_dim0-1] = 0;
|
||||||
|
|
@ -536,7 +536,7 @@ namespace std {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(globalin) char [ANY] {
|
%typemap(globalin,fragment="<string.h>") char [ANY] {
|
||||||
if($input) {
|
if($input) {
|
||||||
strncpy((char*)$1, (const char *)$input, $1_dim0-1);
|
strncpy((char*)$1, (const char *)$input, $1_dim0-1);
|
||||||
$1[$1_dim0-1] = 0;
|
$1[$1_dim0-1] = 0;
|
||||||
|
|
@ -545,25 +545,25 @@ namespace std {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(memberin) char [] {
|
%typemap(memberin,fragment="<string.h>") char [] {
|
||||||
if ($input) strcpy((char *)$1, (const char *)$input);
|
if ($input) strcpy((char *)$1, (const char *)$input);
|
||||||
else $1[0] = 0;
|
else $1[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(globalin) char [] {
|
%typemap(globalin,fragment="<string.h>") char [] {
|
||||||
if ($input) strcpy((char *)$1, (const char *)$input);
|
if ($input) strcpy((char *)$1, (const char *)$input);
|
||||||
else $1[0] = 0;
|
else $1[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* memberin/globalin typemap for arrays. */
|
/* memberin/globalin typemap for arrays. */
|
||||||
|
|
||||||
%typemap(memberin) SWIGTYPE [ANY] {
|
%typemap(memberin,fragment="<string.h>") SWIGTYPE [ANY] {
|
||||||
size_t ii;
|
size_t ii;
|
||||||
$1_basetype *b = ($1_basetype *) $1;
|
$1_basetype *b = ($1_basetype *) $1;
|
||||||
for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii);
|
for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii);
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(globalin) SWIGTYPE [ANY] {
|
%typemap(globalin,fragment="<string.h>") SWIGTYPE [ANY] {
|
||||||
size_t ii;
|
size_t ii;
|
||||||
$1_basetype *b = ($1_basetype *) $1;
|
$1_basetype *b = ($1_basetype *) $1;
|
||||||
for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii);
|
for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii);
|
||||||
|
|
@ -571,7 +571,7 @@ namespace std {
|
||||||
|
|
||||||
/* memberin/globalin typemap for double arrays. */
|
/* memberin/globalin typemap for double arrays. */
|
||||||
|
|
||||||
%typemap(memberin) SWIGTYPE [ANY][ANY] {
|
%typemap(memberin,fragment="<string.h>") SWIGTYPE [ANY][ANY] {
|
||||||
$basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
|
$basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
|
||||||
$basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
|
$basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
|
||||||
size_t ii = 0;
|
size_t ii = 0;
|
||||||
|
|
@ -583,7 +583,7 @@ namespace std {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(globalin) SWIGTYPE [ANY][ANY] {
|
%typemap(globalin,fragment="<string.h>") SWIGTYPE [ANY][ANY] {
|
||||||
$basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
|
$basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
|
||||||
$basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
|
$basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
|
||||||
size_t ii = 0;
|
size_t ii = 0;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%fragment("<string.h>", "header") %{
|
||||||
|
#include <string.h>
|
||||||
|
%}
|
||||||
|
|
||||||
%fragment("<stddef.h>", "header") %{
|
%fragment("<stddef.h>", "header") %{
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue