⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slang.h

📁 一个C格式的脚本处理函数库源代码,可让你的C程序具有执行C格式的脚本文件
💻 H
📖 第 1 页 / 共 5 页
字号:
#define SLANG_CLASS_TYPE_SCALAR		1#define SLANG_CLASS_TYPE_VECTOR		2#define SLANG_CLASS_TYPE_PTR		3   unsigned int cl_data_type;	       /* SLANG_INTEGER_TYPE, etc... */   char *cl_name;			       /* slstring type */   unsigned int cl_sizeof_type;   VOID_STAR cl_transfer_buf;	       /* cl_sizeof_type bytes*/   /* Methods */   /* Most of the method functions are prototyped:    * int method (SLtype type, VOID_STAR addr);    * Here, @type@ represents the type of object that the method is asked    * to deal with.  The second parameter @addr@ will contain the ADDRESS of    * the object.  For example, if type is SLANG_INT_TYPE, then @addr@ will    * actually be int *.  Similary, if type is SLANG_STRING_TYPE,    * then @addr@ will contain the address of the string, i.e., char **.    */   void (*cl_destroy)_PROTO((SLtype, VOID_STAR));   /* Prototype: void destroy(unsigned type, VOID_STAR val)    * Called to delete/free the object */   char *(*cl_string)_PROTO((SLtype, VOID_STAR));   /* Prototype: char *to_string (SLtype t, VOID_STAR p);    * Here p is a pointer to the object for which a string representation    * is to be returned.  The returned pointer is to be a MALLOCED string.    */   /* Prototype: void push(SLtype type, VOID_STAR v);    * Push a copy of the object of type @type@ at address @v@ onto the    * stack.    */   int (*cl_push)_PROTO((SLtype, VOID_STAR));   /* Prototype: int pop(SLtype type, VOID_STAR v);    * Pops value from stack and assign it to object, whose address is @v@.    */   int (*cl_pop)_PROTO((SLtype, VOID_STAR));   int (*cl_unary_op_result_type)_PROTO((int, SLtype, SLtype *));   int (*cl_unary_op)_PROTO((int, SLtype, VOID_STAR, unsigned int, VOID_STAR));   int (*cl_app_unary_op_result_type)_PROTO((int, SLtype, SLtype *));   int (*cl_app_unary_op)_PROTO((int, SLtype, VOID_STAR, unsigned int, VOID_STAR));   /* If this function is non-NULL, it will be called for sin, cos, etc... */#define SLMATH_SIN	1#define SLMATH_COS	2#define SLMATH_TAN	3#define SLMATH_ATAN	4#define SLMATH_ASIN	5#define SLMATH_ACOS	6#define SLMATH_EXP	7#define SLMATH_LOG	8#define SLMATH_SQRT	9#define SLMATH_LOG10	10#define SLMATH_REAL	11#define SLMATH_IMAG	12#define SLMATH_SINH	13#define SLMATH_COSH	14#define SLMATH_TANH	15#define SLMATH_ATANH	16#define SLMATH_ASINH	17#define SLMATH_ACOSH	18#define SLMATH_TODOUBLE	19#define SLMATH_CONJ	20   int (*cl_math_op)_PROTO((int, SLtype, VOID_STAR, unsigned int, VOID_STAR));   int (*cl_math_op_result_type)_PROTO((int, SLtype, SLtype *));   SL_OOBinary_Type *cl_binary_ops;   SL_Typecast_Type *cl_typecast_funs;   void (*cl_byte_code_destroy)_PROTO((SLtype, VOID_STAR));   void (*cl_user_destroy_fun)_PROTO((SLtype, VOID_STAR));   int (*cl_init_array_object)_PROTO((SLtype, VOID_STAR));   int (*cl_datatype_deref)_PROTO((SLtype));   SLang_Struct_Type *cl_struct_def;   int (*cl_dereference) _PROTO((SLtype, VOID_STAR));   int (*cl_acopy) (SLtype, VOID_STAR, VOID_STAR);   int (*cl_apop) _PROTO((SLtype, VOID_STAR));   int (*cl_apush) _PROTO((SLtype, VOID_STAR));   int (*cl_push_literal) _PROTO((SLtype, VOID_STAR));   void (*cl_adestroy)_PROTO((SLtype, VOID_STAR));   int (*cl_push_intrinsic)_PROTO((SLtype, VOID_STAR));   int (*cl_void_typecast)_PROTO((SLtype, VOID_STAR, unsigned int, SLtype, VOID_STAR));   int (*cl_anytype_typecast)_PROTO((SLtype, VOID_STAR, unsigned int, SLtype, VOID_STAR));   /* Array access functions */   int (*cl_aput) (SLtype, unsigned int);   int (*cl_aget) (SLtype, unsigned int);   int (*cl_anew) (SLtype, unsigned int);   /* length method */   int (*cl_length) (SLtype, VOID_STAR, unsigned int *);   /* foreach */   SLang_Foreach_Context_Type *(*cl_foreach_open) (SLtype, unsigned int);   void (*cl_foreach_close) (SLtype, SLang_Foreach_Context_Type *);   int (*cl_foreach) (SLtype, SLang_Foreach_Context_Type *);   /* Structure access: get and put (assign to) fields */   int (*cl_sput) (SLtype, char *);   int (*cl_sget) (SLtype, char *);   /* File I/O */   int (*cl_fread) (SLtype, FILE *, VOID_STAR, unsigned int, unsigned int *);   int (*cl_fwrite) (SLtype, FILE *, VOID_STAR, unsigned int, unsigned int *);   int (*cl_fdread) (SLtype, int, VOID_STAR, unsigned int, unsigned int *);   int (*cl_fdwrite) (SLtype, int, VOID_STAR, unsigned int, unsigned int *);   int (*cl_to_bool) (SLtype, int *);      int (*cl_cmp)(SLtype, VOID_STAR, VOID_STAR, int *);   } SLang_Class_Type;/* These are the low-level functions for building push/pop methods.  They * know nothing about memory management.  For SLANG_CLASS_TYPE_MMT, use the * MMT push/pop functions instead. */extern int SLclass_push_double_obj (SLtype, double);extern int SLclass_push_float_obj (SLtype, float);extern int SLclass_push_long_obj (SLtype, long);extern int SLclass_push_int_obj (SLtype, int);extern int SLclass_push_short_obj (SLtype, short);extern int SLclass_push_char_obj (SLtype, char);extern int SLclass_push_ptr_obj (SLtype, VOID_STAR);extern int SLclass_pop_double_obj (SLtype, double *);extern int SLclass_pop_float_obj (SLtype, float *);extern int SLclass_pop_long_obj (SLtype, long *);extern int SLclass_pop_int_obj (SLtype, int *);extern int SLclass_pop_short_obj (SLtype, short *);extern int SLclass_pop_char_obj (SLtype, char *);extern int SLclass_pop_ptr_obj (SLtype, VOID_STAR *);extern SLang_Class_Type *SLclass_allocate_class (char *);extern int SLclass_get_class_id (SLang_Class_Type *cl);extern int SLclass_create_synonym (char *, SLtype);extern int SLclass_is_class_defined (SLtype);extern int SLclass_dup_object (SLtype type, VOID_STAR from, VOID_STAR to);extern int SLclass_register_class (SLang_Class_Type *, SLtype, unsigned int, SLtype);extern int SLclass_set_string_function (SLang_Class_Type *, char *(*)(SLtype, VOID_STAR));extern int SLclass_set_destroy_function (SLang_Class_Type *, void (*)(SLtype, VOID_STAR));extern int SLclass_set_push_function (SLang_Class_Type *, int (*)(SLtype, VOID_STAR));extern int SLclass_set_apush_function (SLang_Class_Type *, int (*)(SLtype, VOID_STAR));extern int SLclass_set_pop_function (SLang_Class_Type *, int (*)(SLtype, VOID_STAR));extern int SLclass_set_aget_function (SLang_Class_Type *, int (*)(SLtype, unsigned int));extern int SLclass_set_aput_function (SLang_Class_Type *, int (*)(SLtype, unsigned int));extern int SLclass_set_anew_function (SLang_Class_Type *, int (*)(SLtype, unsigned int));extern int SLclass_set_sget_function (SLang_Class_Type *, int (*)(SLtype, char *));extern int SLclass_set_sput_function (SLang_Class_Type *, int (*)(SLtype, char *));extern int SLclass_set_acopy_function (SLang_Class_Type *, int (*)(SLtype, VOID_STAR, VOID_STAR));/* Typecast object on the stack to type p1.  p2 and p3 should be set to 1 */extern int SLclass_typecast (SLtype, int, int);extern int SLclass_add_unary_op (SLtype,				 int (*) (int,					  SLtype, VOID_STAR, unsigned int,					  VOID_STAR),				 int (*) (int, SLtype, SLtype *));extern intSLclass_add_app_unary_op (SLtype,			  int (*) (int,				   SLtype, VOID_STAR, unsigned int,				   VOID_STAR),			  int (*) (int, SLtype, SLtype *));extern intSLclass_add_binary_op (SLtype, SLtype,		       int (*) (int,				SLtype, VOID_STAR, unsigned int,				SLtype, VOID_STAR, unsigned int,				VOID_STAR),		       int (*) (int, SLtype, SLtype, SLtype *));extern intSLclass_add_math_op (SLtype,		     int (*)(int,			     SLtype, VOID_STAR, unsigned int,			     VOID_STAR),		     int (*)(int, SLtype, SLtype *));extern intSLclass_add_typecast (SLtype /* from */, SLtype /* to */,		      int (*)_PROTO((SLtype, VOID_STAR, unsigned int,				     SLtype, VOID_STAR)),		      int	       /* allow implicit typecasts */		      );extern char *SLclass_get_datatype_name (SLtype);extern double SLcomplex_abs (double *);extern double *SLcomplex_times (double *, double *, double *);extern double *SLcomplex_divide (double *, double *, double *);extern double *SLcomplex_sin (double *, double *);extern double *SLcomplex_cos (double *, double *);extern double *SLcomplex_tan (double *, double *);extern double *SLcomplex_asin (double *, double *);extern double *SLcomplex_acos (double *, double *);extern double *SLcomplex_atan (double *, double *);extern double *SLcomplex_exp (double *, double *);extern double *SLcomplex_log (double *, double *);extern double *SLcomplex_log10 (double *, double *);extern double *SLcomplex_sqrt (double *, double *);extern double *SLcomplex_sinh (double *, double *);extern double *SLcomplex_cosh (double *, double *);extern double *SLcomplex_tanh (double *, double *);extern double *SLcomplex_pow (double *, double *, double *);extern double SLmath_hypot (double x, double y);/* Not implemented yet */extern double *SLcomplex_asinh (double *, double *);extern double *SLcomplex_acosh (double *, double *);extern double *SLcomplex_atanh (double *, double *);#ifdef _SLANG_SOURCE_typedef struct _SLang_MMT_Type SLang_MMT_Type;#elsetypedef int SLang_MMT_Type;#endifextern void SLang_free_mmt (SLang_MMT_Type *);extern VOID_STAR SLang_object_from_mmt (SLang_MMT_Type *);extern SLang_MMT_Type *SLang_create_mmt (SLtype, VOID_STAR);extern int SLang_push_mmt (SLang_MMT_Type *);extern SLang_MMT_Type *SLang_pop_mmt (SLtype);extern void SLang_inc_mmt (SLang_MMT_Type *);/* Maximum number of dimensions of an array. */#define SLARRAY_MAX_DIMS		7typedef struct _SLang_Array_Type{   SLtype data_type;   unsigned int sizeof_type;   VOID_STAR data;   unsigned int num_elements;   unsigned int num_dims;   int dims [SLARRAY_MAX_DIMS];   VOID_STAR (*index_fun)_PROTO((struct _SLang_Array_Type *, int *));   /* This function is designed to allow a type to store an array in    * any manner it chooses.  This function returns the address of the data    * value at the specified index location.    */   unsigned int flags;#define SLARR_DATA_VALUE_IS_READ_ONLY		1#define SLARR_DATA_VALUE_IS_POINTER		2#define SLARR_DATA_VALUE_IS_RANGE		4#define SLARR_DATA_VALUE_IS_INTRINSIC		8   SLang_Class_Type *cl;   unsigned int num_refs;   void (*free_fun)_PROTO((struct _SLang_Array_Type *));   VOID_STAR client_data;}SLang_Array_Type;extern int SLang_pop_array_of_type (SLang_Array_Type **, SLtype);extern int SLang_pop_array (SLang_Array_Type **, int);extern int SLang_push_array (SLang_Array_Type *, int);extern void SLang_free_array (SLang_Array_Type *);extern SLang_Array_Type *SLang_create_array (SLtype, int, VOID_STAR, int *, unsigned int);extern SLang_Array_Type *SLang_duplicate_array (SLang_Array_Type *);extern int SLang_get_array_element (SLang_Array_Type *, int *, VOID_STAR);extern int SLang_set_array_element (SLang_Array_Type *, int *, VOID_STAR);typedef int SLarray_Contract_Fun_Type (VOID_STAR xp, unsigned int increment, unsigned int num, VOID_STAR yp);typedef struct{   SLtype from_type;		       /* if array is this type */   SLtype typecast_to_type;	       /* typecast it to this */   SLtype result_type;		       /* to produce this */   SLarray_Contract_Fun_Type *f;       /* via this function */}SLarray_Contract_Type;extern int SLarray_contract_array (SLCONST SLarray_Contract_Type *);typedef int SLarray_Map_Fun_Type (SLtype xtype, VOID_STAR xp, 				  unsigned int increment, unsigned int num,				  SLtype ytype, VOID_STAR yp, VOID_STAR clientdata);typedef struct{   SLtype from_type;		       /* if array is this type */   SLtype typecast_to_type;	       /* typecast it to this */   SLtype result_type;		       /* to produce this */   SLarray_Map_Fun_Type *f;	       /* via this function */}SLarray_Map_Type;extern int SLarray_map_array_1 (SLCONST SLarray_Map_Type *, 				int *use_this_dim, 				VOID_STAR clientdata);extern int SLarray_map_array (SLCONST SLarray_Map_Type *);/*}}}*//*{{{ Interpreter Function Prototypes */  extern volatile int SLang_Error;/* Non zero if error occurs.  Must be reset to zero to continue. *//* error codes, severe errors are less than 0 */#define SL_APPLICATION_ERROR		-2#define SL_VARIABLE_UNINITIALIZED	-3#define SL_INTERNAL_ERROR		-5#define SL_STACK_OVERFLOW		-6#define SL_STACK_UNDERFLOW		-7#define SL_UNDEFINED_NAME		-8#define SL_SYNTAX_ERROR			-9#define SL_DUPLICATE_DEFINITION		-10#define SL_TYPE_MISMATCH		-11#define SL_OBJ_UNKNOWN			-13#define SL_UNKNOWN_ERROR		-14#define SL_TYPE_UNDEFINED_OP_ERROR	-16#define SL_INTRINSIC_ERROR		1/* Intrinsic error is an error generated by intrinsic functions */#define SL_USER_BREAK			2#define SL_DIVIDE_ERROR			3#define SL_OBJ_NOPEN			4#define SL_USER_ERROR			5#define SL_USAGE_ERROR			6#define SL_READONLY_ERROR		7#define SL_INVALID_PARM			8#define SL_NOT_IMPLEMENTED		9#define SL_MALLOC_ERROR			10#define SL_OVERFLOW			11#define SL_FLOATING_EXCEPTION		12/* Compatibility */#define USER_BREAK SL_USER_BREAK#define INTRINSIC_ERROR SL_INTRINSIC_ERROR  extern int SLang_Traceback;  /* If non-zero, dump an S-Lang traceback upon error.  Available as     _traceback in S-Lang. */  extern char *SLang_User_Prompt;  /* Prompt to use when reading from stdin */  extern int SLang_Version;  extern char *SLang_Version_String;extern char *SLang_Doc_Dir;extern void (*SLang_VMessage_Hook) (char *, va_list);extern void SLang_vmessage (char *, ...) _SLATTRIBUTE_PRINTF(1,2);  extern void (*SLang_Error_Hook)(char *);  /* Pointer to application dependent error messaging routine.  By default,     messages are displayed on stderr. */  extern void (*SLang_Exit_Error_Hook)(char *, va_list);extern void SLang_exit_error (char *, ...) _SLATTRIBUTE_((format (printf, 1, 2), noreturn));  extern void (*SLang_Dump_Routine)(char *);  /* Called if S-Lang traceback is enabled as well as other debugging     routines (e.g., trace).  By default, these messages go to stderr. */  extern void (*SLang_Interrupt)(void);  /* function to call whenever inner interpreter is entered.  This is     a good place to set SLang_Error to USER_BREAK. */  extern void (*SLang_User_Clear_Error)(void);  /* function that gets called when '_clear_error' is called. */  /* If non null, these call C functions before and after a slang function. */  extern void (*SLang_Enter_Function)(char *);extern void (*SLang_Exit_Function)(char *);extern int SLang_Num_Function_Args;/* Functions: */extern int SLang_init_all (void);/* Initializes interpreter and all modules */extern int SLang_init_slang (void);/* This function is mandatory and must be called by all applications that * use the interpreter */extern int SLang_init_posix_process (void);   /* process specific intrinsics */extern int SLang_init_stdio (void);    /* fgets, etc. stdio functions  */extern int SLang_init_posix_dir (void);extern int SLang_init_ospath (void);extern int SLang_init_slmath (void);/* called if math functions sin, cos, etc... are needed. */   extern int SLang_init_slfile (void);   extern int SLang_init_slunix (void);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -