double _clip_parnd(ClipMachine * cm,int num) int _clip_parni(ClipMachine * cm,int num) long _clip_parnl(ClipMachine * cm,int num) void _clip_retnd(ClipMachine * cm,double n) void _clip_retni(ClipMachine * cm,int n) void _clip_retnl(ClipMachine * cm,long n)
CLIP's C-API is a set of C-functions that allows using C-language along with CLIP. It could be necessary for writing some speed critical functions of your project; for writing "wrappers" for existing 3rd party functions or whole libraries, etc. Besides, learning C-API will help you understand internal structure of CLIP.
C-functions aimed to be used with CLIP (that is, which can be called from some CLIP function, 'exported functions' in further) are in separate C source file(s). This file must include "clip.h", which contains declarations of C-API functions and structures.
Each exported function's name must have prefix 'clip_' and the name itself must be in capital letters. Type of function must be 'int' and it must get one and only parameter of type 'ClipMachine *', which is a pointer to the structure containing context of the current CLIP Virtual Machine.
Exported function should return 0 (zero) if successful, or appropriate error code (those described in error.ch, with 'EG_' prefix).
Example:
/* my.c */
#include <stdio.h>
#include "clip.h"
int clip_MYFUNCTION(ClipMachine *cm)
{
printf("Hello from MyFunction()\n");
return 0;
}
/* end of my.c */
/* test.prg */
MyFunction()
/* end of test.prg */
Compilation:
gcc -c -I${CLIPROOT}/include my.c
clip -eM test.prg my.o
Running:
#./test
Hello from MyFunction
#
_clip_parnd(ClipMachine * cm,int num) --> double
_clip_parnd() retrieves a numeric value passed as a parameter from CLIP and converts it to a double type.
| <num> | - position of the parameter in parameters list |
| Returns : | _clip_parnd() returns the value of the specified parameter as a double type. |
| See also : | _clip_parni() _clip_parnl() _clip_retnd() _clip_stornd() |
_clip_parni(ClipMachine * cm,int num) --> int
_clip_parni() retrieves a numeric value passed as a parameter from CLIP and converts it to an int type.
| <num> | - position of the parameter in parameters list |
| Returns : | _clip_parni() returns the value of the specified parameter as an int type. |
| See also : | _clip_parnd() _clip_parnl() _clip_retni() _clip_storni() |
_clip_parnl(ClipMachine * cm,int num) --> long
_clip_parnl() retrieves a numeric value passed as a parameter from CLIP and converts it to a long type.
| <num> | - position of the parameter in parameters list |
| Returns : | _clip_parnl() returns the value of the specified parameter as a long type. |
| See also : | _clip_parni() _clip_parnd() _clip_retnl() _clip_stornl() |
_clip_retnd(ClipMachine * cm,double n) --> void
_clip_retnd() posts a numeric value into CLIP's return value area. When your exported function returns control to the calling CLIP program, the posted value becomes the CLIP return value of your exported function.
| <n> | - a numeric expression of double type |
| Returns : | _clip_retnd() has no return value. |
| See also : | _clip_parnd() _clip_retni() _clip_retnl() _clip_stornd() |
_clip_retni(ClipMachine * cm,int n) --> void
_clip_retni() posts a numeric value into CLIP's return value area. When your exported function returns control to the calling CLIP program, the posted value becomes the CLIP return value of your exported function.
| <n> | - a numeric expression of integer type |
| Returns : | _clip_retni() has no return value. |
| See also : | _clip_parni() _clip_retnd() _clip_retnl() _clip_storni() |
_clip_retnl(ClipMachine * cm,long n) --> void
_clip_retnl() posts a numeric value into CLIP's return value area. When your exported function returns control to the calling CLIP program, the posted value becomes the CLIP return value of your exported function.
| <n> | - a numeric expression of long type |
| Returns : | _clip_retnl() has no return value. |
| See also : | _clip_parnl() _clip_retni() _clip_retnd() _clip_stornl() |