Removing the Getter / Setters SWIG generator from the Java class structure
I am using the javacode linkmap to add some additional functionality instead of the ones generated by SWIG. I would like to delete the new default recipient and the default installer unsigned char mac[6];
( public short[] getMac()
and public void setMac(short[] value)
) structure details_t_
. I tried to do it with a directive %ignore details_t_::setMac;
, but it doesn't work. Any suggestions as to a suitable technique for this?
%module Test
%typemap(javacode) struct details_t_ %{
public String getMacAddress() {
return Test.getMacAddressAsString(this); //another API in Test.java
}
%};
%rename (Details) details_t_;
typedef struct details_t_ {
uint16_t code;
char *name;
sockaddr *saddr;
uint32_t saddr_len;
uint8_t flag;
ios_boolean is_child;
unsigned char mac[6];
} details_t;
source to share
Instead of talking %ignore
to the installer and recipient, name the field directly, for example:
%module Test
%typemap(javacode) struct details_t_ %{
public String getMacAddress() {
return Test.getMacAddressAsString(this); //another API in Test.java
}
%};
// Ignore field, not get/sets
%ignore details_t_::mac;
%rename (Details) details_t_;
typedef struct details_t_ {
uint16_t code;
char *name;
sockaddr *saddr;
uint32_t saddr_len;
uint8_t flag;
ios_boolean is_child;
unsigned char mac[6];
} details_t;
If you want to make it immutable and not hidden (i.e. just a getter generated by a setter) you can write:
%immutable details_t_::mac;
instead of %ignore
in the previous example.
If you want to make a whole immutable structure, you can do:
// Read only, i.e. only getters
%immutable;
%rename (Details) details_t_;
typedef struct details_t_ {
uint16_t code;
char *name;
sockaddr *saddr;
uint32_t saddr_len;
uint8_t flag;
ios_boolean is_child;
unsigned char mac[6];
} details_t;
// Cancel the immutable directive
%mutable;
source to share