PageRenderTime 23ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/octave/pointer/runme.m

#
MATLAB | 42 lines | 29 code | 13 blank | 0 comment | 2 complexity | d307b3f9559b270a4ba07e6abc5f6aca MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. # file: runme.m
  2. example;
  3. # First create some objects using the pointer library.
  4. printf("Testing the pointer library\n");
  5. a = example.new_intp();
  6. b = example.new_intp();
  7. c = example.new_intp();
  8. example.intp_assign(a,37);
  9. example.intp_assign(b,42);
  10. a,b,c
  11. # Call the add() function with some pointers
  12. example.add(a,b,c);
  13. # Now get the result
  14. r = example.intp_value(c);
  15. printf(" 37 + 42 = %i\n",r);
  16. # Clean up the pointers
  17. example.delete_intp(a);
  18. example.delete_intp(b);
  19. example.delete_intp(c);
  20. # Now try the typemap library
  21. # This should be much easier. Now how it is no longer
  22. # necessary to manufacture pointers.
  23. printf("Trying the typemap library\n");
  24. r = example.sub(37,42);
  25. printf(" 37 - 42 = %i\n",r);
  26. # Now try the version with multiple return values
  27. printf("Testing multiple return values\n");
  28. [q,r] = example.divide(42,37);
  29. printf(" 42/37 = %d remainder %d\n",q,r);