| 1 |
#ifndef TCLASS_H |
| 2 |
#define TCLASS_H |
| 3 |
|
| 4 |
#include <stdio.h> |
| 5 |
|
| 6 |
namespace Test { |
| 7 |
|
| 8 |
class Tst_Dummy |
| 9 |
{ |
| 10 |
}; |
| 11 |
|
| 12 |
class Tst_A |
| 13 |
{ |
| 14 |
|
| 15 |
int number; |
| 16 |
public: |
| 17 |
static Tst_A* last; |
| 18 |
Tst_A () {last = this;} |
| 19 |
virtual char* a () { return "A"; } |
| 20 |
class Tst_AA |
| 21 |
{ |
| 22 |
public: |
| 23 |
Tst_AA () {} |
| 24 |
~Tst_AA () { } |
| 25 |
char* aa () { return "AA"; } |
| 26 |
}; |
| 27 |
class Tst_BB : public Tst_AA |
| 28 |
{ |
| 29 |
public: |
| 30 |
Tst_BB () {} |
| 31 |
~Tst_BB () {} |
| 32 |
Tst_AA* Base () { return this; } |
| 33 |
}; |
| 34 |
|
| 35 |
void set_number(int p_number) { number = p_number;}; |
| 36 |
int get_number() {return number*2;}; |
| 37 |
|
| 38 |
virtual ~Tst_A() {}; |
| 39 |
}; |
| 40 |
|
| 41 |
class Tst_B : public Tst_A |
| 42 |
{ |
| 43 |
public: |
| 44 |
static Tst_B* last; |
| 45 |
Tst_B () {last = this;} |
| 46 |
virtual char* b () { return "B"; } |
| 47 |
|
| 48 |
static Tst_A* create() {return new Tst_B;}; |
| 49 |
static void* create_void() {return new Tst_B;}; |
| 50 |
|
| 51 |
virtual ~Tst_B() {}; |
| 52 |
}; |
| 53 |
|
| 54 |
class Tst_C : public Tst_B |
| 55 |
{ |
| 56 |
int i; |
| 57 |
public: |
| 58 |
static Tst_C* last; |
| 59 |
Tst_C (int n) : i(n) {last = this;} |
| 60 |
virtual ~Tst_C () { printf("deleting C: %d\n",i); } |
| 61 |
virtual char* c () { return "C"; } |
| 62 |
}; |
| 63 |
|
| 64 |
inline Tst_A::Tst_AA* Tst_create_aa () |
| 65 |
{ |
| 66 |
return new Tst_A::Tst_AA(); |
| 67 |
} |
| 68 |
|
| 69 |
inline bool Tst_is_aa (Tst_A::Tst_AA* obj) |
| 70 |
{ |
| 71 |
return true; |
| 72 |
} |
| 73 |
|
| 74 |
class Tst_E { |
| 75 |
void* ptr; |
| 76 |
|
| 77 |
public: |
| 78 |
enum Pete { |
| 79 |
ONE, |
| 80 |
TWO, |
| 81 |
} pete; |
| 82 |
|
| 83 |
void get_pete(Pete p) {}; |
| 84 |
|
| 85 |
template <class T> |
| 86 |
T get_t() {T a=0; return a;}; |
| 87 |
|
| 88 |
Tst_E& operator+(const Tst_E& rvalue) {return *this;}; |
| 89 |
|
| 90 |
void pars(int a=0, int b=0) {}; |
| 91 |
void get_pointer(void* a) {}; |
| 92 |
|
| 93 |
Tst_A a; |
| 94 |
|
| 95 |
void set_ptr(void* p_ptr) { |
| 96 |
printf("this is %p, ptr is %p\n", this, p_ptr); |
| 97 |
ptr = p_ptr; |
| 98 |
}; |
| 99 |
void* get_ptr() {return ptr;}; |
| 100 |
|
| 101 |
Tst_E(int) {}; |
| 102 |
}; |
| 103 |
|
| 104 |
class Tst_Outside { |
| 105 |
|
| 106 |
public: |
| 107 |
|
| 108 |
Tst_Outside() {}; |
| 109 |
}; |
| 110 |
|
| 111 |
}; // end of namespace |
| 112 |
|
| 113 |
|
| 114 |
static void outside_func(Test::Tst_Outside* p_out, lua_State* ls) { |
| 115 |
|
| 116 |
if (p_out) printf("method!\n"); |
| 117 |
else printf("static!\n"); |
| 118 |
//printf("luastate: %i\n", ls); |
| 119 |
}; |
| 120 |
|
| 121 |
#endif |