ctpbee-opt-api 0.1.0__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (414) hide show
  1. ctpbee_api/__init__.py +17 -0
  2. ctpbee_api/ctp/__init__.py +3 -0
  3. ctpbee_api/ctp/ctp_constant.py +1253 -0
  4. ctpbee_api/ctp/generator/concat.py +93 -0
  5. ctpbee_api/ctp/generator/const.py +325 -0
  6. ctpbee_api/ctp/generator/ctp_constant.py +1274 -0
  7. ctpbee_api/ctp/generator/ctp_md_header_define.h +13 -0
  8. ctpbee_api/ctp/generator/ctp_md_header_function.h +6 -0
  9. ctpbee_api/ctp/generator/ctp_md_header_on.h +26 -0
  10. ctpbee_api/ctp/generator/ctp_md_header_process.h +26 -0
  11. ctpbee_api/ctp/generator/ctp_md_source_function.cpp +42 -0
  12. ctpbee_api/ctp/generator/ctp_md_source_module.cpp +18 -0
  13. ctpbee_api/ctp/generator/ctp_md_source_on.cpp +156 -0
  14. ctpbee_api/ctp/generator/ctp_md_source_process.cpp +282 -0
  15. ctpbee_api/ctp/generator/ctp_md_source_switch.cpp +78 -0
  16. ctpbee_api/ctp/generator/ctp_md_source_task.cpp +211 -0
  17. ctpbee_api/ctp/generator/ctp_struct.py +5640 -0
  18. ctpbee_api/ctp/generator/ctp_td_header_define.h +130 -0
  19. ctpbee_api/ctp/generator/ctp_td_header_function.h +174 -0
  20. ctpbee_api/ctp/generator/ctp_td_header_on.h +260 -0
  21. ctpbee_api/ctp/generator/ctp_td_header_process.h +260 -0
  22. ctpbee_api/ctp/generator/ctp_td_source_function.cpp +1456 -0
  23. ctpbee_api/ctp/generator/ctp_td_source_module.cpp +222 -0
  24. ctpbee_api/ctp/generator/ctp_td_source_on.cpp +1572 -0
  25. ctpbee_api/ctp/generator/ctp_td_source_process.cpp +5472 -0
  26. ctpbee_api/ctp/generator/ctp_td_source_switch.cpp +780 -0
  27. ctpbee_api/ctp/generator/ctp_td_source_task.cpp +2444 -0
  28. ctpbee_api/ctp/generator/ctp_typedef.py +800 -0
  29. ctpbee_api/ctp/generator/generate_api_functions.py +345 -0
  30. ctpbee_api/ctp/generator/generate_data_type.py +76 -0
  31. ctpbee_api/ctp/generator/generate_struct.py +84 -0
  32. ctpbee_api/ctp/include/mac/ctp/ThostFtdcMdApi.h +168 -0
  33. ctpbee_api/ctp/include/mac/ctp/ThostFtdcTraderApi.h +770 -0
  34. ctpbee_api/ctp/include/mac/ctp/ThostFtdcUserApiDataType.h +6878 -0
  35. ctpbee_api/ctp/include/mac/ctp/ThostFtdcUserApiStruct.h +10915 -0
  36. ctpbee_api/ctp/include/mac/pybind11/attr.h +690 -0
  37. ctpbee_api/ctp/include/mac/pybind11/buffer_info.h +208 -0
  38. ctpbee_api/ctp/include/mac/pybind11/cast.h +1704 -0
  39. ctpbee_api/ctp/include/mac/pybind11/chrono.h +225 -0
  40. ctpbee_api/ctp/include/mac/pybind11/common.h +2 -0
  41. ctpbee_api/ctp/include/mac/pybind11/complex.h +74 -0
  42. ctpbee_api/ctp/include/mac/pybind11/detail/class.h +743 -0
  43. ctpbee_api/ctp/include/mac/pybind11/detail/common.h +1255 -0
  44. ctpbee_api/ctp/include/mac/pybind11/detail/descr.h +171 -0
  45. ctpbee_api/ctp/include/mac/pybind11/detail/init.h +434 -0
  46. ctpbee_api/ctp/include/mac/pybind11/detail/internals.h +656 -0
  47. ctpbee_api/ctp/include/mac/pybind11/detail/type_caster_base.h +1177 -0
  48. ctpbee_api/ctp/include/mac/pybind11/detail/typeid.h +65 -0
  49. ctpbee_api/ctp/include/mac/pybind11/eigen/common.h +9 -0
  50. ctpbee_api/ctp/include/mac/pybind11/eigen/matrix.h +714 -0
  51. ctpbee_api/ctp/include/mac/pybind11/eigen/tensor.h +516 -0
  52. ctpbee_api/ctp/include/mac/pybind11/eigen.h +12 -0
  53. ctpbee_api/ctp/include/mac/pybind11/embed.h +316 -0
  54. ctpbee_api/ctp/include/mac/pybind11/eval.h +156 -0
  55. ctpbee_api/ctp/include/mac/pybind11/functional.h +137 -0
  56. ctpbee_api/ctp/include/mac/pybind11/gil.h +239 -0
  57. ctpbee_api/ctp/include/mac/pybind11/iostream.h +265 -0
  58. ctpbee_api/ctp/include/mac/pybind11/numpy.h +1998 -0
  59. ctpbee_api/ctp/include/mac/pybind11/operators.h +202 -0
  60. ctpbee_api/ctp/include/mac/pybind11/options.h +92 -0
  61. ctpbee_api/ctp/include/mac/pybind11/pybind11.h +2890 -0
  62. ctpbee_api/ctp/include/mac/pybind11/pytypes.h +2557 -0
  63. ctpbee_api/ctp/include/mac/pybind11/stl/filesystem.h +116 -0
  64. ctpbee_api/ctp/include/mac/pybind11/stl.h +447 -0
  65. ctpbee_api/ctp/include/mac/pybind11/stl_bind.h +851 -0
  66. ctpbee_api/ctp/include/mac/pybind11/type_caster_pyobject_ptr.h +61 -0
  67. ctpbee_api/ctp/include/new/ctp/ThostFtdcMdApi.h +168 -0
  68. ctpbee_api/ctp/include/new/ctp/ThostFtdcTraderApi.h +770 -0
  69. ctpbee_api/ctp/include/new/ctp/ThostFtdcUserApiDataType.h +6878 -0
  70. ctpbee_api/ctp/include/new/ctp/ThostFtdcUserApiStruct.h +10915 -0
  71. ctpbee_api/ctp/include/new/pybind11/attr.h +690 -0
  72. ctpbee_api/ctp/include/new/pybind11/buffer_info.h +208 -0
  73. ctpbee_api/ctp/include/new/pybind11/cast.h +1704 -0
  74. ctpbee_api/ctp/include/new/pybind11/chrono.h +225 -0
  75. ctpbee_api/ctp/include/new/pybind11/common.h +2 -0
  76. ctpbee_api/ctp/include/new/pybind11/complex.h +74 -0
  77. ctpbee_api/ctp/include/new/pybind11/detail/class.h +743 -0
  78. ctpbee_api/ctp/include/new/pybind11/detail/common.h +1255 -0
  79. ctpbee_api/ctp/include/new/pybind11/detail/descr.h +171 -0
  80. ctpbee_api/ctp/include/new/pybind11/detail/init.h +434 -0
  81. ctpbee_api/ctp/include/new/pybind11/detail/internals.h +656 -0
  82. ctpbee_api/ctp/include/new/pybind11/detail/type_caster_base.h +1177 -0
  83. ctpbee_api/ctp/include/new/pybind11/detail/typeid.h +65 -0
  84. ctpbee_api/ctp/include/new/pybind11/eigen/common.h +9 -0
  85. ctpbee_api/ctp/include/new/pybind11/eigen/matrix.h +714 -0
  86. ctpbee_api/ctp/include/new/pybind11/eigen/tensor.h +516 -0
  87. ctpbee_api/ctp/include/new/pybind11/eigen.h +12 -0
  88. ctpbee_api/ctp/include/new/pybind11/embed.h +316 -0
  89. ctpbee_api/ctp/include/new/pybind11/eval.h +156 -0
  90. ctpbee_api/ctp/include/new/pybind11/functional.h +137 -0
  91. ctpbee_api/ctp/include/new/pybind11/gil.h +239 -0
  92. ctpbee_api/ctp/include/new/pybind11/iostream.h +265 -0
  93. ctpbee_api/ctp/include/new/pybind11/numpy.h +1998 -0
  94. ctpbee_api/ctp/include/new/pybind11/operators.h +202 -0
  95. ctpbee_api/ctp/include/new/pybind11/options.h +92 -0
  96. ctpbee_api/ctp/include/new/pybind11/pybind11.h +2890 -0
  97. ctpbee_api/ctp/include/new/pybind11/pytypes.h +2557 -0
  98. ctpbee_api/ctp/include/new/pybind11/stl/filesystem.h +116 -0
  99. ctpbee_api/ctp/include/new/pybind11/stl.h +447 -0
  100. ctpbee_api/ctp/include/new/pybind11/stl_bind.h +851 -0
  101. ctpbee_api/ctp/include/new/pybind11/type_caster_pyobject_ptr.h +61 -0
  102. ctpbee_api/ctp/include/previous/ctp/ThostFtdcMdApi.h +168 -0
  103. ctpbee_api/ctp/include/previous/ctp/ThostFtdcTraderApi.h +770 -0
  104. ctpbee_api/ctp/include/previous/ctp/ThostFtdcUserApiDataType.h +6878 -0
  105. ctpbee_api/ctp/include/previous/ctp/ThostFtdcUserApiStruct.h +10915 -0
  106. ctpbee_api/ctp/include/previous/pybind11/attr.h +489 -0
  107. ctpbee_api/ctp/include/previous/pybind11/buffer_info.h +108 -0
  108. ctpbee_api/ctp/include/previous/pybind11/cast.h +2067 -0
  109. ctpbee_api/ctp/include/previous/pybind11/chrono.h +162 -0
  110. ctpbee_api/ctp/include/previous/pybind11/common.h +2 -0
  111. ctpbee_api/ctp/include/previous/pybind11/complex.h +61 -0
  112. ctpbee_api/ctp/include/previous/pybind11/detail/class.h +626 -0
  113. ctpbee_api/ctp/include/previous/pybind11/detail/common.h +803 -0
  114. ctpbee_api/ctp/include/previous/pybind11/detail/descr.h +185 -0
  115. ctpbee_api/ctp/include/previous/pybind11/detail/init.h +335 -0
  116. ctpbee_api/ctp/include/previous/pybind11/detail/internals.h +285 -0
  117. ctpbee_api/ctp/include/previous/pybind11/detail/typeid.h +53 -0
  118. ctpbee_api/ctp/include/previous/pybind11/eigen.h +604 -0
  119. ctpbee_api/ctp/include/previous/pybind11/embed.h +194 -0
  120. ctpbee_api/ctp/include/previous/pybind11/eval.h +117 -0
  121. ctpbee_api/ctp/include/previous/pybind11/functional.h +85 -0
  122. ctpbee_api/ctp/include/previous/pybind11/iostream.h +200 -0
  123. ctpbee_api/ctp/include/previous/pybind11/numpy.h +1601 -0
  124. ctpbee_api/ctp/include/previous/pybind11/operators.h +168 -0
  125. ctpbee_api/ctp/include/previous/pybind11/options.h +65 -0
  126. ctpbee_api/ctp/include/previous/pybind11/pybind11.h +1965 -0
  127. ctpbee_api/ctp/include/previous/pybind11/pytypes.h +1332 -0
  128. ctpbee_api/ctp/include/previous/pybind11/stl.h +376 -0
  129. ctpbee_api/ctp/include/previous/pybind11/stl_bind.h +599 -0
  130. ctpbee_api/ctp/libs/libcomunicationkey.a +0 -0
  131. ctpbee_api/ctp/libs/libcrypto.a +0 -0
  132. ctpbee_api/ctp/libs/libssl.a +0 -0
  133. ctpbee_api/ctp/libs/thostmduserapi_se.lib +0 -0
  134. ctpbee_api/ctp/libs/thosttraderapi_se.lib +0 -0
  135. ctpbee_api/ctp/libthostmduserapi_se.so +0 -0
  136. ctpbee_api/ctp/libthosttraderapi_se.so +0 -0
  137. ctpbee_api/ctp/thostmduserapi_se.dll +0 -0
  138. ctpbee_api/ctp/thosttraderapi_se.dll +0 -0
  139. ctpbee_api/ctp/vnctp/vnctp.h +189 -0
  140. ctpbee_api/ctp/vnctp/vnctp.sln +41 -0
  141. ctpbee_api/ctp/vnctp/vnctpmd/dllmain.cpp +19 -0
  142. ctpbee_api/ctp/vnctp/vnctpmd/stdafx.cpp +1 -0
  143. ctpbee_api/ctp/vnctp/vnctpmd/stdafx.h +17 -0
  144. ctpbee_api/ctp/vnctp/vnctpmd/targetver.h +8 -0
  145. ctpbee_api/ctp/vnctp/vnctpmd/vnctpmd.cpp +953 -0
  146. ctpbee_api/ctp/vnctp/vnctpmd/vnctpmd.h +209 -0
  147. ctpbee_api/ctp/vnctp/vnctpmd/vnctpmd.vcxproj +200 -0
  148. ctpbee_api/ctp/vnctp/vnctpmd/vnctpmd.vcxproj.filters +54 -0
  149. ctpbee_api/ctp/vnctp/vnctpmd/vnctpmd.vcxproj.user +4 -0
  150. ctpbee_api/ctp/vnctp/vnctptd/dllmain.cpp +19 -0
  151. ctpbee_api/ctp/vnctp/vnctptd/stdafx.cpp +1 -0
  152. ctpbee_api/ctp/vnctp/vnctptd/stdafx.h +16 -0
  153. ctpbee_api/ctp/vnctp/vnctptd/targetver.h +8 -0
  154. ctpbee_api/ctp/vnctp/vnctptd/vnctptd.cpp +12148 -0
  155. ctpbee_api/ctp/vnctp/vnctptd/vnctptd.h +1329 -0
  156. ctpbee_api/ctp/vnctp/vnctptd/vnctptd.vcxproj +198 -0
  157. ctpbee_api/ctp/vnctp/vnctptd/vnctptd.vcxproj.filters +54 -0
  158. ctpbee_api/ctp/vnctp/vnctptd/vnctptd.vcxproj.user +4 -0
  159. ctpbee_api/ctp/vnctpmd.cp312-win_amd64.pyd +0 -0
  160. ctpbee_api/ctp/vnctptd.cp312-win_amd64.pyd +0 -0
  161. ctpbee_api/ctp_mini/__init__.py +3 -0
  162. ctpbee_api/ctp_mini/generator/generate_api_functions.py +343 -0
  163. ctpbee_api/ctp_mini/generator/generate_data_type.py +76 -0
  164. ctpbee_api/ctp_mini/generator/generate_struct.py +85 -0
  165. ctpbee_api/ctp_mini/generator/mini_constant.py +1186 -0
  166. ctpbee_api/ctp_mini/generator/mini_md_header_define.h +13 -0
  167. ctpbee_api/ctp_mini/generator/mini_md_header_function.h +4 -0
  168. ctpbee_api/ctp_mini/generator/mini_md_header_on.h +26 -0
  169. ctpbee_api/ctp_mini/generator/mini_md_header_process.h +26 -0
  170. ctpbee_api/ctp_mini/generator/mini_md_source_function.cpp +29 -0
  171. ctpbee_api/ctp_mini/generator/mini_md_source_module.cpp +17 -0
  172. ctpbee_api/ctp_mini/generator/mini_md_source_on.cpp +156 -0
  173. ctpbee_api/ctp_mini/generator/mini_md_source_process.cpp +264 -0
  174. ctpbee_api/ctp_mini/generator/mini_md_source_switch.cpp +78 -0
  175. ctpbee_api/ctp_mini/generator/mini_md_source_task.cpp +203 -0
  176. ctpbee_api/ctp_mini/generator/mini_struct.py +4599 -0
  177. ctpbee_api/ctp_mini/generator/mini_td_header_define.h +63 -0
  178. ctpbee_api/ctp_mini/generator/mini_td_header_function.h +84 -0
  179. ctpbee_api/ctp_mini/generator/mini_td_header_on.h +126 -0
  180. ctpbee_api/ctp_mini/generator/mini_td_header_process.h +126 -0
  181. ctpbee_api/ctp_mini/generator/mini_td_source_function.cpp +663 -0
  182. ctpbee_api/ctp_mini/generator/mini_td_source_module.cpp +107 -0
  183. ctpbee_api/ctp_mini/generator/mini_td_source_on.cpp +756 -0
  184. ctpbee_api/ctp_mini/generator/mini_td_source_process.cpp +2492 -0
  185. ctpbee_api/ctp_mini/generator/mini_td_source_switch.cpp +378 -0
  186. ctpbee_api/ctp_mini/generator/mini_td_source_task.cpp +1193 -0
  187. ctpbee_api/ctp_mini/generator/mini_typedef.py +755 -0
  188. ctpbee_api/ctp_mini/generator/package/vnminimd.cpp +886 -0
  189. ctpbee_api/ctp_mini/generator/package/vnminimd.h +205 -0
  190. ctpbee_api/ctp_mini/include/new/mini/ThostFtdcMdApi.h +148 -0
  191. ctpbee_api/ctp_mini/include/new/mini/ThostFtdcTraderApi.h +419 -0
  192. ctpbee_api/ctp_mini/include/new/mini/ThostFtdcUserApiDataType.h +6458 -0
  193. ctpbee_api/ctp_mini/include/new/mini/ThostFtdcUserApiStruct.h +8890 -0
  194. ctpbee_api/ctp_mini/include/new/pybind11/attr.h +690 -0
  195. ctpbee_api/ctp_mini/include/new/pybind11/buffer_info.h +208 -0
  196. ctpbee_api/ctp_mini/include/new/pybind11/cast.h +1704 -0
  197. ctpbee_api/ctp_mini/include/new/pybind11/chrono.h +225 -0
  198. ctpbee_api/ctp_mini/include/new/pybind11/common.h +2 -0
  199. ctpbee_api/ctp_mini/include/new/pybind11/complex.h +74 -0
  200. ctpbee_api/ctp_mini/include/new/pybind11/detail/class.h +743 -0
  201. ctpbee_api/ctp_mini/include/new/pybind11/detail/common.h +1255 -0
  202. ctpbee_api/ctp_mini/include/new/pybind11/detail/descr.h +171 -0
  203. ctpbee_api/ctp_mini/include/new/pybind11/detail/init.h +434 -0
  204. ctpbee_api/ctp_mini/include/new/pybind11/detail/internals.h +656 -0
  205. ctpbee_api/ctp_mini/include/new/pybind11/detail/type_caster_base.h +1177 -0
  206. ctpbee_api/ctp_mini/include/new/pybind11/detail/typeid.h +65 -0
  207. ctpbee_api/ctp_mini/include/new/pybind11/eigen/common.h +9 -0
  208. ctpbee_api/ctp_mini/include/new/pybind11/eigen/matrix.h +714 -0
  209. ctpbee_api/ctp_mini/include/new/pybind11/eigen/tensor.h +516 -0
  210. ctpbee_api/ctp_mini/include/new/pybind11/eigen.h +12 -0
  211. ctpbee_api/ctp_mini/include/new/pybind11/embed.h +316 -0
  212. ctpbee_api/ctp_mini/include/new/pybind11/eval.h +156 -0
  213. ctpbee_api/ctp_mini/include/new/pybind11/functional.h +137 -0
  214. ctpbee_api/ctp_mini/include/new/pybind11/gil.h +239 -0
  215. ctpbee_api/ctp_mini/include/new/pybind11/iostream.h +265 -0
  216. ctpbee_api/ctp_mini/include/new/pybind11/numpy.h +1998 -0
  217. ctpbee_api/ctp_mini/include/new/pybind11/operators.h +202 -0
  218. ctpbee_api/ctp_mini/include/new/pybind11/options.h +92 -0
  219. ctpbee_api/ctp_mini/include/new/pybind11/pybind11.h +2890 -0
  220. ctpbee_api/ctp_mini/include/new/pybind11/pytypes.h +2557 -0
  221. ctpbee_api/ctp_mini/include/new/pybind11/stl/filesystem.h +116 -0
  222. ctpbee_api/ctp_mini/include/new/pybind11/stl.h +447 -0
  223. ctpbee_api/ctp_mini/include/new/pybind11/stl_bind.h +851 -0
  224. ctpbee_api/ctp_mini/include/new/pybind11/type_caster_pyobject_ptr.h +61 -0
  225. ctpbee_api/ctp_mini/include/previous/mini/ThostFtdcMdApi.h +148 -0
  226. ctpbee_api/ctp_mini/include/previous/mini/ThostFtdcTraderApi.h +419 -0
  227. ctpbee_api/ctp_mini/include/previous/mini/ThostFtdcUserApiDataType.h +6458 -0
  228. ctpbee_api/ctp_mini/include/previous/mini/ThostFtdcUserApiStruct.h +8890 -0
  229. ctpbee_api/ctp_mini/include/previous/pybind11/attr.h +489 -0
  230. ctpbee_api/ctp_mini/include/previous/pybind11/buffer_info.h +108 -0
  231. ctpbee_api/ctp_mini/include/previous/pybind11/cast.h +2067 -0
  232. ctpbee_api/ctp_mini/include/previous/pybind11/chrono.h +162 -0
  233. ctpbee_api/ctp_mini/include/previous/pybind11/common.h +2 -0
  234. ctpbee_api/ctp_mini/include/previous/pybind11/complex.h +61 -0
  235. ctpbee_api/ctp_mini/include/previous/pybind11/detail/class.h +626 -0
  236. ctpbee_api/ctp_mini/include/previous/pybind11/detail/common.h +803 -0
  237. ctpbee_api/ctp_mini/include/previous/pybind11/detail/descr.h +185 -0
  238. ctpbee_api/ctp_mini/include/previous/pybind11/detail/init.h +335 -0
  239. ctpbee_api/ctp_mini/include/previous/pybind11/detail/internals.h +285 -0
  240. ctpbee_api/ctp_mini/include/previous/pybind11/detail/typeid.h +53 -0
  241. ctpbee_api/ctp_mini/include/previous/pybind11/eigen.h +604 -0
  242. ctpbee_api/ctp_mini/include/previous/pybind11/embed.h +194 -0
  243. ctpbee_api/ctp_mini/include/previous/pybind11/eval.h +117 -0
  244. ctpbee_api/ctp_mini/include/previous/pybind11/functional.h +85 -0
  245. ctpbee_api/ctp_mini/include/previous/pybind11/iostream.h +200 -0
  246. ctpbee_api/ctp_mini/include/previous/pybind11/numpy.h +1601 -0
  247. ctpbee_api/ctp_mini/include/previous/pybind11/operators.h +168 -0
  248. ctpbee_api/ctp_mini/include/previous/pybind11/options.h +65 -0
  249. ctpbee_api/ctp_mini/include/previous/pybind11/pybind11.h +1965 -0
  250. ctpbee_api/ctp_mini/include/previous/pybind11/pytypes.h +1332 -0
  251. ctpbee_api/ctp_mini/include/previous/pybind11/stl.h +376 -0
  252. ctpbee_api/ctp_mini/include/previous/pybind11/stl_bind.h +599 -0
  253. ctpbee_api/ctp_mini/libs/thostmduserapi.lib +0 -0
  254. ctpbee_api/ctp_mini/libs/thosttraderapi.lib +0 -0
  255. ctpbee_api/ctp_mini/libthostmduserapi.so +0 -0
  256. ctpbee_api/ctp_mini/libthosttraderapi.so +0 -0
  257. ctpbee_api/ctp_mini/mini_constant.py +1186 -0
  258. ctpbee_api/ctp_mini/thostmduserapi.dll +0 -0
  259. ctpbee_api/ctp_mini/thosttraderapi.dll +0 -0
  260. ctpbee_api/ctp_mini/vnctp_mini/vnctp_mini.h +146 -0
  261. ctpbee_api/ctp_mini/vnctp_mini/vnctp_mini.sln +41 -0
  262. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/dllmain.cpp +0 -0
  263. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/stdafx.cpp +0 -0
  264. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/stdafx.h +0 -0
  265. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/targetver.h +0 -0
  266. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/vnctp_minimd.cpp +886 -0
  267. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/vnctp_minimd.h +203 -0
  268. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/vnctp_minimd.vcxproj +183 -0
  269. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/vnctp_minimd.vcxproj.filters +54 -0
  270. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minimd/vnctp_minimd.vcxproj.user +4 -0
  271. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/dllmain.cpp +0 -0
  272. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/stdafx.cpp +0 -0
  273. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/stdafx.h +0 -0
  274. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/targetver.h +0 -0
  275. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/vnctp_minitd.cpp +5716 -0
  276. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/vnctp_minitd.h +680 -0
  277. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/vnctp_minitd.vcxproj +180 -0
  278. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/vnctp_minitd.vcxproj.filters +54 -0
  279. ctpbee_api/ctp_mini/vnctp_mini/vnctp_minitd/vnctp_minitd.vcxproj.user +4 -0
  280. ctpbee_api/ctp_mini/vnctp_minimd.cp312-win_amd64.pyd +0 -0
  281. ctpbee_api/ctp_mini/vnctp_minitd.cp312-win_amd64.pyd +0 -0
  282. ctpbee_api/ctp_mini/vnctp_minitd.lib +0 -0
  283. ctpbee_api/rohon/RohonBaseV64.dll +0 -0
  284. ctpbee_api/rohon/WinDataCollect.dll +0 -0
  285. ctpbee_api/rohon/__init__.py +3 -0
  286. ctpbee_api/rohon/generator/generate_api_functions.py +348 -0
  287. ctpbee_api/rohon/generator/generate_data_type.py +76 -0
  288. ctpbee_api/rohon/generator/generate_struct.py +84 -0
  289. ctpbee_api/rohon/generator/rohon_constant.py +1242 -0
  290. ctpbee_api/rohon/generator/rohon_md_header_define.h +13 -0
  291. ctpbee_api/rohon/generator/rohon_md_header_function.h +6 -0
  292. ctpbee_api/rohon/generator/rohon_md_header_on.h +26 -0
  293. ctpbee_api/rohon/generator/rohon_md_header_process.h +26 -0
  294. ctpbee_api/rohon/generator/rohon_md_source_function.cpp +40 -0
  295. ctpbee_api/rohon/generator/rohon_md_source_module.cpp +18 -0
  296. ctpbee_api/rohon/generator/rohon_md_source_on.cpp +156 -0
  297. ctpbee_api/rohon/generator/rohon_md_source_process.cpp +271 -0
  298. ctpbee_api/rohon/generator/rohon_md_source_switch.cpp +78 -0
  299. ctpbee_api/rohon/generator/rohon_md_source_task.cpp +211 -0
  300. ctpbee_api/rohon/generator/rohon_struct.py +4958 -0
  301. ctpbee_api/rohon/generator/rohon_td_header_define.h +125 -0
  302. ctpbee_api/rohon/generator/rohon_td_header_function.h +164 -0
  303. ctpbee_api/rohon/generator/rohon_td_header_on.h +250 -0
  304. ctpbee_api/rohon/generator/rohon_td_header_process.h +250 -0
  305. ctpbee_api/rohon/generator/rohon_td_source_function.cpp +1338 -0
  306. ctpbee_api/rohon/generator/rohon_td_source_module.cpp +209 -0
  307. ctpbee_api/rohon/generator/rohon_td_source_on.cpp +1500 -0
  308. ctpbee_api/rohon/generator/rohon_td_source_process.cpp +5125 -0
  309. ctpbee_api/rohon/generator/rohon_td_source_switch.cpp +750 -0
  310. ctpbee_api/rohon/generator/rohon_td_source_task.cpp +2339 -0
  311. ctpbee_api/rohon/generator/rohon_typedef.py +781 -0
  312. ctpbee_api/rohon/include/new/pybind11/attr.h +690 -0
  313. ctpbee_api/rohon/include/new/pybind11/buffer_info.h +208 -0
  314. ctpbee_api/rohon/include/new/pybind11/cast.h +1704 -0
  315. ctpbee_api/rohon/include/new/pybind11/chrono.h +225 -0
  316. ctpbee_api/rohon/include/new/pybind11/common.h +2 -0
  317. ctpbee_api/rohon/include/new/pybind11/complex.h +74 -0
  318. ctpbee_api/rohon/include/new/pybind11/detail/class.h +743 -0
  319. ctpbee_api/rohon/include/new/pybind11/detail/common.h +1255 -0
  320. ctpbee_api/rohon/include/new/pybind11/detail/descr.h +171 -0
  321. ctpbee_api/rohon/include/new/pybind11/detail/init.h +434 -0
  322. ctpbee_api/rohon/include/new/pybind11/detail/internals.h +656 -0
  323. ctpbee_api/rohon/include/new/pybind11/detail/type_caster_base.h +1177 -0
  324. ctpbee_api/rohon/include/new/pybind11/detail/typeid.h +65 -0
  325. ctpbee_api/rohon/include/new/pybind11/eigen/common.h +9 -0
  326. ctpbee_api/rohon/include/new/pybind11/eigen/matrix.h +714 -0
  327. ctpbee_api/rohon/include/new/pybind11/eigen/tensor.h +516 -0
  328. ctpbee_api/rohon/include/new/pybind11/eigen.h +12 -0
  329. ctpbee_api/rohon/include/new/pybind11/embed.h +316 -0
  330. ctpbee_api/rohon/include/new/pybind11/eval.h +156 -0
  331. ctpbee_api/rohon/include/new/pybind11/functional.h +137 -0
  332. ctpbee_api/rohon/include/new/pybind11/gil.h +239 -0
  333. ctpbee_api/rohon/include/new/pybind11/iostream.h +265 -0
  334. ctpbee_api/rohon/include/new/pybind11/numpy.h +1998 -0
  335. ctpbee_api/rohon/include/new/pybind11/operators.h +202 -0
  336. ctpbee_api/rohon/include/new/pybind11/options.h +92 -0
  337. ctpbee_api/rohon/include/new/pybind11/pybind11.h +2890 -0
  338. ctpbee_api/rohon/include/new/pybind11/pytypes.h +2557 -0
  339. ctpbee_api/rohon/include/new/pybind11/stl/filesystem.h +116 -0
  340. ctpbee_api/rohon/include/new/pybind11/stl.h +447 -0
  341. ctpbee_api/rohon/include/new/pybind11/stl_bind.h +851 -0
  342. ctpbee_api/rohon/include/new/pybind11/type_caster_pyobject_ptr.h +61 -0
  343. ctpbee_api/rohon/include/new/rohon/ThostFtdcMdApi.h +168 -0
  344. ctpbee_api/rohon/include/new/rohon/ThostFtdcTraderApi.h +739 -0
  345. ctpbee_api/rohon/include/new/rohon/ThostFtdcUserApiDataType.h +6708 -0
  346. ctpbee_api/rohon/include/new/rohon/ThostFtdcUserApiStruct.h +9580 -0
  347. ctpbee_api/rohon/include/previous/pybind11/attr.h +489 -0
  348. ctpbee_api/rohon/include/previous/pybind11/buffer_info.h +108 -0
  349. ctpbee_api/rohon/include/previous/pybind11/cast.h +2067 -0
  350. ctpbee_api/rohon/include/previous/pybind11/chrono.h +162 -0
  351. ctpbee_api/rohon/include/previous/pybind11/common.h +2 -0
  352. ctpbee_api/rohon/include/previous/pybind11/complex.h +61 -0
  353. ctpbee_api/rohon/include/previous/pybind11/detail/class.h +626 -0
  354. ctpbee_api/rohon/include/previous/pybind11/detail/common.h +803 -0
  355. ctpbee_api/rohon/include/previous/pybind11/detail/descr.h +185 -0
  356. ctpbee_api/rohon/include/previous/pybind11/detail/init.h +335 -0
  357. ctpbee_api/rohon/include/previous/pybind11/detail/internals.h +285 -0
  358. ctpbee_api/rohon/include/previous/pybind11/detail/typeid.h +53 -0
  359. ctpbee_api/rohon/include/previous/pybind11/eigen.h +604 -0
  360. ctpbee_api/rohon/include/previous/pybind11/embed.h +194 -0
  361. ctpbee_api/rohon/include/previous/pybind11/eval.h +117 -0
  362. ctpbee_api/rohon/include/previous/pybind11/functional.h +85 -0
  363. ctpbee_api/rohon/include/previous/pybind11/iostream.h +200 -0
  364. ctpbee_api/rohon/include/previous/pybind11/numpy.h +1601 -0
  365. ctpbee_api/rohon/include/previous/pybind11/operators.h +168 -0
  366. ctpbee_api/rohon/include/previous/pybind11/options.h +65 -0
  367. ctpbee_api/rohon/include/previous/pybind11/pybind11.h +1965 -0
  368. ctpbee_api/rohon/include/previous/pybind11/pytypes.h +1332 -0
  369. ctpbee_api/rohon/include/previous/pybind11/stl.h +376 -0
  370. ctpbee_api/rohon/include/previous/pybind11/stl_bind.h +599 -0
  371. ctpbee_api/rohon/include/previous/rohon/ThostFtdcMdApi.h +168 -0
  372. ctpbee_api/rohon/include/previous/rohon/ThostFtdcTraderApi.h +739 -0
  373. ctpbee_api/rohon/include/previous/rohon/ThostFtdcUserApiDataType.h +6708 -0
  374. ctpbee_api/rohon/include/previous/rohon/ThostFtdcUserApiStruct.h +9580 -0
  375. ctpbee_api/rohon/libLinuxDataCollect.so +0 -0
  376. ctpbee_api/rohon/librohonbase.so +0 -0
  377. ctpbee_api/rohon/librohonbase.so.1.1 +0 -0
  378. ctpbee_api/rohon/librohonbase.so.1.1.0.1 +0 -0
  379. ctpbee_api/rohon/libs/thostmduserapi_se.lib +0 -0
  380. ctpbee_api/rohon/libs/thosttraderapi_se.lib +0 -0
  381. ctpbee_api/rohon/libthostmduserapi_se.so +0 -0
  382. ctpbee_api/rohon/libthosttraderapi_se.so +0 -0
  383. ctpbee_api/rohon/rohon_constant.py +1242 -0
  384. ctpbee_api/rohon/thostmduserapi_se.dll +0 -0
  385. ctpbee_api/rohon/thosttraderapi_se.dll +0 -0
  386. ctpbee_api/rohon/vnrohon/.vs/vnrohon/v15/.suo +0 -0
  387. ctpbee_api/rohon/vnrohon/.vs/vnrohon/v15/Browse.VC.db +0 -0
  388. ctpbee_api/rohon/vnrohon/.vs/vnrohon/v15/Solution.VC.db +0 -0
  389. ctpbee_api/rohon/vnrohon/vnrohon.h +147 -0
  390. ctpbee_api/rohon/vnrohon/vnrohon.sln +41 -0
  391. ctpbee_api/rohon/vnrohon/vnrohonmd/dllmain.cpp +19 -0
  392. ctpbee_api/rohon/vnrohon/vnrohonmd/framework.h +5 -0
  393. ctpbee_api/rohon/vnrohon/vnrohonmd/pch.cpp +5 -0
  394. ctpbee_api/rohon/vnrohon/vnrohonmd/pch.h +13 -0
  395. ctpbee_api/rohon/vnrohon/vnrohonmd/vnrohonmd.cpp +931 -0
  396. ctpbee_api/rohon/vnrohon/vnrohonmd/vnrohonmd.h +207 -0
  397. ctpbee_api/rohon/vnrohon/vnrohonmd/vnrohonmd.vcxproj +188 -0
  398. ctpbee_api/rohon/vnrohon/vnrohonmd/vnrohonmd.vcxproj.filters +54 -0
  399. ctpbee_api/rohon/vnrohon/vnrohonmd/vnrohonmd.vcxproj.user +4 -0
  400. ctpbee_api/rohon/vnrohon/vnrohontd/dllmain.cpp +19 -0
  401. ctpbee_api/rohon/vnrohon/vnrohontd/framework.h +5 -0
  402. ctpbee_api/rohon/vnrohon/vnrohontd/pch.cpp +5 -0
  403. ctpbee_api/rohon/vnrohon/vnrohontd/pch.h +13 -0
  404. ctpbee_api/rohon/vnrohon/vnrohontd/vnrohontd.cpp +11395 -0
  405. ctpbee_api/rohon/vnrohon/vnrohontd/vnrohontd.h +1259 -0
  406. ctpbee_api/rohon/vnrohon/vnrohontd/vnrohontd.vcxproj +188 -0
  407. ctpbee_api/rohon/vnrohon/vnrohontd/vnrohontd.vcxproj.filters +54 -0
  408. ctpbee_api/rohon/vnrohon/vnrohontd/vnrohontd.vcxproj.user +4 -0
  409. ctpbee_api/rohon/vnrohonmd.cp312-win_amd64.pyd +0 -0
  410. ctpbee_api/rohon/vnrohontd.cp312-win_amd64.pyd +0 -0
  411. ctpbee_opt_api-0.1.0.dist-info/METADATA +46 -0
  412. ctpbee_opt_api-0.1.0.dist-info/RECORD +414 -0
  413. ctpbee_opt_api-0.1.0.dist-info/WHEEL +5 -0
  414. ctpbee_opt_api-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,194 @@
