Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > SWIG CallBack from C++ into Java-Class

Reply
Thread Tools

SWIG CallBack from C++ into Java-Class

 
 
HalloUlrich
Guest
Posts: n/a
 
      04-12-2007
I tried from Java-Example in SWIG:

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()");
}
}

***********************************************

But the Call into Java does not work. (Both callbacks only in c++).
Knows somebody why?

Regards, Ulrich

 
Reply With Quote
 
 
 
 
migger migger is offline
Junior Member
Join Date: May 2011
Location: Moscow
Posts: 1
 
      05-04-2011
Most probably you just forgot to add
Code:
%module(directors="1") example
....
%feature("director") Callback;
...
In your *.i file
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ruby callback for a SWIG wrapped C function Lyes Amazouz Ruby 2 08-20-2008 01:11 PM
SWIG -- Passing python proxy class instance to python callback Keith Sabine Python 0 06-06-2008 03:52 PM
SWIG CallBack from C++ into Java-Class HalloUlrich Java 0 04-12-2007 02:55 PM
SWIG -- Passing python proxy class instance to python callback Jeff Python 0 05-02-2005 02:55 PM
SWIG callback problem on win32 Markus von Ehr Python 1 05-18-2004 01:12 PM



Advertisments