2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-22 05:22:45 +00:00

no message

[SVN r18628]
This commit is contained in:
Bruno da Silva de Oliveira
2003-05-31 20:57:03 +00:00
parent f1a06b14de
commit bb55c4a855
34 changed files with 0 additions and 585 deletions

View File

@@ -1,2 +0,0 @@
.sconsign
*.obj

View File

@@ -1,5 +0,0 @@
To use this examples, just execute the command-line:
pyste --module=<example> <example>.pyste
For more information, please refer to the documentation.

View File

@@ -1,8 +0,0 @@
#include "basic.h"
namespace basic {
int C::static_value = 3;
const int C::const_static_value = 100;
}

View File

@@ -1,59 +0,0 @@
#ifndef BASIC_H
#define BASIC_H
#include <string>
namespace basic {
struct C
{
// test virtuallity
C(): value(1), const_value(0) {}
virtual int f(int x = 10)
{
return x*2;
}
int foo(int x=1){
return x+1;
}
const std::string& name() { return _name; }
void set_name(const std::string& name) { _name = name; }
std::string _name;
// test data members
static int static_value;
static const int const_static_value;
int value;
const int const_value;
// test static functions
static int mul(int x=2, int y=3) { return x*y; }
};
inline int call_f(C& c)
{
return c.f();
}
inline int call_f(C& c, int x)
{
return c.f(x);
}
inline int get_static()
{
return C::static_value;
}
inline int get_value(C& c)
{
return c.value;
}
}
#endif

View File

@@ -1,5 +0,0 @@
Class('basic::C', 'basic.h')
Function('basic::call_f', 'basic.h')
Function('basic::get_static', 'basic.h')
Function('basic::get_value', 'basic.h')

View File

@@ -1,24 +0,0 @@
#ifndef ENUMS_H
#define ENUMS_H
namespace enums {
enum color { red, blue };
struct X
{
enum choices
{
good = 1,
bad = 2
};
int set(choices c)
{
return (int)c;
}
};
}
#endif

View File

@@ -1,8 +0,0 @@
color = Enum('enums::color', 'enums.h')
rename(color.red, 'Red')
rename(color.blue, 'Blue')
X = Class('enums::X', 'enums.h')
rename(X.choices.bad, 'Bad')
rename(X.choices.good, 'Good')
rename(X.choices, 'Choices')

View File

@@ -1,38 +0,0 @@
#ifndef HEADER_TEST_H
#define HEADER_TEST_H
#include <map>
#include <string>
namespace header_test {
enum choice { red, blue };
inline std::string choice_str(choice c)
{
std::map<choice, std::string> choice_map;
choice_map[red] = "red";
choice_map[blue] = "blue";
return choice_map[c];
}
struct C
{
choice c;
std::string get()
{
return choice_str(c);
}
};
// test the exclusion of the following
struct ForwardDeclared; // should be excluded automatically
struct A {};
void foo();
enum bar { value };
}
#endif

View File

@@ -1,4 +0,0 @@
h = AllFromHeader('header_test.h')
exclude(h.A)
exclude(h.foo)
exclude(h.bar)

View File

@@ -1,18 +0,0 @@
template<typename T>
class A
{
public:
void set(T v) { mData = v; }
T get() const { return mData; }
private:
T mData;
};
class B : public A<int>
{
public:
int go() { return get(); }
};

View File

@@ -1,8 +0,0 @@
# Doesn't work:
A = Template('A', 'inherit.h')
A_int = A('int')
Class('B', 'inherit.h')
# Does work:
#AllFromHeader('inherit.h')

View File

@@ -1,4 +0,0 @@
#include "nested.h"
int nested::X::staticXValue = 10;
int nested::X::Y::staticYValue = 20;

View File

@@ -1,26 +0,0 @@
#ifndef NESTED_H
#define NESTED_H
namespace nested {
struct X
{
struct Y
{
int valueY;
static int staticYValue;
struct Z
{
int valueZ;
};
};
static int staticXValue;
int valueX;
};
typedef X Root;
}
#endif

View File

