Difference between revisions of "Lianja/SDK C API"
Yvonne.milne (Talk | contribs) m (Text replace - "lianjaapi.h" to "lianja_api.h") |
Barrymavin (Talk | contribs) |
||
Line 4: | Line 4: | ||
The main source file for the DLL must include the following four elements: | The main source file for the DLL must include the following four elements: | ||
− | ====The include file " | + | ====The include file "lianja_api.h"==== |
Line 12: | Line 12: | ||
− | ====The | + | ====The LIANJA_EXTENSION_TABLE structure==== |
Used to define the 'C' functions and classes included in the library: | Used to define the 'C' functions and classes included in the library: | ||
<code lang="c"> | <code lang="c"> | ||
− | + | static struct LIANJA_EXTENSION_TABLE lianja_extension_table[] = | |
− | static | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
{ | { | ||
− | + | {"example_character", "fnExampleCharacter", API_FUNCTION}, | |
− | + | {"example_type", "fnExampleType", API_FUNCTION}, | |
− | } | + | {"example_logical", "fnExampleLogical", API_FUNCTION}, |
− | + | {"example_numeric", "fnExampleNumeric", API_FUNCTION}, | |
+ | {"example_execute", "fnExampleExecute", API_FUNCTION}, | ||
+ | {"example_evaluate", "fnExampleEvaluate", API_FUNCTION}, | ||
+ | {"example_class", "clsMyClass", API_CLASS}, | ||
+ | {NULL, NULL, -1} | ||
+ | }; | ||
− | ==== | + | //================================================================================ |
+ | // *** REQUIRED *** only once in each extension library and *must* come after the | ||
+ | // declaration for LIANJA_EXTENSION_TABLE. | ||
+ | //-------------------------------------------------------------------------------- | ||
+ | LIANJA_INIT_API; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</code> | </code> | ||
==Using the 'C' functions and classes== | ==Using the 'C' functions and classes== | ||
− | Shared libraries are loaded | + | Shared libraries are loaded automatically by placing directives in the extensions.ini file in the Lianja extensions directory. |
− | + | Here is an example of the extensions.ini file: | |
− | <code | + | <code> |
− | + | [windows] | |
− | + | library=example.dll | |
− | + | [linux] | |
− | + | #library=example.so | |
− | + | [mac] | |
+ | #library=example.dylib | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
− | |||
The [[LIST PROCEDURE]] and [[DISPLAY PROCEDURE]] commands include loaded shared library function names in their listings and the [[LIST CLASSES]] and [[DISPLAY CLASSES]] commands include loaded shared library class names in their listings. | The [[LIST PROCEDURE]] and [[DISPLAY PROCEDURE]] commands include loaded shared library function names in their listings and the [[LIST CLASSES]] and [[DISPLAY CLASSES]] commands include loaded shared library class names in their listings. |
Revision as of 23:56, 15 April 2013
'C' functions and classes defined in dynamic link libraries (DLLs) can be used on Windows.
Contents
Defining the C functions
The main source file for the DLL must include the following four elements:
The include file "lianja_api.h"
#include "lianja_api.h"
The LIANJA_EXTENSION_TABLE structure
Used to define the 'C' functions and classes included in the library:
static struct LIANJA_EXTENSION_TABLE lianja_extension_table[] = { {"example_character", "fnExampleCharacter", API_FUNCTION}, {"example_type", "fnExampleType", API_FUNCTION}, {"example_logical", "fnExampleLogical", API_FUNCTION}, {"example_numeric", "fnExampleNumeric", API_FUNCTION}, {"example_execute", "fnExampleExecute", API_FUNCTION}, {"example_evaluate", "fnExampleEvaluate", API_FUNCTION}, {"example_class", "clsMyClass", API_CLASS}, {NULL, NULL, -1} }; //================================================================================ // *** REQUIRED *** only once in each extension library and *must* come after the // declaration for LIANJA_EXTENSION_TABLE. //-------------------------------------------------------------------------------- LIANJA_INIT_API;
Using the 'C' functions and classes
Shared libraries are loaded automatically by placing directives in the extensions.ini file in the Lianja extensions directory.
Here is an example of the extensions.ini file:
[windows]
library=example.dll
[linux]
- library=example.so
[mac]
- library=example.dylib code>
The LIST PROCEDURE and DISPLAY PROCEDURE commands include loaded shared library function names in their listings and the LIST CLASSES and DISPLAY CLASSES commands include loaded shared library class names in their listings.
Loaded shared library functions can be used in the same way as an internal function. Loaded shared library classes can be used in the same way as system classes.