example code to access some C++ classes in a DLL

Discussion in 'Python' started by Torsten Mohr, Feb 28, 2004.

  1. Torsten Mohr

    Torsten Mohr Guest

    Hi,

    i have written a DLL that implements some C++ classes and
    their methods. Now i would like to make the classes and
    their methods known to python.

    Is there some example code available on how to do this?
    I want to make some classes, their constructors and some
    methods known to python.

    I've read the python docu "Tutorial", "Distributing Python Modules",
    "Extending and Embedding" and "Python/X API".
    But none of them seems to tell me how i can interface to:


    namespace abc {
    class Abc {
    Abc();
    ~Abc();

    int meth1(int abd, std::string s);
    };

    class Def {
    Def();
    ~Def();

    int meth1(long abd, char* g);
    }
    }

    Has anybody got some example code for the necessary wrapper to make
    all the above known to python?


    Thanks for any hints,
    Torsten.
     
    Torsten Mohr, Feb 28, 2004
    #1
    1. Advertising

  2. Torsten Mohr

    Larry Bates Guest

    You can interface Python to ANY .DLL by using
    CALLDLL. I've written a wrapper that I feel makes
    doing this easier that is posted at:

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146847

    -Larry

    "Torsten Mohr" <> wrote in message
    news:c1qlv5$58m$...
    > Hi,
    >
    > i have written a DLL that implements some C++ classes and
    > their methods. Now i would like to make the classes and
    > their methods known to python.
    >
    > Is there some example code available on how to do this?
    > I want to make some classes, their constructors and some
    > methods known to python.
    >
    > I've read the python docu "Tutorial", "Distributing Python Modules",
    > "Extending and Embedding" and "Python/X API".
    > But none of them seems to tell me how i can interface to:
    >
    >
    > namespace abc {
    > class Abc {
    > Abc();
    > ~Abc();
    >
    > int meth1(int abd, std::string s);
    > };
    >
    > class Def {
    > Def();
    > ~Def();
    >
    > int meth1(long abd, char* g);
    > }
    > }
    >
    > Has anybody got some example code for the necessary wrapper to make
    > all the above known to python?
    >
    >
    > Thanks for any hints,
    > Torsten.
    >
    >
     
    Larry Bates, Feb 28, 2004
    #2
    1. Advertising

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. Anushi
    Replies:
    5
    Views:
    8,807
  2. Colin Goudie
    Replies:
    6
    Views:
    477
    Victor Bazarov
    Jan 26, 2004
  3. Noralf Trønnes
    Replies:
    4
    Views:
    289
    Noralf Trønnes
    May 9, 2007
  4. ThunderMusic
    Replies:
    1
    Views:
    156
    ThunderMusic
    Feb 22, 2007
  5. H. Simpson
    Replies:
    4
    Views:
    294
    H. Simpson
    Aug 3, 2004
Loading...

Share This Page