diff options
author | Misha Seltzer <misha@seltzer.com> | 2015-02-09 18:34:04 +0200 |
---|---|---|
committer | Misha Seltzer <mishas@google.com> | 2015-02-17 10:27:45 +0200 |
commit | 8da4d20308c015e679eaba6b1d312af45cccbe48 (patch) | |
tree | 2b2198a7b3b5bcc8f7b22b70bc6b38af7130c132 /Examples/test-suite | |
parent | ece9854e8f54b88962ae9285e390b0c206b176a1 (diff) | |
download | swig-8da4d20308c015e679eaba6b1d312af45cccbe48.tar.gz |
Fixed SWIG go for cases when SWIG %import-s another package which is located in a subdirectory.
Diffstat (limited to 'Examples/test-suite')
-rw-r--r-- | Examples/test-suite/go/Makefile.in | 23 | ||||
-rw-r--r-- | Examples/test-suite/go/go_subdir_import_runme.go | 16 | ||||
-rw-r--r-- | Examples/test-suite/go_subdir_import.list | 3 | ||||
-rw-r--r-- | Examples/test-suite/go_subdir_import_a.i | 37 | ||||
-rw-r--r-- | Examples/test-suite/go_subdir_import_b.i | 12 | ||||
-rw-r--r-- | Examples/test-suite/testdir/go_subdir_import/go_subdir_import_c.i | 12 |
6 files changed, 103 insertions, 0 deletions
diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in index 4480ecf1f..7eb12d2f8 100644 --- a/Examples/test-suite/go/Makefile.in +++ b/Examples/test-suite/go/Makefile.in @@ -28,6 +28,9 @@ CPP_TEST_CASES = \ go_inout \ go_director_inout +MULTI_CPP_TEST_CASES = \ + go_subdir_import + include $(srcdir)/../common.mk .SUFFIXES: .cpptest .ctest .multicpptest @@ -59,6 +62,25 @@ multi_import.multicpptest: done $(run_multi_testcase) +go_subdir_import.multicpptest: + $(setup) + mkdir -p testdir/go_subdir_import/ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ + SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ + INTERFACEPATH="go_subdir_import_b.i" \ + INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) -outdir ." NOLINK=true \ + TARGET="$(TARGETPREFIX)go_subdir_import_b$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" \ + INTERFACE="testdir/go_subdir_import/go_subdir_import_b.i" \ + $(LANGUAGE)$(VARIANT)_cpp; + for f in testdir/go_subdir_import/go_subdir_import_c go_subdir_import_a ; do \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \ + SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ + INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ + $(LANGUAGE)$(VARIANT)_cpp; \ + done + $(run_multi_testcase) + # Runs the testcase. run_testcase = \ if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ @@ -108,6 +130,7 @@ clean: rm -f mod_a.go mod_b.go imports_a.go imports_b.go rm -f clientdata_prop_a.go clientdata_prop_b.go rm -f multi_import_a.go multi_import_b.go + rm -rf go_subdir_import_a.go testdir rm -f packageoption_a.go packageoption_b.go packageoption_c.go rm -f import_stl_a.go import_stl_b.go diff --git a/Examples/test-suite/go/go_subdir_import_runme.go b/Examples/test-suite/go/go_subdir_import_runme.go new file mode 100644 index 000000000..f90a6eb54 --- /dev/null +++ b/Examples/test-suite/go/go_subdir_import_runme.go @@ -0,0 +1,16 @@ +package main + +import ( + "go_subdir_import_a" + "testdir/go_subdir_import/go_subdir_import_b" + "testdir/go_subdir_import/go_subdir_import_c" +) + +func main() { + b := go_subdir_import_b.NewObjB(); + c := go_subdir_import_c.NewObjC(); + v := go_subdir_import_a.AddFive(b, c) + if v != 50 { + panic(0) + } +} diff --git a/Examples/test-suite/go_subdir_import.list b/Examples/test-suite/go_subdir_import.list new file mode 100644 index 000000000..e117d32fa --- /dev/null +++ b/Examples/test-suite/go_subdir_import.list @@ -0,0 +1,3 @@ +testdir/go_subdir_import/go_subdir_import_c +go_subdir_import_b +go_subdir_import_a diff --git a/Examples/test-suite/go_subdir_import_a.i b/Examples/test-suite/go_subdir_import_a.i new file mode 100644 index 000000000..72b28786e --- /dev/null +++ b/Examples/test-suite/go_subdir_import_a.i @@ -0,0 +1,37 @@ +/* File : go_subdir_import_a.i */ + +/* + * This files helps check the case where the SWIG-generated .go file needs to + * import another, SWIG-generated, module that is in a relative subdirectory. + * This case might happen for two different reasons: + * 1) Importing a module for which the .i file is in a subdirectory relatively + * to this file (this is tested here with go_subdir_import_c). + * 2) Importing a module whos module name is a path (this is tested here with + * go_subdir_import_b). + * + * This file is the "root" file that imports the two modules which will be + * generated (by swig) in a relative subdirectory. + */ +%module go_subdir_import_a + +%import(module="testdir/go_subdir_import/go_subdir_import_c") "testdir/go_subdir_import/go_subdir_import_c.i" +%import "go_subdir_import_b.i" + +%{ +class ObjC { + public: + int getInt() const; +}; + +class ObjB { + public: + int getInt() const; +}; +%} + +%inline %{ +int AddFive(const ObjB& b, const ObjC& c) { + return b.getInt() + c.getInt() + 5; +} +%} + diff --git a/Examples/test-suite/go_subdir_import_b.i b/Examples/test-suite/go_subdir_import_b.i new file mode 100644 index 000000000..b87f7cf3c --- /dev/null +++ b/Examples/test-suite/go_subdir_import_b.i @@ -0,0 +1,12 @@ +/* File : go_subdir_import_b.i */ +%module "testdir/go_subdir_import/go_subdir_import_b" + +%inline %{ +class ObjB { + public: + int getInt() const { + return 27; + } +}; +%} + diff --git a/Examples/test-suite/testdir/go_subdir_import/go_subdir_import_c.i b/Examples/test-suite/testdir/go_subdir_import/go_subdir_import_c.i new file mode 100644 index 000000000..2c2c2e1fe --- /dev/null +++ b/Examples/test-suite/testdir/go_subdir_import/go_subdir_import_c.i @@ -0,0 +1,12 @@ +/* File : go_subdir_import_c.i */ +%module go_subdir_import_c + +%inline %{ +class ObjC { + public: + int getInt() const { + return 18; + } +}; +%} + |