Merge pull request #2104 from nanoric/tap_wrappers

[Mod] TapGateway: roll back custom callback_wrapper to fix invalid po…
This commit is contained in:
vn.py 2019-09-23 21:15:47 +08:00 committed by GitHub
commit ff85ab7642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 159 additions and 161 deletions

Binary file not shown.

View File

@ -6,168 +6,169 @@
namespace c2py
{
// TapAPIOrderInfoNotice
struct FixedTapAPIOrderInfoNotice : ITapTrade::TapAPIOrderInfoNotice
// // TapAPIOrderInfoNotice
// struct FixedTapAPIOrderInfoNotice : ITapTrade::TapAPIOrderInfoNotice
// {
// ITapTrade::TapAPIOrderInfo order_info;
//
// // copy from original structure
// FixedTapAPIOrderInfoNotice(const ITapTrade::TapAPIOrderInfoNotice* info)
// : TapAPIOrderInfoNotice(*info), order_info(info->OrderInfo != nullptr ? *info->OrderInfo : ITapTrade::TapAPIOrderInfo{})
// {
// // fix pointer if there is one
// this->OrderInfo = info->OrderInfo != nullptr ? &this->order_info : nullptr;
// }
//
// // copy constructor
// FixedTapAPIOrderInfoNotice(const FixedTapAPIOrderInfoNotice& fixed)
// : TapAPIOrderInfoNotice(fixed), order_info(fixed.order_info)
// {
// // fix pointer if there is one
// this->OrderInfo = this->OrderInfo != nullptr ? &this->order_info : nullptr;
// }
// };
// // TapAPIPositionProfit
// struct FixedTapAPIPositionProfitNotice : ITapTrade::TapAPIPositionProfitNotice
// {
// ITapTrade::TapAPIPositionProfit data;
//
// // copy from original structure
// FixedTapAPIPositionProfitNotice(const ITapTrade::TapAPIPositionProfitNotice* info)
// : TapAPIPositionProfitNotice(*info), data(info->Data != nullptr ? *info->Data : ITapTrade::TapAPIPositionProfit{})
// {
// // fix pointer if there is one
// this->Data = info->Data != nullptr ? &this->data : nullptr;
// }
//
// // copy constructor
// FixedTapAPIPositionProfitNotice(const FixedTapAPIPositionProfitNotice& fixed)
// : TapAPIPositionProfitNotice(fixed), data(fixed.data)
// {
// // fix pointer if there is one
// this->Data = this->Data != nullptr ? &this->data : nullptr;
// }
// };
//
// namespace arg_helper
// {
// inline auto save(const ITapTrade::TapAPIOrderInfoNotice* info)
// { // match char []
// return FixedTapAPIOrderInfoNotice(info);
// }
//
// template <>
// struct loader<ITapTrade::TapAPIOrderInfoNotice>
// {
// inline FixedTapAPIOrderInfoNotice operator ()(FixedTapAPIOrderInfoNotice& val)
// {
// return val;
// }
// };
//
// inline auto save(const ITapTrade::TapAPIPositionProfitNotice* info)
// { // match char []
// return FixedTapAPIPositionProfitNotice(info);
// }
//
// template <>
// struct loader<ITapTrade::TapAPIPositionProfitNotice>
// {
// inline FixedTapAPIPositionProfitNotice operator ()(FixedTapAPIPositionProfitNotice& val)
// {
// return val;
// }
// };
// }
template<>
struct callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRspOrderAction>
{
ITapTrade::TapAPIOrderInfo order_info;
// copy from original structure
FixedTapAPIOrderInfoNotice(const ITapTrade::TapAPIOrderInfoNotice* info)
: TapAPIOrderInfoNotice(*info), order_info(info->OrderInfo != nullptr ? *info->OrderInfo : ITapTrade::TapAPIOrderInfo{})
inline static void call(ITapTrade::ITapTradeAPINotify* instance, const char* py_func_name, ITapTrade::TAPIUINT32 sessionID, ITapTrade::TAPIINT32 errorCode, const ITapTrade::TapAPIOrderActionRsp* info)
{
// fix pointer if there is one
this->OrderInfo = info->OrderInfo != nullptr ? &this->order_info : nullptr;
}
ITapTrade::TapAPIOrderInfo orderInfo;
if (info->OrderInfo != nullptr)
{
orderInfo = *info->OrderInfo;
}
ITapTrade::TapAPIOrderActionRsp copied_info = *info;
auto task = [=]() mutable
{
if (copied_info.OrderInfo != nullptr)
{
copied_info.OrderInfo = &orderInfo; // ensure pointer is pointer to the correct address(address changes after constructed lambda)
}
try
{
return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRspOrderAction>::sync(instance, py_func_name, sessionID, errorCode, &copied_info);
}
catch (const async_dispatch_exception& e)
{
async_callback_exception_handler::handle_excepiton(e);
}
// copy constructor
FixedTapAPIOrderInfoNotice(const FixedTapAPIOrderInfoNotice& fixed)
: TapAPIOrderInfoNotice(fixed), order_info(fixed.order_info)
{
// fix pointer if there is one
this->OrderInfo = this->OrderInfo != nullptr ? &this->order_info : nullptr;
};
dispatcher::instance().add(std::move(task));
}
};
// TapAPIPositionProfit
struct FixedTapAPIPositionProfitNotice : ITapTrade::TapAPIPositionProfitNotice
template<>
struct callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnOrder>
{
ITapTrade::TapAPIPositionProfit data;
// copy from original structure
FixedTapAPIPositionProfitNotice(const ITapTrade::TapAPIPositionProfitNotice* info)
: TapAPIPositionProfitNotice(*info), data(info->Data != nullptr ? *info->Data : ITapTrade::TapAPIPositionProfit{})
inline static void call(ITapTrade::ITapTradeAPINotify* instance, const char* py_func_name, const ITapTrade::TapAPIOrderInfoNotice* info)
{
// fix pointer if there is one
this->Data = info->Data != nullptr ? &this->data : nullptr;
}
// copy constructor
FixedTapAPIPositionProfitNotice(const FixedTapAPIPositionProfitNotice& fixed)
: TapAPIPositionProfitNotice(fixed), data(fixed.data)
{
// fix pointer if there is one
this->Data = this->Data != nullptr ? &this->data : nullptr;
ITapTrade::TapAPIOrderInfo orderInfo;
if (info->OrderInfo != nullptr)
{
orderInfo = *info->OrderInfo;
}
ITapTrade::TapAPIOrderInfoNotice copied_info = *info;
auto task = [=]() mutable
{
if (copied_info.OrderInfo != nullptr)
{
copied_info.OrderInfo = &orderInfo; // ensure pointer is pointer to the correct address(address changes after constructed lambda)
}
try
{
return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnOrder>::sync(instance, py_func_name, &copied_info);
}
catch (const async_dispatch_exception& e)
{
async_callback_exception_handler::handle_excepiton(e);
}
};
dispatcher::instance().add(std::move(task));
}
};
namespace arg_helper
template<>
struct callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnPositionProfit>
{
inline auto save(const ITapTrade::TapAPIOrderInfoNotice* info)
{ // match char []
return FixedTapAPIOrderInfoNotice(info);
}
template <>
struct loader<ITapTrade::TapAPIOrderInfoNotice>
inline static void call(ITapTrade::ITapTradeAPINotify* instance, const char* py_func_name, const ITapTrade::TapAPIPositionProfitNotice* info)
{
inline FixedTapAPIOrderInfoNotice operator ()(FixedTapAPIOrderInfoNotice& val)
{
return val;
}
};
inline auto save(const ITapTrade::TapAPIPositionProfitNotice* info)
{ // match char []
return FixedTapAPIPositionProfitNotice(info);
ITapTrade::TapAPIPositionProfit profit;
if (info->Data != nullptr)
{
profit = *info->Data;
}
ITapTrade::TapAPIPositionProfitNotice copied_info = *info;
auto task = [=]() mutable
{
if (copied_info.Data != nullptr)
{
copied_info.Data = &profit; // ensure pointer is pointer to the correct address(address changes after constructed lambda)
}
try
{
return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnPositionProfit>::sync(instance, py_func_name, &copied_info);
}
catch (const async_dispatch_exception& e)
{
async_callback_exception_handler::handle_excepiton(e);
}
};
dispatcher::instance().add(std::move(task));
}
template <>
struct loader<ITapTrade::TapAPIPositionProfitNotice>
{
inline FixedTapAPIPositionProfitNotice operator ()(FixedTapAPIPositionProfitNotice& val)
{
return val;
}
};
}
//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)
// {
// ITapTrade::TapAPIOrderInfo orderInfo;
// if (info->OrderInfo != nullptr)
// {
// orderInfo = *info->OrderInfo;
// }
// ITapTrade::TapAPIOrderActionRsp copied_info = *info;
// auto task = [=]() mutable
// {
// if (copied_info.OrderInfo != nullptr)
// {
// copied_info.OrderInfo = &orderInfo; // ensure pointer is pointer to the correct address(address changes after constructed lambda)
// }
// try
// {
// return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRspOrderAction>::sync(instance, py_func_name, sessionID, errorCode, &copied_info);
// }
// catch (const async_dispatch_exception& e)
// {
// async_callback_exception_handler::handle_excepiton(e);
// }
// };
// dispatcher::instance().add(std::move(task));
// }
//};
//template<>
//struct callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnOrder>
//{
// inline static void call(ITapTrade::ITapTradeAPINotify* instance, const char* py_func_name, const ITapTrade::TapAPIOrderInfoNotice* info)
// {
// ITapTrade::TapAPIOrderInfo orderInfo;
// if (info->OrderInfo != nullptr)
// {
// orderInfo = *info->OrderInfo;
// }
// ITapTrade::TapAPIOrderInfoNotice copied_info = *info;
// auto task = [=]() mutable
// {
// if (copied_info.OrderInfo != nullptr)
// {
// copied_info.OrderInfo = &orderInfo; // ensure pointer is pointer to the correct address(address changes after constructed lambda)
// }
// try
// {
// return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnOrder>::sync(instance, py_func_name, &copied_info);
// }
// catch (const async_dispatch_exception& e)
// {
// async_callback_exception_handler::handle_excepiton(e);
// }
// };
// dispatcher::instance().add(std::move(task));
// }
//};
//template<>
//struct callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnPositionProfit>
//{
// inline static void call(ITapTrade::ITapTradeAPINotify* instance, const char* py_func_name, const ITapTrade::TapAPIPositionProfitNotice* info)
// {
// ITapTrade::TapAPIPositionProfit profit;
// if (info->Data != nullptr)
// {
// profit = *info->Data;
// }
// ITapTrade::TapAPIPositionProfitNotice copied_info = *info;
// auto task = [=]() mutable
// {
// if (copied_info.Data != nullptr)
// {
// copied_info.Data = &profit; // ensure pointer is pointer to the correct address(address changes after constructed lambda)
// }
// try
// {
// return default_callback_wrapper<&ITapTrade::ITapTradeAPINotify::OnRtnPositionProfit>::sync(instance, py_func_name, &copied_info);
// }
// catch (const async_dispatch_exception& e)
// {
// async_callback_exception_handler::handle_excepiton(e);
// }
// };
// dispatcher::instance().add(std::move(task));
// }
//};
};
}

