I have the following problem. I am trying to wrap code from C ++ in java.
common.h
namespace rinad {
namespace mad_manager {
template<class T>
class Encoder{
public:
virtual ~Encoder(){}
virtual void encode(const T &obj, ser_obj_t& serobj) = 0;
virtual void decode(const ser_obj_t &serobj,
T& des_obj) = 0;
};
typedef struct ipcp_config{
....
}ipcp_config_t;
}}
encoders.h
namespace rinad {
namespace mad_manager {
class IPCPConfigEncoder: public Encoder<ipcp_config_t> {
public:
void encode (const ipcp_config_t &obj,
ser_obj_t& ser_obj);
void decode(const ser_obj_t &ser_obj,
ipcp_config_t& obj);
std::string get_type() const{ return "ipcp-config"; };
};
}}
librinad.i
%{
#include "common.h"
#include "encoders.h"
%}
%include "common.h"
%template(TempIPCPConfigEncoder) rinad::mad_manager::Encoder<rinad::mad_manager::ipcp_config_t>;
%include "encoders.h"
The generated .cc ( swig <options> -o librinad_java.cc) file , however, does not consider some namespaces that lead to an error.
librinad_java.cc:836:32: error: "ipcp_config_t" was not declared in this area Rinad :: mad_manager :: Encoder <ipcp_config_t> * arg1 = (rinad :: mad_manager :: Encoder <ipcp_config_t> *) 0;
I tried to specify each namespace (even if it is not necessary), but it does not work. If I manually add the namespace rinad::mad_manager::ipcp_config_tto librinad_java.cc, it works, so the problem is that SWIG does not export this namespace. I can’t understand what the problem is.
. , common.h, encoders.h, .i (encoders.h), ipcp_config_t (common.h). ?