File: example1.h

package info (click to toggle)
android-platform-development 10.0.0%2Br36-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 135,564 kB
  • sloc: java: 160,253; xml: 127,434; python: 40,579; cpp: 17,579; sh: 2,569; javascript: 1,612; ansic: 879; lisp: 261; ruby: 183; makefile: 172; sql: 140; perl: 88
file content (126 lines) | stat: -rw-r--r-- 2,508 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef EXAMPLE1_H_
#define EXAMPLE1_H_

#include "example2.h"

#if defined(__cplusplus)
extern "C" {
#endif

struct ForwardDeclaration;
int uses_forward_decl(struct ForwardDeclaration *);

struct Hello {
  int foo;
  int bar;
  wchar_t d;
  enum {A, B} enum_field;
  enum {C, D} enum_field2;
  struct {
    int a;
    int b;
    struct {
      int c;
    };
  };
};

#if defined(__cplusplus)
}  // extern "C"
#endif
using namespace test2;
using namespace test3;
typedef float float_type;
typedef const float_type cfloat_type;
struct CPPHello : private HelloAgain, public ByeAgain<float_type> {
  const int cpp_foo;
  cfloat_type cpp_bar;
  virtual int again() { return 0; }
  CPPHello() : cpp_foo(20), cpp_bar(1.234) {}
  CPPHello(CPPHello &) = delete;
  enum Bla{BLA = 1};
  int test_enum() {return CPPHello::BLA;}
};


void fooVariadic (int &, int *, ...);

int boo (const CPPHello, int *, float *) {
  return CPPHello::BLA;
}

template<typename T>
struct StackNode {
public:
  T value_;
  StackNode<T>* next_;

public:
  StackNode(T t, StackNode* next = nullptr)
    : value_(static_cast<T&&>(t)),
      next_(next) {}
};

template<typename T>
class Stack {
private:
  StackNode<T>* head_;

public:
  Stack() : head_(nullptr) {}

  void push(T t) {
    head_ = new StackNode<T>(static_cast<T&&>(t), head_);
  }

  T pop() {
    StackNode<T>* cur = head_;
    head_ = cur->next_;
    T res = static_cast<T&&>(cur->value_);
    delete cur;
    return res;
  }
};

// Replicated from libsysutils.
template<typename T>
class List
{
public:
    /*
     * One element in the list.
     */
    class _Node {
    public:
        explicit _Node(const T& val) : mVal(val) {}
        ~_Node() {}
        inline T& getRef() { return mVal; }
        inline const T& getRef() const { return mVal; }
    private:
        void PrivateNode();
        friend class List;
        friend class _ListIterator;
        T           mVal;
        _Node*      mpPrev;
        _Node*      mpNext;
    };
    _Node *middle;
};


typedef List<float> float_list;
float_list float_list_test;

typedef List<int> int_list;
int_list int_list_test;
List<float>::_Node node(2);
int ListMangle(int_list *, StackNode<int> *);

template<typename IChild, typename IParent, typename BpChild, typename BpParent>
List<IChild> castInterface(List<IParent> parent, const char *childIndicator, bool emitError) {return List<IChild>();}

void format() {
castInterface<float, float, float , float>(List<float>(), "foo", true);
}

#endif  // EXAMPLE1_H_