From 4079b53396b93a368e3dedac9050fe3d68a69461 Mon Sep 17 00:00:00 2001 From: Erez Geva Date: Sun, 16 Apr 2023 16:46:00 +0200 Subject: Add argc and argv multi-argument to go. Make argc and argv test works in C. Signed-off-by: Erez Geva --- Examples/test-suite/argcargvtest.i | 6 +++++- Examples/test-suite/go/argcargvtest_runme.go | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/go/argcargvtest_runme.go (limited to 'Examples') diff --git a/Examples/test-suite/argcargvtest.i b/Examples/test-suite/argcargvtest.i index 5711441d9..4aea298fb 100644 --- a/Examples/test-suite/argcargvtest.i +++ b/Examples/test-suite/argcargvtest.i @@ -1,6 +1,6 @@ %module argcargvtest -#if !defined(SWIGCSHARP) && !defined(SWIGD) && !defined(SWIGGO) && !defined(SWIGGUILE) && !defined(SWIGJAVA) && !defined(SWIGJAVASCRIPT) && !defined(SWIGMZSCHEME) && !defined(SWIGOCAML) && !defined(SWIGR) && !defined(SWIGSCILAB) +#if !defined(SWIGCSHARP) && !defined(SWIGD) && !defined(SWIGGUILE) && !defined(SWIGJAVA) && !defined(SWIGJAVASCRIPT) && !defined(SWIGMZSCHEME) && !defined(SWIGOCAML) && !defined(SWIGR) && !defined(SWIGSCILAB) %include %apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) } @@ -18,7 +18,11 @@ const char* mainv(size_t argc, const char **argv, int idx) return argv[idx]; } +#ifdef __cplusplus void initializeApp(size_t argc, const char **argv, bool setPGid = true, bool isMakeline = false) +#else +void initializeApp(size_t argc, const char **argv) +#endif { } diff --git a/Examples/test-suite/go/argcargvtest_runme.go b/Examples/test-suite/go/argcargvtest_runme.go new file mode 100644 index 000000000..31c56b8c0 --- /dev/null +++ b/Examples/test-suite/go/argcargvtest_runme.go @@ -0,0 +1,19 @@ +package main + +import wrap "swigtests/argcargvtest" + +func main() { + largs := []string{"hi", "hola", "hello"} + if ri := wrap.Mainc(largs); ri != 3 { + panic(ri) + } + + targs := []string{"hi", "hola"} + if rs := wrap.Mainv(targs, 1); rs != "hola" { + panic(rs) + } + +// wrap.Mainv("hello", 1) // Fail compilation!! + + wrap.InitializeApp(largs) +} -- cgit v1.2.1 From 8c7241040716f72922b6ee88fdee1d28760e82a4 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 20 Apr 2023 09:51:00 +1200 Subject: Drop __cplusplus conditionals from testcase This is a C++ testcase so these aren't useful. --- Examples/test-suite/argcargvtest.i | 4 ---- 1 file changed, 4 deletions(-) (limited to 'Examples') diff --git a/Examples/test-suite/argcargvtest.i b/Examples/test-suite/argcargvtest.i index 4aea298fb..e14e370d8 100644 --- a/Examples/test-suite/argcargvtest.i +++ b/Examples/test-suite/argcargvtest.i @@ -18,11 +18,7 @@ const char* mainv(size_t argc, const char **argv, int idx) return argv[idx]; } -#ifdef __cplusplus void initializeApp(size_t argc, const char **argv, bool setPGid = true, bool isMakeline = false) -#else -void initializeApp(size_t argc, const char **argv) -#endif { } -- cgit v1.2.1 From 0e0e2fffb97d39ff52e2d3c68a4d30c38c692630 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 20 Apr 2023 09:51:44 +1200 Subject: Clarify comment in _runme.go --- Examples/test-suite/go/argcargvtest_runme.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Examples') diff --git a/Examples/test-suite/go/argcargvtest_runme.go b/Examples/test-suite/go/argcargvtest_runme.go index 31c56b8c0..3da3d76dd 100644 --- a/Examples/test-suite/go/argcargvtest_runme.go +++ b/Examples/test-suite/go/argcargvtest_runme.go @@ -13,7 +13,10 @@ func main() { panic(rs) } -// wrap.Mainv("hello", 1) // Fail compilation!! +// For dynamically typed languages we test this throws an exception or similar +// at runtime, but for Go this doesn't even compile (but we can't easily +// test for that here). +// wrap.Mainv("hello", 1) wrap.InitializeApp(largs) } -- cgit v1.2.1