/usr/share/yacas/include/lispuserfunc.h is in yacas 1.3.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #ifndef __lispuserfunc_h__
#define __lispuserfunc_h__
#include "yacasbase.h"
#include "lispobject.h"
#include "lispenvironment.h"
#include "lisphash.h"
#include "grower.h"
#include "evalfunc.h"
/// Abstract class providing the basic user function API.
/// Instances of this class are associated to the name of the function
/// via an associated hash table. When obtained, they can be used to
/// evaluate the function with some arguments.
class LispUserFunction : public EvalFuncBase
{
public:
LispUserFunction() : iFenced(LispTrue),iTraced(LispFalse) {};
virtual ~LispUserFunction();
virtual void Evaluate(LispPtr& aResult,LispEnvironment& aEnvironment,
LispPtr& aArguments)=0;
virtual void HoldArgument(LispString * aVariable) = 0;
virtual void DeclareRule(LispInt aPrecedence, LispPtr& aPredicate,
LispPtr& aBody) = 0;
virtual void DeclareRule(LispInt aPrecedence, LispPtr& aBody) = 0;
virtual void DeclarePattern(LispInt aPrecedence, LispPtr& aPredicate,
LispPtr& aBody) = 0;
virtual LispPtr& ArgList() = 0;
public: //unfencing
inline void UnFence() {iFenced = LispFalse;};
inline LispBoolean Fenced() {return iFenced;};
public: //tracing
inline void Trace() {iTraced = LispTrue;};
inline void UnTrace() {iTraced = LispFalse;};
inline LispBoolean Traced() {return iTraced;};
private:
LispBoolean iFenced;
LispBoolean iTraced;
};
/// User function with a specific arity.
/// This is still an abstract class, but the arity (number of
/// arguments) of the function is now fixed.
class LispArityUserFunction : public LispUserFunction
{
public:
virtual LispInt Arity() const = 0;
virtual LispInt IsArity(LispInt aArity) const = 0;
};
class LispDefFile;
/// Set of LispArityUserFunction's.
/// By using this class, you can associate multiple functions (with
/// different arities) to one name. A specific LispArityUserFunction
/// can be selected by providing its name. Additionally, the name of
/// the file in which the function is defined, can be specified.
class LispMultiUserFunction : public YacasBase
{
public:
/// Constructor.
LispMultiUserFunction() : iFunctions(),iFileToOpen(NULL) {};
/** When adding a multi-user function to the association hash table, the copy constructor is used.
* We should at least make sure that iFunctions is empty, so there is no copying needed (for efficiency).
* Casually having a copy-constructor on CDeletingArrayGrower should be avoided, to make sure it is
* not used accidentally.
*/
inline LispMultiUserFunction(const LispMultiUserFunction& aOther) : iFunctions(), iFileToOpen(NULL)
{
LISPASSERT(aOther.iFileToOpen == 0);
LISPASSERT(aOther.iFunctions.Size() == 0);
}
inline LispMultiUserFunction& operator=(const LispMultiUserFunction& aOther)
{
// copy constructor not written yet, hence the assert
LISPASSERT(aOther.iFileToOpen == 0);
LISPASSERT(aOther.iFunctions.Size() == 0);
LISPASSERT(iFileToOpen == 0);
LISPASSERT(iFunctions.Size() == 0);
return *this;
}
/// Return user function with given arity.
LispUserFunction* UserFunc(LispInt aArity);
/// Destructor.
virtual ~LispMultiUserFunction();
/// Specify that some argument should be held.
virtual void HoldArgument(LispString * aVariable);
/// Add another LispArityUserFunction to #iFunctions.
virtual void DefineRuleBase(LispArityUserFunction* aNewFunction);
/// Delete tuser function with given arity.
virtual void DeleteBase(LispInt aArity);
private:
/// Set of LispArityUserFunction's provided by this LispMultiUserFunction.
CDeletingArrayGrower<LispArityUserFunction*, ArrOpsDeletingPtr<LispArityUserFunction> > iFunctions;
public:
/// File to read for the definition of this function.
LispDefFile* iFileToOpen;
};
/// Associated hash of LispMultiUserFunction objects.
class LispUserFunctions : public LispAssociatedHash<LispMultiUserFunction>
{
};
#endif
|