PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-24/SWIG/Examples/modula3/enum/example.cxx

#
C++ | 32 lines | 28 code | 3 blank | 1 comment | 21 complexity | 810384cc97edb4587bf3e4fefb85ac79 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* File : example.cxx */
  2. #include "example.h"
  3. #include <stdio.h>
  4. void Foo::enum_test(speed s) {
  5. if (s == IMPULSE) {
  6. printf("IMPULSE speed\n");
  7. } else if (s == WARP) {
  8. printf("WARP speed\n");
  9. } else if (s == LUDICROUS) {
  10. printf("LUDICROUS speed\n");
  11. } else if (s == HYPER) {
  12. printf("HYPER speed\n");
  13. } else {
  14. printf("Unknown speed\n");
  15. }
  16. }
  17. void enum_test(color c, Foo::speed s) {
  18. if (c == RED) {
  19. printf("color = RED, ");
  20. } else if (c == BLUE) {
  21. printf("color = BLUE, ");
  22. } else if (c == GREEN) {
  23. printf("color = GREEN, ");
  24. } else {
  25. printf("color = Unknown color!, ");
  26. }
  27. Foo obj;
  28. obj.enum_test(s);
  29. }