annotate lib/swig/swigwin-2.0.11/Lib/std/std_stack.i @ 2276:e2433db49428

ActorHasItems
author Ritor1
date Fri, 14 Mar 2014 10:47:22 +0600
parents b3009adc0e2f
children
rev   line source
1899
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
1 /**
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
2 * @file std_stack.i
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
3 * @date Sun May 6 01:48:07 2007
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
4 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
5 * @brief A wrapping of std::stack for Ruby.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
6 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
7 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
8 */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
9
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
10 %include <std_container.i>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
11
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
12 // Stack
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
13
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
14 %define %std_stack_methods(stack...)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
15 stack();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
16 stack( const _Sequence& );
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
17
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
18 bool empty() const;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
19 size_type size() const;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
20 const value_type& top() const;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
21 void pop();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
22 void push( const value_type& );
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
23 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
24
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
25 %define %std_stack_methods_val(stack...)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
26 %std_stack_methods(stack)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
27 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
28
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
29 // ------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
30 // std::stack
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
31 //
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
32 // const declarations are used to guess the intent of the function being
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
33 // exported; therefore, the following rationale is applied:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
34 //
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
35 // -- f(std::stack<T>), f(const std::stack<T>&):
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
36 // the parameter being read-only, either a sequence or a
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
37 // previously wrapped std::stack<T> can be passed.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
38 // -- f(std::stack<T>&), f(std::stack<T>*):
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
39 // the parameter may be modified; therefore, only a wrapped std::stack
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
40 // can be passed.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
41 // -- std::stack<T> f(), const std::stack<T>& f():
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
42 // the stack is returned by copy; therefore, a sequence of T:s
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
43 // is returned which is most easily used in other functions
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
44 // -- std::stack<T>& f(), std::stack<T>* f():
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
45 // the stack is returned by reference; therefore, a wrapped std::stack
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
46 // is returned
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
47 // -- const std::stack<T>* f(), f(const std::stack<T>*):
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
48 // for consistency, they expect and return a plain stack pointer.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
49 // ------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
50
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
51 %{
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
52 #include <stack>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
53 %}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
54
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
55 // exported classes
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
56
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
57 namespace std {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
58
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
59 template<class _Tp, class _Sequence = std::deque<_Tp> >
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
60 class stack {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
61 public:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
62 typedef size_t size_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
63 typedef _Tp value_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
64 typedef value_type& reference;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
65 typedef const value_type& const_reference;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
66 typedef _Sequence container_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
67
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
68 %traits_swigtype(_Tp);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
69
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
70 %fragment(SWIG_Traits_frag(std::stack<_Tp, _Sequence >), "header",
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
71 fragment=SWIG_Traits_frag(_Tp),
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
72 fragment="StdStackTraits") {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
73 namespace swig {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
74 template <> struct traits<std::stack<_Tp, _Sequence > > {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
75 typedef pointer_category category;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
76 static const char* type_name() {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
77 return "std::stack<" #_Tp "," #_Sequence " >";
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
78 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
79 };
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
80 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
81 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
82
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
83 %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp, _Sequence >);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
84
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
85 #ifdef %swig_stack_methods
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
86 // Add swig/language extra methods
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
87 %swig_stack_methods(std::stack<_Tp, _Sequence >);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
88 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
89
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
90 %std_stack_methods(stack);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
91 };
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
92
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
93 template<class _Tp, class _Sequence >
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
94 class stack<_Tp*, _Sequence > {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
95 public:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
96 typedef size_t size_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
97 typedef _Sequence::value_type value_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
98 typedef value_type reference;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
99 typedef value_type const_reference;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
100 typedef _Sequence container_type;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
101
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
102 %traits_swigtype(_Tp);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
103
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
104 %fragment(SWIG_Traits_frag(std::stack<_Tp*, _Sequence >), "header",
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
105 fragment=SWIG_Traits_frag(_Tp),
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
106 fragment="StdStackTraits") {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
107 namespace swig {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
108 template <> struct traits<std::stack<_Tp*, _Sequence > > {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
109 typedef value_category category;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
110 static const char* type_name() {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
111 return "std::stack<" #_Tp "," #_Sequence " * >";
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
112 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
113 };
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
114 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
115 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
116
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
117 %typemap_traits_ptr(SWIG_TYPECHECK_STACK, std::stack<_Tp*, _Sequence >);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
118
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
119 #ifdef %swig_stack_methods_val
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
120 // Add swig/language extra methods
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
121 %swig_stack_methods_val(std::stack<_Tp*, _Sequence >);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
122 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
123
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
124 %std_stack_methods_val(std::stack<_Tp*, _Sequence >);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
125 };
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
126
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
127 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
128