PageRenderTime 47ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-26/SWIG/Examples/test-suite/private_assign.i

#
Swig | 68 lines | 50 code | 18 blank | 0 comment | 0 complexity | 8c77808ee791a95cc75f9eeb1287d9e8 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. // A class with a private assignment operator.
  2. // This is rare, but sometimes used with singletons and
  3. // objects that have complicated state.
  4. %module private_assign
  5. %inline %{
  6. class Foo {
  7. private:
  8. Foo &operator=(const Foo &f) {
  9. return *this;
  10. }
  11. public:
  12. void bar() { }
  13. };
  14. Foo blah() {
  15. return Foo();
  16. }
  17. class Bar : protected Foo
  18. {
  19. };
  20. %}
  21. #pragma SWIG nowarn=350 // operator new
  22. %inline %{
  23. class TROOT {
  24. protected:
  25. void *operator new(size_t l) { return malloc(sizeof(TROOT)); }
  26. int prot_meth()
  27. {
  28. return 1;
  29. }
  30. public:
  31. TROOT()
  32. {
  33. }
  34. TROOT(const char *name, const char *title, void *initfunc = 0)
  35. {
  36. }
  37. };
  38. class A : protected TROOT
  39. {
  40. };
  41. %}
  42. #ifdef SWIGPYTHON
  43. // This case only works in python
  44. %inline %{
  45. struct FooBar : Foo
  46. {
  47. };
  48. FooBar bar;
  49. %}
  50. #endif