summaryrefslogtreecommitdiff
path: root/Lib/go
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2013-01-28 07:01:37 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2013-01-28 07:01:37 +0000
commite805d5f9256cdafab06f9958cc48c51083d860da (patch)
treed5ab9ab1f58d3c291a49529a2696798f46de70fa /Lib/go
parent34d46510cfbcecdeb4fd1a98a2957ecfe5a2db6a (diff)
parent38d454a1022f65d76e292fd13d699da896c0c2cf (diff)
downloadswig-e805d5f9256cdafab06f9958cc48c51083d860da.tar.gz
Merge branch 'master' into gsoc2009-matevz
parser.y still to be fixed up Conflicts: Doc/Devel/engineering.html Examples/Makefile.in Lib/allegrocl/allegrocl.swg Lib/csharp/csharp.swg Lib/csharp/enums.swg Lib/csharp/enumsimple.swg Lib/csharp/enumtypesafe.swg Lib/java/java.swg Lib/python/pydocs.swg Lib/r/rtype.swg Source/Include/swigwarn.h Source/Modules/octave.cxx Source/Modules/python.cxx Source/Modules/ruby.cxx Source/Swig/scanner.c Source/Swig/stype.c Source/Swig/swig.h configure.ac
Diffstat (limited to 'Lib/go')
-rw-r--r--Lib/go/cdata.i79
-rw-r--r--Lib/go/go.swg77
-rw-r--r--Lib/go/goruntime.swg228
-rw-r--r--Lib/go/std_list.i40
-rw-r--r--Lib/go/std_string.i8
-rw-r--r--Lib/go/typemaps.i67
6 files changed, 236 insertions, 263 deletions
diff --git a/Lib/go/cdata.i b/Lib/go/cdata.i
index decf297c1..0dac6420c 100644
--- a/Lib/go/cdata.i
+++ b/Lib/go/cdata.i
@@ -12,83 +12,12 @@ typedef struct SWIGCDATA {
%}
%typemap(gotype) SWIGCDATA %{ []byte %}
-%typemap(out) SWIGCDATA (swigcdata argp) {
- argp = _swig_makegobyteslice($1.data, $1.len);
- $result.data = (char*)argp.data;
- $result.len = (int)argp.len;
-}
-
-/* The makegobyteslice function. */
-
-%insert(runtime) %{
-typedef struct {
- char *data;
- int len;
-} swigcdata;
-
-%}
-
-#ifndef SWIGGO_GCCGO
-%insert(runtime) %{
-extern
-#ifdef __cplusplus
-"C"
-#endif
-void _swig_gc_makegobyteslice(void *, int);
-static swigcdata _swig_makegobyteslice(const char *data, int len) {
- struct {
- const char *data;
- int len;
- swigcdata ret;
- } a;
- a.data = data;
- a.len = len;
- crosscall2(_swig_gc_makegobyteslice, &a, (int) sizeof a);
- return a.ret;
-}
-%}
-
-%insert(gc_header) %{
-typedef struct {
- byte *data;
- int32 len;
-} swigcdata;
-extern void ·_swig_internal_makegobyteslice(void);
-#pragma dynexport _swig_gc_makegobyteslice _swig_gc_makegobyteslice
-void _swig_gc_makegobyteslice(void *a, int32 n) {
- cgocallback(·_swig_internal_makegobyteslice, a, n);
-}
-void ·_swig_allocategobyteslice(byte *data, int32 len, swigcdata ret) {
- ret.data = mal(len);
- mcpy(ret.data, data, len);
- ret.len = len;
- FLUSH(&ret);
-}
+%typemap(out) SWIGCDATA %{
+ $result.data = (char*)_swig_goallocate($1.len);
+ memcpy($result.data, $1.data, $1.len);
+ $result.len = (int)$1.len;
%}
-%insert(go_header) %{
-type swigcdata struct { data *byte; len int }
-func _swig_allocategobyteslice(*byte, int) swigcdata
-func _swig_internal_makegobyteslice(data *byte, len int) swigcdata {
- return _swig_allocategobyteslice(data, len)
-}
-%}
-
-#else
-
-%insert(runtime) %{
-static swigcdata _swig_makegobyteslice(const char *data, int len) {
- swigcdata ret;
- ret.data = (char*)__go_alloc(len);
- memcpy(ret.data, data, len);
- ret.len = (int)len;
- return ret;
-}
-
-%}
-
-#endif
-
/* -----------------------------------------------------------------------------
* %cdata(TYPE [, NAME])
*
diff --git a/Lib/go/go.swg b/Lib/go/go.swg
index 7eb7c62c7..4e442c7e9 100644
--- a/Lib/go/go.swg
+++ b/Lib/go/go.swg
@@ -108,7 +108,7 @@
unsigned long long,
float,
double
-%{ $input = ($1_ltype)$1_name; %}
+%{ $input = ($1_ltype)$1; %}
%typemap(directorin) const bool &,
const char &,
@@ -124,7 +124,7 @@
const unsigned long long &,
const float &,
const double &
-%{ $input = ($*1_ltype)$1_name; %}
+%{ $input = ($*1_ltype)$1; %}
%typemap(directorout) bool,
char,
@@ -157,8 +157,8 @@
const float &,
const double &
%{
- $result = ($1_ltype)_swig_allocate(sizeof($*1_ltype));
- *$result = *($1_ltype)$input;
+ $result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype));
+ *$result = *($1_ltype)&$input;
%}
/* The size_t type. */
@@ -182,17 +182,17 @@
%{ $result = ($*1_ltype)*$1; %}
%typemap(directorin) size_t
-%{ $input = (size_t)$1_name; %}
+%{ $input = (size_t)$1; %}
%typemap(directorin) const size_t &
-%{ $input = ($*1_ltype)$1_name; %}
+%{ $input = ($*1_ltype)$1; %}
%typemap(directorout) size_t
%{ $result = ($1_ltype)$input; %}
%typemap(directorout) const size_t &
%{
- $result = ($1_ltype)_swig_allocate(sizeof($*1_ltype));
+ $result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype));
*$result = *($1_ltype)$input;
%}
@@ -206,16 +206,16 @@
%typemap(out) SWIGTYPE (CLASS::*)
%{
- $result = _swig_allocate(sizeof($1_ltype));
+ $result = _swig_goallocate(sizeof($1_ltype));
*($&1_ltype)$result = $1;
%}
%typemap(directorin) SWIGTYPE (CLASS::*)
-%{ $input = *($&1_ltype)$1_name; %}
+%{ $input = *($&1_ltype)$1; %}
%typemap(directorout) SWIGTYPE (CLASS::*)
%{
- $result = _swig_allocate(sizeof($1_ltype));
+ $result = _swig_goallocate(sizeof($1_ltype));
*($&1_ltype)$result = $input;
%}
@@ -233,7 +233,7 @@
%{ *($&1_ltype)&$result = $1; %}
%typemap(directorin) SWIGTYPE *
-%{ $input = ($1_ltype)$1_name; %}
+%{ $input = ($1_ltype)$1; %}
%typemap(directorout) SWIGTYPE *
%{ $result = ($1_ltype)$input; %}
@@ -254,14 +254,6 @@
%typemap(out) SWIGTYPE *const&
%{ *($1_ltype)&$result = *$1; %}
-/* Function pointers are translated by the code in go.cxx into
- _swig_fnptr. Member pointers are translated to _swig_memberptr. */
-
-%insert(go_header) %{
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-%}
-
/* References. */
/* Converting a C++ reference to Go has to be handled in the C++
@@ -276,7 +268,7 @@ type _swig_memberptr *byte
%{ *($&1_ltype)&$result = $1; %}
%typemap(directorin) SWIGTYPE &
-%{ $input = ($1_ltype)&$1_name; %}
+%{ $input = ($1_ltype)&$1; %}
%typemap(directorout) SWIGTYPE &
%{ *($&1_ltype)&$result = $input; %}
@@ -309,7 +301,7 @@ type _swig_memberptr *byte
%{ *($&1_ltype)&$result = $1; %}
%typemap(directorin) SWIGTYPE []
-%{ $input = *($1_ltype)&$1_name; %}
+%{ $input = *($1_ltype)&$1; %}
%typemap(directorout) SWIGTYPE []
%{ *($&1_ltype)&$result = $input; %}
@@ -347,7 +339,7 @@ type _swig_memberptr *byte
signed char *, signed char *&, signed char[ANY], signed char[],
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
%{
- $input = _swig_makegostring((char*)$1_name, $1_name ? strlen((char*)$1_name) : 0);
+ $input = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0);
%}
%typemap(directorout)
@@ -356,6 +348,28 @@ type _swig_memberptr *byte
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
%{ $result = ($1_ltype)$input.p; %}
+/* String & length */
+
+%typemap(gotype) (char *STRING, size_t LENGTH) "string"
+
+%typemap(in) (char *STRING, size_t LENGTH)
+%{
+ $1 = ($1_ltype)$input.p;
+ $2 = ($2_ltype)$input.n;
+%}
+
+%typemap(out) (char *STRING, size_t LENGTH)
+%{ $result = _swig_makegostring((char*)$1, (size_t)$2); %}
+
+%typemap(directorin) (char *STRING, size_t LENGTH)
+%{ $input = _swig_makegostring((char*)$1, $2); %}
+
+%typemap(directorout) (char *STRING, size_t LENGTH)
+%{
+ $1 = ($1_ltype)$input.p;
+ $2 = ($2_ltype)$input.n;
+%}
+
/* Enums. We can't do the right thing for enums in typemap(gotype) so
we deliberately don't define them. The right thing would be to
capitalize the name. This is instead done in go.cxx. */
@@ -367,14 +381,26 @@ type _swig_memberptr *byte
%{ $1 = ($1_ltype)$input; %}
%typemap(out) enum SWIGTYPE
-%{ $result = $1; %}
+%{ $result = (intgo)$1; %}
%typemap(directorin) enum SWIGTYPE
-%{ $input = ($1_ltype)$1_name; %}
+%{ $input = ($1_ltype)$1; %}
%typemap(directorout) enum SWIGTYPE
%{ $result = ($1_ltype)$input; %}
+%typemap(directorin) enum SWIGTYPE & (intgo e)
+%{
+ e = (intgo)$1;
+ $input = &e;
+%}
+
+%typemap(directorout) enum SWIGTYPE &
+%{
+ $*1_ltype f = ($*1_ltype)*$input;
+ $result = ($1_ltype)&f;
+%}
+
/* Arbitrary type. This is a type passed by value in the C/C++ code.
We convert it to a pointer for the Go code. Note that all basic
types are explicitly handled above. */
@@ -403,7 +429,7 @@ type _swig_memberptr *byte
#endif
%typemap(directorin) SWIGTYPE
-%{ $input = ($&1_ltype)&$1_name; %}
+%{ $input = ($&1_ltype)&$1; %}
%typemap(directorout) SWIGTYPE
%{ $result = *($&1_ltype)$input; %}
@@ -524,6 +550,7 @@ type _swig_memberptr *byte
SWIGTYPE [],
SWIGTYPE (CLASS::*)
""
+
/* Go keywords. */
%include <gokw.swg>
diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg
index 057f81d01..4b7daf41f 100644
--- a/Lib/go/goruntime.swg
+++ b/Lib/go/goruntime.swg
@@ -5,12 +5,35 @@
* ------------------------------------------------------------ */
%insert(runtime) %{
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
-typedef struct { char *p; int n; } _gostring_;
-typedef struct { void* array; unsigned int len; unsigned int cap; } _goslice_;
+%}
+
+#if SWIGGO_INTGO_SIZE == 32
+%insert(runtime) %{
+typedef int intgo;
+typedef unsigned int uintgo;
+%}
+#elif SWIGGO_INTGO_SIZE == 64
+%insert(runtime) %{
+typedef long long intgo;
+typedef unsigned long long uintgo;
+%}
+#else
+%insert(runtime) %{
+typedef ptrdiff_t intgo;
+typedef size_t uintgo;
+%}
+#endif
+
+%insert(runtime) %{
+
+typedef struct { char *p; intgo n; } _gostring_;
+typedef struct { void* array; intgo len; intgo cap; } _goslice_;
%}
@@ -30,57 +53,32 @@ swiggo_size_assert(swiggo_long_long, 8)
swiggo_size_assert(float, 4)
swiggo_size_assert(double, 8)
-extern
#ifdef __cplusplus
-"C"
+extern "C" {
#endif
-void crosscall2(void (*fn)(void *, int), void *, int);
-
-extern
+extern void crosscall2(void (*fn)(void *, int), void *, int);
+extern void _cgo_allocate(void *, int);
+extern void _cgo_panic(void *, int);
#ifdef __cplusplus
-"C"
+}
#endif
-void _swig_gc_allocate(void *, int);
-static void *_swig_allocate(int len) {
+
+static void *_swig_goallocate(size_t len) {
struct {
- int len;
+ size_t len;
void *ret;
} a;
a.len = len;
- crosscall2(_swig_gc_allocate, &a, (int) sizeof a);
+ crosscall2(_cgo_allocate, &a, (int) sizeof a);
return a.ret;
}
-extern
-#ifdef __cplusplus
-"C"
-#endif
-void _swig_gc_makegostring(void *, int);
-static _gostring_ _swig_makegostring(const char *p, size_t l) {
- struct {
- const char *p;
- int l;
- _gostring_ ret;
- } a;
- a.p = p;
- a.l = l;
- crosscall2(_swig_gc_makegostring, &a, (int) sizeof a);
- return a.ret;
-}
-
-extern
-#ifdef __cplusplus
-"C"
-#endif
-void _swig_gc_gopanic(void *, int);
static void _swig_gopanic(const char *p) {
struct {
const char *p;
- int l;
} a;
a.p = p;
- a.l = strlen(p);
- crosscall2(_swig_gc_gopanic, &a, (int) sizeof a);
+ crosscall2(_cgo_panic, &a, (int) sizeof a);
}
%}
@@ -91,10 +89,6 @@ static void _swig_gopanic(const char *p) {
#include "runtime.h"
#include "cgocall.h"
-#pragma dynimport initcgo initcgo "libcgo.so"
-#pragma dynimport libcgo_thread_start libcgo_thread_start "libcgo.so"
-#pragma dynimport libcgo_set_scheduler libcgo_set_scheduler "libcgo.so"
-
#ifdef _64BIT
#define SWIG_PARM_SIZE 8
#else
@@ -102,97 +96,123 @@ static void _swig_gopanic(const char *p) {
#endif
%}
-/* 6g/8g C boilerplate that is only needed once in a program. This
- only gets added to the file if nothing is imported. */
-%insert(gc_once) %{
-
-extern void ·_swig_internal_allocate(void);
-#pragma dynexport _swig_gc_allocate _swig_gc_allocate
-void _swig_gc_allocate(void *a, int32 n) {
- cgocallback(·_swig_internal_allocate, a, n);
-}
+#else
-void ·_swig_allocatememory(int32 len, byte *ret) {
- ret = mal(len);
- FLUSH(&ret);
-}
+/* Boilerplate for C/C++ code when using gccgo. */
+%insert(runtime) %{
+#define SWIGGO_GCCGO
-extern void ·_swig_internal_makegostring(void);
-#pragma dynexport _swig_gc_makegostring _swig_gc_makegostring
-void _swig_gc_makegostring(void *a, int32 n) {
- cgocallback(·_swig_internal_makegostring, a, n);
-}
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void *_cgo_allocate(size_t);
+extern void _cgo_panic(const char *);
+
+/* Implementations of SwigCgocall and friends for different versions
+ of gccgo. The Go code will call these functions using C names with
+ a prefix of the module name. The implementations here call the
+ routine in libgo. The routines to call vary depending on the gccgo
+ version. We assume that the version of gcc used to compile this
+ file is the same as the version of gccgo. */
+
+#define SWIGCONCAT2(s1, s2) s1 ## s2
+#define SWIGCONCAT1(s1, s2) SWIGCONCAT2(s1, s2)
+#define SwigCgocall SWIGCONCAT1(SWIGMODULE, SwigCgocall)
+#define SwigCgocallDone SWIGCONCAT1(SWIGMODULE, SwigCgocallDone)
+#define SwigCgocallBack SWIGCONCAT1(SWIGMODULE, SwigCgocallBack)
+#define SwigCgocallBackDone SWIGCONCAT1(SWIGMODULE, SwigCgocallBackDone)
+
+#define SWIG_GCC_VERSION \
+ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC__PATH_LEVEL__)
+
+#if SWIG_GCC_VERSION < 40700
+#define SwigDoCgocall()
+#define SwigDoCgocallDone()
+#define SwigDoCgocallBack()
+#define SwigDoCgocallBackDone()
+#elif SWIG_GCC_VERSION == 40700
+void SwigDoCgocall(void) __asm__("libgo_syscall.syscall.Entersyscall");
+void SwigDoCgocallDone(void) __asm__("libgo_syscall.syscall.Exitsyscall");
+void SwigDoCgocallBack(void) __asm__("libgo_syscall.syscall.Exitsyscall");
+void SwigDoCgocallBackDone(void) __asm__("libgo_syscall.syscall.Entersyscall");
+#else
+void SwigDoCgocall(void) __asm__("syscall.Cgocall");
+void SwigDoCgocallDone(void) __asm__("syscall.CgocallDone");
+void SwigDoCgocallBack(void) __asm__("syscall.CgocallBack");
+void SwigDoCgocallBackDone(void) __asm__("syscall.CgocallBackDone");
+#endif
-void ·_swig_allocatestring(byte *p, int32 l, String ret) {
- ret.str = mal(l+1);
- mcpy(ret.str, p, l);
- ret.len = l;
- FLUSH(&ret);
+void SwigCgocall() {
+ SwigDoCgocall();
}
-extern void ·_swig_internal_gopanic(void);
-#pragma dynexport _swig_gc_gopanic _swig_gc_gopanic
-void _swig_gc_gopanic(void *a, int32 n) {
- cgocallback(·_swig_internal_gopanic, a, n);
+void SwigCgocallDone() {
+ SwigDoCgocallDone();
}
-%}
-
-/* Go code that is only needed once in a program. This is only added
- to the file if nothing is imported. */
-%insert(go_once) %{
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
+void SwigCgocallBack() {
+ SwigDoCgocallBack();
}
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
+void SwigCgocallBackDone() {
+ SwigDoCgocallBackDone();
}
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
+#ifdef __cplusplus
}
-%}
+#endif
-#else
+#define _swig_goallocate _cgo_allocate
+#define _swig_gopanic _cgo_panic
-/* Boilerplate for C/C++ code when using gccgo. */
-%insert(runtime) %{
-#define SWIGGO_GCCGO
+%}
-extern
-#ifdef __cplusplus
-"C"
#endif
-void *__go_alloc (size_t);
-static void *_swig_allocate(int len) {
- return __go_alloc(len);
-}
+%insert(runtime) %{
static _gostring_ _swig_makegostring(const char *p, size_t l) {
_gostring_ ret;
- ret.p = (char*)__go_alloc(l);
+ ret.p = (char*)_swig_goallocate(l + 1);
memcpy(ret.p, p, l);
ret.n = l;
return ret;
}
-extern
-#ifdef __cplusplus
-"C"
-#endif
-void __go_panic_msg(const char *);
-#define _swig_gopanic __go_panic_msg
+#define SWIG_contract_assert(expr, msg) \
+ if (!(expr)) { _swig_gopanic(msg); } else
+%}
+
+#ifndef SWIGGO_GCCGO
+
+%insert(go_header) %{
+
+import _ "runtime/cgo"
+import "unsafe"
+
+type _ unsafe.Pointer
%}
-#endif
+#else
+
+%insert(go_header) %{
+
+import "syscall"
+import "unsafe"
+
+type _ syscall.Sockaddr
+
+type _ unsafe.Pointer
-%insert(runtime) %{
-#define SWIG_contract_assert(expr, msg) \
- if (!(expr)) { _swig_gopanic(msg); } else
%}
+#endif
+
+/* Function pointers are translated by the code in go.cxx into
+ _swig_fnptr. Member pointers are translated to _swig_memberptr. */
+
+%insert(go_header) %{
+type _swig_fnptr *byte
+type _swig_memberptr *byte
+%}
diff --git a/Lib/go/std_list.i b/Lib/go/std_list.i
new file mode 100644
index 000000000..e0262331e
--- /dev/null
+++ b/Lib/go/std_list.i
@@ -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);
+ };
+
+}
diff --git a/Lib/go/std_string.i b/Lib/go/std_string.i
index fb99ccdcd..9922fbe13 100644
--- a/Lib/go/std_string.i
+++ b/Lib/go/std_string.i
@@ -31,17 +31,17 @@ class string;
%{ $result = _swig_makegostring($1.data(), $1.length()); %}
%typemap(directorin) string
-%{ $input = _swig_makegostring($1_name.data(), $1_name.length()); %}
+%{ $input = _swig_makegostring($1.data(), $1.length()); %}
%typemap(in) const string &
%{
- std::string $1_str($input.p, $input.n);
+ $*1_ltype $1_str($input.p, $input.n);
$1 = &$1_str;
%}
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
%{
- static std::string $1_str;
+ static $*1_ltype $1_str;
$1_str.assign($input.p, $input.n);
$result = &$1_str;
%}
@@ -50,6 +50,6 @@ class string;
%{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %}
%typemap(directorin) const string &
-%{ $input = _swig_makegostring($1_name.data(), $1_name.length()); %}
+%{ $input = _swig_makegostring($1.data(), $1.length()); %}
}
diff --git a/Lib/go/typemaps.i b/Lib/go/typemaps.i
index b03daf626..c339fb37e 100644
--- a/Lib/go/typemaps.i
+++ b/Lib/go/typemaps.i
@@ -62,22 +62,14 @@ char * typemaps instead:
%define INPUT_TYPEMAP(TYPE, GOTYPE)
%typemap(gotype) TYPE *INPUT, TYPE &INPUT "GOTYPE"
-%typemap(in) TYPE *INPUT
+ %typemap(in) TYPE *INPUT, TYPE &INPUT
%{ $1 = ($1_ltype)&$input; %}
-%typemap(in) TYPE &INPUT
-%{ $1 = ($1_ltype)$input; %}
+%typemap(out) TYPE *INPUT, TYPE &INPUT ""
%typemap(freearg) TYPE *INPUT, TYPE &INPUT ""
-%typemap(directorout) TYPE *INPUT
-%{ $result = ($1_ltype)&$input; %}
-
-%typemap(directorout) TYPE &INPUT
-%{ $result = ($1_ltype)$input; %}
-
-%typemap(directorin) TYPE &INPUT
-%{ $1 = ($input_ltype)&$input; %}
+%typemap(argout) TYPE *INPUT, TYPE &INPUT ""
// %typemap(typecheck) TYPE *INPUT = TYPE;
// %typemap(typecheck) TYPE &INPUT = TYPE;
@@ -95,7 +87,7 @@ INPUT_TYPEMAP(long, int64);
INPUT_TYPEMAP(unsigned long, uint64);
INPUT_TYPEMAP(long long, int64);
INPUT_TYPEMAP(unsigned long long, uint64);
-INPUT_TYPEMAP(float, float);
+INPUT_TYPEMAP(float, float32);
INPUT_TYPEMAP(double, float64);
#undef INPUT_TYPEMAP
@@ -165,7 +157,7 @@ char * typemaps instead:
%define OUTPUT_TYPEMAP(TYPE, GOTYPE)
%typemap(gotype) TYPE *OUTPUT, TYPE &OUTPUT %{[]GOTYPE%}
-%typemap(in) TYPE *OUTPUT($*1_ltype temp)
+%typemap(in) TYPE *OUTPUT($*1_ltype temp), TYPE &OUTPUT($*1_ltype temp)
{
if ($input.len == 0) {
_swig_gopanic("array must contain at least 1 element");
@@ -173,38 +165,16 @@ char * typemaps instead:
$1 = &temp;
}
-%typemap(in) TYPE &OUTPUT($*1_ltype temp)
-{
- if ($input->len == 0) {
- _swig_gopanic("array must contain at least 1 element");
- }
- $1 = &temp;
-}
+%typemap(out) TYPE *OUTPUT, TYPE &OUTPUT ""
%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT ""
-%typemap(argout) TYPE *OUTPUT
+%typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT
{
TYPE* a = (TYPE *) $input.array;
a[0] = temp$argnum;
}
-%typemap(argout) TYPE &OUTPUT
-{
- TYPE* a = (TYPE *) $input->array;
- a[0] = temp$argnum;
-}
-
-%typemap(directorout,warning="Need to provide TYPE *OUTPUT directorout typemap") TYPE *OUTPUT, TYPE &OUTPUT {
-}
-
-%typemap(directorin) TYPE &OUTPUT
-%{ *(($&1_ltype) $input = &$1; %}
-
-%typemap(directorin,warning="Need to provide TYPE *OUTPUT directorin typemap, TYPE array length is unknown") TYPE *OUTPUT
-{
-}
-
%enddef
OUTPUT_TYPEMAP(bool, bool);
@@ -219,7 +189,7 @@ OUTPUT_TYPEMAP(long, int64);
OUTPUT_TYPEMAP(unsigned long, uint64);
OUTPUT_TYPEMAP(long long, int64);
OUTPUT_TYPEMAP(unsigned long long, uint64);
-OUTPUT_TYPEMAP(float, float);
+OUTPUT_TYPEMAP(float, float32);
OUTPUT_TYPEMAP(double, float64);
#undef OUTPUT_TYPEMAP
@@ -289,31 +259,18 @@ char * typemaps instead:
%define INOUT_TYPEMAP(TYPE, GOTYPE)
%typemap(gotype) TYPE *INOUT, TYPE &INOUT %{[]GOTYPE%}
-%typemap(in) TYPE *INOUT {
+%typemap(in) TYPE *INOUT, TYPE &INOUT {
if ($input.len == 0) {
_swig_gopanic("array must contain at least 1 element");
}
$1 = ($1_ltype) $input.array;
}
-%typemap(in) TYPE &INOUT {
- if ($input->len == 0) {
- _swig_gopanic("array must contain at least 1 element");
- }
- $1 = ($1_ltype) $input->array;
-}
+%typemap(out) TYPE *INOUT, TYPE &INOUT ""
%typemap(freearg) TYPE *INOUT, TYPE &INOUT ""
-%typemap(directorout,warning="Need to provide TYPE *INOUT directorout typemap") TYPE *INOUT, TYPE &INOUT {
-}
-
-%typemap(directorin) TYPE &INOUT
-%{ *(($&1_ltype)&$input) = &$1; %}
-
-%typemap(directorin,warning="Need to provide TYPE *INOUT directorin typemap, TYPE array length is unknown") TYPE *INOUT, TYPE &INOUT
-{
-}
+%typemap(argout) TYPE *INOUT, TYPE &INOUT ""
%enddef
@@ -329,7 +286,7 @@ INOUT_TYPEMAP(long, int64);
INOUT_TYPEMAP(unsigned long, uint64);
INOUT_TYPEMAP(long long, int64);
INOUT_TYPEMAP(unsigned long long, uint64);
-INOUT_TYPEMAP(float, float);
+INOUT_TYPEMAP(float, float32);
INOUT_TYPEMAP(double, float64);
#undef INOUT_TYPEMAP