View File

@ -115,30 +115,30 @@
<TargetExt>.pyd</TargetExt>
<OutDir>$(SolutionDir)</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<IncludePath>$(ProjectDir);$(ProjectDir)include;C:\Python37\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)\libs;C:\Python37\libs;$(LibraryPath)</LibraryPath>
<IncludePath>$(ProjectDir);$(ProjectDir)include;C:\Python37\include;C:\Python373\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)\libs;C:\Python37\libs;C:\Python373\libs;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetExt>.pyd</TargetExt>
<OutDir>$(SolutionDir)</OutDir>
<IncludePath>$(ProjectDir);$(ProjectDir)include;C:\Python37\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)\libs;C:\Python37\libs;$(LibraryPath)</LibraryPath>
<IncludePath>$(ProjectDir);$(ProjectDir)include;C:\Python37\include;C:\Python373\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)\libs;C:\Python37\libs;C:\Python373\libs;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetExt>.pyd</TargetExt>
<OutDir>$(SolutionDir)</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<IncludePath>$(ProjectDir);$(ProjectDir)include;C:\Python37\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)\libs;C:\Python37\libs;$(LibraryPath)</LibraryPath>
<IncludePath>$(ProjectDir);$(ProjectDir)include;C:\Python37\include;C:\Python373\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)\libs;C:\Python37\libs;C:\Python373\libs;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetExt>.pyd</TargetExt>
<OutDir>$(SolutionDir)</OutDir>
<IncludePath>$(ProjectDir);$(ProjectDir)include;C:\Python37\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)\libs;C:\Python37\libs;$(LibraryPath)</LibraryPath>
<IncludePath>$(ProjectDir);$(ProjectDir)include;C:\Python37\include;C:\Python373\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)\libs;C:\Python37\libs;C:\Python373\libs;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>

View File

@ -98,8 +98,5 @@
<ClCompile Include="generated_files\generated_functions_10.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="generated_files\generated_functions_11.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>