[Go] Add -cgo option, required for Go version 1.5 and later.
This commit is contained in:
parent
df36d84f1b
commit
9ad497c08e
11 changed files with 1697 additions and 300 deletions
|
|
@ -533,7 +533,7 @@
|
|||
%typemap(directorin) enum SWIGTYPE & (intgo e)
|
||||
%{
|
||||
e = (intgo)$1;
|
||||
$input = &e;
|
||||
$input = ($1_ltype)&e;
|
||||
%}
|
||||
|
||||
%typemap(godirectorin) enum SWIGTYPE & ""
|
||||
|
|
|
|||
|
|
@ -19,21 +19,45 @@ static void Swig_free(void* p) {
|
|||
|
||||
%}
|
||||
|
||||
#if SWIGGO_CGO
|
||||
%insert(cgo_comment_typedefs) %{
|
||||
#include <stdint.h>
|
||||
%}
|
||||
#endif
|
||||
|
||||
#if SWIGGO_INTGO_SIZE == 32
|
||||
%insert(runtime) %{
|
||||
typedef int intgo;
|
||||
typedef unsigned int uintgo;
|
||||
%}
|
||||
#if SWIGGO_CGO
|
||||
%insert(cgo_comment_typedefs) %{
|
||||
typedef int intgo;
|
||||
typedef unsigned int uintgo;
|
||||
%}
|
||||
#endif
|
||||
#elif SWIGGO_INTGO_SIZE == 64
|
||||
%insert(runtime) %{
|
||||
typedef long long intgo;
|
||||
typedef unsigned long long uintgo;
|
||||
%}
|
||||
#if SWIGGO_CGO
|
||||
%insert(cgo_comment_typedefs) %{
|
||||
typedef long long intgo;
|
||||
typedef unsigned long long uintgo;
|
||||
%}
|
||||
#endif
|
||||
#else
|
||||
%insert(runtime) %{
|
||||
typedef ptrdiff_t intgo;
|
||||
typedef size_t uintgo;
|
||||
%}
|
||||
#if SWIGGO_CGO
|
||||
%insert(cgo_comment_typedefs) %{
|
||||
typedef ptrdiff_t intgo;
|
||||
typedef size_t uintgo;
|
||||
%}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
%insert(runtime) %{
|
||||
|
|
@ -43,6 +67,17 @@ typedef struct { void* array; intgo len; intgo cap; } _goslice_;
|
|||
|
||||
%}
|
||||
|
||||
#ifdef SWIGGO_CGO
|
||||
|
||||
%insert(cgo_comment_typedefs) %{
|
||||
|
||||
typedef struct { char *p; intgo n; } _gostring_;
|
||||
typedef struct { void* array; intgo len; intgo cap; } _goslice_;
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef SWIGGO_GCCGO
|
||||
/* Boilerplate for C/C++ code when using 6g/8g. This code is compiled
|
||||
with gcc. */
|
||||
|
|
@ -98,6 +133,8 @@ static void _swig_gopanic(const char *p) {
|
|||
|
||||
%}
|
||||
|
||||
#if !SWIGGO_CGO
|
||||
|
||||
/* Boilerplate for C code when using 6g/8g. This code is compiled
|
||||
with 6c/8c. */
|
||||
%insert(gc_header) %{
|
||||
|
|
@ -111,6 +148,8 @@ void *·_cgo_runtime_cgocall = &cgocall;
|
|||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
/* Boilerplate for C/C++ code when using gccgo. */
|
||||
|
|
@ -122,6 +161,17 @@ extern "C" {
|
|||
#endif
|
||||
extern void *_cgo_allocate(size_t);
|
||||
extern void _cgo_panic(const char *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define _swig_goallocate _cgo_allocate
|
||||
#define _swig_gopanic _cgo_panic
|
||||
%}
|
||||
|
||||
#if !SWIGGO_CGO
|
||||
|
||||
%insert(runtime) %{
|
||||
|
||||
/* Implementations of SwigCgocall and friends for different versions
|
||||
of gccgo. The Go code will call these functions using C names with
|
||||
|
|
@ -130,6 +180,10 @@ extern void _cgo_panic(const char *);
|
|||
version. We assume that the version of gcc used to compile this
|
||||
file is the same as the version of gccgo. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SWIG_GCC_VERSION \
|
||||
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
||||
|
||||
|
|
@ -184,13 +238,12 @@ void SwigCgocallBackDone() {
|
|||
}
|
||||
#endif
|
||||
|
||||
#define _swig_goallocate _cgo_allocate
|
||||
#define _swig_gopanic _cgo_panic
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
%insert(runtime) %{
|
||||
|
||||
static _gostring_ _swig_makegostring(const char *p, size_t l) {
|
||||
|
|
@ -209,9 +262,11 @@ static _gostring_ _swig_makegostring(const char *p, size_t l) {
|
|||
|
||||
%go_import("unsafe", _ "runtime/cgo")
|
||||
|
||||
#if !SWIGGO_CGO
|
||||
%insert(go_header) %{
|
||||
var _cgo_runtime_cgocall func(unsafe.Pointer, uintptr)
|
||||
%}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
|
|
@ -231,6 +286,8 @@ type _ unsafe.Pointer
|
|||
|
||||
%}
|
||||
|
||||
#if !SWIGGO_CGO
|
||||
|
||||
/* Swig_always_false is used to conditionally assign parameters to
|
||||
Swig_escape_val so that the compiler thinks that they escape. We
|
||||
only assign them if Swig_always_false is true, which it never is.
|
||||
|
|
@ -241,6 +298,8 @@ var Swig_escape_always_false bool
|
|||
var Swig_escape_val interface{}
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
/* Function pointers are translated by the code in go.cxx into
|
||||
_swig_fnptr. Member pointers are translated to _swig_memberptr. */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue