PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 47 lines | 39 code | 8 blank | 0 comment | 0 complexity | f976f450d5fd66c10defb7fdc0a57b9a MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. // Tests passing of references to primitive datatypes
  2. %module primitive_ref
  3. %define ref(type,name)
  4. %inline %{
  5. const type &ref_##name(const type &x) {
  6. static type y = x;
  7. return y;
  8. }
  9. %}
  10. %enddef
  11. ref(int,int);
  12. ref(unsigned int, uint);
  13. ref(short, short);
  14. ref(unsigned short, ushort);
  15. ref(long,long);
  16. ref(unsigned long, ulong);
  17. ref(signed char, schar);
  18. ref(unsigned char, uchar);
  19. ref(char, char);
  20. ref(float, float);
  21. ref(double, double);
  22. ref(bool, bool);
  23. ref(long long, longlong);
  24. ref(unsigned long long, ulonglong);
  25. %inline %{
  26. int ref_over(int a)
  27. {
  28. return a;
  29. }
  30. struct A
  31. {
  32. int v;
  33. A(int V) :v(V) {}
  34. };
  35. int ref_over(const A& a)
  36. {
  37. return a.v;
  38. }
  39. %}