00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _H_extnfunc
00028
00029 #define _H_extnfunc
00030
00031 #ifndef _H_symbol
00032 #include "symbol.h"
00033 #endif
00034 #ifndef _H_expressn
00035 #include "expressn.h"
00036 #endif
00037
00038 #include "userdata.h"
00039
00040 struct FunctionDefinition
00041 {
00042 struct symbolHashNode *callFunctionName;
00043 char *actualFunctionName;
00044 char returnValueType;
00045 int (*functionPointer)(void);
00046 struct expr *(*parser)(void *,struct expr *,char *);
00047 char *restrictions;
00048 short int overloadable;
00049 short int sequenceuseok;
00050 short int environmentAware;
00051 short int bsaveIndex;
00052 struct FunctionDefinition *next;
00053 struct userData *usrData;
00054 void *context;
00055 };
00056
00057 #define ValueFunctionType(target) (((struct FunctionDefinition *) target)->returnValueType)
00058 #define ExpressionFunctionType(target) (((struct FunctionDefinition *) ((target)->value))->returnValueType)
00059 #define ExpressionFunctionPointer(target) (((struct FunctionDefinition *) ((target)->value))->functionPointer)
00060 #define ExpressionFunctionCallName(target) (((struct FunctionDefinition *) ((target)->value))->callFunctionName)
00061 #define ExpressionFunctionRealName(target) (((struct FunctionDefinition *) ((target)->value))->actualFunctionName)
00062
00063 #define PTIF (int (*)(void))
00064 #define PTIEF (int (*)(void *))
00065
00066
00067
00068
00069
00070 #define EXTERNAL_FUNCTION_DATA 50
00071
00072 struct externalFunctionData
00073 {
00074 struct FunctionDefinition *ListOfFunctions;
00075 struct FunctionHash **FunctionHashtable;
00076 };
00077
00078 #define ExternalFunctionData(theEnv) ((struct externalFunctionData *) GetEnvironmentData(theEnv,EXTERNAL_FUNCTION_DATA))
00079
00080 #ifdef LOCALE
00081 #undef LOCALE
00082 #endif
00083
00084 #ifdef _EXTNFUNC_SOURCE_
00085 #define LOCALE
00086 #else
00087 #define LOCALE extern
00088 #endif
00089
00090 #ifdef LOCALE
00091 struct FunctionHash
00092 {
00093 struct FunctionDefinition *fdPtr;
00094 struct FunctionHash *next;
00095 };
00096
00097 #define SIZE_FUNCTION_HASH 517
00098 #endif
00099
00100 LOCALE int DefineFunction(char *,int,int (*)(void),char *);
00101 LOCALE int DefineFunction2(char *,int,int (*)(void),char *,char *);
00102
00103 LOCALE void InitializeExternalFunctionData(void *);
00104 LOCALE int EnvDefineFunction(void *,char *,int,
00105 int (*)(void *),char *);
00106 LOCALE int EnvDefineFunction2(void *,char *,int,
00107 int (*)(void *),char *,char *);
00108 LOCALE int EnvDefineFunctionWithContext(void *,char *,int,
00109 int (*)(void *),char *,void *);
00110 LOCALE int EnvDefineFunction2WithContext(void *,char *,int,
00111 int (*)(void *),char *,char *,void *);
00112 LOCALE int DefineFunction3(void *,char *,int,
00113 int (*)(void *),char *,char *,intBool,void *);
00114 LOCALE int AddFunctionParser(void *,char *,
00115 struct expr *(*)( void *,struct expr *,char *));
00116 LOCALE int RemoveFunctionParser(void *,char *);
00117 LOCALE int FuncSeqOvlFlags(void *,char *,int,int);
00118 LOCALE struct FunctionDefinition *GetFunctionList(void *);
00119 LOCALE void InstallFunctionList(void *,struct FunctionDefinition *);
00120 LOCALE struct FunctionDefinition *FindFunction(void *,char *);
00121 LOCALE int GetNthRestriction(struct FunctionDefinition *,int);
00122 LOCALE char *GetArgumentTypeName(int);
00123 LOCALE int UndefineFunction(void *,char *);
00124 LOCALE int GetMinimumArgs(struct FunctionDefinition *);
00125 LOCALE int GetMaximumArgs(struct FunctionDefinition *);
00126
00127 #endif
00128
00129
00130