/tags/rel-1.3.35/Examples/octave/operator/example.i

# · Swig · 24 lines · 16 code · 5 blank · 3 comment · 0 complexity · 50ea2f09ac7aad81fce2aa21c5590d7b MD5 · raw file

  1. /* File : example.i */
  2. %module example
  3. #pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ
  4. %{
  5. #include "example.h"
  6. %}
  7. /* Now grab the original header file */
  8. %include "example.h"
  9. /* An output method that turns a complex into a short string */
  10. %extend ComplexVal {
  11. char *__str() {
  12. static char temp[512];
  13. sprintf(temp,"(%g,%g)", $self->re(), $self->im());
  14. return temp;
  15. }
  16. ComplexVal __paren(int j) {
  17. return ComplexVal($self->re()*j,$self->im()*j);
  18. }
  19. };