I am trying to build a Go SWIG wrapper for E57Format, the C++ library for E57 files (see https://github.com/asmaloney/libE57Format). Go can't compile the wrapper because it needs default constructors for some classes in which the default constructor is deleted.
In E57Format.h, pick the e57::Node::parent()
function (line 179):
class Node
{
public:
Node() = delete;
NodeType type() const;
bool isRoot() const;
Node parent() const;
The generated C wrapper is:
e57::Node *_wrap_Node_parent_libe57format_c463bf06275b76de(e57::Node *_swig_go_0) {
e57::Node *arg1 = (e57::Node *) 0 ;
e57::Node result;
e57::Node *_swig_go_result;
arg1 = *(e57::Node **)&_swig_go_0;
result = ((e57::Node const *)arg1)->parent();
*(e57::Node **)&_swig_go_result = new e57::Node(result);
return _swig_go_result;
}
Note the line
e57::Node result;
This line is not compilable, since e57::Node
default constructor is deleted.
I tried many things:
- ignoring functions that fail, buy I really need some of them
- the
%nodefaultctor
directive, but it noes not avoid using default costructors, it prevent the generation of wrappers of default constructors.
This is my current swigcxx file
%module libe57format
%include "stdint.i"
%include "std_string.i"
%include "std_vector.i"
namespace std {
typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef long int int64_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long int uint64_t;
}
//Things that do not work:
%nodefaultctor e57::Node;
%ignore e57::Node::Node();
%ignore e57::Node::destImageFile() const;
//%ignore e57::Node::parent() const;
%ignore e57::Node::operator ==(e57::Node) const;
%ignore e57::Node::__equals__(e57::Node) const;
%ignore e57::Node::operator !=(e57::Node) const;
%ignore e57::Node::__notEquals__(e57::Node) const;
%ignore e57::StructureNode::StructureNode(ImageFile);
%ignore e57::StructureNode::destImageFile() const;
%ignore e57::StructureNode::parent() const;
//%ignore e57::StructureNode::get(const ustring&) const;
//%ignore e57::StructureNode::get(int64_t) const;
%ignore e57::StructureNode::operator Node() const;
%ignore e57::VectorNode::VectorNode(ImageFile);
%ignore e57::VectorNode::VectorNode(ImageFile, bool);
%ignore e57::VectorNode::destImageFile() const;
%ignore e57::VectorNode::parent() const;
%ignore e57::VectorNode::append(Node);
%ignore e57::VectorNode::get(const ustring&) const;
//%ignore e57::VectorNode::get(int64_t) const;
%ignore e57::VectorNode::operator Node() const;
//%ignore e57::SourceDestBuffer::SourceDestBuffer;
%{
#include </usr/local/include/E57Format/E57Format.h>
%}
%template(SDBVector) std::vector<e57::SourceDestBuffer>;
%ignore e57::BlobNode;
%ignore e57::ScaledIntegerNode;
%ignore e57::CompressedVectorWriter;
%rename(__type__) e57::Node::type;
%rename(__equals__) e57::Node::operator==;
%rename(__notEquals__) e57::Node::operator!=;
%rename(__equals__) e57::ImageFile::operator==;
%rename(__notEquals__) e57::ImageFile::operator!=;
%rename(__Node__) e57::StructureNode::operator Node;
%rename(__Node__) e57::VectorNode::operator Node;
%rename(__Node__) e57::CompressedVectorNode::operator Node;
%rename(__Node__) e57::IntegerNode::operator Node;
%rename(__Node__) e57::ScaledIntegerNode::operator Node;
%rename(__Node__) e57::FloatNode::operator Node;
%rename(__Node__) e57::StringNode::operator Node;
%rename(__Node__) e57::BlobNode::operator Node;
%include </usr/local/include/E57Format/E57Format.h>
I'd like to generate wrappers that C++ can compile, possibly without writing C code myself (not writing C code is the reason for which I'm using Go).
Thank-you.