PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/python/std_carray.i

#
Swig | 54 lines | 42 code | 12 blank | 0 comment | 0 complexity | baf44c1cb7492739ee71df1d9bb5b28e MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %include <pycontainer.swg>
  2. %fragment("StdCarrayTraits","header",fragment="StdSequenceTraits")
  3. {
  4. namespace swig {
  5. template <class T, size_t S>
  6. struct traits_asptr<std::carray<T, S> > {
  7. static int asptr(PyObject *obj, std::carray<T, S> **array) {
  8. return traits_asptr_stdseq<std::carray<T, S> >::asptr(obj, array);
  9. }
  10. };
  11. }
  12. }
  13. %warnfilter(SWIGWARN_IGNORE_OPERATOR_INDEX) std::carray::operator[];
  14. %extend std::carray {
  15. %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header",
  16. fragment="SwigPyIterator_T",
  17. fragment=SWIG_Traits_frag(_Type),
  18. fragment="StdCarrayTraits") {
  19. namespace swig {
  20. template <> struct traits<std::carray<_Type, _Size > > {
  21. typedef pointer_category category;
  22. static const char* type_name() {
  23. return "std::carray<" #_Type "," #_Size " >";
  24. }
  25. };
  26. }
  27. }
  28. %typemaps_asptr(SWIG_TYPECHECK_VECTOR, swig::asptr,
  29. SWIG_Traits_frag(std::carray<_Type, _Size >),
  30. std::carray<_Type, _Size >);
  31. %typemap(out,noblock=1) iterator, const_iterator {
  32. $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1),
  33. swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
  34. }
  35. inline size_t __len__() const { return self->size(); }
  36. inline const _Type& __getitem__(size_t i) const { return (*self)[i]; }
  37. inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; }
  38. swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) {
  39. return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
  40. }
  41. }
  42. %include <std/std_carray.swg>