@@ -1 +0,0 @@
Class('nested::Root', 'nested.h')

View File

@@ -1,47 +0,0 @@
#ifndef OPAQUE_H
#define OPAQUE_H
#include <iostream>
namespace opaque {
struct C {
C(int v): value(v) {}
int value;
};
inline C* new_C()
{
return new C(10);
}
inline int get(C* c)
{
return c->value;
}
struct D {
D(double v): value(v) {}
double value;
};
struct A
{
D* new_handle()
{
return new D(3.0);
}
double get(D* d)
{
return d->value;
}
int f(int x=0) { return x; }
};
}
#endif

View File

@@ -1,5 +0,0 @@
foo = Function('opaque::new_C', 'opaque.h')
set_policy(foo, return_value_policy(return_opaque_pointer))
Function('opaque::get', 'opaque.h' )
A = Class('opaque::A', 'opaque.h')
set_policy(A.new_handle, return_value_policy(return_opaque_pointer))

View File

@@ -1,3 +0,0 @@
#include "operators.h"
double operators::C::x = 10;

View File

@@ -1,49 +0,0 @@
#ifndef OPERATORS_H
#define OPERATORS_H
#include <iostream>
namespace operators {
struct C
{
static double x;
double value;
const C operator+(const C other) const
{
C c;
c.value = value + other.value;
return c;
}
operator int() const
{
return (int)value;
}
double operator()()
{
return C::x;
}
double operator()(double other)
{
return C::x + other;
}
operator const char*() { return "C"; }
};
inline const C operator*(const C& lhs, const C& rhs)
{
C c;
c.value = lhs.value * rhs.value;
return c;
}
}
#endif

View File

@@ -1,2 +0,0 @@
C = Class('operators::C', 'operators.h')
#exclude(C.operator['+'])

View File

@@ -1,44 +0,0 @@
#ifndef SMART_PTR_H
#define SMART_PTR_H
#include <memory>
#include <boost/shared_ptr.hpp>
namespace smart_ptr {
struct C
{
int value;
};
inline boost::shared_ptr<C> NewC() { return boost::shared_ptr<C>( new C() ); }
struct D
{
boost::shared_ptr<C> Get() { return ptr; }
void Set( boost::shared_ptr<C> c ) { ptr = c; }
private:
boost::shared_ptr<C> ptr;
};
inline std::auto_ptr<D> NewD() { return std::auto_ptr<D>( new D() ); }
// test an abstract class
struct A
{
virtual int f() = 0;
};
struct B: A
{
virtual int f(){ return 1; }
};
inline boost::shared_ptr<A> NewA() { return boost::shared_ptr<A>(new B()); }
inline int GetA(boost::shared_ptr<A> a) { return a->f(); }
}
#endif

View File

@@ -1,13 +0,0 @@
C = Class('smart_ptr::C', 'smart_ptr.h')
use_shared_ptr(C)
D = Class('smart_ptr::D', 'smart_ptr.h')
use_auto_ptr(D)
A = Class('smart_ptr::A', 'smart_ptr.h')
use_shared_ptr(A)
Function('smart_ptr::NewC', 'smart_ptr.h')
Function('smart_ptr::NewD', 'smart_ptr.h')
Function('smart_ptr::NewA', 'smart_ptr.h')
Function('smart_ptr::GetA', 'smart_ptr.h')

View File

@@ -1,10 +0,0 @@
namespace templates {
template <class T>
struct Point
{
T x;
T y;
};
}

View File

@@ -1,8 +0,0 @@
Point = Template('templates::Point', 'templates.h')
rename(Point.x, 'i')
rename(Point.y, 'j')
IPoint = Point('int')
FPoint = Point('double', 'FPoint')
rename(IPoint, 'IPoint')
rename(IPoint.x, 'x')
rename(IPoint.y, 'y')

View File

@@ -1,16 +0,0 @@
namespace unions {
class UnionTest
{
public:
union // unions are not supported for now
{
int i;
short s1;
short s2;
} mBad;
int mGood;
};
}

View File

