Merge pull request #1809 from nanoric/tap
[Fix] TapApi: fixed nullptr error.
This commit is contained in:
commit
dbdb099a95
@ -1,19 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# autocxxpy version: 0.2.4
|
# autocxxpy version: 0.2.5
|
||||||
python -m autocxxpy \
|
python -m autocxxpy \
|
||||||
vntap \
|
vntap \
|
||||||
iTapTradeAPI.h TapQuoteAPI.h TapAPIError.h iTapAPIError.h \
|
iTapTradeAPI.h TapQuoteAPI.h TapAPIError.h iTapAPIError.h \
|
||||||
-I vntap/include \
|
-I vntap/include \
|
||||||
-A custom/custom_wrappers.hpp\
|
-A custom/custom_wrappers.hpp\
|
||||||
--output-dir vntap/generated_files \
|
--output-dir vntap/generated_files \
|
||||||
--pyi-output-dir . \
|
--copy-autocxxpy-includes vntap/include \
|
||||||
\
|
--pyi-output-dir . \
|
||||||
--no-clear-pyi-output \
|
\
|
||||||
\
|
--no-clear-pyi-output \
|
||||||
--output-arg-pattern \
|
\
|
||||||
"(.*API::.*(sessionID$|.*ClientBuyOrderNo$|.*ClientSellOrderNo$|.*ClientOrderNo$))|(.*Result)" \
|
--output-arg-pattern \
|
||||||
\
|
"(.*API::.*(sessionID$|.*ClientBuyOrderNo$|.*ClientSellOrderNo$|.*ClientOrderNo$))|(.*Result)" \
|
||||||
--no-callback-pattern \
|
\
|
||||||
".*API::.*"
|
--no-callback-pattern \
|
||||||
|
".*API::.*"
|
||||||
|
|
||||||
python generate_error_map.py
|
python generate_error_map.py
|
Binary file not shown.
@ -7,7 +7,7 @@ if typing.TYPE_CHECKING:
|
|||||||
from .vntap import *
|
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)
|
set a customize exception handler for async callback in this module(pyd)
|
||||||
\a handler should return True if it handles that exception,
|
\a handler should return True if it handles that exception,
|
||||||
|
@ -46,13 +46,20 @@ namespace autocxxpy
|
|||||||
template<>
|
template<>
|
||||||
struct callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRspOrderAction>
|
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;
|
ITapTrade::TapAPIOrderActionRsp copied_info = *info;
|
||||||
auto task = [=]() mutable
|
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);
|
return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRspOrderAction>::sync(instance, py_func_name, sessionID, errorCode, &copied_info);
|
||||||
};
|
};
|
||||||
dispatcher::instance().add(std::move(task));
|
dispatcher::instance().add(std::move(task));
|
||||||
@ -61,13 +68,20 @@ namespace autocxxpy
|
|||||||
template<>
|
template<>
|
||||||
struct callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnOrder>
|
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;
|
ITapTrade::TapAPIOrderInfoNotice copied_info = *info;
|
||||||
auto task = [=]() mutable
|
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);
|
return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnOrder>::sync(instance, py_func_name, &copied_info);
|
||||||
};
|
};
|
||||||
dispatcher::instance().add(std::move(task));
|
dispatcher::instance().add(std::move(task));
|
||||||
@ -77,13 +91,21 @@ namespace autocxxpy
|
|||||||
template<>
|
template<>
|
||||||
struct callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnPositionProfit>
|
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;
|
ITapTrade::TapAPIPositionProfitNotice copied_info = *info;
|
||||||
auto task = [=]() mutable
|
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);
|
return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnPositionProfit>::sync(instance, py_func_name, &copied_info);
|
||||||
};
|
};
|
||||||
dispatcher::instance().add(std::move(task));
|
dispatcher::instance().add(std::move(task));
|
||||||
|
@ -7,7 +7,7 @@ if typing.TYPE_CHECKING:
|
|||||||
from .vntap import *
|
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)
|
set a customize exception handler for async callback in this module(pyd)
|
||||||
\a handler should return True if it handles that exception,
|
\a handler should return True if it handles that exception,
|
||||||
|
Loading…
Reference in New Issue
Block a user