diff --git a/vnpy/api/tap/TapQuoteAPI.dll b/vnpy/api/tap/TapQuoteAPI.dll index e0c7cee7..3ff68b41 100644 Binary files a/vnpy/api/tap/TapQuoteAPI.dll and b/vnpy/api/tap/TapQuoteAPI.dll differ diff --git a/vnpy/api/tap/generate_tap.sh b/vnpy/api/tap/generate_tap.sh index 8ef1addc..706cac18 100644 --- a/vnpy/api/tap/generate_tap.sh +++ b/vnpy/api/tap/generate_tap.sh @@ -1,19 +1,20 @@ #!/usr/bin/env bash -# autocxxpy version: 0.2.4 +# autocxxpy version: 0.2.5 python -m autocxxpy \ - vntap \ - iTapTradeAPI.h TapQuoteAPI.h TapAPIError.h iTapAPIError.h \ - -I vntap/include \ - -A custom/custom_wrappers.hpp\ - --output-dir vntap/generated_files \ - --pyi-output-dir . \ - \ - --no-clear-pyi-output \ - \ - --output-arg-pattern \ - "(.*API::.*(sessionID$|.*ClientBuyOrderNo$|.*ClientSellOrderNo$|.*ClientOrderNo$))|(.*Result)" \ - \ - --no-callback-pattern \ - ".*API::.*" + vntap \ + iTapTradeAPI.h TapQuoteAPI.h TapAPIError.h iTapAPIError.h \ + -I vntap/include \ + -A custom/custom_wrappers.hpp\ + --output-dir vntap/generated_files \ + --copy-autocxxpy-includes vntap/include \ + --pyi-output-dir . \ + \ + --no-clear-pyi-output \ + \ + --output-arg-pattern \ + "(.*API::.*(sessionID$|.*ClientBuyOrderNo$|.*ClientSellOrderNo$|.*ClientOrderNo$))|(.*Result)" \ + \ + --no-callback-pattern \ + ".*API::.*" python generate_error_map.py \ No newline at end of file diff --git a/vnpy/api/tap/vntap.pyd b/vnpy/api/tap/vntap.pyd index 9406f1ff..9837a4cb 100644 Binary files a/vnpy/api/tap/vntap.pyd and b/vnpy/api/tap/vntap.pyd differ diff --git a/vnpy/api/tap/vntap.pyi b/vnpy/api/tap/vntap.pyi index e78564e2..15d05e82 100644 --- a/vnpy/api/tap/vntap.pyi +++ b/vnpy/api/tap/vntap.pyi @@ -7,7 +7,7 @@ if typing.TYPE_CHECKING: from .vntap import * -def set_async_callback_exception_handler(handler: Callable[[AsyncDispatchException], bool]): +def set_async_callback_exception_handler(handler: Callable[[AsyncDispatchException], None]): """ set a customize exception handler for async callback in this module(pyd) \a handler should return True if it handles that exception, diff --git a/vnpy/api/tap/vntap/custom/custom_wrappers.hpp b/vnpy/api/tap/vntap/custom/custom_wrappers.hpp index c3c92b6c..46faf958 100644 --- a/vnpy/api/tap/vntap/custom/custom_wrappers.hpp +++ b/vnpy/api/tap/vntap/custom/custom_wrappers.hpp @@ -46,13 +46,20 @@ namespace autocxxpy template<> struct callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRspOrderAction> { - inline static void call(ITapTrade::ITapTradeAPINotify* instance, const char*py_func_name, ITapTrade::TAPIUINT32 sessionID, ITapTrade::TAPIINT32 errorCode, const ITapTrade::TapAPIOrderActionRsp* info) + inline static void call(ITapTrade::ITapTradeAPINotify* instance, const char* py_func_name, ITapTrade::TAPIUINT32 sessionID, ITapTrade::TAPIINT32 errorCode, const ITapTrade::TapAPIOrderActionRsp* info) { - ITapTrade::TapAPIOrderInfo orderInfo = *info->OrderInfo; + ITapTrade::TapAPIOrderInfo orderInfo; + if (info->OrderInfo != nullptr) + { + orderInfo = *info->OrderInfo; + } ITapTrade::TapAPIOrderActionRsp copied_info = *info; auto task = [=]() mutable { - copied_info.OrderInfo = &orderInfo; // ensure pointer is pointer to the correct address(address changes after constructed lambda) + if (copied_info.OrderInfo != nullptr) + { + copied_info.OrderInfo = &orderInfo; // ensure pointer is pointer to the correct address(address changes after constructed lambda) + } return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRspOrderAction>::sync(instance, py_func_name, sessionID, errorCode, &copied_info); }; dispatcher::instance().add(std::move(task)); @@ -61,13 +68,20 @@ namespace autocxxpy template<> struct callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnOrder> { - inline static void call(ITapTrade::ITapTradeAPINotify* instance, const char*py_func_name, const ITapTrade::TapAPIOrderInfoNotice* info) + inline static void call(ITapTrade::ITapTradeAPINotify* instance, const char* py_func_name, const ITapTrade::TapAPIOrderInfoNotice* info) { - ITapTrade::TapAPIOrderInfo orderInfo = *info->OrderInfo; + ITapTrade::TapAPIOrderInfo orderInfo; + if (info->OrderInfo != nullptr) + { + orderInfo = *info->OrderInfo; + } ITapTrade::TapAPIOrderInfoNotice copied_info = *info; auto task = [=]() mutable { - copied_info.OrderInfo = &orderInfo; // ensure pointer is pointer to the correct address(address changes after constructed lambda) + if (copied_info.OrderInfo != nullptr) + { + copied_info.OrderInfo = &orderInfo; // ensure pointer is pointer to the correct address(address changes after constructed lambda) + } return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnOrder>::sync(instance, py_func_name, &copied_info); }; dispatcher::instance().add(std::move(task)); @@ -77,13 +91,21 @@ namespace autocxxpy template<> struct callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnPositionProfit> { - inline static void call(ITapTrade::ITapTradeAPINotify* instance, const char*py_func_name, const ITapTrade::TapAPIPositionProfitNotice* info) + inline static void call(ITapTrade::ITapTradeAPINotify* instance, const char* py_func_name, const ITapTrade::TapAPIPositionProfitNotice* info) { - ITapTrade::TapAPIPositionProfit profit = *info->Data; + + ITapTrade::TapAPIPositionProfit profit; + if (info->Data != nullptr) + { + profit = *info->Data; + } ITapTrade::TapAPIPositionProfitNotice copied_info = *info; auto task = [=]() mutable { - copied_info.Data = &profit; // ensure pointer is pointer to the correct address(address changes after constructed lambda) + if (copied_info.Data != nullptr) + { + copied_info.Data = &profit; // ensure pointer is pointer to the correct address(address changes after constructed lambda) + } return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnPositionProfit>::sync(instance, py_func_name, &copied_info); }; dispatcher::instance().add(std::move(task)); diff --git a/vnpy/api/tap/vntap/libs/TapQuoteAPI.lib b/vnpy/api/tap/vntap/libs/TapQuoteAPI.lib index 86af933f..359d3562 100644 Binary files a/vnpy/api/tap/vntap/libs/TapQuoteAPI.lib and b/vnpy/api/tap/vntap/libs/TapQuoteAPI.lib differ diff --git a/vnpy/api/tap/vntap_ITapTrade.pyi b/vnpy/api/tap/vntap_ITapTrade.pyi index 2be7b3a7..2ded0e27 100644 --- a/vnpy/api/tap/vntap_ITapTrade.pyi +++ b/vnpy/api/tap/vntap_ITapTrade.pyi @@ -7,7 +7,7 @@ if typing.TYPE_CHECKING: from .vntap import * -def set_async_callback_exception_handler(handler: Callable[[AsyncDispatchException], bool]): +def set_async_callback_exception_handler(handler: Callable[[AsyncDispatchException], None]): """ set a customize exception handler for async callback in this module(pyd) \a handler should return True if it handles that exception,