我有一堆用 C++ 编写的类和 API,并在 Boost.Python 的帮助下暴露于 Python
我目前正在研究创建以下架构的可能性。
在蟒蛇中:
from boostPythonModule import *
AddFunction( boostPythonObject.Method1, args )
AddFunction( boostPythonObject.Method2, args )
AddFunction( boostPythonObject.Method2, args )
RunAll( ) # running is done by C++
在 C++ 中:
void AddFunction( boost::object method, boost::object args )
{
/// 1. Here i need to extract a real pointer to a function
/// 2. Make argument and type checking for a function under method
/// 3. Unpack all arguments to native types
/// 4. Store the pointer to a function somewhere in local storage
}
void RunAll( )
{
/// 1. run all previously stored functions and arguments for them
}
基本上,我试图将所有功能都归结为程序的本机部分。问题是我不确定是否可以从 Boost 元信息中提取所有必需的数据以通用方式执行此操作 - 在编译时我不应该知道我将调用哪些函数以及它们接受哪些参数。
几个问题:
1. 我可以访问任何共享的 Python 信息表来检查这些东西吗?
2. Boost.Python 进行类型参数检查。可以单独重复使用吗?
让我知道你的想法。
谢谢