calling_conventions.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Copyright Nicolas Lelong, 2010. Distributed under the Boost
  2. # Software License, Version 1.0 (See accompanying
  3. # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. """
  5. >>> from calling_conventions_ext import *
  6. >>> f_0__cdecl()
  7. 17041
  8. >>> f_1__cdecl(1)
  9. 1
  10. >>> f_2__cdecl(1, 2)
  11. 21
  12. >>> f_3__cdecl(1, 2, 3)
  13. 321
  14. >>> f_4__cdecl(1, 2, 3, 4)
  15. 4321
  16. >>> f_5__cdecl(1, 2, 3, 4, 5)
  17. 54321
  18. >>> f_6__cdecl(1, 2, 3, 4, 5, 6)
  19. 654321
  20. >>> f_7__cdecl(1, 2, 3, 4, 5, 6, 7)
  21. 7654321
  22. >>> f_8__cdecl(1, 2, 3, 4, 5, 6, 7, 8)
  23. 87654321
  24. >>> f_9__cdecl(1, 2, 3, 4, 5, 6, 7, 8, 9)
  25. 987654321
  26. >>> f_0__stdcall()
  27. 17041
  28. >>> f_1__stdcall(1)
  29. 1
  30. >>> f_2__stdcall(1, 2)
  31. 21
  32. >>> f_3__stdcall(1, 2, 3)
  33. 321
  34. >>> f_4__stdcall(1, 2, 3, 4)
  35. 4321
  36. >>> f_5__stdcall(1, 2, 3, 4, 5)
  37. 54321
  38. >>> f_6__stdcall(1, 2, 3, 4, 5, 6)
  39. 654321
  40. >>> f_7__stdcall(1, 2, 3, 4, 5, 6, 7)
  41. 7654321
  42. >>> f_8__stdcall(1, 2, 3, 4, 5, 6, 7, 8)
  43. 87654321
  44. >>> f_9__stdcall(1, 2, 3, 4, 5, 6, 7, 8, 9)
  45. 987654321
  46. >>> f_0__fastcall()
  47. 17041
  48. >>> f_1__fastcall(1)
  49. 1
  50. >>> f_2__fastcall(1, 2)
  51. 21
  52. >>> f_3__fastcall(1, 2, 3)
  53. 321
  54. >>> f_4__fastcall(1, 2, 3, 4)
  55. 4321
  56. >>> f_5__fastcall(1, 2, 3, 4, 5)
  57. 54321
  58. >>> f_6__fastcall(1, 2, 3, 4, 5, 6)
  59. 654321
  60. >>> f_7__fastcall(1, 2, 3, 4, 5, 6, 7)
  61. 7654321
  62. >>> f_8__fastcall(1, 2, 3, 4, 5, 6, 7, 8)
  63. 87654321
  64. >>> f_9__fastcall(1, 2, 3, 4, 5, 6, 7, 8, 9)
  65. 987654321
  66. """
  67. def run(args = None):
  68. import sys
  69. import doctest
  70. if args is not None:
  71. sys.argv = args
  72. return doctest.testmod(sys.modules.get(__name__))
  73. if __name__ == '__main__':
  74. print("running...")
  75. import sys
  76. status = run()[0]
  77. if (status == 0): print("Done.")
  78. sys.exit(status)