Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > example code to access some C++ classes in a DLL

Reply
Thread Tools

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

 
 
Torsten Mohr
Guest
Posts: n/a
 
      02-28-2004
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.


 
Reply With Quote
 
 
 
 
Larry Bates
Guest
Posts: n/a
 
      02-28-2004
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/Coo.../Recipe/146847

-Larry

"Torsten Mohr" <(E-Mail Removed)> wrote in message
news:c1qlv5$58m$(E-Mail Removed)...
> 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.
>
>



 
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
I can't access some classes, but can access others in the same namespace, why? ThunderMusic ASP .Net Web Services 1 02-22-2007 01:55 PM
How to determine if a DLL is a COM DLL or .NET DLL Anushi ASP .Net 5 10-28-2004 01:59 PM
mprapi.dll --> samlib.dll --> ntdll.dll issue. Some1 Computer Support 4 04-05-2004 02:02 AM
Base Classes in .exe, derived classes in .dll Colin Goudie C++ 6 01-26-2004 03:18 PM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments