PageRenderTime 43ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/smart_pointer_templatevariables.i

#
Swig | 39 lines | 33 code | 6 blank | 0 comment | 0 complexity | 8dd00f976f94d60f4cc11341aaa021cc MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module smart_pointer_templatevariables
  2. %inline %{
  3. template <class _CharT>
  4. struct basic_string {
  5. int npos;
  6. };
  7. template<class T>
  8. struct Ptr {
  9. Ptr(T *p = 0) : ptr(p) {}
  10. ~Ptr() { delete ptr; }
  11. T *operator->() const { return ptr; }
  12. private:
  13. T *ptr;
  14. };
  15. template <typename KernelPixelT>
  16. struct DiffImContainer {
  17. int id;
  18. // static members seem to be can of worms. Note that SWIG wraps them as non-static members. Why?
  19. // Note CHANGES entry 10/14/2003. Static const variables are not wrapped as constants but as a read only variable. Why?
  20. // static short xyz;
  21. // static const short constvar = 555;
  22. };
  23. //template<typename KernelPixelT> short DiffImContainer<KernelPixelT>::xyz = 0;
  24. DiffImContainer<double>* create(int id, short xyz) {
  25. DiffImContainer<double> *d = new DiffImContainer<double>();
  26. d->id = id;
  27. // DiffImContainer<double>::xyz = xyz;
  28. return d;
  29. }
  30. %}
  31. %template(BasicString) basic_string<char>;
  32. %template(DiffImContainer_D) DiffImContainer<double>;
  33. %template(DiffImContainerPtr_D) Ptr<DiffImContainer<double> >;