diff options
| author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2009-08-18 20:56:02 +0000 |
|---|---|---|
| committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-25 16:59:08 +0000 |
| commit | 9f8a09ed743cedd9547bf0661d518647966ab114 (patch) | |
| tree | 9c7803d3b27a8ec22e91792ac7f7932efa128b20 /Examples/php/callback/runme.php | |
| download | swig-tarball-master.tar.gz | |
Imported from /srv/lorry/lorry-area/swig-tarball/swig-1.3.40.tar.gz.HEADswig-1.3.40master
Diffstat (limited to 'Examples/php/callback/runme.php')
| -rw-r--r-- | Examples/php/callback/runme.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Examples/php/callback/runme.php b/Examples/php/callback/runme.php new file mode 100644 index 0000000..2be7199 --- /dev/null +++ b/Examples/php/callback/runme.php @@ -0,0 +1,47 @@ +<?php + +# This file illustrates the cross language polymorphism using directors. + +require("example.php"); + +# Class, which overwrites Callback::run(). + +class PhpCallback extends Callback { + function run() { + print "PhpCallback.run()\n"; + } +}; + +# Create an Caller instance + +$caller = new Caller(); + +# Add a simple C++ callback (caller owns the callback, so +# we disown it first by clearing the .thisown flag). + +print "Adding and calling a normal C++ callback\n"; +print "----------------------------------------\n"; + +$callback = new Callback(); +$callback->thisown = 0; +$caller->setCallback($callback); +$caller->call(); +$caller->delCallback(); + +print "\n"; +print "Adding and calling a PHP callback\n"; +print "------------------------------------\n"; + +# Add a PHP callback. + +$callback = new PhpCallback(); +$callback->thisown = 0; +$caller->setCallback($callback); +$caller->call(); +$caller->delCallback(); + +# All done. + +print "php exit\n"; + +?> |
