如何将 C# 委托连接到 boost::signal
How can I connect a C# delegate to a boost::signal
我试过这样连接
TextStore
typedef boost::signals2::signal<VOID(TextStore*, RECT*)> signal_GetCompExt;
signal_GetCompExt m_sigGetCompExt;
信号处理器
delegate VOID GetCompsitionExtDelegate(TextStore* textStore, RECT* rect);
VOID onGetCompsitionExt(TextStore* textStore, RECT* rect);
连接信号
using namespace System::Runtime::InteropServices;
m_TextStore->m_sigGetCompExt.connect(reinterpret_cast<TextStore::signal_GetCompExt::slot_type*>(Marshal::GetFunctionPointerForDelegate(gcnew GetCompsitionExtDelegate(this, &AppWrapper::onGetCompsitionExt)).ToPointer()));
但它告诉我
C2064 term does not evaluate to a function taking 2 arguments
https://github.com/Windmill-City/libtf/blob/master/libtfWrapper/AppWrapper.cpp
在构建之前设置 Boost Root
路径:TextServiceFramework\libtf\PropertySheet.props
升压版本
boost_1_74_0
typedef void (*GetCompExtCallback)(TextStore* ts, RECT* rect);
m_TextStore->m_sigGetCompExt.connect(reinterpret_cast<GetCompExtCallback>(Marshal::GetFunctionPointerForDelegate(gcnew GetCompsitionExtDelegate(this, &AppWrapper::onGetCompsitionExt)).ToPointer()));
我试过这样连接
TextStore
typedef boost::signals2::signal<VOID(TextStore*, RECT*)> signal_GetCompExt;
signal_GetCompExt m_sigGetCompExt;
信号处理器
delegate VOID GetCompsitionExtDelegate(TextStore* textStore, RECT* rect);
VOID onGetCompsitionExt(TextStore* textStore, RECT* rect);
连接信号
using namespace System::Runtime::InteropServices;
m_TextStore->m_sigGetCompExt.connect(reinterpret_cast<TextStore::signal_GetCompExt::slot_type*>(Marshal::GetFunctionPointerForDelegate(gcnew GetCompsitionExtDelegate(this, &AppWrapper::onGetCompsitionExt)).ToPointer()));
但它告诉我
C2064 term does not evaluate to a function taking 2 arguments
https://github.com/Windmill-City/libtf/blob/master/libtfWrapper/AppWrapper.cpp
在构建之前设置 Boost Root
路径:TextServiceFramework\libtf\PropertySheet.props
升压版本 boost_1_74_0
typedef void (*GetCompExtCallback)(TextStore* ts, RECT* rect);
m_TextStore->m_sigGetCompExt.connect(reinterpret_cast<GetCompExtCallback>(Marshal::GetFunctionPointerForDelegate(gcnew GetCompsitionExtDelegate(this, &AppWrapper::onGetCompsitionExt)).ToPointer()));