Remove obscure mpointer example and replace with member_pointer.i testcase and runtime examples

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9887 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2007-08-09 23:47:13 +00:00
commit f5bdd056f7
38 changed files with 397 additions and 929 deletions

View file

@ -0,0 +1,43 @@
# Example using pointers to member functions
from member_pointer import *
def check(what, expected, actual):
if expected != actual:
raise RuntimeError ("Failed: " , what , " Expected: " , expected , " Actual: " , actual)
# Get the pointers
area_pt = areapt()
perim_pt = perimeterpt()
# Create some objects
s = Square(10)
# Do some calculations
check ("Square area ", 100.0, do_op(s,area_pt))
check ("Square perim", 40.0, do_op(s,perim_pt))
memberPtr = cvar.areavar
memberPtr = cvar.perimetervar
# Try the variables
check ("Square area ", 100.0, do_op(s,cvar.areavar))
check ("Square perim", 40.0, do_op(s,cvar.perimetervar))
# Modify one of the variables
cvar.areavar = perim_pt
check ("Square perimeter", 40.0, do_op(s,cvar.areavar))
# Try the constants
memberPtr = AREAPT
memberPtr = PERIMPT
memberPtr = NULLPT
check ("Square area ", 100.0, do_op(s,AREAPT))
check ("Square perim", 40.0, do_op(s,PERIMPT))