1#ifndef __nsi_procedural_h
2#define __nsi_procedural_h
3
4#include "nsi.h"
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10struct NSIProcedural_t;
11
12/* A function that reports messages through the renderer */
13typedef void (*NSIReport_t)(NSIContext_t ctx, int level, const char* message);
14
15/* A function that cleans-up after the last execution of the procedural */
16#define NSI_PROCEDURAL_UNLOAD(name) \
17 void name( \
18 NSIContext_t ctx, \
19 NSIReport_t report, \
20 struct NSIProcedural_t* proc)
21typedef NSI_PROCEDURAL_UNLOAD((*NSIProceduralUnload_t));
22
23/* A function that translates the procedural into NSI calls */
24#define NSI_PROCEDURAL_EXECUTE(name) \
25 void name( \
26 NSIContext_t ctx, \
27 NSIReport_t report, \
28 struct NSIProcedural_t* proc, \
29 int nparams, \
30 const struct NSIParam_t* params)
31typedef NSI_PROCEDURAL_EXECUTE((*NSIProceduralExecute_t));
32
33/* Descriptor of procedural */
34struct NSIProcedural_t
35{
36 /* Expected version of NSI */
37 unsigned nsi_version;
38 /* Pointers to procedural's functions */
39 NSIProceduralUnload_t unload;
40 NSIProceduralExecute_t execute;
41};
42
43/* Convenient macro for procedural descriptor initialization */
44#define NSI_PROCEDURAL_INIT(proc, unload_fct, execute_fct) \
45 { \
46 (proc).nsi_version = NSI_VERSION; \
47 (proc).unload = unload_fct; \
48 (proc).execute = execute_fct; \
49 }
50
51/* The entry-point of the procedural. Returns a descriptor. */
52#define NSI_PROCEDURAL_LOAD_SYMBOL NSIProceduralLoad
53#define NSI_PROCEDURAL_LOAD_PARAMS \
54 NSIContext_t ctx, \
55 NSIReport_t report, \
56 const char* nsi_library_path, \
57 const char* renderer_version
58typedef struct NSIProcedural_t* (*NSIProceduralLoad_t)(
59 NSI_PROCEDURAL_LOAD_PARAMS);
60
61/* Convenient macro for declaration of NSIProceduralLoad */
62#define NSI_PROCEDURAL_LOAD \
63 _3DL_EXTERN_C _3DL_EXPORT \
64 struct NSIProcedural_t* NSI_PROCEDURAL_LOAD_SYMBOL( \
65 NSI_PROCEDURAL_LOAD_PARAMS)
66
67#ifdef __cplusplus
68}
69#endif
70
71#endif