Swig typemaps for struct datamembers

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Swig typemaps for struct datamembers

the4thamigo_uk

Hi,


I am trying to create (in swig 3.0) bindings in golang for Lasso (http://lasso.entrouvert.org/documentation/api-reference/index.html)


The problem I have is that some 'struct' types have datamembers that are 'gchar *'. 'gchar' is a type defined in glib-2.0 and is trivially typedef-ed to 'char'. 


For example this is one such struct in lasso :


struct _LassoServer {
LassoProvider parent;

/*< public >*/
GHashTable *providers; /* of LassoProvider */
/* Can actually contain LassoDataService or LassoIdWsf2DataService or any subclass */
/*< private >*/
GHashTable *services; /* of LassoDataService */
/*< public >*/

gchar *private_key;
gchar *private_key_password;
gchar *certificate;
LassoSignatureMethod signature_method;

/*< private >*/
LassoServerPrivate *private_data;
};


Unfortunately, the accessor functions for the golang interface do not use the standard golang 'string', so I get the following in the golang binding :


type X_LassoServer interface {
Swigcptr() uintptr
SwigIsX_LassoServer()
SetParent(arg2 X_LassoProvider)
GetParent() (_swig_ret X_LassoProvider)
SetProviders(arg2 Struct_SS__GHashTable)
GetProviders() (_swig_ret Struct_SS__GHashTable)
SetServices(arg2 Struct_SS__GHashTable)
GetServices() (_swig_ret Struct_SS__GHashTable)
SetPrivate_key(arg2 Gchar)
GetPrivate_key() (_swig_ret Gchar)
SetPrivate_key_password(arg2 Gchar)
GetPrivate_key_password() (_swig_ret Gchar)
SetCertificate(arg2 Gchar)
GetCertificate() (_swig_ret Gchar)
SetSignature_method(arg2 LassoSignatureMethod)
GetSignature_method() (_swig_ret LassoSignatureMethod)
SetPrivate_data(arg2 Struct_SS__LassoServerPrivate)
GetPrivate_data() (_swig_ret Struct_SS__LassoServerPrivate)
}

In particular you can see the Gchar argument types in some of the accessors. Since a gchar is just a char, how can I set up the typemaps to force the accessors to bind with 'string'?


NB: I notice that gchar* arguments in normal functions are correctly mapped to 'string' in golang.


Thanks


Andy


lasso.entrouvert.org
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License as published by the Free Software ...



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|

Re: Swig typemaps for struct datamembers

William S Fulton


On 18 October 2016 at 14:19, Andrew Smith <[hidden email]> wrote:

Hi,


I am trying to create (in swig 3.0) bindings in golang for Lasso (http://lasso.entrouvert.org/documentation/api-reference/index.html)


The problem I have is that some 'struct' types have datamembers that are 'gchar *'. 'gchar' is a type defined in glib-2.0 and is trivially typedef-ed to 'char'. 


Make sure SWIG parses this typedef otherwise it won't know what gchar is. Once it does know, you should get wrappers equally as good as if you had instead used plain char instead of gchar.

William


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user