Lianja/SDK C API

From Lianjapedia
Revision as of 00:03, 16 April 2013 by Barrymavin (Talk | contribs)

Jump to: navigation, search

'C' functions and classes defined in dynamic link libraries (DLLs on Windows, .so files on Linux and .dylib files on Mac) can be used to extend Lianja.

Defining the C functions

The main source file for the extension must include the following:

#include "lianja_api.h"
 
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


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.