PageRenderTime 31ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Lib/std/std_deque.i

#
Swig | 127 lines | 103 code | 24 blank | 0 comment | 0 complexity | 22bb370afb28e6945f2beeaedad72c38 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. //
  2. // std::deque
  3. %include <std_container.i>
  4. // Deque
  5. %define %std_deque_methods(deque...)
  6. %std_sequence_methods(deque)
  7. void pop_front();
  8. void push_front(const value_type& x);
  9. %enddef
  10. %define %std_deque_methods_val(deque...)
  11. %std_sequence_methods_val(deque)
  12. void pop_front();
  13. void push_front(value_type x);
  14. %enddef
  15. // ------------------------------------------------------------------------
  16. // std::deque
  17. //
  18. // const declarations are used to guess the intent of the function being
  19. // exported; therefore, the following rationale is applied:
  20. //
  21. // -- f(std::deque<T>), f(const std::deque<T>&):
  22. // the parameter being read-only, either a sequence or a
  23. // previously wrapped std::deque<T> can be passed.
  24. // -- f(std::deque<T>&), f(std::deque<T>*):
  25. // the parameter may be modified; therefore, only a wrapped std::deque
  26. // can be passed.
  27. // -- std::deque<T> f(), const std::deque<T>& f():
  28. // the deque is returned by copy; therefore, a sequence of T:s
  29. // is returned which is most easily used in other functions
  30. // -- std::deque<T>& f(), std::deque<T>* f():
  31. // the deque is returned by reference; therefore, a wrapped std::deque
  32. // is returned
  33. // -- const std::deque<T>* f(), f(const std::deque<T>*):
  34. // for consistency, they expect and return a plain deque pointer.
  35. // ------------------------------------------------------------------------
  36. %{
  37. #include <deque>
  38. %}
  39. // exported classes
  40. namespace std {
  41. template<class _Tp, class _Alloc = allocator<_Tp> >
  42. class deque {
  43. public:
  44. typedef size_t size_type;
  45. typedef ptrdiff_t difference_type;
  46. typedef _Tp value_type;
  47. typedef value_type* pointer;
  48. typedef const value_type* const_pointer;
  49. typedef value_type& reference;
  50. typedef const value_type& const_reference;
  51. typedef _Alloc allocator_type;
  52. %traits_swigtype(_Tp);
  53. %fragment(SWIG_Traits_frag(std::deque<_Tp, _Alloc >), "header",
  54. fragment=SWIG_Traits_frag(_Tp),
  55. fragment="StdDequeTraits") {
  56. namespace swig {
  57. template <> struct traits<std::deque<_Tp, _Alloc > > {
  58. typedef pointer_category category;
  59. static const char* type_name() {
  60. return "std::deque<" #_Tp " >";
  61. }
  62. };
  63. }
  64. }
  65. %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp, _Alloc >);
  66. #ifdef %swig_deque_methods
  67. // Add swig/language extra methods
  68. %swig_deque_methods(std::deque<_Tp, _Alloc >);
  69. #endif
  70. %std_deque_methods(deque);
  71. };
  72. template<class _Tp, class _Alloc >
  73. class deque<_Tp*, _Alloc > {
  74. public:
  75. typedef size_t size_type;
  76. typedef ptrdiff_t difference_type;
  77. typedef _Tp* value_type;
  78. typedef value_type* pointer;
  79. typedef const value_type* const_pointer;
  80. typedef value_type reference;
  81. typedef value_type const_reference;
  82. typedef _Alloc allocator_type;
  83. %traits_swigtype(_Tp);
  84. %fragment(SWIG_Traits_frag(std::deque<_Tp*, _Alloc >), "header",
  85. fragment=SWIG_Traits_frag(_Tp),
  86. fragment="StdDequeTraits") {
  87. namespace swig {
  88. template <> struct traits<std::deque<_Tp*, _Alloc > > {
  89. typedef value_category category;
  90. static const char* type_name() {
  91. return "std::deque<" #_Tp " * >";
  92. }
  93. };
  94. }
  95. }
  96. %typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp*, _Alloc >);
  97. #ifdef %swig_deque_methods_val
  98. // Add swig/language extra methods
  99. %swig_deque_methods_val(std::deque<_Tp*, _Alloc >);
  100. #endif
  101. %std_deque_methods_val(std::deque<_Tp*, _Alloc >);
  102. };
  103. }