PageRenderTime 50ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/simple_array.i

#
Swig | 42 lines | 30 code | 12 blank | 0 comment | 0 complexity | 1a214d4bc92dc6d2241c70b8c571436c MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module simple_array
  2. extern int x[10];
  3. extern double y[7];
  4. %inline %{
  5. struct BarArray {
  6. int i;
  7. double d;
  8. };
  9. extern struct BarArray bars[2];
  10. int x[10];
  11. double y[7];
  12. struct BarArray bars[2];
  13. void
  14. initArray()
  15. {
  16. int i, n;
  17. n = sizeof(x)/sizeof(x[0]);
  18. for(i = 0; i < n; i++)
  19. x[i] = i;
  20. n = sizeof(y)/sizeof(y[0]);
  21. for(i = 0; i < n; i++)
  22. y[i] = ((double) i)/ ((double) n);
  23. n = sizeof(bars)/sizeof(bars[0]);
  24. for(i = 0; i < n; i++) {
  25. bars[i].i = x[i+2];
  26. bars[i].d = y[i+2];
  27. }
  28. return;
  29. }
  30. %}