Initial commit of Octave module.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10290 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
50b1578e19
commit
393391965c
275 changed files with 14004 additions and 5 deletions
45
Examples/test-suite/octave/member_pointer_runme.m
Normal file
45
Examples/test-suite/octave/member_pointer_runme.m
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Example using pointers to member functions
|
||||
|
||||
member_pointer
|
||||
|
||||
function check(what,expected,actual)
|
||||
if (expected != actual)
|
||||
error ("Failed: %s, Expected: %f, Actual: %f",what,expected,actual);
|
||||
endif
|
||||
end
|
||||
|
||||
# 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));
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue