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

# · Swig · 71 lines · 53 code · 18 blank · 0 comment · 0 complexity · aec6392c813522e46b63d5dc83c6468d MD5 · raw file

  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. %{
  6. #include <stdlib.h>
  7. %}
  8. %inline %{
  9. class Foo {
  10. private:
  11. Foo &operator=(const Foo &f) {
  12. return *this;
  13. }
  14. public:
  15. void bar() { }
  16. };
  17. Foo blah() {
  18. return Foo();
  19. }
  20. class Bar : protected Foo
  21. {
  22. };
  23. %}
  24. #pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_NEW // operator new
  25. %inline %{
  26. class TROOT {
  27. protected:
  28. void *operator new(size_t l) { return malloc(sizeof(TROOT)); }
  29. int prot_meth()
  30. {
  31. return 1;
  32. }
  33. public:
  34. TROOT()
  35. {
  36. }
  37. TROOT(const char *name, const char *title, void *initfunc = 0)
  38. {
  39. }
  40. };
  41. class A : protected TROOT
  42. {
  43. };
  44. %}
  45. #ifdef SWIGPYTHON
  46. // This case only works in python
  47. %inline %{
  48. struct FooBar : Foo
  49. {
  50. };
  51. FooBar bar;
  52. %}
  53. #endif