
2 Appendix A1 Extending Ox
dependencies of oxexport.h
jdsystem.h platform and compiler specific defines
jdtypes.h basic types and constants
jdmatrix.h basic matrix services
jdmath.h mathematical and statistical functions
oxtypes.h basic Ox constants and types
The remaining sections all give examples on extending Ox. For the Windows plat-
form the sample code is in:
purpose ox/ directory section
calling functions from the Ox DLL dev/windows/threes A1.2
a simple example of linking C code dev/windows/threes A1.2
returning values in arguments A1.3
calling Ox functions from C dev/windows/callback A1.4
writing a C
++
interface wrapper dev/windows/ranapp A1.5
writing a Visual Basic interface dev/windows/vb/ranapp A1.6
linking Fortran code dev/windows/fortran A1.7
For Unix there is only the threes example. The remaining windows code is easily
adapted for Unix platforms (but GiveWin is currently unsupported under Unix).
A1.2 Adding C/C
++
code: a simple dynamic link library
In this section we shall write a function called Threes, which creates a matrix of threes
(cf. the library function ones). The first argument is the number of rows, the second
the number of columns. The C source code is in threes.c:
..................................................ox/dev/windows/threes/threes.c
#include "oxexport.h"
void OXCALL FnThrees(OxVALUE *rtn, OxVALUE *pv, int cArg)
{
int i, j, c, r;
OxLibCheckType(OX_INT, pv, 0, 1);
r = OxInt(pv, 0);
c = OxInt(pv, 1);
OxLibValMatMalloc(rtn, r, c);
for (i = 0; i < r; i++)
for (j = 0; j < c; j++)
OxMat(rtn, 0)[i][j] = 3;
}
.......................................................................................
• The oxexport.h header file defines all types and functions required to link to
Ox.
Kommentare zu diesen Handbüchern