PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Swig | 61 lines | 43 code | 16 blank | 2 comment | 0 complexity | 3da58ccd42e8c984f45b44f2d016b242 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module csharp_lib_arrays
  2. %include "arrays_csharp.i"
  3. %apply int INPUT[] { int* sourceArray }
  4. %apply int OUTPUT[] { int* targetArray }
  5. %apply int INOUT[] { int* array1 }
  6. %apply int INOUT[] { int* array2 }
  7. %inline %{
  8. /* copy the contents of the first array to the second */
  9. void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) {
  10. int i;
  11. for ( i = 0; i < nitems; i++ ) {
  12. targetArray[ i ] = sourceArray[ i ];
  13. }
  14. }
  15. /* swap the contents of the two arrays */
  16. void myArraySwap( int* array1, int* array2, int nitems ) {
  17. int i, temp;
  18. for ( i = 0; i < nitems; i++ ) {
  19. temp = array1[ i ];
  20. array1[ i ] = array2[ i ];
  21. array2[ i ] = temp;
  22. }
  23. }
  24. %}
  25. %clear int* sourceArray;
  26. %clear int* targetArray;
  27. %clear int* array1;
  28. %clear int* array2;
  29. // Below replicates the above array handling but this time using the pinned (fixed) array typemaps
  30. %csmethodmodifiers myArrayCopyUsingFixedArrays "public unsafe";
  31. %csmethodmodifiers myArraySwapUsingFixedArrays "public unsafe";
  32. %apply int FIXED[] { int* sourceArray }
  33. %apply int FIXED[] { int* targetArray }
  34. %inline %{
  35. void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) {
  36. myArrayCopy(sourceArray, targetArray, nitems);
  37. }
  38. %}
  39. %apply int FIXED[] { int* array1 }
  40. %apply int FIXED[] { int* array2 }
  41. %inline %{
  42. void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) {
  43. myArraySwap(array1, array2, nitems);
  44. }
  45. %}