From 40a17a664e8e0dc891a8484bd32d2b30bfaa7408 Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Sun, 24 Dec 2000 04:07:20 +0000 Subject: [PATCH] various updates git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@969 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Examples/perl5/class/example.pl | 6 ++---- SWIG/Examples/perl5/variables/example.i | 4 ++-- SWIG/Examples/python/class/example.py | 7 ++----- SWIG/Examples/python/constants/example.i | 11 +++++++++++ SWIG/Examples/python/constants/example.py | 2 +- SWIG/Examples/python/variables/example.i | 4 ++-- SWIG/Examples/tcl/class/example1.tcl | 9 +++++---- SWIG/Examples/tcl/variables/example.i | 8 ++++---- 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/SWIG/Examples/perl5/class/example.pl b/SWIG/Examples/perl5/class/example.pl index 07c718488..c14160e92 100644 --- a/SWIG/Examples/perl5/class/example.pl +++ b/SWIG/Examples/perl5/class/example.pl @@ -22,10 +22,8 @@ print "\nA total of $example::Shape_nshapes shapes were created\n"; # Set the location of the object -# Notice how we can do this using functions specific to -# the 'Circle' class. -example::Circle_x_set($c, 20); -example::Circle_y_set($c, 30); +example::Shape_x_set($c, 20); +example::Shape_y_set($c, 30); # Now use the same functions in the base class example::Shape_x_set($s,-10); diff --git a/SWIG/Examples/perl5/variables/example.i b/SWIG/Examples/perl5/variables/example.i index d62f973da..35eafc2c0 100644 --- a/SWIG/Examples/perl5/variables/example.i +++ b/SWIG/Examples/perl5/variables/example.i @@ -27,10 +27,10 @@ extern Point pt; /* Some read-only variables */ -%readonly +%readonly { extern int status; extern char path[256]; -%readwrite +} /* Some helper functions to make it easier to test */ extern void print_vars(); diff --git a/SWIG/Examples/python/class/example.py b/SWIG/Examples/python/class/example.py index 0e578da7b..a8c80502a 100644 --- a/SWIG/Examples/python/class/example.py +++ b/SWIG/Examples/python/class/example.py @@ -22,12 +22,9 @@ print "\nA total of", example.cvar.Shape_nshapes,"shapes were created" # Set the location of the object -# Notice how we can do this using functions specific to -# the 'Circle' class. -example.Circle_x_set(c, 20) -example.Circle_y_set(c, 30) -# Now use the same functions in the base class +example.Shape_x_set(c, 20) +example.Shape_y_set(c, 30) example.Shape_x_set(s,-10) example.Shape_y_set(s,5) diff --git a/SWIG/Examples/python/constants/example.i b/SWIG/Examples/python/constants/example.i index 29a1a7f11..7d69a4d47 100644 --- a/SWIG/Examples/python/constants/example.i +++ b/SWIG/Examples/python/constants/example.i @@ -23,4 +23,15 @@ const int iconst = 37; const double fconst = 3.14; +%constant(double) PI = 3.14159; + +/* Test address of operator */ + +%{ +static double blah = 1.2345; +%} + +%constant(double *) blahptr = &blah; + + diff --git a/SWIG/Examples/python/constants/example.py b/SWIG/Examples/python/constants/example.py index f13c4c373..5c1b00154 100644 --- a/SWIG/Examples/python/constants/example.py +++ b/SWIG/Examples/python/constants/example.py @@ -11,7 +11,7 @@ print "SCONST2 =", example.SCONST2, "(should be '\"Hello World\"')" print "EXPR =", example.EXPR, "(should be 48.5484)" print "iconst =", example.iconst, "(should be 37)" print "fconst =", example.fconst, "(should be 3.14)" - +print "PI =", example.PI, "(should be 3.14159)" try: print "EXTERN = ", example.EXTERN, "(Arg! This shouldn't print anything)" except AttributeError: diff --git a/SWIG/Examples/python/variables/example.i b/SWIG/Examples/python/variables/example.i index d62f973da..35eafc2c0 100644 --- a/SWIG/Examples/python/variables/example.i +++ b/SWIG/Examples/python/variables/example.i @@ -27,10 +27,10 @@ extern Point pt; /* Some read-only variables */ -%readonly +%readonly { extern int status; extern char path[256]; -%readwrite +} /* Some helper functions to make it easier to test */ extern void print_vars(); diff --git a/SWIG/Examples/tcl/class/example1.tcl b/SWIG/Examples/tcl/class/example1.tcl index 9700d01e2..f766a4f92 100644 --- a/SWIG/Examples/tcl/class/example1.tcl +++ b/SWIG/Examples/tcl/class/example1.tcl @@ -23,10 +23,8 @@ puts "\nA total of $Shape_nshapes shapes were created" # Set the location of the object -# Notice how we can do this using functions specific to -# the 'Circle' class. -Circle_x_set $c 20 -Circle_y_set $c 30 +Shape_x_set $c 20 +Shape_y_set $c 30 # Now use the same functions in the base class Shape_x_set $s -10 @@ -71,3 +69,6 @@ delete_Shape $s puts "$Shape_nshapes shapes remain" puts "Goodbye" + + + diff --git a/SWIG/Examples/tcl/variables/example.i b/SWIG/Examples/tcl/variables/example.i index d62f973da..c1e614cec 100644 --- a/SWIG/Examples/tcl/variables/example.i +++ b/SWIG/Examples/tcl/variables/example.i @@ -27,10 +27,10 @@ extern Point pt; /* Some read-only variables */ -%readonly -extern int status; -extern char path[256]; -%readwrite +%readonly { + extern int status; + extern char path[256]; +} /* Some helper functions to make it easier to test */ extern void print_vars();