diff --git a/examples/app-library/linux/bridge/Bridge.go b/examples/app-library/linux/bridge/Bridge.go new file mode 100644 index 00000000000000..6cfc24f08a692d --- /dev/null +++ b/examples/app-library/linux/bridge/Bridge.go @@ -0,0 +1,297 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (https://www.swig.org). + * Version 4.3.0 + * + * Do not make changes to this file unless you know what you are doing - modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +// source: Bridge.i + +package bridge + +/* +#define intgo swig_intgo +typedef void *swig_voidp; + +#include +#include + + +typedef ptrdiff_t intgo; +typedef size_t uintgo; + + + +typedef struct { char *p; intgo n; } _gostring_; +typedef struct { void* array; intgo len; intgo cap; } _goslice_; + + +extern void _wrap_Swig_free_Bridge_3fd1683bd95671e7(uintptr_t arg1); +extern uintptr_t _wrap_Swig_malloc_Bridge_3fd1683bd95671e7(swig_intgo arg1); +extern void _wrap_ApplicationInit_Bridge_3fd1683bd95671e7(void); +extern void _wrap_ApplicationShutdown_Bridge_3fd1683bd95671e7(void); +extern uintptr_t _wrap__swig_NewDirectorBridgeBridge_Bridge_3fd1683bd95671e7(int); +extern void _wrap_DeleteDirectorBridge_Bridge_3fd1683bd95671e7(uintptr_t arg1); +extern void _wrap__swig_DirectorBridge_upcall_Cb_Bridge_3fd1683bd95671e7(uintptr_t); +extern void _wrap_delete_Bridge_Bridge_3fd1683bd95671e7(uintptr_t arg1); +extern void _wrap_Bridge_cb_Bridge_3fd1683bd95671e7(uintptr_t arg1); +extern uintptr_t _wrap_new_Bridge_Bridge_3fd1683bd95671e7(void); +extern uintptr_t _wrap_new_App_Bridge_3fd1683bd95671e7(void); +extern void _wrap_delete_App_Bridge_3fd1683bd95671e7(uintptr_t arg1); +extern void _wrap_App_delBridge_Bridge_3fd1683bd95671e7(uintptr_t arg1); +extern void _wrap_App_setBridge_Bridge_3fd1683bd95671e7(uintptr_t arg1, uintptr_t arg2); +extern swig_intgo _wrap_App_start_Bridge_3fd1683bd95671e7(uintptr_t arg1, swig_intgo arg2, swig_voidp arg3); +extern void _wrap_App_cb_Bridge_3fd1683bd95671e7(uintptr_t arg1); +#undef intgo +*/ +import "C" + +import "syscall" +import "unsafe" +import "sync" + + +type _ syscall.Sockaddr + + + + +type _ unsafe.Pointer + + + +var Swig_escape_always_false bool +var Swig_escape_val interface{} + + +type _swig_fnptr *byte +type _swig_memberptr *byte + + +func getSwigcptr(v interface { Swigcptr() uintptr }) uintptr { + if v == nil { + return 0 + } + return v.Swigcptr() +} + + +type _ sync.Mutex + +func Swig_free(arg1 uintptr) { + _swig_i_0 := arg1 + C._wrap_Swig_free_Bridge_3fd1683bd95671e7(C.uintptr_t(_swig_i_0)) +} + +func Swig_malloc(arg1 int) (_swig_ret uintptr) { + var swig_r uintptr + _swig_i_0 := arg1 + swig_r = (uintptr)(C._wrap_Swig_malloc_Bridge_3fd1683bd95671e7(C.swig_intgo(_swig_i_0))) + return swig_r +} + +func ApplicationInit() { + C._wrap_ApplicationInit_Bridge_3fd1683bd95671e7() +} + +func ApplicationShutdown() { + C._wrap_ApplicationShutdown_Bridge_3fd1683bd95671e7() +} + +type _swig_DirectorBridge struct { + SwigcptrBridge + v interface{} +} + +func (p *_swig_DirectorBridge) Swigcptr() uintptr { + return getSwigcptr(p.SwigcptrBridge) +} + +func (p *_swig_DirectorBridge) SwigIsBridge() { +} + +func (p *_swig_DirectorBridge) DirectorInterface() interface{} { + return p.v +} + +func NewDirectorBridge(v interface{}) Bridge { + p := &_swig_DirectorBridge{0, v} + p.SwigcptrBridge = SwigcptrBridge(C._wrap__swig_NewDirectorBridgeBridge_Bridge_3fd1683bd95671e7(C.int(swigDirectorAdd(p)))) + return p +} + +func DeleteDirectorBridge(arg1 Bridge) { + _swig_i_0 := getSwigcptr(arg1) + C._wrap_DeleteDirectorBridge_Bridge_3fd1683bd95671e7(C.uintptr_t(_swig_i_0)) +} + +//export Swiggo_DeleteDirector_Bridge_Bridge_3fd1683bd95671e7 +func Swiggo_DeleteDirector_Bridge_Bridge_3fd1683bd95671e7(c int) { + swigDirectorLookup(c).(*_swig_DirectorBridge).SwigcptrBridge = 0 + swigDirectorDelete(c) +} + +type _swig_DirectorInterfaceBridgeCb interface { + Cb() +} + +func (swig_p *_swig_DirectorBridge) Cb() { + if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceBridgeCb); swig_ok { + swig_g.Cb() + return + } + C._wrap__swig_DirectorBridge_upcall_Cb_Bridge_3fd1683bd95671e7(C.uintptr_t(swig_p.SwigcptrBridge)) +} + +func DirectorBridgeCb(swig_p Bridge) { + C._wrap__swig_DirectorBridge_upcall_Cb_Bridge_3fd1683bd95671e7(C.uintptr_t(swig_p.(*_swig_DirectorBridge).SwigcptrBridge)) +} + +//export Swig_DirectorBridge_callback_cb_Bridge_3fd1683bd95671e7 +func Swig_DirectorBridge_callback_cb_Bridge_3fd1683bd95671e7(swig_c int) { + swig_p := swigDirectorLookup(swig_c).(*_swig_DirectorBridge) + swig_p.Cb() +} + +type SwigcptrBridge uintptr + +func (p SwigcptrBridge) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrBridge) SwigIsBridge() { +} + +func (p SwigcptrBridge) DirectorInterface() interface{} { + return nil +} + +func DeleteBridge(arg1 Bridge) { + _swig_i_0 := getSwigcptr(arg1) + C._wrap_delete_Bridge_Bridge_3fd1683bd95671e7(C.uintptr_t(_swig_i_0)) +} + +func (arg1 SwigcptrBridge) Cb() { + _swig_i_0 := arg1 + C._wrap_Bridge_cb_Bridge_3fd1683bd95671e7(C.uintptr_t(_swig_i_0)) +} + +func NewBridge() (_swig_ret Bridge) { + var swig_r Bridge + swig_r = (Bridge)(SwigcptrBridge(C._wrap_new_Bridge_Bridge_3fd1683bd95671e7())) + return swig_r +} + +type Bridge interface { + Swigcptr() uintptr + SwigIsBridge() + DirectorInterface() interface{} + Cb() +} + +type SwigcptrApp uintptr + +func (p SwigcptrApp) Swigcptr() uintptr { + return (uintptr)(p) +} + +func (p SwigcptrApp) SwigIsApp() { +} + +func NewApp() (_swig_ret App) { + var swig_r App + swig_r = (App)(SwigcptrApp(C._wrap_new_App_Bridge_3fd1683bd95671e7())) + return swig_r +} + +func DeleteApp(arg1 App) { + _swig_i_0 := getSwigcptr(arg1) + C._wrap_delete_App_Bridge_3fd1683bd95671e7(C.uintptr_t(_swig_i_0)) +} + +func (arg1 SwigcptrApp) DelBridge() { + _swig_i_0 := arg1 + C._wrap_App_delBridge_Bridge_3fd1683bd95671e7(C.uintptr_t(_swig_i_0)) +} + +func (arg1 SwigcptrApp) SetBridge(arg2 Bridge) { + _swig_i_0 := arg1 + _swig_i_1 := getSwigcptr(arg2) + C._wrap_App_setBridge_Bridge_3fd1683bd95671e7(C.uintptr_t(_swig_i_0), C.uintptr_t(_swig_i_1)) +} + +func (arg1 SwigcptrApp) Start(arg2 int, arg3 *string) (_swig_ret int) { + var swig_r int + _swig_i_0 := arg1 + _swig_i_1 := arg2 + _swig_i_2 := arg3 + swig_r = (int)(C._wrap_App_start_Bridge_3fd1683bd95671e7(C.uintptr_t(_swig_i_0), C.swig_intgo(_swig_i_1), C.swig_voidp(_swig_i_2))) + return swig_r +} + +func (arg1 SwigcptrApp) Cb() { + _swig_i_0 := arg1 + C._wrap_App_cb_Bridge_3fd1683bd95671e7(C.uintptr_t(_swig_i_0)) +} + +type App interface { + Swigcptr() uintptr + SwigIsApp() + DelBridge() + SetBridge(arg2 Bridge) + Start(arg2 int, arg3 *string) (_swig_ret int) + Cb() +} + + +type SwigcptrSwigDirector_Bridge uintptr +type SwigDirector_Bridge interface { + Swigcptr() uintptr; +} +func (p SwigcptrSwigDirector_Bridge) Swigcptr() uintptr { + return uintptr(p) +} + + + +var swigDirectorTrack struct { + sync.Mutex + m map[int]interface{} + c int +} + +func swigDirectorAdd(v interface{}) int { + swigDirectorTrack.Lock() + defer swigDirectorTrack.Unlock() + if swigDirectorTrack.m == nil { + swigDirectorTrack.m = make(map[int]interface{}) + } + swigDirectorTrack.c++ + ret := swigDirectorTrack.c + swigDirectorTrack.m[ret] = v + return ret +} + +func swigDirectorLookup(c int) interface{} { + swigDirectorTrack.Lock() + defer swigDirectorTrack.Unlock() + ret := swigDirectorTrack.m[c] + if ret == nil { + panic("C++ director pointer not found (possible use-after-free)") + } + return ret +} + +func swigDirectorDelete(c int) { + swigDirectorTrack.Lock() + defer swigDirectorTrack.Unlock() + if swigDirectorTrack.m[c] == nil { + if c > swigDirectorTrack.c { + panic("C++ director pointer invalid (possible memory corruption") + } else { + panic("C++ director pointer not found (possible use-after-free)") + } + } + delete(swigDirectorTrack.m, c) +} diff --git a/examples/app-library/linux/bridge/Bridge.h b/examples/app-library/linux/bridge/Bridge.h new file mode 100644 index 00000000000000..518dd5ebe2af6c --- /dev/null +++ b/examples/app-library/linux/bridge/Bridge.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include + +class App +{ +private: + Bridge * _bridge; + +public: + App() : _bridge(0) {} + ~App() { delBridge(); } + void delBridge() + { + delete _bridge; + _bridge = 0; + } + void setBridge(Bridge * cb) + { + delBridge(); + _bridge = cb; + } + void cb() + { + if (_bridge) + _bridge->cb(); + } +}; diff --git a/examples/app-library/linux/bridge/Bridge.i b/examples/app-library/linux/bridge/Bridge.i new file mode 100644 index 00000000000000..1f324a86e45da1 --- /dev/null +++ b/examples/app-library/linux/bridge/Bridge.i @@ -0,0 +1,9 @@ +/* File : Bridge.i */ +%module(directors="1") Bridge +%{ +#include "Bridge.h" +%} +/* turn on director wrapping Bridge */ +%feature("director") Bridge; + +%include "Bridge.h" diff --git a/examples/app-library/linux/bridge/Bridge_wrap.cxx b/examples/app-library/linux/bridge/Bridge_wrap.cxx new file mode 100644 index 00000000000000..712fea801dee92 --- /dev/null +++ b/examples/app-library/linux/bridge/Bridge_wrap.cxx @@ -0,0 +1,561 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (https://www.swig.org). + * Version 4.3.0 + * + * Do not make changes to this file unless you know what you are doing - modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +// source: Bridge.i + + + +#define SWIG_VERSION 0x040300 +#define SWIGGO +#define SWIGMODULE Bridge +#define SWIGGO_PREFIX go.Bridge +#define SWIG_DIRECTORS +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + +#if defined(__cplusplus) && __cplusplus >=201103L +# define SWIG_NULLPTR nullptr +#else +# define SWIG_NULLPTR NULL +#endif + +/* ----------------------------------------------------------------------------- + * swigcompat.swg + * + * Macros to provide support compatibility with older C and C++ standards. + * + * Note that SWIG expects __cplusplus to be defined to the appropriate C++ standard. + * MSVC users are urged to check and examine the /Zc:__cplusplus compiler option. + * See https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus. + * ----------------------------------------------------------------------------- */ + +/* C99 and C++11 should provide snprintf, but define SWIG_NO_SNPRINTF + * if you're missing it. + */ +#if ((defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || \ + (defined __cplusplus && __cplusplus >= 201103L) || \ + defined SWIG_HAVE_SNPRINTF) && \ + !defined SWIG_NO_SNPRINTF +# define SWIG_snprintf(O,S,F,A) snprintf(O,S,F,A) +# define SWIG_snprintf2(O,S,F,A,B) snprintf(O,S,F,A,B) +#else +/* Fallback versions ignore the buffer size, but most of our uses either have a + * fixed maximum possible size or dynamically allocate a buffer that's large + * enough. + */ +# define SWIG_snprintf(O,S,F,A) sprintf(O,F,A) +# define SWIG_snprintf2(O,S,F,A,B) sprintf(O,F,A,B) +#endif + + +#include +#include +#include +#include +#include + + + +typedef ptrdiff_t intgo; +typedef size_t uintgo; + + + +typedef struct { char *p; intgo n; } _gostring_; +typedef struct { void* array; intgo len; intgo cap; } _goslice_; + + + +#define SWIGGO_GCCGO + +#ifdef __cplusplus +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 + +/* ----------------------------------------------------------------------------- + * director_common.swg + * + * This file contains support for director classes which is common between + * languages. + * ----------------------------------------------------------------------------- */ + +/* + Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the + 'Swig' namespace. This could be useful for multi-modules projects. +*/ +#ifdef SWIG_DIRECTOR_STATIC +/* Force anonymous (static) namespace */ +#define Swig +#endif +/* ----------------------------------------------------------------------------- + * director.swg + * + * This file contains support for director classes so that Go proxy + * methods can be called from C++. + * ----------------------------------------------------------------------------- */ + +#include +#include + +namespace Swig { + + class DirectorException : public std::exception { + }; +} + +/* Handle memory management for directors. */ + +namespace { + struct GCItem { + virtual ~GCItem() {} + }; + + struct GCItem_var { + GCItem_var(GCItem *item = 0) : _item(item) { + } + + GCItem_var& operator=(GCItem *item) { + GCItem *tmp = _item; + _item = item; + delete tmp; + return *this; + } + + ~GCItem_var() { + delete _item; + } + + GCItem* operator->() { + return _item; + } + + private: + GCItem *_item; + }; + + template + struct GCItem_T : GCItem { + GCItem_T(Type *ptr) : _ptr(ptr) { + } + + virtual ~GCItem_T() { + delete _ptr; + } + + private: + Type *_ptr; + }; +} + +class Swig_memory { +public: + template + void swig_acquire_pointer(Type* vptr) { + if (vptr) { + swig_owner[vptr] = new GCItem_T(vptr); + } + } +private: + typedef std::map swig_ownership_map; + swig_ownership_map swig_owner; +}; + +template +static void swig_acquire_pointer(Swig_memory** pmem, Type* ptr) { + if (!pmem) { + *pmem = new Swig_memory; + } + (*pmem)->swig_acquire_pointer(ptr); +} + +#ifdef __cplusplus +#include +/* SwigValueWrapper is described in swig.swg */ +template class SwigValueWrapper { + struct SwigSmartPointer { + T *ptr; + SwigSmartPointer(T *p) : ptr(p) { } + ~SwigSmartPointer() { delete ptr; } + SwigSmartPointer& operator=(SwigSmartPointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } + void reset(T *p) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = p; } + } pointer; + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); + SwigValueWrapper(const SwigValueWrapper& rhs); +public: + SwigValueWrapper() : pointer(0) { } + SwigValueWrapper& operator=(const T& t) { SwigSmartPointer tmp(new T(t)); pointer = tmp; return *this; } +#if __cplusplus >=201103L + SwigValueWrapper& operator=(T&& t) { SwigSmartPointer tmp(new T(std::move(t))); pointer = tmp; return *this; } + operator T&&() const { return std::move(*pointer.ptr); } +#else + operator T&() const { return *pointer.ptr; } +#endif + T *operator&() const { return pointer.ptr; } + static void reset(SwigValueWrapper& t, T *p) { t.pointer.reset(p); } +}; + +/* + * SwigValueInit() is a generic initialisation solution as the following approach: + * + * T c_result = T(); + * + * doesn't compile for all types for example: + * + * unsigned int c_result = unsigned int(); + */ +template T SwigValueInit() { + return T(); +} + +#if __cplusplus >=201103L +# define SWIG_STD_MOVE(OBJ) std::move(OBJ) +#else +# define SWIG_STD_MOVE(OBJ) OBJ +#endif + +#endif + + +static void Swig_free(void* p) { + free(p); +} + +static void* Swig_malloc(int c) { + return malloc(c); +} + + +#include "Bridge.h" + + +// C++ director class methods. +#include "Bridge_wrap.h" + +SwigDirector_Bridge::SwigDirector_Bridge(int swig_p) + : Bridge(), + go_val(swig_p), swig_mem(0) +{ } + +extern "C" void Swiggo_DeleteDirector_Bridge_Bridge_3fd1683bd95671e7(intgo); +SwigDirector_Bridge::~SwigDirector_Bridge() +{ + Swiggo_DeleteDirector_Bridge_Bridge_3fd1683bd95671e7(go_val); + delete swig_mem; +} + +extern "C" void Swig_DirectorBridge_callback_cb_Bridge_3fd1683bd95671e7(int); +void SwigDirector_Bridge::cb() { + Swig_DirectorBridge_callback_cb_Bridge_3fd1683bd95671e7(go_val); +} + +#ifdef __cplusplus +extern "C" { +#endif + +void _wrap_Swig_free_Bridge_3fd1683bd95671e7(void *_swig_go_0) { + void *arg1 = (void *) 0 ; + + arg1 = *(void **)&_swig_go_0; + + Swig_free(arg1); + +} + + +void *_wrap_Swig_malloc_Bridge_3fd1683bd95671e7(intgo _swig_go_0) { + int arg1 ; + void *result = 0 ; + void *_swig_go_result; + + arg1 = (int)_swig_go_0; + + result = (void *)Swig_malloc(arg1); + *(void **)&_swig_go_result = (void *)result; + return _swig_go_result; +} + + +void _wrap_ApplicationInit_Bridge_3fd1683bd95671e7() { + ApplicationInit(); + +} + + +void _wrap_ApplicationShutdown_Bridge_3fd1683bd95671e7() { + ApplicationShutdown(); + +} + + +Bridge *_wrap__swig_NewDirectorBridgeBridge_Bridge_3fd1683bd95671e7(intgo _swig_go_0) { + int arg1 ; + Bridge *result = 0 ; + Bridge *_swig_go_result; + + arg1 = (int)_swig_go_0; + + result = new SwigDirector_Bridge(arg1); + *(Bridge **)&_swig_go_result = (Bridge *)result; + return _swig_go_result; +} + + +void _wrap_DeleteDirectorBridge_Bridge_3fd1683bd95671e7(Bridge *_swig_go_0) { + Bridge *arg1 = (Bridge *) 0 ; + + arg1 = *(Bridge **)&_swig_go_0; + + delete arg1; + +} + + +void _wrap__swig_DirectorBridge_upcall_Cb_Bridge_3fd1683bd95671e7(SwigDirector_Bridge *_swig_go_0) { + SwigDirector_Bridge *arg1 = (SwigDirector_Bridge *) 0 ; + + arg1 = *(SwigDirector_Bridge **)&_swig_go_0; + + arg1->_swig_upcall_cb(); + +} + + +void _wrap_delete_Bridge_Bridge_3fd1683bd95671e7(Bridge *_swig_go_0) { + Bridge *arg1 = (Bridge *) 0 ; + + arg1 = *(Bridge **)&_swig_go_0; + + delete arg1; + +} + + +void _wrap_Bridge_cb_Bridge_3fd1683bd95671e7(Bridge *_swig_go_0) { + Bridge *arg1 = (Bridge *) 0 ; + + arg1 = *(Bridge **)&_swig_go_0; + + (arg1)->cb(); + +} + + +Bridge *_wrap_new_Bridge_Bridge_3fd1683bd95671e7() { + Bridge *result = 0 ; + Bridge *_swig_go_result; + + + result = (Bridge *)new Bridge(); + *(Bridge **)&_swig_go_result = (Bridge *)result; + return _swig_go_result; +} + + +App *_wrap_new_App_Bridge_3fd1683bd95671e7() { + App *result = 0 ; + App *_swig_go_result; + + + result = (App *)new App(); + *(App **)&_swig_go_result = (App *)result; + return _swig_go_result; +} + + +void _wrap_delete_App_Bridge_3fd1683bd95671e7(App *_swig_go_0) { + App *arg1 = (App *) 0 ; + + arg1 = *(App **)&_swig_go_0; + + delete arg1; + +} + + +void _wrap_App_delBridge_Bridge_3fd1683bd95671e7(App *_swig_go_0) { + App *arg1 = (App *) 0 ; + + arg1 = *(App **)&_swig_go_0; + + (arg1)->delBridge(); + +} + + +void _wrap_App_setBridge_Bridge_3fd1683bd95671e7(App *_swig_go_0, Bridge *_swig_go_1) { + App *arg1 = (App *) 0 ; + Bridge *arg2 = (Bridge *) 0 ; + + arg1 = *(App **)&_swig_go_0; + arg2 = *(Bridge **)&_swig_go_1; + + (arg1)->setBridge(arg2); + +} + + +intgo _wrap_App_start_Bridge_3fd1683bd95671e7(App *_swig_go_0, intgo _swig_go_1, _gostring_* _swig_go_2) { + App *arg1 = (App *) 0 ; + int arg2 ; + char **arg3 = (char **) 0 ; + int result; + intgo _swig_go_result; + + arg1 = *(App **)&_swig_go_0; + arg2 = (int)_swig_go_1; + arg3 = *(char ***)&_swig_go_2; + + result = (int)(arg1)->start(arg2,arg3); + _swig_go_result = result; + return _swig_go_result; +} + + +void _wrap_App_cb_Bridge_3fd1683bd95671e7(App *_swig_go_0) { + App *arg1 = (App *) 0 ; + + arg1 = *(App **)&_swig_go_0; + + (arg1)->cb(); + +} + + +#ifdef __cplusplus +} +#endif + diff --git a/examples/app-library/linux/bridge/Bridge_wrap.h b/examples/app-library/linux/bridge/Bridge_wrap.h new file mode 100644 index 00000000000000..38b61db24cb887 --- /dev/null +++ b/examples/app-library/linux/bridge/Bridge_wrap.h @@ -0,0 +1,30 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (https://www.swig.org). + * Version 4.3.0 + * + * Do not make changes to this file unless you know what you are doing - modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +// source: Bridge.i + +#ifndef SWIG_Bridge_WRAP_H_ +#define SWIG_Bridge_WRAP_H_ + +class Swig_memory; + +class SwigDirector_Bridge : public Bridge +{ + public: + SwigDirector_Bridge(int swig_p); + virtual ~SwigDirector_Bridge(); + void _swig_upcall_cb() { + Bridge::cb(); + } + virtual void cb(); + private: + intgo go_val; + Swig_memory *swig_mem; +}; + +#endif diff --git a/examples/app-library/linux/bridge/GoBridge.go b/examples/app-library/linux/bridge/GoBridge.go new file mode 100644 index 00000000000000..50b4432336bd0f --- /dev/null +++ b/examples/app-library/linux/bridge/GoBridge.go @@ -0,0 +1,41 @@ +package bridge + +import ( + "fmt" +) + +type GoBridge interface { + Bridge + deleteBridge() + IsBridge() +} + +type goBridge struct { + Bridge +} + +func (p *goBridge) deleteBridge() { + DeleteDirectorCallback(p.Bridge) +} + +func (p *goBridge) IsBridge() {} + +type overwrittenMethodsOnBridge struct { + p Bridge +} + +func NewApp() App { + om := &overwrittenMethodsOnBridge{} + p := NewDirectorBridge(om) + om.p = p + + return &goBridge{Bridge: p} +} + +func DeleteBridge(p GoBridge) { + p.deleteBridge() +} + +func (p *overwrittenMethodsOnBridge) Run() { + fmt.Println("GoBridge.Run") +} \ No newline at end of file