Revert rev 11187 "Merged with recent changes from trunk."
This reverts commit c595e4d90ebfd63eb55430c735bb121cf690bd59. Conflicts: Source/Modules/c.cxx From: William S Fulton <wsf@fultondesigns.co.uk> git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@13033 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
34a628c7c7
commit
d6b81eb831
703 changed files with 9266 additions and 21128 deletions
56
Examples/java/callback/main.java
Normal file
56
Examples/java/callback/main.java
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
public class main
|
||||
{
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("example");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.println("Adding and calling a normal C++ callback");
|
||||
System.out.println("----------------------------------------");
|
||||
|
||||
Caller caller = new Caller();
|
||||
Callback callback = new Callback();
|
||||
|
||||
caller.setCallback(callback);
|
||||
caller.call();
|
||||
caller.delCallback();
|
||||
|
||||
callback = new JavaCallback();
|
||||
|
||||
System.out.println();
|
||||
System.out.println("Adding and calling a Java callback");
|
||||
System.out.println("------------------------------------");
|
||||
|
||||
caller.setCallback(callback);
|
||||
caller.call();
|
||||
caller.delCallback();
|
||||
|
||||
// Test that a double delete does not occur as the object has already been deleted from the C++ layer.
|
||||
// Note that the garbage collector can also call the delete() method via the finalizer (callback.finalize())
|
||||
// at any point after here.
|
||||
callback.delete();
|
||||
|
||||
System.out.println();
|
||||
System.out.println("java exit");
|
||||
}
|
||||
}
|
||||
|
||||
class JavaCallback extends Callback
|
||||
{
|
||||
public JavaCallback()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
System.out.println("JavaCallback.run()");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue