📄 cref.txt
字号:
NOTES The default string callback simply returns the name of the data type. SEE ALSO SLclass_allocate_class, SLclass_register_class--------------------------------------------------------------SLclass_set_destroy_function SYNOPSIS Set the destroy method callback for a data type USAGE int SLclass_set_destroy_function (cl, destroy_fun) SLang_Class_Type *cl void (*destroy_fun) (unsigned char, VOID_STAR); DESCRIPTION `SLclass_set_destroy_function' is used to set the destroy callback for a data type. The data type's class `cl' must have been previously obtained via a call to `SLclass_allocate_class'. When called, `destroy_fun' will be passed two arguments: a unsigned char which represents the data type, and the address of the object to be destroyed. `SLclass_set_destroy_function' returns zero upon success, and -1 upon failure. EXAMPLE The destroy method for `SLANG_STRING_TYPE' looks like: static void string_destroy (unsigned char type, VOID_STAR ptr) { char *s = *(char **) ptr; if (s != NULL) SLang_free_slstring (*(char **) s); } NOTES Data types of class SLANG_CLASS_TYPE_SCALAR do not require a destroy callback. However, other classes do. SEE ALSO SLclass_allocate_class, SLclass_register_class--------------------------------------------------------------SLclass_set_push_function SYNOPSIS Set the push callback for a new data type USAGE int SLclass_set_push_function (cl, push_fun) SLang_Class_Type *cl int (*push_fun) (unsigned char, VOID_STAR); DESCRIPTION `SLclass_set_push_function' is used to set the push callback for a new data type specified by `cl', which must have been previously obtained via `SLclass_allocate_class'. The parameter `push_fun' is a pointer to the push callback. It is required to take two arguments: an unsigned character representing the data type, and the address of the object to be pushed. It must return zero upon success, or -1 upon failure. `SLclass_set_push_function' returns zero upon success, or -1 upon failure. EXAMPLE The push callback for `SLANG_COMPLEX_TYPE' looks like: static int complex_push (unsigned char type, VOID_STAR ptr) { double *z = *(double **) ptr; return SLang_push_complex (z[0], z[1]); } SEE ALSO SLclass_allocate_class, SLclass_register_class--------------------------------------------------------------SLclass_set_pop_function SYNOPSIS Set the pop callback for a new data type USAGE int SLclass_set_pop_function (cl, pop_fun) SLang_Class_Type *cl int (*pop_fun) (unsigned char, VOID_STAR); DESCRIPTION `SLclass_set_pop_function' is used to set the callback for popping an object from the stack for a new data type specified by `cl', which must have been previously obtained via `SLclass_allocate_class'. The parameter `pop_fun' is a pointer to the pop callback function, which is required to take two arguments: an unsigned character representing the data type, and the address of the object to be popped. It must return zero upon success, or -1 upon failure. `SLclass_set_pop_function' returns zero upon success, or -1 upon failure. EXAMPLE The pop callback for `SLANG_COMPLEX_TYPE' looks like: static int complex_push (unsigned char type, VOID_STAR ptr) { double *z = *(double **) ptr; return SLang_pop_complex (&z[0], &z[1]); } SEE ALSO SLclass_allocate_class, SLclass_register_class--------------------------------------------------------------SLclass_get_datatype_name SYNOPSIS Get the name of a data type USAGE char *SLclass_get_datatype_name (unsigned char type) DESCRIPTION The `SLclass_get_datatype_name' function returns the name of the data type specified by `type'. For example, if `type' is `SLANG_INT_TYPE', the string `"Integer_Type"' will be returned. This function returns a pointer that should not be modified or freed. SEE ALSO SLclass_allocate_class, SLclass_register_class--------------------------------------------------------------SLang_free_mmt SYNOPSIS Free a memory managed type USAGE void SLang_free_mmt (SLang_MMT_Type *mmt) DESCRIPTION The `SLang_MMT_Type' function is used to free a memory managed data type. SEE ALSO SLang_object_from_mmt, SLang_create_mmt--------------------------------------------------------------SLang_object_from_mmt SYNOPSIS Get a pointer to the value of a memory managed type USAGE VOID_STAR SLang_object_from_mmt (SLang_MMT_Type *mmt) DESCRIPTION The `SLang_object_from_mmt' function returns a pointer to the actual object whose memory is being managed by the interpreter. SEE ALSO SLang_free_mmt, SLang_create_mmt--------------------------------------------------------------SLang_create_mmt SYNOPSIS Create a memory managed data type USAGE SLang_MMT_Type *SLang_create_mmt (unsigned char t, VOID_STAR ptr) DESCRIPTION The `SLang_create_mmt' function returns a pointer to a new memory managed object. This object contains information necessary to manage the memory associated with the pointer `ptr' which represents the application defined data type of type `t'. SEE ALSO SLang_object_from_mmt, SLang_push_mmt, SLang_free_mmt--------------------------------------------------------------SLang_push_mmt SYNOPSIS Push a memory managed type USAGE int SLang_push_mmt (SLang_MMT_Type *mmt) DESCRIPTION This function is used to push a memory managed type onto the interpreter stack. It returns zero upon success, or `-1' upon failure. SEE ALSO SLang_create_mmt, SLang_pop_mmt--------------------------------------------------------------SLang_pop_mmt SYNOPSIS Pop a memory managed data type USAGE SLang_MMT_Type *SLang_pop_mmt (unsigned char t) DESCRIPTION The `SLang_pop_mmt' function may be used to pop a memory managed type of type `t' from the stack. It returns a pointer to the memory managed object upon success, or `NULL' upon failure. The function `SLang_object_from_mmt' should be used to access the actual pointer to the data type. SEE ALSO SLang_object_from_mmt, SLang_push_mmt--------------------------------------------------------------SLang_inc_mmt SYNOPSIS Increment a memory managed type reference count USAGE void SLang_inc_mmt (SLang_MMT_Type *mmt); DESCRIPTION The `SLang_inc_mmt' function may be used to increment the reference count associated with the memory managed data type given by `mmt'. SEE ALSO SLang_free_mmt, SLang_create_mmt, SLang_pop_mmt, SLang_pop_mmt--------------------------------------------------------------SLang_vmessage SYNOPSIS Display a message to the message device USAGE void SLang_vmessage (char *fmt, ...) DESCRIPTION This function prints a `printf' style formatted variable argument list to the message device. The default message device is `stdout'. SEE ALSO SLang_verror--------------------------------------------------------------SLang_exit_error SYNOPSIS Exit the program and display an error message USAGE void SLang_exit_error (char *fmt, ...) DESCRIPTION The `SLang_exit_error' function terminates the program and displays an error message using a `printf' type variable argument list. The default behavior to this function is to write the message to `stderr' and exit with the `exit' system call. If the function pointer `SLang_Exit_Error_Hook' is non-NULL, the function to which it points will be called. This permits an application to perform whatever cleanup is necessary. This hook has the prototype: void (*SLang_Exit_Error_Hook)(char *, va_list); SEE ALSO SLang_verror, exit--------------------------------------------------------------SLang_init_slang SYNOPSIS Initialize the interpreter USAGE int SLang_init_slang (void) DESCRIPTION The `SLang_init_slang' function must be called by all applications that use the S-Lang interpreter. It initializes the interpreter, defines the built-in data types, and adds a set of core intrinsic functions. The function returns `0' upon success, or `-1' upon failure. SEE ALSO SLang_init_slfile, SLang_init_slmath, SLang_init_slunix--------------------------------------------------------------SLang_init_slfile SYNOPSIS Initialize the interpreter file I/O intrinsics USAGE int SLang_init_slfile (void) DESCRIPTION This function initializes the interpreters file I/O intrinsic functions. This function adds intrinsic functions such as `fopen', `fclose', and `fputs' to the interpreter. It returns `0' if successful, or `-1' upon error. NOTES Before this function can be called, it is first necessary to call `SLang_init_slang'. It also adds the preprocessor symbol `__SLFILE__' to the interpreter. SEE ALSO SLang_init_slang, SLang_init_slunix, SLang_init_slmath--------------------------------------------------------------SLang_init_slmath SYNOPSIS Initialize the interpreter math intrinsics USAGE int SLang_init_slmath (void) DESCRIPTION The `SLang_init_slmath' function initializes the interpreter's mathematical intrinsic functions and makes them available to the language. The intrinsic functions include `sin', `cos', `tan', etc... It returns `0' if successful, or `-1' upon failure. NOTES This function must be called after `SLang_init_slang'. It adds the preprocessor symbol `__SLMATH__' to the interpreter. SEE ALSO SLang_init_slang, SLang_init_slfile, SLang_init_slunix--------------------------------------------------------------SLang_init_slunix SYNOPSIS Make available some unix system calls to the interpreter USAGE int SLang_init_slunix (void) DESCRIPTION The `SLang_init_slunix' function initializes the interpreter's unix system call intrinsic functions and makes them available to the language. Examples of functions made available by `SLang_init_slunix' include `chmod', `chown', and `stat_file'. It returns `0' if successful, or `-1' upon failure. NOTES This function must be called after `SLang_init_slang'. It adds the preprocessor symbol `__SLUNIX__' to the interpreter. SEE ALSO SLang_init_slang, SLang_init_slfile, SLang_init_slmath--------------------------------------------------------------SLadd_intrin_fun_table SYNOPSIS Add a table of intrinsic functions to the interpreter USAGE int SLadd_intrin_fun_table(SLang_Intrin_Fun_Type *tbl, char *pp_name); DESCRIPTION The `SLadd_intrin_fun_table' function adds an array, or table, of `SLang_Intrin_Fun_Type' objects to the interpreter. The first parameter, `tbl' specifies the table to be added. The second parameter `pp_name', if non-NULL will be added to the list of preprocessor symbols. This function returns -1 upon failure or zero upon success. NOTES A table should only be loaded one time and it is considered to be an error on the part of the application if it loads a table more than once. SEE ALSO SLadd_intrin_var_table, SLadd_intrinsic_function, SLdefine_for_ifdef--------------------------------------------------------------SLadd_intrin_var_table SYNOPSIS Add a table of intrinsic variables to the interpreter USAGE int SLadd_intrin_var_table (SLang_Intrin_Var_Type *tbl, char *pp_name); DESCRIPTION The `SLadd_intrin_var_table' function adds an array, or table, of `SLang_Intrin_Var_Type' objects to the interpreter. The first parameter, `tbl' specifies the table to be added. The second parameter `pp_name', if non-NULL will be added to the list of preprocessor symbols. This function returns -1 upon failure or zero upon success. NOTES A table should only be loaded one time and it is considered to be an error on the part of the application if it loads a table more than once. SEE ALSO SLadd_intrin_var_table, SLadd_intrinsic_function, SLdefine_for_ifdef--------------------------------------------------------------SLang_load_file SYNOPSIS Load a file into the interpreter USAGE int SLang_load_file (char *fn) DESCRIPTION The `SLang_load_file' function opens the file whose name is specified by `fn' and feeds it to the interpreter, line by line, for execution. If `fn' is `NULL', the function will take input from `stdin'. If no error occurs, it returns `0'; otherwise, it returns `-1', and sets `SLang_Error' accordingly. For example, if it fails to open the file, it will return `-1' with `SLang_Error' set to `SL_OBJ_NOPEN'. NOTES If the hook `SLang_Load_File_Hook' declared as int (*SLang_Load_File_Hook)(char *); is non-NULL, the function point to by it will be used to load the file. For example, the jed editor uses this hook to load files via its own routines. SEE ALSO SLang_load_object, SLang_load_string--------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -