Skip to content

Commit

Permalink
add std::vector types variables into swig file for avoiding raw swig
Browse files Browse the repository at this point in the history
files generation.
  • Loading branch information
ZhangLe2016 committed Jan 9, 2025
1 parent 5f187e7 commit c36a2da
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions src/java/commissioner.i
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@

%module(directors="1") commissionerModule

// Tells SWIG to use const T& paramters for setters of struct member fields.
// This allows generated java code to accept immutable objects for setters.
// See https://www.swig.org/Doc4.0/SWIGDocumentation.html#SWIGPlus_member_data
%naturalvar;

%{
#include <commissioner/defines.hpp>
#include <commissioner/error.hpp>
Expand All @@ -45,9 +50,9 @@
%}

%include <std_shared_ptr.i>
%include <std_string.i>
%include <std_vector.i>
%include <stl.i>
%include "base/swig/google.swig"
%include "base/swig/java/vector.swig"

%include <typemaps.i>

// This is intentional.
Expand All @@ -63,7 +68,7 @@
// `signed char` for `uint8_t` in only context of `std::vector<uint8_t>`.
%apply signed char { uint8_t };
%apply const signed char & { const uint8_t & };
%template(ByteArray) std::vector<uint8_t>;
VECTOR(uint8_t)

// Override the typemap of `uint8_t`.
%apply unsigned char { uint8_t };
Expand Down Expand Up @@ -98,11 +103,15 @@
%feature("director") ot::commissioner::CommissionerHandler;
%feature("director") ot::commissioner::Logger;

%template(ChannelMask) std::vector<ot::commissioner::ChannelMaskEntry>;
%template(StringVector) std::vector<std::string>;
%template(ChildIpv6AddrInfoVector) std::vector<ot::commissioner::ChildIpv6AddrInfo>;
%template(ChildTableEntryVector) std::vector<ot::commissioner::ChildTableEntry>;
%template(RouteDataEntryVector) std::vector<ot::commissioner::RouteDataEntry>;
VECTOR(ot::commissioner::ChannelMaskEntry)
VECTOR(std::string)
VECTOR(ot::commissioner::ChildIpv6AddrInfo)
VECTOR(ot::commissioner::ChildTableEntry)
VECTOR(ot::commissioner::RouteDataEntry)
VECTOR(ot::commissioner::HasRouteEntry)
VECTOR(ot::commissioner::BorderRouterEntry)
VECTOR(ot::commissioner::SixLowPanContext)
VECTOR(ot::commissioner::PrefixEntry)

%typemap(jstype) std::string& OUTPUT "String[]"
%typemap(jtype) std::string& OUTPUT "String[]"
Expand Down Expand Up @@ -193,9 +202,9 @@ namespace commissioner {
}
}

%include <commissioner/defines.hpp>
%include <commissioner/error.hpp>
%include <commissioner/network_data.hpp>
%include <commissioner/network_diag_data.hpp>
%include <commissioner/commissioner.hpp>
%include <commissioner/commissioner.hpp>
%include "third_party/ot_commissioner/include/commissioner/defines.hpp"
%include "third_party/ot_commissioner/include/commissioner/error.hpp"
%include "third_party/ot_commissioner/include/commissioner/network_data.hpp"
%include "third_party/ot_commissioner/include/commissioner/network_diag_data.hpp"
%include "third_party/ot_commissioner/include/commissioner/commissioner.hpp"
%include "third_party/ot_commissioner/include/commissioner/commissioner.hpp"

0 comments on commit c36a2da

Please sign in to comment.