Back to index

scribus-ng  1.3.4.dfsg+svn20071115
fptypes.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 //==============================
00008 // Function parser v2.8 by Warp
00009 //==============================
00010 
00011 // NOTE:
00012 // This file contains only internal types for the function parser library.
00013 // You don't need to include this file in your code. Include "fparser.hh"
00014 // only.
00015 
00016 
00017 
00018 namespace FUNCTIONPARSERTYPES
00019 {
00020 // The functions must be in alphabetical order:
00021     enum OPCODE
00022     {
00023         cAbs, cAcos,
00024 #ifndef NO_ASINH
00025         cAcosh,
00026 #endif
00027         cAsin,
00028 #ifndef NO_ASINH
00029         cAsinh,
00030 #endif
00031         cAtan,
00032         cAtan2,
00033 #ifndef NO_ASINH
00034         cAtanh,
00035 #endif
00036         cCeil, cCos, cCosh, cCot, cCsc,
00037 #ifndef DISABLE_EVAL
00038         cEval,
00039 #endif
00040         cExp, cFloor, cIf, cInt, cLog, cLog10, cMax, cMin,
00041         cSec, cSin, cSinh, cSqrt, cTan, cTanh,
00042 
00043 // These do not need any ordering:
00044         cImmed, cJump,
00045         cNeg, cAdd, cSub, cMul, cDiv, cMod, cPow,
00046         cEqual, cNEqual, cLess, cLessOrEq, cGreater, cGreaterOrEq,
00047         cNot, cAnd, cOr,
00048 
00049         cDeg, cRad,
00050 
00051         cFCall, cPCall,
00052 
00053 #ifdef SUPPORT_OPTIMIZER
00054         cVar, cDup, cInv,
00055 #endif
00056 
00057         VarBegin
00058     };
00059 
00060     struct FuncDefinition
00061     {
00062         const char* name;
00063         unsigned nameLength;
00064         unsigned opcode;
00065         unsigned params;
00066 
00067         // This is basically strcmp(), but taking 'nameLength' as string
00068         // length (not ending '\0'):
00069         bool operator<(const FuncDefinition& rhs) const
00070         {
00071             for(unsigned i = 0; i < nameLength; ++i)
00072             {
00073                 if(i == rhs.nameLength) return false;
00074                 const char c1 = name[i], c2 = rhs.name[i];
00075                 if(c1 < c2) return true;
00076                 if(c2 < c1) return false;
00077             }
00078             return nameLength < rhs.nameLength;
00079         }
00080     };
00081 
00082 
00083 // This list must be in alphabetical order:
00084     const FuncDefinition Functions[]=
00085     {
00086         { "abs", 3, cAbs, 1 },
00087         { "acos", 4, cAcos, 1 },
00088 #ifndef NO_ASINH
00089         { "acosh", 5, cAcosh, 1 },
00090 #endif
00091         { "asin", 4, cAsin, 1 },
00092 #ifndef NO_ASINH
00093         { "asinh", 5, cAsinh, 1 },
00094 #endif
00095         { "atan", 4, cAtan, 1 },
00096         { "atan2", 5, cAtan2, 2 },
00097 #ifndef NO_ASINH
00098         { "atanh", 5, cAtanh, 1 },
00099 #endif
00100         { "ceil", 4, cCeil, 1 },
00101         { "cos", 3, cCos, 1 },
00102         { "cosh", 4, cCosh, 1 },
00103         { "cot", 3, cCot, 1 },
00104         { "csc", 3, cCsc, 1 },
00105 #ifndef DISABLE_EVAL
00106         { "eval", 4, cEval, 0 },
00107 #endif
00108         { "exp", 3, cExp, 1 },
00109         { "floor", 5, cFloor, 1 },
00110         { "if", 2, cIf, 0 },
00111         { "int", 3, cInt, 1 },
00112         { "log", 3, cLog, 1 },
00113         { "log10", 5, cLog10, 1 },
00114         { "max", 3, cMax, 2 },
00115         { "min", 3, cMin, 2 },
00116         { "sec", 3, cSec, 1 },
00117         { "sin", 3, cSin, 1 },
00118         { "sinh", 4, cSinh, 1 },
00119         { "sqrt", 4, cSqrt, 1 },
00120         { "tan", 3, cTan, 1 },
00121         { "tanh", 4, cTanh, 1 }
00122     };
00123 }