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