Interfacing C,C++ and Python with Swig by Beazley D.M.

By Beazley D.M.

Show description

Read or Download Interfacing C,C++ and Python with Swig PDF

Best programming: programming languages books

Java and the Java Virtual Machine: Definition, Verification, Validation

This publication presents a high-level description, including a mathematical and an experimental research, of Java and of the Java digital desktop (JVM), together with a customary compiler of Java courses to JVM code and the safety severe bytecode verifier component to the JVM. the outline is based into language layers and computing device parts.

Additional resources for Interfacing C,C++ and Python with Swig

Example text

Quick Summary You now know almost everything you need to know • C declarations are transformed into Python equivalents. • C datatypes are mapped to an appropriate Python representation. • Pointers can be manipulated and are type-checked. • Complex objects are managed by reference. • SWIG provides special directives for renaming, inserting code, including files, etc... This forms the foundation for discussing the rest of SWIG. • Handling of structures, unions, and classes. • Using the SWIG library.

The SWIG run-time checker makes up for much of this. • Future versions of SWIG are likely to change the current pointer representation of strings to an entirely new Python type. This change should not substantially affect the use of SWIG however. Array Handling Arrays are pointers • Same model used in C (the "value" of an array is a pointer to the first element). • Multidimensional arrays are supported. • There is no difference between an ordinary pointer and an array. • However, SWIG does not perform bounds or size checking.

Error. Function pointer not allowed. h here ... i SWIG Tutorial Notes 7th International Python Conference 47 Second Attempt No more errors! • In fact, we can load the module and start executing functions >>> from opengl import * >>> glClear(GL_DEPTH_BUFFER_BIT) ... • Instant gratification! But there are other problems • Many functions are unusable. void glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); • No way to manufacture suitable function arguments SWIG Tutorial Notes 7th International Python Conference 48 Helper Functions Some functions may be difficult to use from Python void glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); • ‘params’ is supposed to be an array.

Download PDF sample

Interfacing C,C++ and Python with Swig by Beazley D.M.
Rated 4.37 of 5 – based on 48 votes