SWIG/Lua typemap for Boost Array in
SWIG/Lua typemap for Boost Array in
我正在尝试构建一个类型图(in)以用于C++提升scoped_arrays。我有C++函数来获取提升数组,但我想将它们传递给 Lua 列表。
我看过Python的例子,但它们似乎包含太多特定于Python的代码。
有没有人得到帮助或指向示例的指示来让我入门?
你可以使用这样的东西:
%{
#include <boost/scoped_array.hpp>
%}
namespace boost {
template<class T>
class scoped_array {
public:
scoped_array();
~scoped_array();
void reset();
void swap(scoped_array& b);
%extend
{
scoped_array(unsigned n)
{
return new scoped_array<T>(new T[n]);
}
T __getitem__(unsigned int idx)
{
return (*self)[idx];
}
void __setitem__(unsigned int idx,T val)
{
(*self)[idx]=val;
}
};
};
}
作为起点。它公开了boost::scoped_array
的重要部分,并松散地基于 SWIG 在其标准类型图库中具有的std::vector
实现。
它添加了特殊的成员函数和一个新的构造函数,该构造函数还同时分配了一些存储。它没有向SWIG显示一些定义,因为我看不到它们在您的目标语言中的用途。
注意:我没有编译和检查这个。SWIG对此感到满意,生成的包装器看起来很理智。
相关文章:
- 是否可以使用 Boost.Hana 将 std::array 解压缩到非类型模板参数包中
- 有没有一种优雅的方法可以从 std::vector 实例化 boost::array
- Boost.Fusion define struct array member
- 如何将 std::array 转换为 boost::asio::buffer
- 如何返回 boost::fusion::vector<x,y,z> 元素以添加到 std::array<boost::fusion::vector<x,y,z>>?
- SWIG/Lua typemap for Boost Array in
- 使用 boost::iostreams::array_sink 和 boost::array<char, n>
- C++类似于 std::vector / boost::array 的文件内存映射容器
- 将 boost::array<char> 复制到 std::string
- C++ // 将 Boost::array 传递给 Boost::thread
- Cast boost::array<float, 12> for function with argument(const float (&arr)[12])
- 错误:“boost::array”不是一种类型
- 如何从 boost::p ython 返回 numpy.array
- std::array 和 boost::array 之间的区别
- Concatenate boost::array and std::string
- 在这种情况下可以使用std::array(或boost::array)吗?或者我是不是一直使用std::vector和本
- Boost read_also()函数不能与Boost::array一起工作,不能使用std::array
- 如何将std::array的c++ 11操作转换为Boost+VS08
- 从 boost::array<char, 100 中提取字符集>
- 如何创建对数组和boost::array的引用(或不必这样做的想法)