SWIG CallBack from C++ into Java-Class

Discussion in 'Java' started by HalloUlrich, Apr 12, 2007.

  1. HalloUlrich

    HalloUlrich Guest

    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
     
    HalloUlrich, Apr 12, 2007
    #1
    1. Advertisements

  2. HalloUlrich

    migger

    Joined:
    May 4, 2011
    Messages:
    1
    Likes Received:
    0
    Location:
    Moscow
    Most probably you just forgot to add
    Code (Text):

    %module(directors="1") example
    ....
    %feature("director") Callback;
    ...
     
    In your *.i file
     
    migger, May 4, 2011
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. E11
    Replies:
    1
    Views:
    5,733
    Thomas Weidenfeller
    Oct 12, 2005
  2. mosfet
    Replies:
    1
    Views:
    1,156
    Mike Wahler
    Jul 4, 2003
  3. Markus von Ehr

    SWIG callback problem on win32

    Markus von Ehr, May 18, 2004, in forum: Python
    Replies:
    1
    Views:
    537
    Markus von Ehr
    May 18, 2004
  4. Jeff
    Replies:
    0
    Views:
    909
  5. HalloUlrich
    Replies:
    0
    Views:
    1,214
    HalloUlrich
    Apr 12, 2007
  6. Keith Sabine
    Replies:
    0
    Views:
    709
    Keith Sabine
    Jun 6, 2008
  7. Lyes Amazouz
    Replies:
    2
    Views:
    385
    Lyes Amazouz
    Aug 20, 2008
  8. ºÎƽ

    c++ swig class => ruby class

    ºÎƽ, Feb 26, 2011, in forum: Ruby
    Replies:
    0
    Views:
    151
    ºÎƽ
    Feb 26, 2011
Loading...