1
+ /*
2
+ pybind11/embed.h: Support for embedding the interpreter
3
+
4
+ Copyright (c) 2017 Wenzel Jakob <wenzel.jakob@epfl.ch>
5
+
6
+ All rights reserved. Use of this source code is governed by a
7
+ BSD-style license that can be found in the LICENSE file.
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include "pybind11.h"
13
+ #include "eval.h"
14
+
15
+ #if defined(PYPY_VERSION)
16
+ # error Embedding the interpreter is not supported with PyPy
17
+ #endif
18
+
19
+ #if PY_MAJOR_VERSION >= 3
20
+ # define PYBIND11_EMBEDDED_MODULE_IMPL(name) \
21
+ extern "C" PyObject *pybind11_init_impl_##name() { \
22
+ return pybind11_init_wrapper_##name(); \
23
+ }
24
+ #else
25
+ # define PYBIND11_EMBEDDED_MODULE_IMPL(name) \
26
+ extern "C" void pybind11_init_impl_##name() { \
27
+ pybind11_init_wrapper_##name(); \
28
+ }
29
+ #endif
30
+
31
+ /** \rst
32
+ Add a new module to the table of builtins for the interpreter. Must be
33
+ defined in global scope. The first macro parameter is the name of the
34
+ module (without quotes). The second parameter is the variable which will
35
+ be used as the interface to add functions and classes to the module.
36
+
37
+ .. code-block:: cpp
38
+
39
+ PYBIND11_EMBEDDED_MODULE(example, m) {
40
+ // ... initialize functions and classes here
41
+ m.def("foo", []() {
42
+ return "Hello, World!";
43
+ });
44
+ }
45
+ \endrst */
46
+ #define PYBIND11_EMBEDDED_MODULE(name, variable) \
47
+ static void PYBIND11_CONCAT(pybind11_init_, name)(pybind11::module &); \
48
+ static PyObject PYBIND11_CONCAT(*pybind11_init_wrapper_, name)() { \
49
+ auto m = pybind11::module(PYBIND11_TOSTRING(name)); \
50
+ try { \
51
+ PYBIND11_CONCAT(pybind11_init_, name)(m); \
52
+ return m.ptr(); \
53
+ } catch (pybind11::error_already_set &e) { \
54
+ PyErr_SetString(PyExc_ImportError, e.what()); \
55
+ return nullptr; \
56
+ } catch (const std::exception &e) { \
57
+ PyErr_SetString(PyExc_ImportError, e.what()); \
58
+ return nullptr; \
59
+ } \
60
+ } \
61
+ PYBIND11_EMBEDDED_MODULE_IMPL(name) \
62
+ pybind11::detail::embedded_module name(PYBIND11_TOSTRING(name), \
63
+ PYBIND11_CONCAT(pybind11_init_impl_, name)); \
64
+ void PYBIND11_CONCAT(pybind11_init_, name)(pybind11::module &variable)
65
+
66
+
67
+ NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
68
+ NAMESPACE_BEGIN(detail)
69
+
70
+ /// Python 2.7/3.x compatible version of `PyImport_AppendInittab` and error checks.
71
+ struct embedded_module {
72
+ #if PY_MAJOR_VERSION >= 3
73
+ using init_t = PyObject *(*)();
74
+ #else
75
+ using init_t = void (*)();
76
+ #endif
77
+ embedded_module(const char *name, init_t init) {
78
+ if (Py_IsInitialized())
79
+ pybind11_fail("Can't add new modules after the interpreter has been initialized");
80
+
81
+ auto result = PyImport_AppendInittab(name, init);
82
+ if (result == -1)
83
+ pybind11_fail("Insufficient memory to add a new module");
84
+ }
85
+ };
86
+
87
+ NAMESPACE_END(detail)
88
+
89
+ /** \rst
90
+ Initialize the Python interpreter. No other pybind11 or CPython API functions can be
91
+ called before this is done; with the exception of `PYBIND11_EMBEDDED_MODULE`. The
92
+ optional parameter can be used to skip the registration of signal handlers (see the
93
+ Python documentation for details). Calling this function again after the interpreter
94
+ has already been initialized is a fatal error.
95
+ \endrst */
96
+ inline void initialize_interpreter(bool init_signal_handlers = true) {
97
+ if (Py_IsInitialized())
98
+ pybind11_fail("The interpreter is already running");
99
+
100
+ Py_InitializeEx(init_signal_handlers ? 1 : 0);
101
+
102
+ // Make .py files in the working directory available by default
103
+ module::import("sys").attr("path").cast<list>().append(".");
104
+ }
105
+
106
+ /** \rst
107
+ Shut down the Python interpreter. No pybind11 or CPython API functions can be called
108
+ after this. In addition, pybind11 objects must not outlive the interpreter:
109
+
110
+ .. code-block:: cpp
111
+
112
+ { // BAD
113
+ py::initialize_interpreter();
114
+ auto hello = py::str("Hello, World!");
115
+ py::finalize_interpreter();
116
+ } // <-- BOOM, hello's destructor is called after interpreter shutdown
117
+
118
+ { // GOOD
119
+ py::initialize_interpreter();
120
+ { // scoped
121
+ auto hello = py::str("Hello, World!");
122
+ } // <-- OK, hello is cleaned up properly
123
+ py::finalize_interpreter();
124
+ }
125
+
126
+ { // BETTER
127
+ py::scoped_interpreter guard{};
128
+ auto hello = py::str("Hello, World!");
129
+ }
130
+
131
+ .. warning::
132
+
133
+ The interpreter can be restarted by calling `initialize_interpreter` again.
134
+ Modules created using pybind11 can be safely re-initialized. However, Python
135
+ itself cannot completely unload binary extension modules and there are several
136
+ caveats with regard to interpreter restarting. All the details can be found
137
+ in the CPython documentation. In short, not all interpreter memory may be
138
+ freed, either due to reference cycles or user-created global data.
139
+
140
+ \endrst */
141
+ inline void finalize_interpreter() {
142
+ handle builtins(PyEval_GetBuiltins());
143
+ const char *id = PYBIND11_INTERNALS_ID;
144
+
145
+ // Get the internals pointer (without creating it if it doesn't exist). It's possible for the
146
+ // internals to be created during Py_Finalize() (e.g. if a py::capsule calls `get_internals()`
147
+ // during destruction), so we get the pointer-pointer here and check it after Py_Finalize().
148
+ detail::internals **internals_ptr_ptr = detail::get_internals_pp();
149
+ // It could also be stashed in builtins, so look there too:
150
+ if (builtins.contains(id) && isinstance<capsule>(builtins[id]))
151
+ internals_ptr_ptr = capsule(builtins[id]);
152
+
153
+ Py_Finalize();
154
+
155
+ if (internals_ptr_ptr) {
156
+ delete *internals_ptr_ptr;
157
+ *internals_ptr_ptr = nullptr;
158
+ }
159
+ }
160
+
161
+ /** \rst
162
+ Scope guard version of `initialize_interpreter` and `finalize_interpreter`.
163
+ This a move-only guard and only a single instance can exist.
164
+
165
+ .. code-block:: cpp
166
+
167
+ #include <pybind11/embed.h>
168
+
169
+ int main() {
170
+ py::scoped_interpreter guard{};
171
+ py::print(Hello, World!);
172
+ } // <-- interpreter shutdown
173
+ \endrst */
174
+ class scoped_interpreter {
175
+ public:
176
+ scoped_interpreter(bool init_signal_handlers = true) {
177
+ initialize_interpreter(init_signal_handlers);
178
+ }
179
+
180
+ scoped_interpreter(const scoped_interpreter &) = delete;
181
+ scoped_interpreter(scoped_interpreter &&other) noexcept { other.is_valid = false; }
182
+ scoped_interpreter &operator=(const scoped_interpreter &) = delete;
183
+ scoped_interpreter &operator=(scoped_interpreter &&) = delete;
184
+
185
+ ~scoped_interpreter() {
186
+ if (is_valid)
187
+ finalize_interpreter();
188
+ }
189
+
190
+ private:
191
+ bool is_valid = true;
192
+ };
193
+
194
+ NAMESPACE_END(PYBIND11_NAMESPACE)
@@ -0,0 +1,117 @@
1
+ /*
2
+ pybind11/exec.h: Support for evaluating Python expressions and statements
3
+ from strings and files
4
+
5
+ Copyright (c) 2016 Klemens Morgenstern <klemens.morgenstern@ed-chemnitz.de> and
6
+ Wenzel Jakob <wenzel.jakob@epfl.ch>
7
+
8
+ All rights reserved. Use of this source code is governed by a
9
+ BSD-style license that can be found in the LICENSE file.
10
+ */
11
+
12
+ #pragma once
13
+
14
+ #include "pybind11.h"
15
+
16
+ NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
17
+
18
+ enum eval_mode {
19
+ /// Evaluate a string containing an isolated expression
20
+ eval_expr,
21
+
22
+ /// Evaluate a string containing a single statement. Returns \c none
23
+ eval_single_statement,
24
+
25
+ /// Evaluate a string containing a sequence of statement. Returns \c none
26
+ eval_statements
27
+ };
28
+
29
+ template <eval_mode mode = eval_expr>
30
+ object eval(str expr, object global = globals(), object local = object()) {
31
+ if (!local)
32
+ local = global;
33
+
34
+ /* PyRun_String does not accept a PyObject / encoding specifier,
35
+ this seems to be the only alternative */
36
+ std::string buffer = "# -*- coding: utf-8 -*-\n" + (std::string) expr;
37
+
38
+ int start;
39
+ switch (mode) {
40
+ case eval_expr: start = Py_eval_input; break;
41
+ case eval_single_statement: start = Py_single_input; break;
42
+ case eval_statements: start = Py_file_input; break;
43
+ default: pybind11_fail("invalid evaluation mode");
44
+ }
45
+
46
+ PyObject *result = PyRun_String(buffer.c_str(), start, global.ptr(), local.ptr());
47
+ if (!result)
48
+ throw error_already_set();
49
+ return reinterpret_steal<object>(result);
50
+ }
51
+
52
+ template <eval_mode mode = eval_expr, size_t N>
53
+ object eval(const char (&s)[N], object global = globals(), object local = object()) {
54
+ /* Support raw string literals by removing common leading whitespace */
55
+ auto expr = (s[0] == '\n') ? str(module::import("textwrap").attr("dedent")(s))
56
+ : str(s);
57
+ return eval<mode>(expr, global, local);
58
+ }
59
+
60
+ inline void exec(str expr, object global = globals(), object local = object()) {
61
+ eval<eval_statements>(expr, global, local);
62
+ }
63
+
64
+ template <size_t N>
65
+ void exec(const char (&s)[N], object global = globals(), object local = object()) {
66
+ eval<eval_statements>(s, global, local);
67
+ }
68
+
69
+ template <eval_mode mode = eval_statements>
70
+ object eval_file(str fname, object global = globals(), object local = object()) {
71
+ if (!local)
72
+ local = global;
73
+
74
+ int start;
75
+ switch (mode) {
76
+ case eval_expr: start = Py_eval_input; break;
77
+ case eval_single_statement: start = Py_single_input; break;
78
+ case eval_statements: start = Py_file_input; break;
79
+ default: pybind11_fail("invalid evaluation mode");
80
+ }
81
+
82
+ int closeFile = 1;
83
+ std::string fname_str = (std::string) fname;
84
+ #if PY_VERSION_HEX >= 0x03040000
85
+ FILE *f = _Py_fopen_obj(fname.ptr(), "r");
86
+ #elif PY_VERSION_HEX >= 0x03000000
87
+ FILE *f = _Py_fopen(fname.ptr(), "r");
88
+ #else
89
+ /* No unicode support in open() :( */
90
+ auto fobj = reinterpret_steal<object>(PyFile_FromString(
91
+ const_cast<char *>(fname_str.c_str()),
92
+ const_cast<char*>("r")));
93
+ FILE *f = nullptr;
94
+ if (fobj)
95
+ f = PyFile_AsFile(fobj.ptr());
96
+ closeFile = 0;
97
+ #endif
98
+ if (!f) {
99
+ PyErr_Clear();
100
+ pybind11_fail("File \"" + fname_str + "\" could not be opened!");
101
+ }
102
+
103
+ #if PY_VERSION_HEX < 0x03000000 && defined(PYPY_VERSION)
104
+ PyObject *result = PyRun_File(f, fname_str.c_str(), start, global.ptr(),
105
+ local.ptr());
106
+ (void) closeFile;
107
+ #else
108
+ PyObject *result = PyRun_FileEx(f, fname_str.c_str(), start, global.ptr(),
109
+ local.ptr(), closeFile);
110
+ #endif
111
+
112
+ if (!result)
113
+ throw error_already_set();
114
+ return reinterpret_steal<object>(result);
115
+ }
116
+
117
+ NAMESPACE_END(PYBIND11_NAMESPACE)
@@ -0,0 +1,85 @@
1
+ /*
2
+ pybind11/functional.h: std::function<> support
3
+
4
+ Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5
+
6
+ All rights reserved. Use of this source code is governed by a
7
+ BSD-style license that can be found in the LICENSE file.
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include "pybind11.h"
13
+ #include <functional>
14
+
15
+ NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
16
+ NAMESPACE_BEGIN(detail)
17
+
18
+ template <typename Return, typename... Args>
19
+ struct type_caster<std::function<Return(Args...)>> {
20
+ using type = std::function<Return(Args...)>;
21
+ using retval_type = conditional_t<std::is_same<Return, void>::value, void_type, Return>;
22
+ using function_type = Return (*) (Args...);
23
+
24
+ public:
25
+ bool load(handle src, bool convert) {
26
+ if (src.is_none()) {
27
+ // Defer accepting None to other overloads (if we aren't in convert mode):
28
+ if (!convert) return false;
29
+ return true;
30
+ }
31
+
32
+ if (!isinstance<function>(src))
33
+ return false;
34
+
35
+ auto func = reinterpret_borrow<function>(src);
36
+
37
+ /*
38
+ When passing a C++ function as an argument to another C++
39
+ function via Python, every function call would normally involve
40
+ a full C++ -> Python -> C++ roundtrip, which can be prohibitive.
41
+ Here, we try to at least detect the case where the function is
42
+ stateless (i.e. function pointer or lambda function without
43
+ captured variables), in which case the roundtrip can be avoided.
44
+ */
45
+ if (auto cfunc = func.cpp_function()) {
46
+ auto c = reinterpret_borrow<capsule>(PyCFunction_GET_SELF(cfunc.ptr()));
47
+ auto rec = (function_record *) c;
48
+
49
+ if (rec && rec->is_stateless &&
50
+ same_type(typeid(function_type), *reinterpret_cast<const std::type_info *>(rec->data[1]))) {
51
+ struct capture { function_type f; };
52
+ value = ((capture *) &rec->data)->f;
53
+ return true;
54
+ }
55
+ }
56
+
57
+ value = [func](Args... args) -> Return {
58
+ gil_scoped_acquire acq;
59
+ object retval(func(std::forward<Args>(args)...));
60
+ /* Visual studio 2015 parser issue: need parentheses around this expression */
61
+ return (retval.template cast<Return>());
62
+ };
63
+ return true;
64
+ }
65
+
66
+ template <typename Func>
67
+ static handle cast(Func &&f_, return_value_policy policy, handle /* parent */) {
68
+ if (!f_)
69
+ return none().inc_ref();
70
+
71
+ auto result = f_.template target<function_type>();
72
+ if (result)
73
+ return cpp_function(*result, policy).release();
74
+ else
75
+ return cpp_function(std::forward<Func>(f_), policy).release();
76
+ }
77
+
78
+ PYBIND11_TYPE_CASTER(type, _("Callable[[") +
79
+ argument_loader<Args...>::arg_names() + _("], ") +
80
+ make_caster<retval_type>::name() +
81
+ _("]"));
82
+ };
83
+
84
+ NAMESPACE_END(detail)
85
+ NAMESPACE_END(PYBIND11_NAMESPACE)
@@ -0,0 +1,200 @@
1
+ /*
2
+ pybind11/iostream.h -- Tools to assist with redirecting cout and cerr to Python
3
+
4
+ Copyright (c) 2017 Henry F. Schreiner
5
+
6
+ All rights reserved. Use of this source code is governed by a
7
+ BSD-style license that can be found in the LICENSE file.
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include "pybind11.h"
13
+
14
+ #include <streambuf>
15
+ #include <ostream>
16
+ #include <string>
17
+ #include <memory>
18
+ #include <iostream>
19
+
20
+ NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
21
+ NAMESPACE_BEGIN(detail)
22
+
23
+ // Buffer that writes to Python instead of C++
24
+ class pythonbuf : public std::streambuf {
25
+ private:
26
+ using traits_type = std::streambuf::traits_type;
27
+
28
+ char d_buffer[1024];
29
+ object pywrite;
30
+ object pyflush;
31
+
32
+ int overflow(int c) {
33
+ if (!traits_type::eq_int_type(c, traits_type::eof())) {
34
+ *pptr() = traits_type::to_char_type(c);
35
+ pbump(1);
36
+ }
37
+ return sync() == 0 ? traits_type::not_eof(c) : traits_type::eof();
38
+ }
39
+
40
+ int sync() {
41
+ if (pbase() != pptr()) {
42
+ // This subtraction cannot be negative, so dropping the sign
43
+ str line(pbase(), static_cast<size_t>(pptr() - pbase()));
44
+
45
+ pywrite(line);
46
+ pyflush();
47
+
48
+ setp(pbase(), epptr());
49
+ }
50
+ return 0;
51
+ }
52
+
53
+ public:
54
+ pythonbuf(object pyostream)
55
+ : pywrite(pyostream.attr("write")),
56
+ pyflush(pyostream.attr("flush")) {
57
+ setp(d_buffer, d_buffer + sizeof(d_buffer) - 1);
58
+ }
59
+
60
+ /// Sync before destroy
61
+ ~pythonbuf() {
62
+ sync();
63
+ }
64
+ };
65
+
66
+ NAMESPACE_END(detail)
67
+
68
+
69
+ /** \rst
70
+ This a move-only guard that redirects output.
71
+
72
+ .. code-block:: cpp
73
+
74
+ #include <pybind11/iostream.h>
75
+
76
+ ...
77
+
78
+ {
79
+ py::scoped_ostream_redirect output;
80
+ std::cout << "Hello, World!"; // Python stdout
81
+ } // <-- return std::cout to normal
82
+
83
+ You can explicitly pass the c++ stream and the python object,
84
+ for example to guard stderr instead.
85
+
86
+ .. code-block:: cpp
87
+
88
+ {
89
+ py::scoped_ostream_redirect output{std::cerr, py::module::import("sys").attr("stderr")};
90
+ std::cerr << "Hello, World!";
91
+ }
92
+ \endrst */
93
+ class scoped_ostream_redirect {
94
+ protected:
95
+ std::streambuf *old;
96
+ std::ostream &costream;
97
+ detail::pythonbuf buffer;
98
+
99
+ public:
100
+ scoped_ostream_redirect(
101
+ std::ostream &costream = std::cout,
102
+ object pyostream = module::import("sys").attr("stdout"))
103
+ : costream(costream), buffer(pyostream) {
104
+ old = costream.rdbuf(&buffer);
105
+ }
106
+
107
+ ~scoped_ostream_redirect() {
108
+ costream.rdbuf(old);
109
+ }
110
+
111
+ scoped_ostream_redirect(const scoped_ostream_redirect &) = delete;
112
+ scoped_ostream_redirect(scoped_ostream_redirect &&other) = default;
113
+ scoped_ostream_redirect &operator=(const scoped_ostream_redirect &) = delete;
114
+ scoped_ostream_redirect &operator=(scoped_ostream_redirect &&) = delete;
115
+ };
116
+
117
+
118
+ /** \rst
119
+ Like `scoped_ostream_redirect`, but redirects cerr by default. This class
120
+ is provided primary to make ``py::call_guard`` easier to make.
121
+
122
+ .. code-block:: cpp
123
+
124
+ m.def("noisy_func", &noisy_func,
125
+ py::call_guard<scoped_ostream_redirect,
126
+ scoped_estream_redirect>());
127
+
128
+ \endrst */
129
+ class scoped_estream_redirect : public scoped_ostream_redirect {
130
+ public:
131
+ scoped_estream_redirect(
132
+ std::ostream &costream = std::cerr,
133
+ object pyostream = module::import("sys").attr("stderr"))
134
+ : scoped_ostream_redirect(costream,pyostream) {}
135
+ };
136
+
137
+
138
+ NAMESPACE_BEGIN(detail)
139
+
140
+ // Class to redirect output as a context manager. C++ backend.
141
+ class OstreamRedirect {
142
+ bool do_stdout_;
143
+ bool do_stderr_;
144
+ std::unique_ptr<scoped_ostream_redirect> redirect_stdout;
145
+ std::unique_ptr<scoped_estream_redirect> redirect_stderr;
146
+
147
+ public:
148
+ OstreamRedirect(bool do_stdout = true, bool do_stderr = true)
149
+ : do_stdout_(do_stdout), do_stderr_(do_stderr) {}
150
+
151
+ void enter() {
152
+ if (do_stdout_)
153
+ redirect_stdout.reset(new scoped_ostream_redirect());
154
+ if (do_stderr_)
155
+ redirect_stderr.reset(new scoped_estream_redirect());
156
+ }
157
+
158
+ void exit() {
159
+ redirect_stdout.reset();
160
+ redirect_stderr.reset();
161
+ }
162
+ };
163
+
164
+ NAMESPACE_END(detail)
165
+
166
+ /** \rst
167
+ This is a helper function to add a C++ redirect context manager to Python
168
+ instead of using a C++ guard. To use it, add the following to your binding code:
169
+
170
+ .. code-block:: cpp
171
+
172
+ #include <pybind11/iostream.h>
173
+
174
+ ...
175
+
176
+ py::add_ostream_redirect(m, "ostream_redirect");
177
+
178
+ You now have a Python context manager that redirects your output:
179
+
180
+ .. code-block:: python
181
+
182
+ with m.ostream_redirect():
183
+ m.print_to_cout_function()
184
+
185
+ This manager can optionally be told which streams to operate on:
186
+
187
+ .. code-block:: python
188
+
189
+ with m.ostream_redirect(stdout=true, stderr=true):
190
+ m.noisy_function_with_error_printing()
191
+
192
+ \endrst */
193
+ inline class_<detail::OstreamRedirect> add_ostream_redirect(module m, std::string name = "ostream_redirect") {
194
+ return class_<detail::OstreamRedirect>(m, name.c_str(), module_local())
195
+ .def(init<bool,bool>(), arg("stdout")=true, arg("stderr")=true)
196
+ .def("__enter__", &detail::OstreamRedirect::enter)
197
+ .def("__exit__", [](detail::OstreamRedirect &self, args) { self.exit(); });
198
+ }
199
+
200
+ NAMESPACE_END(PYBIND11_NAMESPACE)