1 #ifndef EXAMPLE1_H_ 2 #define EXAMPLE1_H_ 3 4 #include "example2.h" 5 6 #if defined(__cplusplus) 7 extern "C" { 8 #endif 9 10 struct ForwardDeclaration; 11 int uses_forward_decl(struct ForwardDeclaration *); 12 13 struct Hello { 14 int foo; 15 int bar; 16 wchar_t d; 17 enum {A, B} enum_field; 18 enum {C, D} enum_field2; 19 struct { 20 int a; 21 int b; 22 struct { 23 int c; 24 }; 25 }; 26 }; 27 28 #if defined(__cplusplus) 29 } // extern "C" 30 #endif 31 using namespace test2; 32 using namespace test3; 33 typedef float float_type; 34 typedef const float_type cfloat_type; 35 struct CPPHello : private HelloAgain, public ByeAgain<float_type> { 36 const int cpp_foo; 37 cfloat_type cpp_bar; 38 virtual int again() { return 0; } 39 CPPHello() : cpp_foo(20), cpp_bar(1.234) { } 40 enum Bla{BLA = 1}; 41 int test_enum() {return CPPHello::BLA;} 42 }; 43 44 45 void fooVariadic (int &, int *, ...); 46 47 int boo (const CPPHello, int *, float *) { 48 return CPPHello::BLA; 49 } 50 51 template<typename T> 52 struct StackNode { 53 public: 54 T value_; 55 StackNode<T>* next_; 56 57 public: 58 StackNode(T t, StackNode* next = nullptr) 59 : value_(static_cast<T&&>(t)), 60 next_(next) { } 61 }; 62 63 template<typename T> 64 class Stack { 65 private: 66 StackNode<T>* head_; 67 68 public: 69 Stack() : head_(nullptr) { } 70 71 void push(T t) { 72 head_ = new StackNode<T>(static_cast<T&&>(t), head_); 73 } 74 75 T pop() { 76 StackNode<T>* cur = head_; 77 head_ = cur->next_; 78 T res = static_cast<T&&>(cur->value_); 79 delete cur; 80 return res; 81 } 82 }; 83 84 // Replicated from libsysutils. 85 template<typename T> 86 class List 87 { 88 public: 89 /* 90 * One element in the list. 91 */ 92 class _Node { 93 public: 94 explicit _Node(const T& val) : mVal(val) {} 95 ~_Node() {} 96 inline T& getRef() { return mVal; } 97 inline const T& getRef() const { return mVal; } 98 private: 99 void PrivateNode(); 100 friend class List; 101 friend class _ListIterator; 102 T mVal; 103 _Node* mpPrev; 104 _Node* mpNext; 105 }; 106 _Node *middle; 107 }; 108 109 110 typedef List<float> float_list; 111 float_list float_list_test; 112 113 typedef List<int> int_list; 114 int_list int_list_test; 115 List<float>::_Node node(2); 116 int ListMangle(int_list *, StackNode<int> *); 117 118 template<typename IChild, typename IParent, typename BpChild, typename BpParent> 119 List<IChild> castInterface(List<IParent> parent, const char *childIndicator, bool emitError) {return List<IChild>();} 120 121 void format() { 122 castInterface<float, float, float , float>(List<float>(), "foo", true); 123 } 124 125 #endif // EXAMPLE1_H_ 126