parent
b819363117
commit
0c0b93f8e0
3 changed files with 53 additions and 9 deletions
|
|
@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
||||||
Version 4.1.0 (in progress)
|
Version 4.1.0 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2022-03-15: ianlancetaylor
|
||||||
|
[Go] Add typemaps for std::string*.
|
||||||
|
|
||||||
2022-03-15: ianlancetaylor
|
2022-03-15: ianlancetaylor
|
||||||
[Go] Don't convert arrays to pointers if there is a "gotype"
|
[Go] Don't convert arrays to pointers if there is a "gotype"
|
||||||
typemap entry.
|
typemap entry.
|
||||||
|
|
|
||||||
|
|
@ -120,15 +120,6 @@ type GoRetStruct struct {
|
||||||
$1.assign(tmp->p, tmp->p + tmp->n);
|
$1.assign(tmp->p, tmp->p + tmp->n);
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(directorin) std::string * (_gostring_ temp) {
|
|
||||||
$input = &temp;
|
|
||||||
$input->p = (char *) $1->data();
|
|
||||||
$input->n = $1->size();
|
|
||||||
}
|
|
||||||
%typemap(directorargout) std::string * {
|
|
||||||
$1->assign($input->p, $input->p + $input->n);
|
|
||||||
}
|
|
||||||
|
|
||||||
%feature("director") MyClass;
|
%feature("director") MyClass;
|
||||||
|
|
||||||
%inline
|
%inline
|
||||||
|
|
|
||||||
|
|
@ -88,4 +88,54 @@ class string;
|
||||||
%typemap(godirectorin,fragment="CopyString") const string &
|
%typemap(godirectorin,fragment="CopyString") const string &
|
||||||
%{ $result = swigCopyString($input) %}
|
%{ $result = swigCopyString($input) %}
|
||||||
|
|
||||||
|
|
||||||
|
%typemap(gotype) string * "*string"
|
||||||
|
|
||||||
|
%typemap(in) string * (string temp)
|
||||||
|
%{
|
||||||
|
temp.assign($input->p, $input->n);
|
||||||
|
$1 = &temp;
|
||||||
|
%}
|
||||||
|
|
||||||
|
%typemap(godirectorout) string *
|
||||||
|
%{
|
||||||
|
{
|
||||||
|
p := Swig_malloc(len(*$input))
|
||||||
|
s := (*[1<<30]byte)(unsafe.Pointer(p))[:len(*$input)]
|
||||||
|
copy(s, *$input)
|
||||||
|
$result = (*string)(unsafe.Pointer(&s))
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
|
%typemap(directorout) string * (string temp)
|
||||||
|
%{
|
||||||
|
temp.assign($input->p, $input->n);
|
||||||
|
$result = &temp;
|
||||||
|
free($input.p);
|
||||||
|
%}
|
||||||
|
|
||||||
|
%typemap(out,fragment="AllocateString") string * (_gostring_ temp)
|
||||||
|
%{
|
||||||
|
temp = Swig_AllocateString($1->data(), $1->length());
|
||||||
|
$result = &temp;
|
||||||
|
%}
|
||||||
|
|
||||||
|
%typemap(goout,fragment="CopyString") string *
|
||||||
|
%{ *$result = swigCopyString(*$1) %}
|
||||||
|
|
||||||
|
%typemap(directorin,fragment="AllocateString") string * (_gostring_ temp)
|
||||||
|
%{
|
||||||
|
temp = Swig_AllocateString($1->data(), $1->length());
|
||||||
|
$input = &temp;
|
||||||
|
%}
|
||||||
|
|
||||||
|
%typemap(godirectorin,fragment="CopyString") string *
|
||||||
|
%{ *$result = swigCopyString(*$input); %}
|
||||||
|
|
||||||
|
%typemap(argout,fragment="AllocateString") string *
|
||||||
|
%{ *$input = Swig_AllocateString($1->data(), $1->length()); %}
|
||||||
|
|
||||||
|
%typemap(goargout,fragment="CopyString") string *
|
||||||
|
%{ *$input = swigCopyString(*$1) %}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue