PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-25/SWIG/Examples/pike/template/runme.pike

#
Unknown | 33 lines | 26 code | 7 blank | 0 comment | 0 complexity | 62439f11e0d312771bab333bdcee477e MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. int main()
  2. {
  3. // Call some templated functions
  4. write(sprintf("%d\n", .example.maxint(3, 7)));
  5. write(sprintf("%f\n", .example.maxdouble(3.14, 2.18)));
  6. // Create some objects
  7. .example.vecint iv = .example.vecint(100);
  8. .example.vecdouble dv = .example.vecdouble(1000);
  9. for (int i = 0; i < 100; i++) {
  10. iv->setitem(i, 2*i);
  11. }
  12. for (int i = 0; i < 1000; i++) {
  13. dv->setitem(i, 1.0/(i+1));
  14. }
  15. int isum = 0;
  16. for (int i = 0; i < 100; i++) {
  17. isum += iv->getitem(i);
  18. }
  19. write(sprintf("%d\n", isum));
  20. float fsum = 0.0;
  21. for (int i = 0; i < 1000; i++) {
  22. fsum += dv->getitem(i);
  23. }
  24. write(sprintf("%f\n", fsum));
  25. return 0;
  26. }