SWIG
SWIG is an open-source utility that can be used to create bindings for C or C++ interfaces in a variety of high-level languages.
Supported Scripting Languages
- Perl
- PHP
- Python
- Tcl
- Ruby
Supported Non-Scripting Languages
- C#
- Common Lisp
- Java
- Lua
- Modula-3
- OCAML
- Octave
- R
source https://www.sobyte.net/post/2021-11/swig-python/
- With SWIG, Python can realistically do the following.
- Call C/C++ libraries with Python
- Inherit C++ classes with Python and use that inherited class in Python. see http://www.swig.org/
- Examples
- Writing Wrapper using SWIG python - https://www.geeksforgeeks.org/wrapping-cc-python-using-swig-set-1/
- C language example SWIG python- https://www.sobyte.net/post/2021-11/swig-python/
Python-Sip
- SIP is a tool that lets you create C and C++ bindings for Python. It was originally created for the
- Python-Sip tool can also be used to create bindings for any C++ API.
- SIP works in a very similar fashion to SWIG, although it does not support the range of languages
- that SWIG does. SIP supports much of the C/C++ syntax for its interface specification files and uses a similar syntax for its commands as SWIG
Boost Python
- Boost Python (also written as boost::python or Boost.Python) is a C++ library that lets C++ APIs interoperate with Python.
- Boost Python allows to create bindings programmatically in C++ code and then link the bindings against the Python and Boost Python libraries.
- This produces a dynamic library that can be imported directly into Python.
- Boost Python includes support for the following capabilities and features in terms of wrapping C++ APIs:
- C++ references
- C++ pointers
- Translation of C++ exceptions to Python
- C++ default arguments and Python keyword arguments
- Manipulating Python objects in C++
- Exporting C++ iterators as Python iterators
- Python documentation strings
- Globally registered type coercions
- Example
- C++ hello world example with boost python https://www.boost.org/doc/libs/1_76_0/libs/python/doc/html/tutorial/index.html
- C++ class example with boost pyhton https://cs.brown.edu/~jwicks/boost/libs/python/doc/tutorial/doc/html/python/exposing.html
COM Automation
- Component Object Model (COM) is a binary interface standard that allows objects to interact with each other via inter-process communication.
- COM objects specify well-defined interfaces that allow software components to be reused and linked together to build end-user applications.
- The technology was developed by Microsoft in 1993 and is still used today, predominantly on the Windows platform, although Microsoft now encourages the use of .NET and SOAP.
- A COM object is identified by a Universally Unique ID (UUID) and exposes its functionality via interfaces that are also identified by UUIDs.
- Supported languages
- Visual Basic
- JScript
- Perl
- Python
- Ruby
- Microsoft .NET .
- The object model for the interface being exposed is described using an interface description language
- (IDL).
- IDL is a language-neutral description of a software component’s interface, normally
- stored in a file with an .idl extension.
- This IDL description can then be translated into various forms using the MIDL.EXE compiler on Windows.
- The generated files include the proxy DLL code for the COM object and a type library that describes the object model. The following sample shows an example of the Microsoft IDL syntax:
CORBA
- The Common Object Request Broker Architecture (CORBA) is an industry standard to allow software components to communicate with each other independent of their location and vendor. In this regard, it is very similar to COM: both technologies solve the problem of communication between objects from different sources and both make use of a language-neutral IDL format to describe each object’s interface.
- CORBA is cross-platform with several open source implementations and provides strong support for UNIX platforms. It was defined by the Object Management Group in 1991 (the same group that manages the UML modeling language).
- CORBA offers a wide range of language bindings
- Python
- Perl
- Ruby
- Smalltalk
- JavaScript
- Tcl
- CORBA Scripting Language (IDL script).
- It also supports interfaces with multiple inheritance versus COM’s single inheritance.
- In terms of scripting, CORBA doesn’t require a specific automation interface as COM does.
- All CORBA objects are scriptable by default via the Dynamic Invocation Interface, which lets scripting languages determine the object’s interface dynamically. As an example of accessing CORBA objects from a scripting language
References
- www.swig.org - https://www.swig.org/Doc1.3/Scripting.html
- www.sobyte.net - https://www.sobyte.net/post/2021-11/swig-python/
- www.boost.org - https://www.boost.org/doc/libs/1_76_0/libs/python/doc/html/tutorial/index.html
- tech.blueyonder.com - https://tech.blueyonder.com/python-calling-c++/