Fixes to Octave examples

- rename example modules from "example" to "swigexample", to avoid a
  warning from shadowing the Octave built-in function "example"
- remove deprecated "static" Makefile targets: there is no longer
  an option to build static Octave modules in the Examples Makefile
- emacs whitespace cleanup run on all files
This commit is contained in:
Karl Wette 2013-05-08 22:43:49 +02:00 committed by william
commit c28d0c6c80
63 changed files with 211 additions and 345 deletions

View file

@ -1,10 +1,10 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS = example.cxx
TARGET = example
TARGET = swigexample
INTERFACE = example.i
LIBS = -lm
SWIGOPT =
SWIGOPT =
check: build
$(MAKE) -f $(TOP)/Makefile octave_run
@ -13,9 +13,5 @@ build:
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
static:
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static
clean:
$(MAKE) -f $(TOP)/Makefile octave_clean

View file

@ -1,4 +1,3 @@
/* File : example.cxx */
#include "example.h"

View file

@ -20,4 +20,3 @@ public:
void setCallback(Callback *cb) { delCallback(); _callback = cb; }
void call() { if (_callback) _callback->run(); }
};

View file

@ -1,5 +1,5 @@
/* File : example.i */
%module(directors="1") example
%module(directors="1") swigexample
%{
#include "example.h"
%}
@ -10,4 +10,3 @@
%feature("director") Callback;
%include "example.h"

View file

@ -2,14 +2,13 @@
# This file illustrates the cross language polymorphism using directors.
example
swigexample
OctCallback=@() subclass(example.Callback(), \
'run',@(self) printf("OctCallback.run()\n"));
OctCallback=@() subclass(swigexample.Callback(),"run",@(self) printf("OctCallback.run()\n"));
# Create an Caller instance
caller = example.Caller();
caller = swigexample.Caller();
# Add a simple C++ callback (caller owns the callback, so
# we disown it first)
@ -17,7 +16,7 @@ caller = example.Caller();
printf("Adding and calling a normal C++ callback\n");
printf("----------------------------------------\n");
callback = example.Callback().__disown();
callback = swigexample.Callback().__disown();
caller.setCallback(callback);
caller.call();
caller.delCallback();
@ -43,7 +42,7 @@ caller.call();
caller.delCallback();
# careful-- using callback here may cause problems; octave_swig_type still
# exists, but is holding a destroyed object (the C++ example.Callback).
# exists, but is holding a destroyed object (the C++ swigexample.Callback).
# to manually drop the octave-side reference, you can use
clear callback;
@ -60,4 +59,3 @@ a.Callback.run();
# All done.
printf("octave exit\n");