Fog Creek Software
Discussion Board




How to script a c++ library

We have a c++ library (dll) on the windows platform. It exports some c++ classes . These dlls are not COM dlls, that is the classes/objects are not COM objects, and they don't support IDispatch interface . The library is basically used by C++ applications  the usual way , by including headers and linking to the dlls. How can we make the libary scriptable ? Meaning that the objects can be created and their methods should be callable from a script like language . This would enable things to be done in batch processing mode , and test suites to be automated.
                                                                    Thanks .

indian programmer
Wednesday, May 21, 2003

Create a hierarchy of COM objects which use the DLL on the backend and expose a COM interface on the other.

Alyosha`
Wednesday, May 21, 2003

>Create a hierarchy of COM objects which use the DLL on >the backend and expose a COM interface on the other.

  Too tough..this is like rewriting the library's client/api layer in com. isn't there a way without getting com in the way. thanks.

indian programmer
Wednesday, May 21, 2003

Have a look at:

http://www.swig.org/

You may even be able to generate the scripting inteface from the library headers...

Mark Watson
Wednesday, May 21, 2003

Wrapping stuff for PHP is very easy.  This is probably why PHP has so  many functions :)

http://www.php.net/manual/en/phpdevel.php

Ged Byrne
Wednesday, May 21, 2003

You can also check out the Boost.Python library. http://www.boost.org/libs/python/doc/

Let's you easily access C++ from python, and python from C++

Oren Miller
Wednesday, May 21, 2003

If you want to put a COM interface on a C++ library, you're going to have to write one. There's really no other way to do it. At least you don't need re-implement the actual logic, so the COM coding is fairly boilerplate.

The other tools mentioned will let you build scripting extensions for specific languages, but none of them will give you a COM interface.

Chris Tavares
Wednesday, May 21, 2003

*  Recent Topics

*  Fog Creek Home