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,516 @@
1
+ /*
2
+ pybind11/eigen/tensor.h: Transparent conversion for Eigen tensors
3
+
4
+ All rights reserved. Use of this source code is governed by a
5
+ BSD-style license that can be found in the LICENSE file.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "../numpy.h"
11
+ #include "common.h"
12
+
13
+ #if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
14
+ static_assert(__GNUC__ > 5, "Eigen Tensor support in pybind11 requires GCC > 5.0");
15
+ #endif
16
+
17
+ // Disable warnings for Eigen
18
+ PYBIND11_WARNING_PUSH
19
+ PYBIND11_WARNING_DISABLE_MSVC(4554)
20
+ PYBIND11_WARNING_DISABLE_MSVC(4127)
21
+ #if defined(__MINGW32__)
22
+ PYBIND11_WARNING_DISABLE_GCC("-Wmaybe-uninitialized")
23
+ #endif
24
+
25
+ #include <unsupported/Eigen/CXX11/Tensor>
26
+
27
+ PYBIND11_WARNING_POP
28
+
29
+ static_assert(EIGEN_VERSION_AT_LEAST(3, 3, 0),
30
+ "Eigen Tensor support in pybind11 requires Eigen >= 3.3.0");
31
+
32
+ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
33
+
34
+ PYBIND11_WARNING_DISABLE_MSVC(4127)
35
+
36
+ PYBIND11_NAMESPACE_BEGIN(detail)
37
+
38
+ inline bool is_tensor_aligned(const void *data) {
39
+ return (reinterpret_cast<std::size_t>(data) % EIGEN_DEFAULT_ALIGN_BYTES) == 0;
40
+ }
41
+
42
+ template <typename T>
43
+ constexpr int compute_array_flag_from_tensor() {
44
+ static_assert((static_cast<int>(T::Layout) == static_cast<int>(Eigen::RowMajor))
45
+ || (static_cast<int>(T::Layout) == static_cast<int>(Eigen::ColMajor)),
46
+ "Layout must be row or column major");
47
+ return (static_cast<int>(T::Layout) == static_cast<int>(Eigen::RowMajor)) ? array::c_style
48
+ : array::f_style;
49
+ }
50
+
51
+ template <typename T>
52
+ struct eigen_tensor_helper {};
53
+
54
+ template <typename Scalar_, int NumIndices_, int Options_, typename IndexType>
55
+ struct eigen_tensor_helper<Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType>> {
56
+ using Type = Eigen::Tensor<Scalar_, NumIndices_, Options_, IndexType>;
57
+ using ValidType = void;
58
+
59
+ static Eigen::DSizes<typename Type::Index, Type::NumIndices> get_shape(const Type &f) {
60
+ return f.dimensions();
61
+ }
62
+
63
+ static constexpr bool
64
+ is_correct_shape(const Eigen::DSizes<typename Type::Index, Type::NumIndices> & /*shape*/) {
65
+ return true;
66
+ }
67
+
68
+ template <typename T>
69
+ struct helper {};
70
+
71
+ template <size_t... Is>
72
+ struct helper<index_sequence<Is...>> {
73
+ static constexpr auto value = concat(const_name(((void) Is, "?"))...);
74
+ };
75
+
76
+ static constexpr auto dimensions_descriptor
77
+ = helper<decltype(make_index_sequence<Type::NumIndices>())>::value;
78
+
79
+ template <typename... Args>
80
+ static Type *alloc(Args &&...args) {
81
+ return new Type(std::forward<Args>(args)...);
82
+ }
83
+
84
+ static void free(Type *tensor) { delete tensor; }
85
+ };
86
+
87
+ template <typename Scalar_, typename std::ptrdiff_t... Indices, int Options_, typename IndexType>
88
+ struct eigen_tensor_helper<
89
+ Eigen::TensorFixedSize<Scalar_, Eigen::Sizes<Indices...>, Options_, IndexType>> {
90
+ using Type = Eigen::TensorFixedSize<Scalar_, Eigen::Sizes<Indices...>, Options_, IndexType>;
91
+ using ValidType = void;
92
+
93
+ static constexpr Eigen::DSizes<typename Type::Index, Type::NumIndices>
94
+ get_shape(const Type & /*f*/) {
95
+ return get_shape();
96
+ }
97
+
98
+ static constexpr Eigen::DSizes<typename Type::Index, Type::NumIndices> get_shape() {
99
+ return Eigen::DSizes<typename Type::Index, Type::NumIndices>(Indices...);
100
+ }
101
+
102
+ static bool
103
+ is_correct_shape(const Eigen::DSizes<typename Type::Index, Type::NumIndices> &shape) {
104
+ return get_shape() == shape;
105
+ }
106
+
107
+ static constexpr auto dimensions_descriptor = concat(const_name<Indices>()...);
108
+
109
+ template <typename... Args>
110
+ static Type *alloc(Args &&...args) {
111
+ Eigen::aligned_allocator<Type> allocator;
112
+ return ::new (allocator.allocate(1)) Type(std::forward<Args>(args)...);
113
+ }
114
+
115
+ static void free(Type *tensor) {
116
+ Eigen::aligned_allocator<Type> allocator;
117
+ tensor->~Type();
118
+ allocator.deallocate(tensor, 1);
119
+ }
120
+ };
121
+
122
+ template <typename Type, bool ShowDetails, bool NeedsWriteable = false>
123
+ struct get_tensor_descriptor {
124
+ static constexpr auto details
125
+ = const_name<NeedsWriteable>(", flags.writeable", "")
126
+ + const_name<static_cast<int>(Type::Layout) == static_cast<int>(Eigen::RowMajor)>(
127
+ ", flags.c_contiguous", ", flags.f_contiguous");
128
+ static constexpr auto value
129
+ = const_name("numpy.ndarray[") + npy_format_descriptor<typename Type::Scalar>::name
130
+ + const_name("[") + eigen_tensor_helper<remove_cv_t<Type>>::dimensions_descriptor
131
+ + const_name("]") + const_name<ShowDetails>(details, const_name("")) + const_name("]");
132
+ };
133
+
134
+ // When EIGEN_AVOID_STL_ARRAY is defined, Eigen::DSizes<T, 0> does not have the begin() member
135
+ // function. Falling back to a simple loop works around this issue.
136
+ //
137
+ // We need to disable the type-limits warning for the inner loop when size = 0.
138
+
139
+ PYBIND11_WARNING_PUSH
140
+ PYBIND11_WARNING_DISABLE_GCC("-Wtype-limits")
141
+
142
+ template <typename T, int size>
143
+ std::vector<T> convert_dsizes_to_vector(const Eigen::DSizes<T, size> &arr) {
144
+ std::vector<T> result(size);
145
+
146
+ for (size_t i = 0; i < size; i++) {
147
+ result[i] = arr[i];
148
+ }
149
+
150
+ return result;
151
+ }
152
+
153
+ template <typename T, int size>
154
+ Eigen::DSizes<T, size> get_shape_for_array(const array &arr) {
155
+ Eigen::DSizes<T, size> result;
156
+ const T *shape = arr.shape();
157
+ for (size_t i = 0; i < size; i++) {
158
+ result[i] = shape[i];
159
+ }
160
+
161
+ return result;
162
+ }
163
+
164
+ PYBIND11_WARNING_POP
165
+
166
+ template <typename Type>
167
+ struct type_caster<Type, typename eigen_tensor_helper<Type>::ValidType> {
168
+ static_assert(!std::is_pointer<typename Type::Scalar>::value,
169
+ PYBIND11_EIGEN_MESSAGE_POINTER_TYPES_ARE_NOT_SUPPORTED);
170
+ using Helper = eigen_tensor_helper<Type>;
171
+ static constexpr auto temp_name = get_tensor_descriptor<Type, false>::value;
172
+ PYBIND11_TYPE_CASTER(Type, temp_name);
173
+
174
+ bool load(handle src, bool convert) {
175
+ if (!convert) {
176
+ if (!isinstance<array>(src)) {
177
+ return false;
178
+ }
179
+ array temp = array::ensure(src);
180
+ if (!temp) {
181
+ return false;
182
+ }
183
+
184
+ if (!temp.dtype().is(dtype::of<typename Type::Scalar>())) {
185
+ return false;
186
+ }
187
+ }
188
+
189
+ array_t<typename Type::Scalar, compute_array_flag_from_tensor<Type>()> arr(
190
+ reinterpret_borrow<object>(src));
191
+
192
+ if (arr.ndim() != Type::NumIndices) {
193
+ return false;
194
+ }
195
+ auto shape = get_shape_for_array<typename Type::Index, Type::NumIndices>(arr);
196
+
197
+ if (!Helper::is_correct_shape(shape)) {
198
+ return false;
199
+ }
200
+
201
+ #if EIGEN_VERSION_AT_LEAST(3, 4, 0)
202
+ auto data_pointer = arr.data();
203
+ #else
204
+ // Handle Eigen bug
205
+ auto data_pointer = const_cast<typename Type::Scalar *>(arr.data());
206
+ #endif
207
+
208
+ if (is_tensor_aligned(arr.data())) {
209
+ value = Eigen::TensorMap<const Type, Eigen::Aligned>(data_pointer, shape);
210
+ } else {
211
+ value = Eigen::TensorMap<const Type>(data_pointer, shape);
212
+ }
213
+
214
+ return true;
215
+ }
216
+
217
+ static handle cast(Type &&src, return_value_policy policy, handle parent) {
218
+ if (policy == return_value_policy::reference
219
+ || policy == return_value_policy::reference_internal) {
220
+ pybind11_fail("Cannot use a reference return value policy for an rvalue");
221
+ }
222
+ return cast_impl(&src, return_value_policy::move, parent);
223
+ }
224
+
225
+ static handle cast(const Type &&src, return_value_policy policy, handle parent) {
226
+ if (policy == return_value_policy::reference
227
+ || policy == return_value_policy::reference_internal) {
228
+ pybind11_fail("Cannot use a reference return value policy for an rvalue");
229
+ }
230
+ return cast_impl(&src, return_value_policy::move, parent);
231
+ }
232
+
233
+ static handle cast(Type &src, return_value_policy policy, handle parent) {
234
+ if (policy == return_value_policy::automatic
235
+ || policy == return_value_policy::automatic_reference) {
236
+ policy = return_value_policy::copy;
237
+ }
238
+ return cast_impl(&src, policy, parent);
239
+ }
240
+
241
+ static handle cast(const Type &src, return_value_policy policy, handle parent) {
242
+ if (policy == return_value_policy::automatic
243
+ || policy == return_value_policy::automatic_reference) {
244
+ policy = return_value_policy::copy;
245
+ }
246
+ return cast(&src, policy, parent);
247
+ }
248
+
249
+ static handle cast(Type *src, return_value_policy policy, handle parent) {
250
+ if (policy == return_value_policy::automatic) {
251
+ policy = return_value_policy::take_ownership;
252
+ } else if (policy == return_value_policy::automatic_reference) {
253
+ policy = return_value_policy::reference;
254
+ }
255
+ return cast_impl(src, policy, parent);
256
+ }
257
+
258
+ static handle cast(const Type *src, return_value_policy policy, handle parent) {
259
+ if (policy == return_value_policy::automatic) {
260
+ policy = return_value_policy::take_ownership;
261
+ } else if (policy == return_value_policy::automatic_reference) {
262
+ policy = return_value_policy::reference;
263
+ }
264
+ return cast_impl(src, policy, parent);
265
+ }
266
+
267
+ template <typename C>
268
+ static handle cast_impl(C *src, return_value_policy policy, handle parent) {
269
+ object parent_object;
270
+ bool writeable = false;
271
+ switch (policy) {
272
+ case return_value_policy::move:
273
+ if (std::is_const<C>::value) {
274
+ pybind11_fail("Cannot move from a constant reference");
275
+ }
276
+
277
+ src = Helper::alloc(std::move(*src));
278
+
279
+ parent_object
280
+ = capsule(src, [](void *ptr) { Helper::free(reinterpret_cast<Type *>(ptr)); });
281
+ writeable = true;
282
+ break;
283
+
284
+ case return_value_policy::take_ownership:
285
+ if (std::is_const<C>::value) {
286
+ // This cast is ugly, and might be UB in some cases, but we don't have an
287
+ // alternative here as we must free that memory
288
+ Helper::free(const_cast<Type *>(src));
289
+ pybind11_fail("Cannot take ownership of a const reference");
290
+ }
291
+
292
+ parent_object
293
+ = capsule(src, [](void *ptr) { Helper::free(reinterpret_cast<Type *>(ptr)); });
294
+ writeable = true;
295
+ break;
296
+
297
+ case return_value_policy::copy:
298
+ writeable = true;
299
+ break;
300
+
301
+ case return_value_policy::reference:
302
+ parent_object = none();
303
+ writeable = !std::is_const<C>::value;
304
+ break;
305
+
306
+ case return_value_policy::reference_internal:
307
+ // Default should do the right thing
308
+ if (!parent) {
309
+ pybind11_fail("Cannot use reference internal when there is no parent");
310
+ }
311
+ parent_object = reinterpret_borrow<object>(parent);
312
+ writeable = !std::is_const<C>::value;
313
+ break;
314
+
315
+ default:
316
+ pybind11_fail("pybind11 bug in eigen.h, please file a bug report");
317
+ }
318
+
319
+ auto result = array_t<typename Type::Scalar, compute_array_flag_from_tensor<Type>()>(
320
+ convert_dsizes_to_vector(Helper::get_shape(*src)), src->data(), parent_object);
321
+
322
+ if (!writeable) {
323
+ array_proxy(result.ptr())->flags &= ~detail::npy_api::NPY_ARRAY_WRITEABLE_;
324
+ }
325
+
326
+ return result.release();
327
+ }
328
+ };
329
+
330
+ template <typename StoragePointerType,
331
+ bool needs_writeable,
332
+ enable_if_t<!needs_writeable, bool> = true>
333
+ StoragePointerType get_array_data_for_type(array &arr) {
334
+ #if EIGEN_VERSION_AT_LEAST(3, 4, 0)
335
+ return reinterpret_cast<StoragePointerType>(arr.data());
336
+ #else
337
+ // Handle Eigen bug
338
+ return reinterpret_cast<StoragePointerType>(const_cast<void *>(arr.data()));
339
+ #endif
340
+ }
341
+
342
+ template <typename StoragePointerType,
343
+ bool needs_writeable,
344
+ enable_if_t<needs_writeable, bool> = true>
345
+ StoragePointerType get_array_data_for_type(array &arr) {
346
+ return reinterpret_cast<StoragePointerType>(arr.mutable_data());
347
+ }
348
+
349
+ template <typename T, typename = void>
350
+ struct get_storage_pointer_type;
351
+
352
+ template <typename MapType>
353
+ struct get_storage_pointer_type<MapType, void_t<typename MapType::StoragePointerType>> {
354
+ using SPT = typename MapType::StoragePointerType;
355
+ };
356
+
357
+ template <typename MapType>
358
+ struct get_storage_pointer_type<MapType, void_t<typename MapType::PointerArgType>> {
359
+ using SPT = typename MapType::PointerArgType;
360
+ };
361
+
362
+ template <typename Type, int Options>
363
+ struct type_caster<Eigen::TensorMap<Type, Options>,
364
+ typename eigen_tensor_helper<remove_cv_t<Type>>::ValidType> {
365
+ static_assert(!std::is_pointer<typename Type::Scalar>::value,
366
+ PYBIND11_EIGEN_MESSAGE_POINTER_TYPES_ARE_NOT_SUPPORTED);
367
+ using MapType = Eigen::TensorMap<Type, Options>;
368
+ using Helper = eigen_tensor_helper<remove_cv_t<Type>>;
369
+
370
+ bool load(handle src, bool /*convert*/) {
371
+ // Note that we have a lot more checks here as we want to make sure to avoid copies
372
+ if (!isinstance<array>(src)) {
373
+ return false;
374
+ }
375
+ auto arr = reinterpret_borrow<array>(src);
376
+ if ((arr.flags() & compute_array_flag_from_tensor<Type>()) == 0) {
377
+ return false;
378
+ }
379
+
380
+ if (!arr.dtype().is(dtype::of<typename Type::Scalar>())) {
381
+ return false;
382
+ }
383
+
384
+ if (arr.ndim() != Type::NumIndices) {
385
+ return false;
386
+ }
387
+
388
+ constexpr bool is_aligned = (Options & Eigen::Aligned) != 0;
389
+
390
+ if (is_aligned && !is_tensor_aligned(arr.data())) {
391
+ return false;
392
+ }
393
+
394
+ auto shape = get_shape_for_array<typename Type::Index, Type::NumIndices>(arr);
395
+
396
+ if (!Helper::is_correct_shape(shape)) {
397
+ return false;
398
+ }
399
+
400
+ if (needs_writeable && !arr.writeable()) {
401
+ return false;
402
+ }
403
+
404
+ auto result = get_array_data_for_type<typename get_storage_pointer_type<MapType>::SPT,
405
+ needs_writeable>(arr);
406
+
407
+ value.reset(new MapType(std::move(result), std::move(shape)));
408
+
409
+ return true;
410
+ }
411
+
412
+ static handle cast(MapType &&src, return_value_policy policy, handle parent) {
413
+ return cast_impl(&src, policy, parent);
414
+ }
415
+
416
+ static handle cast(const MapType &&src, return_value_policy policy, handle parent) {
417
+ return cast_impl(&src, policy, parent);
418
+ }
419
+
420
+ static handle cast(MapType &src, return_value_policy policy, handle parent) {
421
+ if (policy == return_value_policy::automatic
422
+ || policy == return_value_policy::automatic_reference) {
423
+ policy = return_value_policy::copy;
424
+ }
425
+ return cast_impl(&src, policy, parent);
426
+ }
427
+
428
+ static handle cast(const MapType &src, return_value_policy policy, handle parent) {
429
+ if (policy == return_value_policy::automatic
430
+ || policy == return_value_policy::automatic_reference) {
431
+ policy = return_value_policy::copy;
432
+ }
433
+ return cast(&src, policy, parent);
434
+ }
435
+
436
+ static handle cast(MapType *src, return_value_policy policy, handle parent) {
437
+ if (policy == return_value_policy::automatic) {
438
+ policy = return_value_policy::take_ownership;
439
+ } else if (policy == return_value_policy::automatic_reference) {
440
+ policy = return_value_policy::reference;
441
+ }
442
+ return cast_impl(src, policy, parent);
443
+ }
444
+
445
+ static handle cast(const MapType *src, return_value_policy policy, handle parent) {
446
+ if (policy == return_value_policy::automatic) {
447
+ policy = return_value_policy::take_ownership;
448
+ } else if (policy == return_value_policy::automatic_reference) {
449
+ policy = return_value_policy::reference;
450
+ }
451
+ return cast_impl(src, policy, parent);
452
+ }
453
+
454
+ template <typename C>
455
+ static handle cast_impl(C *src, return_value_policy policy, handle parent) {
456
+ object parent_object;
457
+ constexpr bool writeable = !std::is_const<C>::value;
458
+ switch (policy) {
459
+ case return_value_policy::reference:
460
+ parent_object = none();
461
+ break;
462
+
463
+ case return_value_policy::reference_internal:
464
+ // Default should do the right thing
465
+ if (!parent) {
466
+ pybind11_fail("Cannot use reference internal when there is no parent");
467
+ }
468
+ parent_object = reinterpret_borrow<object>(parent);
469
+ break;
470
+
471
+ case return_value_policy::take_ownership:
472
+ delete src;
473
+ // fallthrough
474
+ default:
475
+ // move, take_ownership don't make any sense for a ref/map:
476
+ pybind11_fail("Invalid return_value_policy for Eigen Map type, must be either "
477
+ "reference or reference_internal");
478
+ }
479
+
480
+ auto result = array_t<typename Type::Scalar, compute_array_flag_from_tensor<Type>()>(
481
+ convert_dsizes_to_vector(Helper::get_shape(*src)),
482
+ src->data(),
483
+ std::move(parent_object));
484
+
485
+ if (!writeable) {
486
+ array_proxy(result.ptr())->flags &= ~detail::npy_api::NPY_ARRAY_WRITEABLE_;
487
+ }
488
+
489
+ return result.release();
490
+ }
491
+
492
+ #if EIGEN_VERSION_AT_LEAST(3, 4, 0)
493
+
494
+ static constexpr bool needs_writeable = !std::is_const<typename std::remove_pointer<
495
+ typename get_storage_pointer_type<MapType>::SPT>::type>::value;
496
+ #else
497
+ // Handle Eigen bug
498
+ static constexpr bool needs_writeable = !std::is_const<Type>::value;
499
+ #endif
500
+
501
+ protected:
502
+ // TODO: Move to std::optional once std::optional has more support
503
+ std::unique_ptr<MapType> value;
504
+
505
+ public:
506
+ static constexpr auto name = get_tensor_descriptor<Type, true, needs_writeable>::value;
507
+ explicit operator MapType *() { return value.get(); }
508
+ explicit operator MapType &() { return *value; }
509
+ explicit operator MapType &&() && { return std::move(*value); }
510
+
511
+ template <typename T_>
512
+ using cast_op_type = ::pybind11::detail::movable_cast_op_type<T_>;
513
+ };
514
+
515
+ PYBIND11_NAMESPACE_END(detail)
516
+ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
@@ -0,0 +1,12 @@
1
+ /*
2
+ pybind11/eigen.h: Transparent conversion for dense and sparse Eigen matrices
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 "eigen/matrix.h"