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,743 @@
1
+ /*
2
+ pybind11/detail/class.h: Python C API implementation details for py::class_
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 "../attr.h"
13
+ #include "../options.h"
14
+
15
+ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
16
+ PYBIND11_NAMESPACE_BEGIN(detail)
17
+
18
+ #if !defined(PYPY_VERSION)
19
+ # define PYBIND11_BUILTIN_QUALNAME
20
+ # define PYBIND11_SET_OLDPY_QUALNAME(obj, nameobj)
21
+ #else
22
+ // In PyPy, we still set __qualname__ so that we can produce reliable function type
23
+ // signatures; in CPython this macro expands to nothing:
24
+ # define PYBIND11_SET_OLDPY_QUALNAME(obj, nameobj) \
25
+ setattr((PyObject *) obj, "__qualname__", nameobj)
26
+ #endif
27
+
28
+ inline std::string get_fully_qualified_tp_name(PyTypeObject *type) {
29
+ #if !defined(PYPY_VERSION)
30
+ return type->tp_name;
31
+ #else
32
+ auto module_name = handle((PyObject *) type).attr("__module__").cast<std::string>();
33
+ if (module_name == PYBIND11_BUILTINS_MODULE)
34
+ return type->tp_name;
35
+ else
36
+ return std::move(module_name) + "." + type->tp_name;
37
+ #endif
38
+ }
39
+
40
+ inline PyTypeObject *type_incref(PyTypeObject *type) {
41
+ Py_INCREF(type);
42
+ return type;
43
+ }
44
+
45
+ #if !defined(PYPY_VERSION)
46
+
47
+ /// `pybind11_static_property.__get__()`: Always pass the class instead of the instance.
48
+ extern "C" inline PyObject *pybind11_static_get(PyObject *self, PyObject * /*ob*/, PyObject *cls) {
49
+ return PyProperty_Type.tp_descr_get(self, cls, cls);
50
+ }
51
+
52
+ /// `pybind11_static_property.__set__()`: Just like the above `__get__()`.
53
+ extern "C" inline int pybind11_static_set(PyObject *self, PyObject *obj, PyObject *value) {
54
+ PyObject *cls = PyType_Check(obj) ? obj : (PyObject *) Py_TYPE(obj);
55
+ return PyProperty_Type.tp_descr_set(self, cls, value);
56
+ }
57
+
58
+ // Forward declaration to use in `make_static_property_type()`
59
+ inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type);
60
+
61
+ /** A `static_property` is the same as a `property` but the `__get__()` and `__set__()`
62
+ methods are modified to always use the object type instead of a concrete instance.
63
+ Return value: New reference. */
64
+ inline PyTypeObject *make_static_property_type() {
65
+ constexpr auto *name = "pybind11_static_property";
66
+ auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
67
+
68
+ /* Danger zone: from now (and until PyType_Ready), make sure to
69
+ issue no Python C API calls which could potentially invoke the
70
+ garbage collector (the GC will call type_traverse(), which will in
71
+ turn find the newly constructed type in an invalid state) */
72
+ auto *heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0);
73
+ if (!heap_type) {
74
+ pybind11_fail("make_static_property_type(): error allocating type!");
75
+ }
76
+
77
+ heap_type->ht_name = name_obj.inc_ref().ptr();
78
+ # ifdef PYBIND11_BUILTIN_QUALNAME
79
+ heap_type->ht_qualname = name_obj.inc_ref().ptr();
80
+ # endif
81
+
82
+ auto *type = &heap_type->ht_type;
83
+ type->tp_name = name;
84
+ type->tp_base = type_incref(&PyProperty_Type);
85
+ type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
86
+ type->tp_descr_get = pybind11_static_get;
87
+ type->tp_descr_set = pybind11_static_set;
88
+
89
+ if (PyType_Ready(type) < 0) {
90
+ pybind11_fail("make_static_property_type(): failure in PyType_Ready()!");
91
+ }
92
+
93
+ # if PY_VERSION_HEX >= 0x030C0000
94
+ // PRE 3.12 FEATURE FREEZE. PLEASE REVIEW AFTER FREEZE.
95
+ // Since Python-3.12 property-derived types are required to
96
+ // have dynamic attributes (to set `__doc__`)
97
+ enable_dynamic_attributes(heap_type);
98
+ # endif
99
+
100
+ setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
101
+ PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
102
+
103
+ return type;
104
+ }
105
+
106
+ #else // PYPY
107
+
108
+ /** PyPy has some issues with the above C API, so we evaluate Python code instead.
109
+ This function will only be called once so performance isn't really a concern.
110
+ Return value: New reference. */
111
+ inline PyTypeObject *make_static_property_type() {
112
+ auto d = dict();
113
+ PyObject *result = PyRun_String(R"(\
114
+ class pybind11_static_property(property):
115
+ def __get__(self, obj, cls):
116
+ return property.__get__(self, cls, cls)
117
+
118
+ def __set__(self, obj, value):
119
+ cls = obj if isinstance(obj, type) else type(obj)
120
+ property.__set__(self, cls, value)
121
+ )",
122
+ Py_file_input,
123
+ d.ptr(),
124
+ d.ptr());
125
+ if (result == nullptr)
126
+ throw error_already_set();
127
+ Py_DECREF(result);
128
+ return (PyTypeObject *) d["pybind11_static_property"].cast<object>().release().ptr();
129
+ }
130
+
131
+ #endif // PYPY
132
+
133
+ /** Types with static properties need to handle `Type.static_prop = x` in a specific way.
134
+ By default, Python replaces the `static_property` itself, but for wrapped C++ types
135
+ we need to call `static_property.__set__()` in order to propagate the new value to
136
+ the underlying C++ data structure. */
137
+ extern "C" inline int pybind11_meta_setattro(PyObject *obj, PyObject *name, PyObject *value) {
138
+ // Use `_PyType_Lookup()` instead of `PyObject_GetAttr()` in order to get the raw
139
+ // descriptor (`property`) instead of calling `tp_descr_get` (`property.__get__()`).
140
+ PyObject *descr = _PyType_Lookup((PyTypeObject *) obj, name);
141
+
142
+ // The following assignment combinations are possible:
143
+ // 1. `Type.static_prop = value` --> descr_set: `Type.static_prop.__set__(value)`
144
+ // 2. `Type.static_prop = other_static_prop` --> setattro: replace existing `static_prop`
145
+ // 3. `Type.regular_attribute = value` --> setattro: regular attribute assignment
146
+ auto *const static_prop = (PyObject *) get_internals().static_property_type;
147
+ const auto call_descr_set = (descr != nullptr) && (value != nullptr)
148
+ && (PyObject_IsInstance(descr, static_prop) != 0)
149
+ && (PyObject_IsInstance(value, static_prop) == 0);
150
+ if (call_descr_set) {
151
+ // Call `static_property.__set__()` instead of replacing the `static_property`.
152
+ #if !defined(PYPY_VERSION)
153
+ return Py_TYPE(descr)->tp_descr_set(descr, obj, value);
154
+ #else
155
+ if (PyObject *result = PyObject_CallMethod(descr, "__set__", "OO", obj, value)) {
156
+ Py_DECREF(result);
157
+ return 0;
158
+ } else {
159
+ return -1;
160
+ }
161
+ #endif
162
+ } else {
163
+ // Replace existing attribute.
164
+ return PyType_Type.tp_setattro(obj, name, value);
165
+ }
166
+ }
167
+
168
+ /**
169
+ * Python 3's PyInstanceMethod_Type hides itself via its tp_descr_get, which prevents aliasing
170
+ * methods via cls.attr("m2") = cls.attr("m1"): instead the tp_descr_get returns a plain function,
171
+ * when called on a class, or a PyMethod, when called on an instance. Override that behaviour here
172
+ * to do a special case bypass for PyInstanceMethod_Types.
173
+ */
174
+ extern "C" inline PyObject *pybind11_meta_getattro(PyObject *obj, PyObject *name) {
175
+ PyObject *descr = _PyType_Lookup((PyTypeObject *) obj, name);
176
+ if (descr && PyInstanceMethod_Check(descr)) {
177
+ Py_INCREF(descr);
178
+ return descr;
179
+ }
180
+ return PyType_Type.tp_getattro(obj, name);
181
+ }
182
+
183
+ /// metaclass `__call__` function that is used to create all pybind11 objects.
184
+ extern "C" inline PyObject *pybind11_meta_call(PyObject *type, PyObject *args, PyObject *kwargs) {
185
+
186
+ // use the default metaclass call to create/initialize the object
187
+ PyObject *self = PyType_Type.tp_call(type, args, kwargs);
188
+ if (self == nullptr) {
189
+ return nullptr;
190
+ }
191
+
192
+ // This must be a pybind11 instance
193
+ auto *instance = reinterpret_cast<detail::instance *>(self);
194
+
195
+ // Ensure that the base __init__ function(s) were called
196
+ for (const auto &vh : values_and_holders(instance)) {
197
+ if (!vh.holder_constructed()) {
198
+ PyErr_Format(PyExc_TypeError,
199
+ "%.200s.__init__() must be called when overriding __init__",
200
+ get_fully_qualified_tp_name(vh.type->type).c_str());
201
+ Py_DECREF(self);
202
+ return nullptr;
203
+ }
204
+ }
205
+
206
+ return self;
207
+ }
208
+
209
+ /// Cleanup the type-info for a pybind11-registered type.
210
+ extern "C" inline void pybind11_meta_dealloc(PyObject *obj) {
211
+ auto *type = (PyTypeObject *) obj;
212
+ auto &internals = get_internals();
213
+
214
+ // A pybind11-registered type will:
215
+ // 1) be found in internals.registered_types_py
216
+ // 2) have exactly one associated `detail::type_info`
217
+ auto found_type = internals.registered_types_py.find(type);
218
+ if (found_type != internals.registered_types_py.end() && found_type->second.size() == 1
219
+ && found_type->second[0]->type == type) {
220
+
221
+ auto *tinfo = found_type->second[0];
222
+ auto tindex = std::type_index(*tinfo->cpptype);
223
+ internals.direct_conversions.erase(tindex);
224
+
225
+ if (tinfo->module_local) {
226
+ get_local_internals().registered_types_cpp.erase(tindex);
227
+ } else {
228
+ internals.registered_types_cpp.erase(tindex);
229
+ }
230
+ internals.registered_types_py.erase(tinfo->type);
231
+
232
+ // Actually just `std::erase_if`, but that's only available in C++20
233
+ auto &cache = internals.inactive_override_cache;
234
+ for (auto it = cache.begin(), last = cache.end(); it != last;) {
235
+ if (it->first == (PyObject *) tinfo->type) {
236
+ it = cache.erase(it);
237
+ } else {
238
+ ++it;
239
+ }
240
+ }
241
+
242
+ delete tinfo;
243
+ }
244
+
245
+ PyType_Type.tp_dealloc(obj);
246
+ }
247
+
248
+ /** This metaclass is assigned by default to all pybind11 types and is required in order
249
+ for static properties to function correctly. Users may override this using `py::metaclass`.
250
+ Return value: New reference. */
251
+ inline PyTypeObject *make_default_metaclass() {
252
+ constexpr auto *name = "pybind11_type";
253
+ auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
254
+
255
+ /* Danger zone: from now (and until PyType_Ready), make sure to
256
+ issue no Python C API calls which could potentially invoke the
257
+ garbage collector (the GC will call type_traverse(), which will in
258
+ turn find the newly constructed type in an invalid state) */
259
+ auto *heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0);
260
+ if (!heap_type) {
261
+ pybind11_fail("make_default_metaclass(): error allocating metaclass!");
262
+ }
263
+
264
+ heap_type->ht_name = name_obj.inc_ref().ptr();
265
+ #ifdef PYBIND11_BUILTIN_QUALNAME
266
+ heap_type->ht_qualname = name_obj.inc_ref().ptr();
267
+ #endif
268
+
269
+ auto *type = &heap_type->ht_type;
270
+ type->tp_name = name;
271
+ type->tp_base = type_incref(&PyType_Type);
272
+ type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
273
+
274
+ type->tp_call = pybind11_meta_call;
275
+
276
+ type->tp_setattro = pybind11_meta_setattro;
277
+ type->tp_getattro = pybind11_meta_getattro;
278
+
279
+ type->tp_dealloc = pybind11_meta_dealloc;
280
+
281
+ if (PyType_Ready(type) < 0) {
282
+ pybind11_fail("make_default_metaclass(): failure in PyType_Ready()!");
283
+ }
284
+
285
+ setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
286
+ PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
287
+
288
+ return type;
289
+ }
290
+
291
+ /// For multiple inheritance types we need to recursively register/deregister base pointers for any
292
+ /// base classes with pointers that are difference from the instance value pointer so that we can
293
+ /// correctly recognize an offset base class pointer. This calls a function with any offset base
294
+ /// ptrs.
295
+ inline void traverse_offset_bases(void *valueptr,
296
+ const detail::type_info *tinfo,
297
+ instance *self,
298
+ bool (*f)(void * /*parentptr*/, instance * /*self*/)) {
299
+ for (handle h : reinterpret_borrow<tuple>(tinfo->type->tp_bases)) {
300
+ if (auto *parent_tinfo = get_type_info((PyTypeObject *) h.ptr())) {
301
+ for (auto &c : parent_tinfo->implicit_casts) {
302
+ if (c.first == tinfo->cpptype) {
303
+ auto *parentptr = c.second(valueptr);
304
+ if (parentptr != valueptr) {
305
+ f(parentptr, self);
306
+ }
307
+ traverse_offset_bases(parentptr, parent_tinfo, self, f);
308
+ break;
309
+ }
310
+ }
311
+ }
312
+ }
313
+ }
314
+
315
+ inline bool register_instance_impl(void *ptr, instance *self) {
316
+ get_internals().registered_instances.emplace(ptr, self);
317
+ return true; // unused, but gives the same signature as the deregister func
318
+ }
319
+ inline bool deregister_instance_impl(void *ptr, instance *self) {
320
+ auto &registered_instances = get_internals().registered_instances;
321
+ auto range = registered_instances.equal_range(ptr);
322
+ for (auto it = range.first; it != range.second; ++it) {
323
+ if (self == it->second) {
324
+ registered_instances.erase(it);
325
+ return true;
326
+ }
327
+ }
328
+ return false;
329
+ }
330
+
331
+ inline void register_instance(instance *self, void *valptr, const type_info *tinfo) {
332
+ register_instance_impl(valptr, self);
333
+ if (!tinfo->simple_ancestors) {
334
+ traverse_offset_bases(valptr, tinfo, self, register_instance_impl);
335
+ }
336
+ }
337
+
338
+ inline bool deregister_instance(instance *self, void *valptr, const type_info *tinfo) {
339
+ bool ret = deregister_instance_impl(valptr, self);
340
+ if (!tinfo->simple_ancestors) {
341
+ traverse_offset_bases(valptr, tinfo, self, deregister_instance_impl);
342
+ }
343
+ return ret;
344
+ }
345
+
346
+ /// Instance creation function for all pybind11 types. It allocates the internal instance layout
347
+ /// for holding C++ objects and holders. Allocation is done lazily (the first time the instance is
348
+ /// cast to a reference or pointer), and initialization is done by an `__init__` function.
349
+ inline PyObject *make_new_instance(PyTypeObject *type) {
350
+ #if defined(PYPY_VERSION)
351
+ // PyPy gets tp_basicsize wrong (issue 2482) under multiple inheritance when the first
352
+ // inherited object is a plain Python type (i.e. not derived from an extension type). Fix it.
353
+ ssize_t instance_size = static_cast<ssize_t>(sizeof(instance));
354
+ if (type->tp_basicsize < instance_size) {
355
+ type->tp_basicsize = instance_size;
356
+ }
357
+ #endif
358
+ PyObject *self = type->tp_alloc(type, 0);
359
+ auto *inst = reinterpret_cast<instance *>(self);
360
+ // Allocate the value/holder internals:
361
+ inst->allocate_layout();
362
+
363
+ return self;
364
+ }
365
+
366
+ /// Instance creation function for all pybind11 types. It only allocates space for the
367
+ /// C++ object, but doesn't call the constructor -- an `__init__` function must do that.
368
+ extern "C" inline PyObject *pybind11_object_new(PyTypeObject *type, PyObject *, PyObject *) {
369
+ return make_new_instance(type);
370
+ }
371
+
372
+ /// An `__init__` function constructs the C++ object. Users should provide at least one
373
+ /// of these using `py::init` or directly with `.def(__init__, ...)`. Otherwise, the
374
+ /// following default function will be used which simply throws an exception.
375
+ extern "C" inline int pybind11_object_init(PyObject *self, PyObject *, PyObject *) {
376
+ PyTypeObject *type = Py_TYPE(self);
377
+ std::string msg = get_fully_qualified_tp_name(type) + ": No constructor defined!";
378
+ PyErr_SetString(PyExc_TypeError, msg.c_str());
379
+ return -1;
380
+ }
381
+
382
+ inline void add_patient(PyObject *nurse, PyObject *patient) {
383
+ auto &internals = get_internals();
384
+ auto *instance = reinterpret_cast<detail::instance *>(nurse);
385
+ instance->has_patients = true;
386
+ Py_INCREF(patient);
387
+ internals.patients[nurse].push_back(patient);
388
+ }
389
+
390
+ inline void clear_patients(PyObject *self) {
391
+ auto *instance = reinterpret_cast<detail::instance *>(self);
392
+ auto &internals = get_internals();
393
+ auto pos = internals.patients.find(self);
394
+ assert(pos != internals.patients.end());
395
+ // Clearing the patients can cause more Python code to run, which
396
+ // can invalidate the iterator. Extract the vector of patients
397
+ // from the unordered_map first.
398
+ auto patients = std::move(pos->second);
399
+ internals.patients.erase(pos);
400
+ instance->has_patients = false;
401
+ for (PyObject *&patient : patients) {
402
+ Py_CLEAR(patient);
403
+ }
404
+ }
405
+
406
+ /// Clears all internal data from the instance and removes it from registered instances in
407
+ /// preparation for deallocation.
408
+ inline void clear_instance(PyObject *self) {
409
+ auto *instance = reinterpret_cast<detail::instance *>(self);
410
+
411
+ // Deallocate any values/holders, if present:
412
+ for (auto &v_h : values_and_holders(instance)) {
413
+ if (v_h) {
414
+
415
+ // We have to deregister before we call dealloc because, for virtual MI types, we still
416
+ // need to be able to get the parent pointers.
417
+ if (v_h.instance_registered()
418
+ && !deregister_instance(instance, v_h.value_ptr(), v_h.type)) {
419
+ pybind11_fail(
420
+ "pybind11_object_dealloc(): Tried to deallocate unregistered instance!");
421
+ }
422
+
423
+ if (instance->owned || v_h.holder_constructed()) {
424
+ v_h.type->dealloc(v_h);
425
+ }
426
+ }
427
+ }
428
+ // Deallocate the value/holder layout internals:
429
+ instance->deallocate_layout();
430
+
431
+ if (instance->weakrefs) {
432
+ PyObject_ClearWeakRefs(self);
433
+ }
434
+
435
+ PyObject **dict_ptr = _PyObject_GetDictPtr(self);
436
+ if (dict_ptr) {
437
+ Py_CLEAR(*dict_ptr);
438
+ }
439
+
440
+ if (instance->has_patients) {
441
+ clear_patients(self);
442
+ }
443
+ }
444
+
445
+ /// Instance destructor function for all pybind11 types. It calls `type_info.dealloc`
446
+ /// to destroy the C++ object itself, while the rest is Python bookkeeping.
447
+ extern "C" inline void pybind11_object_dealloc(PyObject *self) {
448
+ auto *type = Py_TYPE(self);
449
+
450
+ // If this is a GC tracked object, untrack it first
451
+ // Note that the track call is implicitly done by the
452
+ // default tp_alloc, which we never override.
453
+ if (PyType_HasFeature(type, Py_TPFLAGS_HAVE_GC) != 0) {
454
+ PyObject_GC_UnTrack(self);
455
+ }
456
+
457
+ clear_instance(self);
458
+
459
+ type->tp_free(self);
460
+
461
+ #if PY_VERSION_HEX < 0x03080000
462
+ // `type->tp_dealloc != pybind11_object_dealloc` means that we're being called
463
+ // as part of a derived type's dealloc, in which case we're not allowed to decref
464
+ // the type here. For cross-module compatibility, we shouldn't compare directly
465
+ // with `pybind11_object_dealloc`, but with the common one stashed in internals.
466
+ auto pybind11_object_type = (PyTypeObject *) get_internals().instance_base;
467
+ if (type->tp_dealloc == pybind11_object_type->tp_dealloc)
468
+ Py_DECREF(type);
469
+ #else
470
+ // This was not needed before Python 3.8 (Python issue 35810)
471
+ // https://github.com/pybind/pybind11/issues/1946
472
+ Py_DECREF(type);
473
+ #endif
474
+ }
475
+
476
+ std::string error_string();
477
+
478
+ /** Create the type which can be used as a common base for all classes. This is
479
+ needed in order to satisfy Python's requirements for multiple inheritance.
480
+ Return value: New reference. */
481
+ inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
482
+ constexpr auto *name = "pybind11_object";
483
+ auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
484
+
485
+ /* Danger zone: from now (and until PyType_Ready), make sure to
486
+ issue no Python C API calls which could potentially invoke the
487
+ garbage collector (the GC will call type_traverse(), which will in
488
+ turn find the newly constructed type in an invalid state) */
489
+ auto *heap_type = (PyHeapTypeObject *) metaclass->tp_alloc(metaclass, 0);
490
+ if (!heap_type) {
491
+ pybind11_fail("make_object_base_type(): error allocating type!");
492
+ }
493
+
494
+ heap_type->ht_name = name_obj.inc_ref().ptr();
495
+ #ifdef PYBIND11_BUILTIN_QUALNAME
496
+ heap_type->ht_qualname = name_obj.inc_ref().ptr();
497
+ #endif
498
+
499
+ auto *type = &heap_type->ht_type;
500
+ type->tp_name = name;
501
+ type->tp_base = type_incref(&PyBaseObject_Type);
502
+ type->tp_basicsize = static_cast<ssize_t>(sizeof(instance));
503
+ type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
504
+
505
+ type->tp_new = pybind11_object_new;
506
+ type->tp_init = pybind11_object_init;
507
+ type->tp_dealloc = pybind11_object_dealloc;
508
+
509
+ /* Support weak references (needed for the keep_alive feature) */
510
+ type->tp_weaklistoffset = offsetof(instance, weakrefs);
511
+
512
+ if (PyType_Ready(type) < 0) {
513
+ pybind11_fail("PyType_Ready failed in make_object_base_type(): " + error_string());
514
+ }
515
+
516
+ setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
517
+ PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
518
+
519
+ assert(!PyType_HasFeature(type, Py_TPFLAGS_HAVE_GC));
520
+ return (PyObject *) heap_type;
521
+ }
522
+
523
+ /// dynamic_attr: Allow the garbage collector to traverse the internal instance `__dict__`.
524
+ extern "C" inline int pybind11_traverse(PyObject *self, visitproc visit, void *arg) {
525
+ PyObject *&dict = *_PyObject_GetDictPtr(self);
526
+ Py_VISIT(dict);
527
+ // https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_traverse
528
+ #if PY_VERSION_HEX >= 0x03090000
529
+ Py_VISIT(Py_TYPE(self));
530
+ #endif
531
+ return 0;
532
+ }
533
+
534
+ /// dynamic_attr: Allow the GC to clear the dictionary.
535
+ extern "C" inline int pybind11_clear(PyObject *self) {
536
+ PyObject *&dict = *_PyObject_GetDictPtr(self);
537
+ Py_CLEAR(dict);
538
+ return 0;
539
+ }
540
+
541
+ /// Give instances of this type a `__dict__` and opt into garbage collection.
542
+ inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
543
+ auto *type = &heap_type->ht_type;
544
+ type->tp_flags |= Py_TPFLAGS_HAVE_GC;
545
+ #if PY_VERSION_HEX < 0x030B0000
546
+ type->tp_dictoffset = type->tp_basicsize; // place dict at the end
547
+ type->tp_basicsize += (ssize_t) sizeof(PyObject *); // and allocate enough space for it
548
+ #else
549
+ type->tp_flags |= Py_TPFLAGS_MANAGED_DICT;
550
+ #endif
551
+ type->tp_traverse = pybind11_traverse;
552
+ type->tp_clear = pybind11_clear;
553
+
554
+ static PyGetSetDef getset[] = {{
555
+ #if PY_VERSION_HEX < 0x03070000
556
+ const_cast<char *>("__dict__"),
557
+ #else
558
+ "__dict__",
559
+ #endif
560
+ PyObject_GenericGetDict,
561
+ PyObject_GenericSetDict,
562
+ nullptr,
563
+ nullptr},
564
+ {nullptr, nullptr, nullptr, nullptr, nullptr}};
565
+ type->tp_getset = getset;
566
+ }
567
+
568
+ /// buffer_protocol: Fill in the view as specified by flags.
569
+ extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int flags) {
570
+ // Look for a `get_buffer` implementation in this type's info or any bases (following MRO).
571
+ type_info *tinfo = nullptr;
572
+ for (auto type : reinterpret_borrow<tuple>(Py_TYPE(obj)->tp_mro)) {
573
+ tinfo = get_type_info((PyTypeObject *) type.ptr());
574
+ if (tinfo && tinfo->get_buffer) {
575
+ break;
576
+ }
577
+ }
578
+ if (view == nullptr || !tinfo || !tinfo->get_buffer) {
579
+ if (view) {
580
+ view->obj = nullptr;
581
+ }
582
+ PyErr_SetString(PyExc_BufferError, "pybind11_getbuffer(): Internal error");
583
+ return -1;
584
+ }
585
+ std::memset(view, 0, sizeof(Py_buffer));
586
+ buffer_info *info = tinfo->get_buffer(obj, tinfo->get_buffer_data);
587
+ if ((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE && info->readonly) {
588
+ delete info;
589
+ // view->obj = nullptr; // Was just memset to 0, so not necessary
590
+ PyErr_SetString(PyExc_BufferError, "Writable buffer requested for readonly storage");
591
+ return -1;
592
+ }
593
+ view->obj = obj;
594
+ view->ndim = 1;
595
+ view->internal = info;
596
+ view->buf = info->ptr;
597
+ view->itemsize = info->itemsize;
598
+ view->len = view->itemsize;
599
+ for (auto s : info->shape) {
600
+ view->len *= s;
601
+ }
602
+ view->readonly = static_cast<int>(info->readonly);
603
+ if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) {
604
+ view->format = const_cast<char *>(info->format.c_str());
605
+ }
606
+ if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) {
607
+ view->ndim = (int) info->ndim;
608
+ view->strides = info->strides.data();
609
+ view->shape = info->shape.data();
610
+ }
611
+ Py_INCREF(view->obj);
612
+ return 0;
613
+ }
614
+
615
+ /// buffer_protocol: Release the resources of the buffer.
616
+ extern "C" inline void pybind11_releasebuffer(PyObject *, Py_buffer *view) {
617
+ delete (buffer_info *) view->internal;
618
+ }
619
+
620
+ /// Give this type a buffer interface.
621
+ inline void enable_buffer_protocol(PyHeapTypeObject *heap_type) {
622
+ heap_type->ht_type.tp_as_buffer = &heap_type->as_buffer;
623
+
624
+ heap_type->as_buffer.bf_getbuffer = pybind11_getbuffer;
625
+ heap_type->as_buffer.bf_releasebuffer = pybind11_releasebuffer;
626
+ }
627
+
628
+ /** Create a brand new Python type according to the `type_record` specification.
629
+ Return value: New reference. */
630
+ inline PyObject *make_new_python_type(const type_record &rec) {
631
+ auto name = reinterpret_steal<object>(PYBIND11_FROM_STRING(rec.name));
632
+
633
+ auto qualname = name;
634
+ if (rec.scope && !PyModule_Check(rec.scope.ptr()) && hasattr(rec.scope, "__qualname__")) {
635
+ qualname = reinterpret_steal<object>(
636
+ PyUnicode_FromFormat("%U.%U", rec.scope.attr("__qualname__").ptr(), name.ptr()));
637
+ }
638
+
639
+ object module_;
640
+ if (rec.scope) {
641
+ if (hasattr(rec.scope, "__module__")) {
642
+ module_ = rec.scope.attr("__module__");
643
+ } else if (hasattr(rec.scope, "__name__")) {
644
+ module_ = rec.scope.attr("__name__");
645
+ }
646
+ }
647
+
648
+ const auto *full_name = c_str(
649
+ #if !defined(PYPY_VERSION)
650
+ module_ ? str(module_).cast<std::string>() + "." + rec.name :
651
+ #endif
652
+ rec.name);
653
+
654
+ char *tp_doc = nullptr;
655
+ if (rec.doc && options::show_user_defined_docstrings()) {
656
+ /* Allocate memory for docstring (using PyObject_MALLOC, since
657
+ Python will free this later on) */
658
+ size_t size = std::strlen(rec.doc) + 1;
659
+ tp_doc = (char *) PyObject_MALLOC(size);
660
+ std::memcpy((void *) tp_doc, rec.doc, size);
661
+ }
662
+
663
+ auto &internals = get_internals();
664
+ auto bases = tuple(rec.bases);
665
+ auto *base = (bases.empty()) ? internals.instance_base : bases[0].ptr();
666
+
667
+ /* Danger zone: from now (and until PyType_Ready), make sure to
668
+ issue no Python C API calls which could potentially invoke the
669
+ garbage collector (the GC will call type_traverse(), which will in
670
+ turn find the newly constructed type in an invalid state) */
671
+ auto *metaclass
672
+ = rec.metaclass.ptr() ? (PyTypeObject *) rec.metaclass.ptr() : internals.default_metaclass;
673
+
674
+ auto *heap_type = (PyHeapTypeObject *) metaclass->tp_alloc(metaclass, 0);
675
+ if (!heap_type) {
676
+ pybind11_fail(std::string(rec.name) + ": Unable to create type object!");
677
+ }
678
+
679
+ heap_type->ht_name = name.release().ptr();
680
+ #ifdef PYBIND11_BUILTIN_QUALNAME
681
+ heap_type->ht_qualname = qualname.inc_ref().ptr();
682
+ #endif
683
+
684
+ auto *type = &heap_type->ht_type;
685
+ type->tp_name = full_name;
686
+ type->tp_doc = tp_doc;
687
+ type->tp_base = type_incref((PyTypeObject *) base);
688
+ type->tp_basicsize = static_cast<ssize_t>(sizeof(instance));
689
+ if (!bases.empty()) {
690
+ type->tp_bases = bases.release().ptr();
691
+ }
692
+
693
+ /* Don't inherit base __init__ */
694
+ type->tp_init = pybind11_object_init;
695
+
696
+ /* Supported protocols */
697
+ type->tp_as_number = &heap_type->as_number;
698
+ type->tp_as_sequence = &heap_type->as_sequence;
699
+ type->tp_as_mapping = &heap_type->as_mapping;
700
+ type->tp_as_async = &heap_type->as_async;
701
+
702
+ /* Flags */
703
+ type->tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE;
704
+ if (!rec.is_final) {
705
+ type->tp_flags |= Py_TPFLAGS_BASETYPE;
706
+ }
707
+
708
+ if (rec.dynamic_attr) {
709
+ enable_dynamic_attributes(heap_type);
710
+ }
711
+
712
+ if (rec.buffer_protocol) {
713
+ enable_buffer_protocol(heap_type);
714
+ }
715
+
716
+ if (rec.custom_type_setup_callback) {
717
+ rec.custom_type_setup_callback(heap_type);
718
+ }
719
+
720
+ if (PyType_Ready(type) < 0) {
721
+ pybind11_fail(std::string(rec.name) + ": PyType_Ready failed: " + error_string());
722
+ }
723
+
724
+ assert(!rec.dynamic_attr || PyType_HasFeature(type, Py_TPFLAGS_HAVE_GC));
725
+
726
+ /* Register type with the parent scope */
727
+ if (rec.scope) {
728
+ setattr(rec.scope, rec.name, (PyObject *) type);
729
+ } else {
730
+ Py_INCREF(type); // Keep it alive forever (reference leak)
731
+ }
732
+
733
+ if (module_) { // Needed by pydoc
734
+ setattr((PyObject *) type, "__module__", module_);
735
+ }
736
+
737
+ PYBIND11_SET_OLDPY_QUALNAME(type, qualname);
738
+
739
+ return (PyObject *) type;
740
+ }
741
+
742
+ PYBIND11_NAMESPACE_END(detail)
743
+ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)