@@ -1,2 +0,0 @@
UnionTest = Class('unions::UnionTest', 'unions.h')
exclude(UnionTest.mBad)

View File

@@ -1,19 +0,0 @@
struct Color
{
Color(int r_ = 0, int g_ = 0, int b_ = 0):
r(r_), g(g_), b(b_)
{}
Color( const Color &c):
r(c.r), g(c.g), b(c.b)
{}
int r;
int g;
int b;
};
const Color black = Color(0, 0, 0);
const Color red = Color(255, 0, 0);
const Color green = Color(0, 255, 0);
const Color blue = Color(0, 0, 255);
Color in_use = black;

View File

@@ -1 +0,0 @@
AllFromHeader('vars.h')

View File

@@ -1,28 +0,0 @@
namespace virtual_ {
struct C
{
public:
virtual int f()
{
return f_abs();
}
virtual void bar(int) {}
virtual void bar(char*) {}
const char* get_name()
{
return name();
}
protected:
virtual int f_abs() = 0;
private:
virtual const char* name() { return "C"; }
};
inline int call_f(C& c) { return c.f(); }
}

View File

@@ -1,2 +0,0 @@
Class('virtual_::C', 'virtual.h')
Function('virtual_::call_f', 'virtual.h')

View File

@@ -1,27 +0,0 @@
namespace virtual2 {
struct A
{
virtual int f() { return 0; }
virtual int f1() { return 10; }
};
struct B: A
{
virtual int f() { return 1; }
virtual int f2() { return 20; }
};
inline int call_fs(A*a)
{
int r = a->f1();
B* b = dynamic_cast<B*>(a);
return r + b->f2();
}
inline int call_f(A* a)
{
return a->f();
}
}

View File

@@ -1,4 +0,0 @@
Class('virtual2::A', 'virtual2.h')
Class('virtual2::B', 'virtual2.h')
Function('virtual2::call_fs', 'virtual2.h')
Function('virtual2::call_f', 'virtual2.h')

View File

@@ -1,46 +0,0 @@
#ifndef WRAPPER_TEST
#define WRAPPER_TEST
#include <vector>
namespace wrappertest {
inline std::vector<int> Range(int count)
{
std::vector<int> v;
v.reserve(count);
for (int i = 0; i < count; ++i){
v.push_back(i);
}
return v;
}
struct C
{
C() {}
std::vector<int> Mul(int value)
{
std::vector<int> res;
res.reserve(value);
std::vector<int>::const_iterator it;
std::vector<int> v(Range(value));
for (it = v.begin(); it != v.end(); ++it){
res.push_back(*it * value);
}
return res;
}
};
struct A
{
virtual int f() { return 1; };
};
inline int call_foo(A* a){ return a->f(); }
}
#endif

View File

@@ -1,21 +0,0 @@
Include('wrappertest_wrappers.h')
f = Function('wrappertest::Range', 'wrappertest.h')
set_wrapper(f, 'RangeWrapper')
mul = Wrapper('MulWrapper',
'''
list MulWrapper(wrappertest::C& c, int value){
return VectorToList(c.Mul(value));
}
'''
)
C = Class('wrappertest::C', 'wrappertest.h')
set_wrapper(C.Mul, mul)
A = Class('wrappertest::A', 'wrappertest.h')
set_wrapper(A.f, 'f_wrapper')
Function('wrappertest::call_foo', 'wrappertest.h')

View File

@@ -1,28 +0,0 @@
#ifndef WRAPPER_TEST_WRAPPERS
#define WRAPPER_TEST_WRAPPERS
#include <vector>
#include <boost/python.hpp>
#include "wrappertest.h"
using namespace boost::python;
template <class T>
list VectorToList(const std::vector<T> & v)
{
list res;
typename std::vector<T>::const_iterator it;
for(it = v.begin(); it != v.end(); ++it){
res.append(*it);
}
Py_XINCREF(res.ptr());
return res;
}
inline list RangeWrapper(int count){
return VectorToList(wrappertest::Range(count));
}
inline int f_wrapper(wrappertest::A*) { return 10; }
#endif