capri, a script language

Home | Documentation | Releases | Sources | Contact

Libraries

Capri can load shared libraries that provide native functions which can be used in scripts just like normal functions.

There are a few such libraries that come with capri. Take a look at the .capri script files of the specific library to find documentation for each function.

Parts of a library

A library consists of two parts:

Each script file declares functions of the library using the native keyword. Importing the following script would make the function MyLibrary.doSomething() available, which would then automatically load the necessary shared library.

The load statement instructs the interpreter to look for a library named "mylib". The interpreter will search for the shared library in its "native" folder, in the directory where the capri executable resides, and in the directory of the executing script file.

load "mylib";

/**
 *
 */
project MyLibrary {

	function native doSomething();
	
}

When using this native function, the interpreter searches for a C symbol named after the following convention:

_CAPRI__<ProjectName>__<functionName>

In our case it would search for:

_CAPRI__MyLibrary__doSomething