diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2018-12-04 23:37:08 -0600 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2018-12-04 23:37:08 -0600 |
| commit | dfe06fd9d474c368cb6c724902dd20369d68f1b6 (patch) | |
| tree | e6cae42e79eba3b9c3d77c6e7f92f7de2320b257 /tests/include | |
| parent | cb1c7f28cbff8ac4e588266b8aa953a6f7f44563 (diff) | |
| download | nimterop-dfe06fd9d474c368cb6c724902dd20369d68f1b6.tar.gz nimterop-dfe06fd9d474c368cb6c724902dd20369d68f1b6.zip | |
Support for unions
Diffstat (limited to 'tests/include')
| -rw-r--r-- | tests/include/test.c | 38 | ||||
| -rw-r--r-- | tests/include/test.h | 21 |
2 files changed, 44 insertions, 15 deletions
diff --git a/tests/include/test.c b/tests/include/test.c index 885723e..d63c974 100644 --- a/tests/include/test.c +++ b/tests/include/test.c @@ -1,35 +1,51 @@ #include "test.h" int test_call_int() { - return 5; + return 5; } #ifdef FORCE -struct STRUCT1 _test_call_int_param_(int param1) { +struct STRUCT1 _test_call_param_(int param1) { struct STRUCT1 s; - + s.field1 = param1; - + return s; } #endif -STRUCT2 test_call_int_param2(int param1, STRUCT2 param2) { +STRUCT2 test_call_param2(int param1, STRUCT2 param2) { STRUCT2 s; - + s.field1 = param1 + param2.field1; - + return s; } -STRUCT2 test_call_int_param3(int param1, struct STRUCT1 param2) { +STRUCT2 test_call_param3(int param1, struct STRUCT1 param2) { STRUCT2 s; - + s.field1 = param1 + param2.field1; - + return s; } -ENUM2 test_call_int_param4(enum ENUM param1) { +ENUM2 test_call_param4(enum ENUM param1) { return enum4; +} + +union UNION1 test_call_param5(float param1) { + union UNION1 u; + + u.field2 = param1; + + return u; +} + +unsigned char test_call_param6(UNION2 param1) { + return param1.field2; +} + +int test_call_param7(union UNION1 param1) { + return param1.field1; }
\ No newline at end of file diff --git a/tests/include/test.h b/tests/include/test.h index 6138ca3..af7eeb8 100644 --- a/tests/include/test.h +++ b/tests/include/test.h @@ -36,8 +36,21 @@ typedef struct { int *field; } STRUCT4; +union UNION1 { + int field1; + float field2; +}; + +typedef union { + double field1; + unsigned char field2; +} UNION2; + int test_call_int(); -struct STRUCT1 _test_call_int_param_(int param1); -STRUCT2 test_call_int_param2(int param1, STRUCT2 param2); -STRUCT2 test_call_int_param3(int param1, struct STRUCT1 param2); -ENUM2 test_call_int_param4(enum ENUM param1); +struct STRUCT1 _test_call_param_(int param1); +STRUCT2 test_call_param2(int param1, STRUCT2 param2); +STRUCT2 test_call_param3(int param1, struct STRUCT1 param2); +ENUM2 test_call_param4(enum ENUM param1); +union UNION1 test_call_param5(float param1); +unsigned char test_call_param6(UNION2 param1); +int test_call_param7(union UNION1 param1);
\ No newline at end of file |
