summaryrefslogtreecommitdiffstats
path: root/Tests/UseSWIG/ModuleName/runme.py
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2018-11-27 14:10:32 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2018-12-07 17:51:57 (GMT)
commitdff28141dcddd90b0bb95740d66b8f698cc8da6a (patch)
tree0a6a26af46a22a672f7e12a53550b7f691559dcb /Tests/UseSWIG/ModuleName/runme.py
parent7b3d4799f8c03162d537e65effd3dd8d56fc3386 (diff)
downloadCMake-dff28141dcddd90b0bb95740d66b8f698cc8da6a.zip
CMake-dff28141dcddd90b0bb95740d66b8f698cc8da6a.tar.gz
CMake-dff28141dcddd90b0bb95740d66b8f698cc8da6a.tar.bz2
UseSWIG: add management of SWIG option -module
When file property SWIG_MODULE_NAME is specified, provide option -module to SWIG compiler. Fixes: #18374
Diffstat (limited to 'Tests/UseSWIG/ModuleName/runme.py')
-rw-r--r--Tests/UseSWIG/ModuleName/runme.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/Tests/UseSWIG/ModuleName/runme.py b/Tests/UseSWIG/ModuleName/runme.py
new file mode 100644
index 0000000..c37e4a7
--- /dev/null
+++ b/Tests/UseSWIG/ModuleName/runme.py
@@ -0,0 +1,52 @@
+# file: runme.py
+
+# This file illustrates the shadow-class C++ interface generated
+# by SWIG.
+
+from __future__ import print_function
+
+import new_example
+
+# ----- Object creation -----
+
+print ("Creating some objects:")
+c = new_example.Circle(10)
+print (" Created circle", c)
+s = new_example.Square(10)
+print (" Created square", s)
+
+# ----- Access a static member -----
+
+print ("\nA total of", new_example.cvar.Shape_nshapes,"shapes were created")
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+print ("\nHere is their current position:")
+print (" Circle = (%f, %f)" % (c.x,c.y))
+print (" Square = (%f, %f)" % (s.x,s.y))
+
+# ----- Call some methods -----
+
+print ("\nHere are some properties of the shapes:")
+for o in [c,s]:
+ print (" ", o)
+ print (" area = ", o.area())
+ print (" perimeter = ", o.perimeter())
+
+print ("\nGuess I'll clean up now")
+
+# Note: this invokes the virtual destructor
+del c
+del s
+
+s = 3
+print (new_example.cvar.Shape_nshapes,"shapes remain")
+print ("Goodbye")