mirror of https://github.com/swig/swig
"Include what you use" for tests
Many of these tests implicitly required the target language library files to include the headers upstream.
This commit is contained in:
parent
c1258323b1
commit
feeb2516ae
|
@ -18,6 +18,7 @@
|
|||
%{
|
||||
#define TESTCASE_THROW1(T1)
|
||||
#define TESTCASE_THROW2(T1, T2)
|
||||
#include <string.h>
|
||||
%}
|
||||
|
||||
%include <std_string.i>
|
||||
|
@ -71,7 +72,7 @@
|
|||
class EnumClass {
|
||||
public:
|
||||
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); };
|
||||
};
|
||||
|
||||
|
@ -83,16 +84,16 @@
|
|||
|
||||
// casts
|
||||
const char * casts1(const char *m = (const char *) NULL) {
|
||||
char *ret = NULL;
|
||||
if (m) {
|
||||
char *ret = NULL;
|
||||
if (m) {
|
||||
ret = new char[strlen(m)+1];
|
||||
strcpy(ret, m);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const char * casts2(const char *m = (const char *) "Hello") {
|
||||
char *ret = NULL;
|
||||
if (m) {
|
||||
char *ret = NULL;
|
||||
if (m) {
|
||||
ret = new char[strlen(m)+1];
|
||||
strcpy(ret, m);
|
||||
}
|
||||
|
@ -108,16 +109,16 @@
|
|||
char chartest6(char c = '\x43') { return c; } // 'C'
|
||||
|
||||
// namespaces
|
||||
namespace AType {
|
||||
enum AType { NoType };
|
||||
}
|
||||
namespace AType {
|
||||
enum AType { NoType };
|
||||
}
|
||||
void dummy(AType::AType aType = AType::NoType) {}
|
||||
namespace A {
|
||||
namespace B {
|
||||
int CONST_NUM = 10;
|
||||
}
|
||||
namespace A {
|
||||
namespace B {
|
||||
int CONST_NUM = 10;
|
||||
}
|
||||
int afunction(int i = B::CONST_NUM) { return i; }
|
||||
}
|
||||
}
|
||||
|
||||
// references
|
||||
int reftest1(const int &x = 42) { return x; }
|
||||
|
@ -131,7 +132,7 @@
|
|||
void test(int x = Oak + Fir + Cedar) {}
|
||||
};
|
||||
enum Tree::types chops(enum Tree::types type) { return type; }
|
||||
|
||||
|
||||
%}
|
||||
|
||||
// Rename a class member
|
||||
|
@ -155,11 +156,11 @@
|
|||
static int spam;
|
||||
|
||||
Foo(){}
|
||||
|
||||
|
||||
Foo(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
|
||||
// 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).
|
||||
|
@ -189,20 +190,20 @@
|
|||
// tests valuewrapper
|
||||
%feature("compactdefaultargs") MyClass2::set;
|
||||
%inline %{
|
||||
enum MyType { Val1, Val2 };
|
||||
enum MyType { Val1, Val2 };
|
||||
|
||||
class MyClass1
|
||||
{
|
||||
public:
|
||||
class MyClass1
|
||||
{
|
||||
public:
|
||||
MyClass1(MyType myType) {}
|
||||
};
|
||||
};
|
||||
|
||||
class MyClass2
|
||||
{
|
||||
public :
|
||||
class MyClass2
|
||||
{
|
||||
public :
|
||||
void set(MyClass1 cl1 = Val1) {}
|
||||
// This could have been written : set(MyClass1 cl1 = MyClass1(Val1))
|
||||
// But it works in C++ since there is a "conversion" constructor in MyClass1.
|
||||
// This could have been written : set(MyClass1 cl1 = MyClass1(Val1))
|
||||
// But it works in C++ since there is a "conversion" constructor in MyClass1.
|
||||
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
|
||||
struct ConstMethods {
|
||||
int coo(double d = 0.0) const;
|
||||
|
@ -305,8 +306,8 @@ struct ConstMethods {
|
|||
return(x+p);
|
||||
}
|
||||
|
||||
typedef struct Pointf {
|
||||
double x,y;
|
||||
typedef struct Pointf {
|
||||
double x,y;
|
||||
} Pointf;
|
||||
}
|
||||
%}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
@ -30,6 +29,7 @@
|
|||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "swig_examples_lock.h"
|
||||
|
||||
class Foo;
|
||||
|
|
|
@ -5,4 +5,8 @@
|
|||
%cdata(int);
|
||||
%cdata(double);
|
||||
|
||||
%{
|
||||
#include <stdlib.h>
|
||||
%}
|
||||
|
||||
void *malloc(size_t size);
|
||||
|
|
|
@ -5,4 +5,8 @@
|
|||
%cdata(int);
|
||||
%cdata(double);
|
||||
|
||||
%{
|
||||
#include <stdlib.h>
|
||||
%}
|
||||
|
||||
void *malloc(size_t size);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
%}
|
||||
|
||||
%inline %{
|
||||
#include <stdexcept>
|
||||
#include <typeinfo>
|
||||
struct E1 : public std::exception
|
||||
{
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@ struct ExtendMe {
|
|||
|
||||
%{
|
||||
#include <map>
|
||||
#include <string.h>
|
||||
std::map<ExtendMe*, char *> ExtendMeStringMap;
|
||||
void ExtendMe_thing_set(ExtendMe *self, const char *val) {
|
||||
char *old_val = ExtendMeStringMap[self];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
#include <cstddef>
|
||||
|
||||
class C;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
%module namespace_typemap
|
||||
|
||||
%{
|
||||
#include <string.h>
|
||||
namespace test {
|
||||
/* A minimalistic string class */
|
||||
class string_class {
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
|
||||
#endif
|
||||
|
||||
%{
|
||||
#include "stdlib.h"
|
||||
%}
|
||||
|
||||
#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8)
|
||||
%extend hiA {
|
||||
hiA() {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
%{
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
using namespace std;
|
||||
%}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#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.
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
%}
|
||||
|
||||
%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) Bar2::operator->; // Overloaded method Bar2::operator ->() ignored
|
||||
|
||||
%{
|
||||
#include <stdlib.h>
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
int CONST_ACCESS = 1;
|
||||
int MUTABLE_ACCESS = 2;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#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.
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
%}
|
||||
|
||||
%ignore Name::operator=;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
%newobject copy_string;
|
||||
|
||||
%inline %{
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
const char* copy_string(const char* str) {
|
||||
size_t len = strlen(str);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
%{
|
||||
typedef char * TypedefString;
|
||||
#include <string.h>
|
||||
%}
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
%inline %{
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
struct Kerfuffle {
|
||||
std::string StdString(std::string str) {
|
||||
return str;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#define MS_NOOVERRIDE -1111
|
||||
|
||||
#include <stdlib.h>
|
||||
%}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue