PageRenderTime 26ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 42 lines | 27 code | 8 blank | 7 comment | 0 complexity | 94ded6016c41cfa9f200f2bd9ec9d452 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /*
  2. This testcase checks that unions can be set and read.
  3. */
  4. %module unions
  5. %{
  6. /* Must undefine small to work on Windows. small is defined as a
  7. char in rpcndr.h */
  8. #ifdef small
  9. #undef small
  10. #endif
  11. %}
  12. %inline %{
  13. typedef struct SmallStruct {
  14. short jill;
  15. } SmallStruct;
  16. typedef struct BigStruct {
  17. int jack;
  18. SmallStruct smallstruct;
  19. } BigStruct;
  20. /* This union is just to check the parser */
  21. typedef union {
  22. BigStruct bs;
  23. SmallStruct ss;
  24. } UnionTest;
  25. /* This union checks the parser and will be used in a runtime test */
  26. typedef struct {
  27. union
  28. {
  29. BigStruct big;
  30. SmallStruct small;
  31. } uni;
  32. int number;
  33. } EmbeddedUnionTest;
  34. %}