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

/trunk/Examples/tcl/reference/example.i

#
Swig | 46 lines | 29 code | 12 blank | 5 comment | 0 complexity | f938896108e73666eec0117148301e11 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. class Vector {
  8. public:
  9. Vector(double x, double y, double z);
  10. ~Vector();
  11. char *print();
  12. };
  13. /* This helper function calls an overloaded operator */
  14. %inline %{
  15. Vector addv(Vector &a, Vector &b) {
  16. return a+b;
  17. }
  18. %}
  19. /* Wrapper around an array of vectors class */
  20. class VectorArray {
  21. public:
  22. VectorArray(int maxsize);
  23. ~VectorArray();
  24. int size();
  25. /* This wrapper provides an alternative to the [] operator */
  26. %extend {
  27. Vector &get(int index) {
  28. return (*$self)[index];
  29. }
  30. void set(int index, Vector &a) {
  31. (*$self)[index] = a;
  32. }
  33. }
  34. };