Common Functions for using C Data Structures from APL2
Original Publication Date: 1992-Jul-01
Included in the Prior Art Database: 2005-Mar-23
Publishing Venue
IBM
Related People
Beaty, KA: AUTHOR [+2]
Abstract
If APL2* is to be able to use C programs as external routines, it must also be able to deal with C data structures. These structures can be described to APL2 in such detail that APL2 can understand their layout. This still leaves open the question of what operations are needed to process these data structures in APL2.
Common Functions for using C Data Structures from APL2
If APL2* is
to be able to use C programs as external
routines, it must also be able to deal with C data structures. These
structures can be described to APL2 in such detail that APL2 can
understand their layout. This still
leaves open the question of what
operations are needed to process these data structures in APL2.
The following
functions are the minimal set of functions needed
to deal with C data structures from within APL2:
sp E Create 'structure'
Create a new
structure instance. The required storage
is
allocated from C's pool of free storage.
The function must return a
pointer to the allocated area, for future uses.
Also, each element
must be initialized appropriately. The
structure class to be used is
identified by the "structure" parameter in the call.
na E Get 'structure' sp
Get a copy of
the structure instance into the APL2 workspace.
The structure values are contained in a nested array matching the C
data structure. Any normal APL2
operation can now be performed on
this array, as it is a normal APL2 variable.
Put 'structure' sp na
Put replaces
the values of a C structure instance, copying a
new set of values contained in an APL2 nested array to the storage
location referred to by sp.
Free 'structure' sp
Free releases
the storage used by a structure instance when it
is no longer required...