Modify a C++ instance from the embed python interpreter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wezzy

    #1

    Modify a C++ instance from the embed python interpreter

    Hi, is there a tool that automatically expose an object to python? i
    have an instance of a C++ (or ObjC) object and i want to pass it to the
    embed interpreter that runs inside my program.
    Python code have to call c++ method and register some callback.

    I know that swig helps when python creates c++ instance but i've the
    instance and i want to use it with python.

    Thanks

    --
    Ciao
    Fabio
  • Diez B. Roggisch

    #2
    Re: Modify a C++ instance from the embed python interpreter

    Wezzy wrote:[color=blue]
    > Hi, is there a tool that automatically expose an object to python? i
    > have an instance of a C++ (or ObjC) object and i want to pass it to the
    > embed interpreter that runs inside my program.
    > Python code have to call c++ method and register some callback.
    >
    > I know that swig helps when python creates c++ instance but i've the
    > instance and i want to use it with python.[/color]

    That is the same case, wrt SWIG - the objects methods get accessed by
    functions like

    int Object_foo(Obje ct *s) {
    return s->foo();
    }


    So passing a exiting object reference to such a function will work. You
    might also consider using SIP, it appears to me to be much more OO.

    Diez

    Comment

    • Wezzy

      #3
      Re: Modify a C++ instance from the embed python interpreter

      Diez B. Roggisch <deets@nospam.w eb.de> wrote:
      [color=blue]
      > Wezzy wrote:[color=green]
      > > Hi, is there a tool that automatically expose an object to python? i
      > > have an instance of a C++ (or ObjC) object and i want to pass it to the
      > > embed interpreter that runs inside my program.
      > > Python code have to call c++ method and register some callback.
      > >
      > > I know that swig helps when python creates c++ instance but i've the
      > > instance and i want to use it with python.[/color]
      >
      > That is the same case, wrt SWIG - the objects methods get accessed by
      > functions like
      >
      > int Object_foo(Obje ct *s) {
      > return s->foo();
      > }[/color]

      Can you post few line of code ?
      [color=blue]
      > So passing a exiting object reference to such a function will work. You
      > might also consider using SIP, it appears to me to be much more OO.
      >
      > Diez[/color]

      well i'll look to SIP but i prefer to use swig because it can interface
      C++ with other language such as ruby

      --
      Ciao
      Fabio

      Comment

      Working...