Fix problems in Go support revealed by recent test cases.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12922 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
589ae60501
commit
eb5130814d
2 changed files with 62 additions and 17 deletions
40
Lib/go/std_list.i
Normal file
40
Lib/go/std_list.i
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* std_vector.i
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <list>
|
||||||
|
#include <stdexcept>
|
||||||
|
%}
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
|
||||||
|
template<class T, class Alloc = allocator<T> >
|
||||||
|
class list {
|
||||||
|
public:
|
||||||
|
typedef size_t size_type;
|
||||||
|
typedef ptrdiff_t difference_type;
|
||||||
|
typedef T value_type;
|
||||||
|
typedef value_type* pointer;
|
||||||
|
typedef const value_type* const_pointer;
|
||||||
|
typedef value_type& reference;
|
||||||
|
typedef const value_type& const_reference;
|
||||||
|
typedef Alloc allocator_type;
|
||||||
|
|
||||||
|
list();
|
||||||
|
size_type size() const;
|
||||||
|
bool empty() const;
|
||||||
|
%rename(isEmpty) empty;
|
||||||
|
void clear();
|
||||||
|
void push_front(const value_type& x);
|
||||||
|
void pop_front();
|
||||||
|
void push_back(const value_type& x);
|
||||||
|
void pop_back();
|
||||||
|
void remove(value_type x);
|
||||||
|
void reverse();
|
||||||
|
void unique();
|
||||||
|
void sort();
|
||||||
|
void merge(list& x);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -3131,22 +3131,27 @@ private:
|
||||||
Printv(action, Swig_cparm_name(NULL, 0), "->", upcall_method_name, "(", NULL);
|
Printv(action, Swig_cparm_name(NULL, 0), "->", upcall_method_name, "(", NULL);
|
||||||
|
|
||||||
p = parms;
|
p = parms;
|
||||||
for (int i = 0; i < parm_count; ++i) {
|
int i = 0;
|
||||||
p = getParm(p);
|
while (p != NULL) {
|
||||||
String *pname = Swig_cparm_name(NULL, i + 1);
|
if (SwigType_type(Getattr(p, "type")) != T_VOID) {
|
||||||
if (i > 0) {
|
String *pname = Swig_cparm_name(NULL, i + 1);
|
||||||
Printv(action, ", ", NULL);
|
if (i > 0) {
|
||||||
|
Printv(action, ", ", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// A parameter whose type is a reference is converted into a
|
||||||
|
// pointer type by gcCTypeForGoValue. We are calling a
|
||||||
|
// function which expects a reference so we need to convert
|
||||||
|
// back.
|
||||||
|
if (SwigType_isreference(Getattr(p, "type"))) {
|
||||||
|
Printv(action, "*", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
Printv(action, pname, NULL);
|
||||||
|
Delete(pname);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
// A parameter whose type is a reference is converted into a
|
p = nextSibling(p);
|
||||||
// pointer type by gcCTypeForGoValue. We are calling a
|
|
||||||
// function which expects a reference so we need to convert
|
|
||||||
// back.
|
|
||||||
if (SwigType_isreference(Getattr(p, "type"))) {
|
|
||||||
Printv(action, "*", NULL);
|
|
||||||
}
|
|
||||||
Printv(action, pname, NULL);
|
|
||||||
Delete(pname);
|
|
||||||
p = nextParm(p);
|
|
||||||
}
|
}
|
||||||
Printv(action, ");", NULL);
|
Printv(action, ");", NULL);
|
||||||
Setattr(n, "wrap:action", action);
|
Setattr(n, "wrap:action", action);
|
||||||
|
|
@ -3546,8 +3551,8 @@ private:
|
||||||
|
|
||||||
Printv(w->code, "}", NULL);
|
Printv(w->code, "}", NULL);
|
||||||
|
|
||||||
Wrapper_print(w, f_c_directors);
|
|
||||||
Replaceall(w->code, "$symname", symname);
|
Replaceall(w->code, "$symname", symname);
|
||||||
|
Wrapper_print(w, f_c_directors);
|
||||||
|
|
||||||
DelWrapper(w);
|
DelWrapper(w);
|
||||||
}
|
}
|
||||||
|
|
@ -4636,7 +4641,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
* gcCTypeForGoValue()
|
* gccgoCTypeForGoValue()
|
||||||
*
|
*
|
||||||
* Given a type, return the C/C++ type which will be used to catch
|
* Given a type, return the C/C++ type which will be used to catch
|
||||||
* the value in Go. This is the gccgo version.
|
* the value in Go. This is the gccgo version.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue