[Go] Remove all generated calls to _swig_makegostring, as it will no
longer as of Go 1.5. In Go 1.5 or later user calls to _swig_makegostring will fail at link time. Instead, use goout and godirectorin typemaps to allocate strings in Go code. Change the Go typemaps support to ignore empty strings, so that we can define empty strings for regular types so that %apply will override the definitions for string types. Fix the gccgo code to wrap SwigCgoCallback around all godirectorin typemaps. Add a few newlines after typemap code so that the typemaps don't have to include them.
This commit is contained in:
parent
603e3b49b3
commit
0a021a938e
7 changed files with 261 additions and 50 deletions
|
|
@ -27,11 +27,17 @@ class string;
|
|||
%typemap(directorout) string
|
||||
%{ $result.assign($input.p, $input.n); %}
|
||||
|
||||
%typemap(out) string
|
||||
%{ $result = _swig_makegostring($1.data(), $1.length()); %}
|
||||
%typemap(out,fragment="AllocateString") string
|
||||
%{ $result = Swig_AllocateString($1.data(), $1.length()); %}
|
||||
|
||||
%typemap(directorin) string
|
||||
%{ $input = _swig_makegostring($1.data(), $1.length()); %}
|
||||
%typemap(goout,fragment="CopyString") string
|
||||
%{ $result = swigCopyString($1) %}
|
||||
|
||||
%typemap(directorin,fragment="AllocateString") string
|
||||
%{ $input = Swig_AllocateString($1.data(), $1.length()); %}
|
||||
|
||||
%typemap(godirectorin,fragment="CopyString") string
|
||||
%{ $result = swigCopyString($input) %}
|
||||
|
||||
%typemap(in) const string &
|
||||
%{
|
||||
|
|
@ -46,10 +52,16 @@ class string;
|
|||
$result = &$1_str;
|
||||
%}
|
||||
|
||||
%typemap(out) const string &
|
||||
%{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %}
|
||||
%typemap(out,fragment="AllocateString") const string &
|
||||
%{ $result = Swig_AllocateString((*$1).data(), (*$1).length()); %}
|
||||
|
||||
%typemap(directorin) const string &
|
||||
%{ $input = _swig_makegostring($1.data(), $1.length()); %}
|
||||
%typemap(goout,fragment="CopyString") const string &
|
||||
%{ $result = swigCopyString($1) %}
|
||||
|
||||
%typemap(directorin,fragment="AllocateString") const string &
|
||||
%{ $input = Swig_AllocateString($1.data(), $1.length()); %}
|
||||
|
||||
%typemap(godirectorin,fragment="CopyString") const string &
|
||||
%{ $result = swigCopyString($input) %}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue