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 CPPHello(CPPHello &) = delete; 41 enum Bla{BLA = 1}; 42 int test_enum() {return CPPHello::BLA;} 43 }; 44 45 46 void fooVariadic (int &, int *, ...); 47 48 int boo (const CPPHello, int *, float *) { 49 return CPPHello::BLA; 50 } 51 52 template<typename T> 53 struct StackNode { 54 public: 55 T value_; 56 StackNode<T>* next_; 57 58 public: 59 StackNode(T t, StackNode* next = nullptr) 60 : value_(static_cast<T&&>(t)), 61 next_(next) {} 62 }; 63 64 template<typename T> 65 class Stack { 66 private: 67 StackNode<T>* head_; 68 69 public: 70 Stack() : head_(nullptr) {} 71 72 void push(T t) { 73 head_ = new StackNode<T>(static_cast<T&&>(t), head_); 74 } 75 76 T pop() { 77 StackNode<T>* cur = head_; 78 head_ = cur->next_; 79 T res = static_cast<T&&>(cur->value_); 80 delete cur; 81 return res; 82 } 83 }; 84 85 // Replicated from libsysutils. 86 template<typename T> 87 class List 88 { 89 public: 90 /* 91 * One element in the list. 92 */ 93 class _Node { 94 public: 95 explicit _Node(const T& val) : mVal(val) {} 96 ~_Node() {} 97 inline T& getRef() { return mVal; } 98 inline const T& getRef() const { return mVal; } 99 private: 100 void PrivateNode(); 101 friend class List; 102 friend class _ListIterator; 103 T mVal; 104 _Node* mpPrev; 105 _Node* mpNext; 106 }; 107 _Node *middle; 108 }; 109 110 111 typedef List<float> float_list; 112 float_list float_list_test; 113 114 typedef List<int> int_list; 115 int_list int_list_test; 116 List<float>::_Node node(2); 117 int ListMangle(int_list *, StackNode<int> *); 118 119 template<typename IChild, typename IParent, typename BpChild, typename BpParent> 120 List<IChild> castInterface(List<IParent> parent, const char *childIndicator, bool emitError) {return List<IChild>();} 121 122 void format() { 123 castInterface<float, float, float , float>(List<float>(), "foo", true); 124 } 125 126 #endif // EXAMPLE1_H_ 127