diff options
author | Haibo Huang <hhb@google.com> | 2019-10-08 15:48:26 -0700 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2019-11-14 22:14:23 +0000 |
commit | 80b4251e302efb18c145a4786249d695397ed42a (patch) | |
tree | 12b9dec2513f7caa92e7835bc17ab16ae5635df6 /Examples/test-suite/csharp_lib_arrays_bool.i | |
parent | 189852d8cdfd5863c52ec7aa73affd926c5a3f43 (diff) | |
parent | 1e36f51346d95f8b9848e682c2eb986e9cb9b4f4 (diff) | |
download | swig-80b4251e302efb18c145a4786249d695397ed42a.tar.gz |
Upgrade swig to 'rel-4.0.1'llvm-r383902b
Also run autogen.sh to generate configure files.
Exempt-From-Owner-Approval: add myself to owners
Change-Id: I391aa20428836ae74dab8c8427627ca4dbc8ecf4
Diffstat (limited to 'Examples/test-suite/csharp_lib_arrays_bool.i')
-rw-r--r-- | Examples/test-suite/csharp_lib_arrays_bool.i | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Examples/test-suite/csharp_lib_arrays_bool.i b/Examples/test-suite/csharp_lib_arrays_bool.i new file mode 100644 index 000000000..58cee9d80 --- /dev/null +++ b/Examples/test-suite/csharp_lib_arrays_bool.i @@ -0,0 +1,78 @@ +%module csharp_lib_arrays_bool + +%include "arrays_csharp.i" + +%apply bool INPUT[] { bool* sourceArray } +%apply bool OUTPUT[] { bool* targetArray } + +%apply bool INOUT[] { bool* array1 } +%apply bool INOUT[] { bool* array2 } + +%inline %{ +#include <iostream> + +/* copy the contents of the first array to the second */ +void myArrayCopyBool( bool* sourceArray, bool* targetArray, int nitems ) { + int i; + for ( i = 0; i < nitems; i++ ) { + targetArray[ i ] = sourceArray[ i ]; + } +} + +/* swap the contents of the two arrays */ +void myArraySwapBool( bool* array1, bool* array2, int nitems ) { + int i; + bool temp; + for ( i = 0; i < nitems; i++ ) { + temp = array1[ i ]; + array1[ i ] = array2[ i ]; + array2[ i ] = temp; + } +} + +bool checkBoolArrayCorrect( bool* sourceArray, int sourceArraySize ) { + if( sourceArraySize != 8 ) { + std::cout << "checkBoolArrayCorrect: Expected array with 8 elements" << std::endl; + return false; + } + return sourceArray[0] == true && + sourceArray[1] == false && + sourceArray[2] == false && + sourceArray[3] == true && + sourceArray[4] == false && + sourceArray[5] == true && + sourceArray[6] == true && + sourceArray[7] == false; +} +%} + +%clear bool* sourceArray; +%clear bool* targetArray; + +%clear bool* array1; +%clear bool* array2; + +// Below replicates the above array handling but this time using the pinned (fixed) array typemaps +%csmethodmodifiers myArrayCopyUsingFixedArraysBool "public unsafe"; +%csmethodmodifiers myArraySwapUsingFixedArraysBool "public unsafe"; + +%apply bool FIXED[] { bool* sourceArray } +%apply bool FIXED[] { bool* targetArray } + +%inline %{ +void myArrayCopyUsingFixedArraysBool( bool *sourceArray, bool* targetArray, int nitems ) { + myArrayCopyBool(sourceArray, targetArray, nitems); +} +%} + +%apply bool FIXED[] { bool* array1 } +%apply bool FIXED[] { bool* array2 } + +%inline %{ +void myArraySwapUsingFixedArraysBool( bool* array1, bool* array2, int nitems ) { + myArraySwapBool(array1, array2, nitems); +} +%} + + + |