PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 51 lines | 38 code | 7 blank | 6 comment | 0 complexity | ed4c8de87e881346ccc5da8607d792dd MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /**
  2. * The purpose of this test is to confirm that a language module
  3. * correctly handles the case when C++ class member functions (of both
  4. * the static and non-static persuasion) have been tagged with the
  5. * %newobject directive.
  6. */
  7. %module newobject1
  8. %newobject Foo::makeFoo();
  9. %newobject Foo::makeMore();
  10. %inline %{
  11. class Foo
  12. {
  13. private:
  14. Foo(const Foo&);
  15. Foo& operator=(const Foo&);
  16. private:
  17. static int m_fooCount;
  18. protected:
  19. Foo() {
  20. m_fooCount++;
  21. }
  22. public:
  23. // Factory function (static)
  24. static Foo *makeFoo() {
  25. return new Foo;
  26. }
  27. // Factory function (regular)
  28. Foo *makeMore() {
  29. return new Foo;
  30. }
  31. // Return the number of instances
  32. static int fooCount() {
  33. return m_fooCount;
  34. }
  35. // Destructor
  36. ~Foo() {
  37. m_fooCount--;
  38. }
  39. };
  40. %}
  41. %{
  42. // Static member initialization (not wrapped)
  43. int Foo::m_fooCount = 0;
  44. %}