| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
8. C interface
MathGL library have interface for a set of languages. Most of them are based on C interface via SWIG tool. There are Python, Java, Octave, Lisp, C#, Guile, Lua, Modula 3, Ocaml, Perl, PHP, Pike, R, Ruby, Tcl. Also there is Fortran interface which have similar set of functions but slightly different type of arguments (integers instead of pointers). The C interface functions are described in C interface. Some of languages listed above support classes (like Python). So for them the special wrapper was written. These classes and functions are described in Python interface. Finally the special command language MGL was written for faster access to C++ plotting functions. Corresponding scripts can be executed separately (by UDAV, mgl2png, mgl2eps and so on) or from the C++ code (see section mglParse class). These commands are described in MGL interface.
C interface is base for many other interfaces. It contain pure C functions for most of methods of MathGL classes. In difference from C++ classes, C functions must have argument HMGL (for graphics) and/or HMDT (for data arrays) which specify the object for drawing or manipulating (changing). So, firstly user have to create this object by function mgl_create_*() and have to delete it after using by function mgl_delete_*().
All C functions are described in header file #include <mgl/mgl_c.h>
and use variable of types:
-
HMGL— Pointer to classmglGraph(see section MathGL core). -
HMDT— Pointer to classmglData(see section mglData class). -
HMPR— Pointer to classmglParse(see section mglParse class)..
These variables contain identifiers for graphics drawing objects and for data objects.
Fortran functions/subroutines have the same names as C functions. However, there is a difference. Variable of types HMGL, HMDT must be integer with sufficient size (integer*4 for 32-bit operating system or integer*8 for 64-bit operating system). All C functions are subroutines in Fortran which should be called by operator call. The exceptions are functions which return variables of types HMGL or HMDT. These functions should be declared as integer in Fortran code. Also one should keep in mind that strings in Fortran are denoted by ' sign but not " one.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
