1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/*******************************************************/
/* "C" Language Integrated Production System */
/* */
/* CLIPS Version 6.30 08/16/14 */
/* */
/* EXTERNAL FUNCTIONS HEADER FILE */
/*******************************************************/
/*************************************************************/
/* Purpose: Routines for adding new user or system defined */
/* functions. */
/* */
/* Principal Programmer(s): */
/* Gary D. Riley */
/* */
/* Contributing Programmer(s): */
/* */
/* Revision History: */
/* */
/* 6.24: Renamed BOOLEAN macro type to intBool. */
/* */
/* 6.30: Added support for passing context information */
/* to user defined functions. */
/* */
/* Support for long long integers. */
/* */
/* Added const qualifiers to remove C++ */
/* deprecation warnings. */
/* */
/* Replaced ALLOW_ENVIRONMENT_GLOBALS macros */
/* with functions. */
/* */
/*************************************************************/
#ifndef _H_extnfunc
#define _H_extnfunc
#ifndef _H_symbol
#include "symbol.h"
#endif
#ifndef _H_expressn
#include "expressn.h"
#endif
#include "userdata.h"
struct FunctionDefinition
{
struct symbolHashNode *callFunctionName;
const char *actualFunctionName;
char returnValueType;
int (*functionPointer)(void);
struct expr *(*parser)(void *,struct expr *,const char *);
const char *restrictions;
short int overloadable;
short int sequenceuseok;
short int environmentAware;
short int bsaveIndex;
struct FunctionDefinition *next;
struct userData *usrData;
void *context;
};
#define ValueFunctionType(target) (((struct FunctionDefinition *) target)->returnValueType)
#define ExpressionFunctionType(target) (((struct FunctionDefinition *) ((target)->value))->returnValueType)
#define ExpressionFunctionPointer(target) (((struct FunctionDefinition *) ((target)->value))->functionPointer)
#define ExpressionFunctionCallName(target) (((struct FunctionDefinition *) ((target)->value))->callFunctionName)
#define ExpressionFunctionRealName(target) (((struct FunctionDefinition *) ((target)->value))->actualFunctionName)
#define PTIF (int (*)(void))
#define PTIEF (int (*)(void *))
/*==================*/
/* ENVIRONMENT DATA */
/*==================*/
#define EXTERNAL_FUNCTION_DATA 50
struct externalFunctionData
{
struct FunctionDefinition *ListOfFunctions;
struct FunctionHash **FunctionHashtable;
};
#define ExternalFunctionData(theEnv) ((struct externalFunctionData *) GetEnvironmentData(theEnv,EXTERNAL_FUNCTION_DATA))
#ifdef LOCALE
#undef LOCALE
#endif
#ifdef _EXTNFUNC_SOURCE_
#define LOCALE
#else
#define LOCALE extern
#endif
#ifdef LOCALE
struct FunctionHash
{
struct FunctionDefinition *fdPtr;
struct FunctionHash *next;
};
#define SIZE_FUNCTION_HASH 517
#endif
LOCALE void InitializeExternalFunctionData(void *);
LOCALE int EnvDefineFunction(void *,const char *,int,
int (*)(void *),const char *);
LOCALE int EnvDefineFunction2(void *,const char *,int,
int (*)(void *),const char *,const char *);
LOCALE int EnvDefineFunctionWithContext(void *,const char *,int,
int (*)(void *),const char *,void *);
LOCALE int EnvDefineFunction2WithContext(void *,const char *,int,
int (*)(void *),const char *,const char *,void *);
LOCALE int DefineFunction3(void *,const char *,int,
int (*)(void *),const char *,const char *,intBool,void *);
LOCALE int AddFunctionParser(void *,const char *,
struct expr *(*)( void *,struct expr *,const char *));
LOCALE int RemoveFunctionParser(void *,const char *);
LOCALE int FuncSeqOvlFlags(void *,const char *,int,int);
LOCALE struct FunctionDefinition *GetFunctionList(void *);
LOCALE void InstallFunctionList(void *,struct FunctionDefinition *);
LOCALE struct FunctionDefinition *FindFunction(void *,const char *);
LOCALE int GetNthRestriction(struct FunctionDefinition *,int);
LOCALE const char *GetArgumentTypeName(int);
LOCALE int UndefineFunction(void *,const char *);
LOCALE int GetMinimumArgs(struct FunctionDefinition *);
LOCALE int GetMaximumArgs(struct FunctionDefinition *);
#if ALLOW_ENVIRONMENT_GLOBALS
#if (! RUN_TIME)
LOCALE int DefineFunction(const char *,int,int (*)(void),const char *);
LOCALE int DefineFunction2(const char *,int,int (*)(void),const char *,const char *);
#endif /* (! RUN_TIME) */
#endif /* ALLOW_ENVIRONMENT_GLOBALS */
#endif /* _H_extnfunc */
|