PageRenderTime 48ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/Root-branch-php-utl/SWIG/Examples/python/reference/example.i

#
Swig | 48 lines | 30 code | 13 blank | 5 comment | 0 complexity | edff5e7d19cfc9349a9da02312c4fd16 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* File : example.i */
  2. /* This file has a few "typical" uses of C++ references. */
  3. %module example
  4. %{
  5. #include "example.h"
  6. %}
  7. %rename(cprint) print;
  8. class Vector {
  9. public:
  10. Vector(double x, double y, double z);
  11. ~Vector();
  12. char *print();
  13. };
  14. /* This helper function calls an overloaded operator */
  15. %inline %{
  16. Vector addv(Vector &a, Vector &b) {
  17. return a+b;
  18. }
  19. %}
  20. /* Wrapper around an array of vectors class */
  21. class VectorArray {
  22. public:
  23. VectorArray(int maxsize);
  24. ~VectorArray();
  25. int size();
  26. /* This wrapper provides an alternative to the [] operator */
  27. %extend {
  28. Vector &get(int index) {
  29. return (*self)[index];
  30. }
  31. void set(int index, Vector &a) {
  32. (*self)[index] = a;
  33. }
  34. }
  35. };