Intialization
SC is provided as a dynamic or static library. If you are using the dynamic library
you must include sc/scdll.h , if the static one - sc/sclib.h .
To use SC you must initialize the environment. It contains all data required to run scripts,
manage memory, export your own data. To initialize the environment
use SCInit function. It returns an object of ISCEnv class (singleton) that
represents the environment.
Its declaration is presented below:
ISCEnv* SCInit(const ISCEnvDesc *desc);
SCInit function takes one argument of type ISCEnvDesc (may be also NULL).
By filling the fields of this structure you may change some parameters of the environment.
- SCHeapAlloc heapAlloc - User heap allocator , must be passed with deallocator (if not NULL)
- SCHeapFree heapFree - User heap deallocator , must be passed with allocator
- SCEnvErrorCallback envErrorCallback - called on environment error
- void *envErrorCallbackUserData - user data passed to environment error callback
- SCCompileErrorCallback compileErrorCallback - called on compile error
- void *compileErrorCallbackUserData - user data passed to callback
- ISCMemMngrLogger MemMngrLogger - optional callback called when memory allocation or deallocatin occurs
- void *memLoggerUserData - data passed to MemMngrLogger
Dll loading note
Because SC environment object is only one, to simplify API, you must declare a function pointer in the global scope:
SCGETENVPROC SCGetEnv = NULL;
It must be initialized before any use of API macros of functions.
Pointers to exported functions are declared as:
typedef ISCEnv* (*SCGETENVPROC)() // for dll function SCGetEnv
typedef ISCEnv* (*SCINITPROC)(const ISCEnvDesc *envDesc); // for dll function SCInit
typedef void (*SCDEINITPROC)(); // for dll function SCDeinit