PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 102 lines | 75 code | 22 blank | 5 comment | 0 complexity | 7ba81122001a5004d7a142eea7545f3a MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* Test whether varios enums in C. */
  2. %module "enums"
  3. /* Suppress warning messages from the Ruby module for all of the following.. */
  4. %warnfilter(SWIGWARN_RUBY_WRONG_NAME) boo;
  5. %warnfilter(SWIGWARN_RUBY_WRONG_NAME) hoo;
  6. %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance1;
  7. %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance2;
  8. %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance3;
  9. %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
  10. %inline %{
  11. typedef enum {
  12. CSP_ITERATION_FWD,
  13. CSP_ITERATION_BWD = 11
  14. } foo1;
  15. typedef enum foo2 {
  16. ABCDE = 0,
  17. FGHJI = 1
  18. } foo3;
  19. void
  20. bar1(foo1 x) {}
  21. void
  22. bar2(enum foo2 x) {}
  23. void
  24. bar3(foo3 x) {}
  25. enum sad { boo, hoo = 5 };
  26. #ifdef __cplusplus /* For Octave and g++ which compiles C test code as C++ */
  27. extern "C" {
  28. #endif
  29. /* Unnamed enum instance */
  30. enum { globalinstance1, globalinstance2, globalinstance3 = 30 } GlobalInstance;
  31. #ifdef __cplusplus
  32. }
  33. #endif
  34. /* Anonymous enum */
  35. enum { AnonEnum1, AnonEnum2 = 100 };
  36. %}
  37. %inline %{
  38. typedef struct _Foo {
  39. enum { BAR1, BAR2 } e;
  40. } Foo;
  41. %}
  42. %warnfilter(SWIGWARN_RUBY_WRONG_NAME) _iFoo;
  43. #ifdef SWIGD
  44. /* Work around missing support for proper char quoting due to parser shortcomings. */
  45. %dconstvalue("'a'") _iFoo::Char;
  46. #endif
  47. #ifndef __cplusplus
  48. %inline %{
  49. typedef struct _iFoo
  50. {
  51. enum {
  52. Phoo = +50,
  53. Char = 'a'
  54. } e;
  55. } iFoo;
  56. %}
  57. #else
  58. %inline %{
  59. struct iFoo
  60. {
  61. enum {
  62. Phoo = +50,
  63. Char = 'a'
  64. };
  65. };
  66. %}
  67. #endif
  68. // enum declaration and initialization
  69. %inline %{
  70. enum Exclamation {
  71. goodness,
  72. gracious,
  73. me
  74. } enumInstance = me;
  75. enum ContainYourself {
  76. slap = 10,
  77. mine,
  78. thigh
  79. } Slap = slap, Mine = mine, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, mine, thigh};
  80. %}