mglib

Personal IDL library for M. Galloy

single page | use frames     summary     class     fields     routine details     file attributes

dist_tools/bindings/

mg_dlm__define.pro

includes main-level program

Class representing a DLM made from a list of wrapper routines.

Examples

This example creates a DLM to access a few internal IDL routines, but this class could be used to access any C routines. The internal routines are:

char *IDL_OutputFormatFunc(int type) int IDL_OutputFormatLenFunc(int type) int IDL_TypeSizeFunc(int type) char *IDL_TypeNameFunc(int type) void IDL_TTYReset(void)
To create a DLM of wrapper to access these routines, first create a MG_DLM object with at least the BASENAME property:
f = mg_dlm(basename='format_example', $ name='FORMAT_EXAMPLE', $ description='Example of using dist_tools bindings', $ version='1.0', source='dist_tools')
Next, add the prototypes of the routines requiring wrappers:
f->addRoutineFromPrototype, 'char *IDL_OutputFormatFunc(int type)' f->addRoutineFromPrototype, 'int IDL_OutputFormatLenFunc(int type)' f->addRoutineFromPrototype, 'int IDL_TypeSizeFunc(int type)' f->addRoutineFromPrototype, 'char *IDL_TypeNameFunc(int type)' f->addRoutineFromPrototype, 'void IDL_TTYReset(void)'
Alternatively, these prototype definitions could be placed in a file and specified with the addRoutinesFromHeaderFile method.

Next, a wrapper to access the value of a #define constant is also created:

f->addPoundDefineAccessor, 'IDL_TYP_UNDEF', type=3L
The write method writes the .c and .dlm files:
f->write
The build method invokes the compiler and linker to make the shared object file containing the wrappers:
f->build, /show_all_output
The register method registers the DLM to be accessed in the current IDL session:
f->register
The MG_DLM object is no longer needed:
obj_destroy, f
These commands are in a main-level program at the end of the file. To run them do:
IDL> .run mg_dlm__define
Then you have access to the routines from IDL:
IDL> print, idl_outputformatfunc(5) %#16.8g IDL> print, idl_outputformatlenfunc(5) 16 IDL> print, idl_typesizefunc(5) 8 IDL> print, idl_typenamefunc(5) DOUBLE IDL> print, get_idl_typ_undef() 0

Class description for mg_dlm

Properties

Properties in mg_dlm

_extra init
basename set

basename (including possible path) for .c and .dlm files

build_date set

date in DLM header

description set

description in DLM header

name get set

name in DLM header

preamble set

string/string array of code to be inserted after declarations, but before argument checking

prefix get set

string to prefix routine names with

source set

source in DLM header

version set

version in DLM header

Routines

Routines from mg_dlm__define.pro

mg_dlm::setProperty, prefix=prefix, basename=basename, name=name, description=description, version=version, source=source, build_date=build_date, preamble=preamble

Set properties.

mg_dlm::getProperty, name=name, prefix=prefix

Get properties.

mg_dlm::write [, /separate]

Writes the .c and .dlm files to the BASENAME location.

mg_dlm::build [, _extra=keywords]

Compiles and links the DLM.

mg_dlm::register

Register the DLM.

mg_dlm::load

Load the DLM.

mg_dlm::addInclude, name [, /system] [, header_directory=string]

Add an include file to the DLM.

mg_dlm::addLibrary [, libFiles] [, lib_directory=string/strarr] [, /static]

Add a library to the link line.

mg_dlm::addRoutine, routine

Adds a wrapper routine to the DLM.

mg_dlm::addRoutineFromPrototype, proto

Adds a wrapper routine defined by a prototype given by a string to the DLM.

mg_dlm::addRoutinesFromHeaderFile, filename

Adds wrapper routines from a header file.

mg_dlm::addPoundDefineAccessor, name, type=long

Adds wrapper routine to access the given #define value.

mg_dlm::cleanup

Free resources.

result = mg_dlm::init(_extra=_extra)

Create the DLM object.

mg_dlm__define

Define instance variables.

Routine details

top mg_dlm::setProperty

mg_dlm::setProperty, prefix=prefix, basename=basename, name=name, description=description, version=version, source=source, build_date=build_date, preamble=preamble

Set properties.

Keywords

prefix

string to prefix routine names with

basename

basename (including possible path) for .c and .dlm files

name

name in DLM header

description

description in DLM header

version

version in DLM header

source

source in DLM header

build_date

date in DLM header

preamble

string/string array of code to be inserted after declarations, but before argument checking

top mg_dlm::getProperty

mg_dlm::getProperty, name=name, prefix=prefix

Get properties.

Keywords

name

name in DLM header

prefix

string to prefix routine names with

top mg_dlm::write

mg_dlm::write [, /separate]

Writes the .c and .dlm files to the BASENAME location.

Keywords

separate in optional type=boolean

set to create separate output for bindings and routine declarations as well as just have routine declarations for the DLM (no header)

top mg_dlm::build

mg_dlm::build [, _extra=keywords]

Compiles and links the DLM.

Keywords

_extra in optional type=keywords

keywords to the MG_MAKE_DLL routine

top mg_dlm::register

mg_dlm::register

Register the DLM.

top mg_dlm::load

mg_dlm::load

Load the DLM.

top mg_dlm::addInclude

mg_dlm::addInclude, name [, /system] [, header_directory=string]

Add an include file to the DLM.

Parameters

name in required type=string

name of the include file, including the .h

Keywords

system in optional type=boolean

set to indicate that the include is a system include file, i.e., that there should be <>'s around the name instead of ""'s

header_directory in optional type=string

filepath to include file, if not in a standard location

top mg_dlm::addLibrary

mg_dlm::addLibrary [, libFiles] [, lib_directory=string/strarr] [, /static]

Add a library to the link line.

Parameters

libFiles in optional type=string/strarr

library files

Keywords

lib_directory in optional type=string/strarr

directory of lib files, either a scalar string or an array the same length as lib_files

static in optional type=boolean

set to indicate libraries are to be statically linked

top mg_dlm::addRoutine

mg_dlm::addRoutine, routine

Adds a wrapper routine to the DLM.

Parameters

routine in required type=routine object

routine object to add to the DLM

top mg_dlm::addRoutineFromPrototype

mg_dlm::addRoutineFromPrototype, proto

Adds a wrapper routine defined by a prototype given by a string to the DLM.

Parameters

proto in required type=string

prototype of the routine to add to the DLM

top mg_dlm::addRoutinesFromHeaderFile

mg_dlm::addRoutinesFromHeaderFile, filename

Adds wrapper routines from a header file.

Parameters

filename in required type=string

header filename

top mg_dlm::addPoundDefineAccessor

mg_dlm::addPoundDefineAccessor, name, type=long

Adds wrapper routine to access the given #define value.

Parameters

name in required type=string

name of #define

Keywords

type in required type=long

SIZE type code for #define value

top mg_dlm::cleanup

mg_dlm::cleanup

Free resources.

top mg_dlm::init

result = mg_dlm::init(_extra=_extra)

Create the DLM object.

Keywords

_extra

top mg_dlm__define

mg_dlm__define

Define instance variables.

File attributes

Modification date: Thu Jun 12 17:10:54 2014
Lines: 366
Docformat: rst rst
Personal library of Michael Galloy
Contact me if you have enhancement requests or bug fixes.