/* @(#)lpixport.t	128.1 1/20/93 19:42:28 */
/************************************************************************\
   Copyright (C) 1990 Lotus Development Corporation.  All rights reserved.
   Name:         lpixport.t
   Date:         20 Nov 1989
   Description:  Exported (LPI) floating point math support.
\************************************************************************/

#if !defined(LPIXPORT_T)
#define LPIXPORT_T


/********************************************************************
**             MACROS & TYPEDEFS
*/

/* placeholder argument for functions accepting no inputs */
#if L_ANSI_C
#define NOPARAMS void
#else /* !L_ANSI_C */
#define NOPARAMS
#endif /* L_ANSI_C */

typedef lubyte stacktype;
typedef union {
   lfloat10 tr;
   lfloat8  lr;
   lfloat4  sr;
} number, *numptr;

/* The types of string compares available (and used) in tos_compare:

   NUM_COLLATING uses the collating compare (where an umlauted "a"
   comes just after the normal "a").

   NUM_CHARSET uses the character set's sequence (where an umlauted
   "a" is near the end of the sequence).

   NUM_DBASE is just like NUM_COLLATING except that blanks are
   treated as NA.
*/
typedef enum {
   NUM_COLLATING,
   NUM_FULL_COLLATE,
   NUM_CHARSET,
   NUM_WILDCARD,
   NUM_DBASE
} strcmp_type;

/* The permissible number stack element types */
#define NOTUSED   0x00
#define NUM_TREAL 0x01
#define NUM_ERR   0x40
#define NUM_NA    0x80


/********************************************************************
**             DATA STRUCTURES
*/

#define MATHTABLE_SKIP 30

#if L_ANSI_C

typedef struct MathTable_ {
   void      (far *skip[MATHTABLE_SKIP]) (NOPARAMS);
   void      (far *drop_one)             (NOPARAMS);
   void      (far *drop_many)            (lsshort);
   lsshort   (far *pop_integer)          (NOPARAMS);
   lslong    (far *pop_long)             (NOPARAMS);
   lbool     (far *pop_double)           (lptr(lfloat8));
   stacktype (far *pop_number)           (lptr(lfloat10));
   void      (far *lts_temp1)            (NOPARAMS);
   stacktype (far *tos_type)             (NOPARAMS);
   lsshort   (far *push_long)            (lslong);
   lsshort   (far *push_integer)         (lsshort);
   void      (far *lts_temp2)            (NOPARAMS);
   void      (far *push_type_err)        (NOPARAMS);
   void      (far *push_na)              (NOPARAMS);
   void      (far *lts_temp3)            (NOPARAMS);
   void      (far *push_number_value)    (lptr(lfloat10));
   void      (far *push_zero)            (NOPARAMS);
   void      (far *push_one)             (NOPARAMS);
   void      (far *push_pi)              (NOPARAMS);
   lsshort   (far *push_double)          (lptr(lfloat8));
   void      (far *lts_temp4)            (NOPARAMS);
   void      (far *op_negate)            (NOPARAMS);
   void      (far *op_pow)               (NOPARAMS);
   void      (far *op_eq)                (NOPARAMS);
   void      (far *op_neq)               (NOPARAMS);
   void      (far *op_lte)               (NOPARAMS);
   void      (far *op_gte)               (NOPARAMS);
   void      (far *op_lt)                (NOPARAMS);
   void      (far *op_gt)                (NOPARAMS);
   void      (far *lts_temp5)            (NOPARAMS);
   void      (far *lts_temp6)            (NOPARAMS);
   void      (far *lts_temp7)            (NOPARAMS);
   stacktype (far *swap_TOS)             (NOPARAMS);
   stacktype (far *swap_nth)             (lsshort);
   stacktype (far *dup)                  (NOPARAMS);
   stacktype (far *dup_nth)              (lsshort);
   lsshort   (far *tos_compare)          (strcmp_type);
   stacktype (far *stack_depth)          (NOPARAMS);
   void      (far *at_sqrt)              (lsshort);
   void      (far *at_ln)                (lsshort);
   void      (far *at_mod)               (lsshort);
   void      (far *at_log)               (lsshort);
   void      (far *at_exp)               (lsshort);
   void      (far *at_sin)               (lsshort);
   void      (far *at_cos)               (lsshort);
   void      (far *at_tan)               (lsshort);
   void      (far *at_asin)              (lsshort);
   void      (far *at_acos)              (lsshort);
   void      (far *at_atan)              (lsshort);
   void      (far *at_atan2)             (lsshort);
   void      (far *at_abs)               (lsshort);
   void      (far *at_int)               (lsshort);
   void      (far *at_rand)              (lsshort);
   void      (far *op_add)               (NOPARAMS);
   void      (far *op_sub)               (NOPARAMS);
   void      (far *op_mul)               (NOPARAMS);
   void      (far *op_div)               (NOPARAMS);
} MathTableType;

#else /* !L_ANSI_C */

typedef struct MathTable_ {
   void      (far *skip[MATHTABLE_SKIP]) ();
   void      (far *drop_one)             ();
   void      (far *drop_many)            ();
   lsshort   (far *pop_integer)          ();
   lslong    (far *pop_long)             ();
   lbool     (far *pop_double)           ();
   stacktype (far *pop_number)           ();
   void      (far *lts_temp1)            ();
   stacktype (far *tos_type)             ();
   lsshort   (far *push_long)            ();
   lsshort   (far *push_integer)         ();
   void      (far *lts_temp2)            ();
   void      (far *push_type_err)        ();
   void      (far *push_na)              ();
   void      (far *lts_temp3)            ();
   void      (far *push_number_value)    ();
   void      (far *push_zero)            ();
   void      (far *push_one)             ();
   void      (far *push_pi)              ();
   lsshort   (far *push_double)          ();
   void      (far *lts_temp4)            ();
   void      (far *op_negate)            ();
   void      (far *op_pow)               ();
   void      (far *op_eq)                ();
   void      (far *op_neq)               ();
   void      (far *op_lte)               ();
   void      (far *op_gte)               ();
   void      (far *op_lt)                ();
   void      (far *op_gt)                ();
   void      (far *lts_temp5)            ();
   void      (far *lts_temp6)            ();
   void      (far *lts_temp7)            ();
   stacktype (far *swap_TOS)             ();
   stacktype (far *swap_nth)             ();
   stacktype (far *dup)                  ();
   stacktype (far *dup_nth)              ();
   lsshort   (far *tos_compare)          ();
   stacktype (far *stack_depth)          ();
   void      (far *at_sqrt)              ();
   void      (far *at_ln)                ();
   void      (far *at_mod)               ();
   void      (far *at_log)               ();
   void      (far *at_exp)               ();
   void      (far *at_sin)               ();
   void      (far *at_cos)               ();
   void      (far *at_tan)               ();
   void      (far *at_asin)              ();
   void      (far *at_acos)              ();
   void      (far *at_atan)              ();
   void      (far *at_atan2)             ();
   void      (far *at_abs)               ();
   void      (far *at_int)               ();
   void      (far *at_rand)              ();
   void      (far *op_add)               ();
   void      (far *op_sub)               ();
   void      (far *op_mul)               ();
   void      (far *op_div)               ();
} MathTableType;

#endif /* L_ANSI_C */

#undef MATHTABLE_SKIP


/********************************************************************
**             STACK BASED MATH API
*/

#define LPI_MATH(func)      (*lpimathtable->func)
#define LPI_MATH_1ARG(func) (*lpimathtable->func)(1)

#define LpiACos()       LPI_MATH_1ARG (at_acos)
#define LpiASin()       LPI_MATH_1ARG (at_asin)
#define LpiATan()       LPI_MATH_1ARG (at_atan)
#define LpiATan2()      LPI_MATH_1ARG (at_atan2)
#define LpiAbs()        LPI_MATH_1ARG (at_abs)
#define LpiAdd          LPI_MATH (op_add)
#define LpiCos()        LPI_MATH_1ARG (at_cos)
#define LpiDiv          LPI_MATH (op_div)
#define LpiDropMany     LPI_MATH (drop_many)
#define LpiDropOne      LPI_MATH (drop_one)
#define LpiDup          LPI_MATH (dup)
#define LpiDupNth       LPI_MATH (dup_nth)
#define LpiEq           LPI_MATH (op_eq)
#define LpiExp()        LPI_MATH_1ARG (at_exp)
#define LpiGt           LPI_MATH (op_gt)
#define LpiGte          LPI_MATH (op_gte)
#define LpiInt()        LPI_MATH_1ARG (at_int)
#define LpiLN()         LPI_MATH_1ARG (at_ln)
#define LpiLog()        LPI_MATH_1ARG (at_log)
#define LpiLt           LPI_MATH (op_lt)
#define LpiLte          LPI_MATH (op_lte)
#define LpiMod()        LPI_MATH_1ARG(at_mod)
#define LpiMul          LPI_MATH (op_mul)
#define LpiNegate       LPI_MATH (op_negate)
#define LpiNeq          LPI_MATH (op_neq)
#define LpiPopLfloat10  LPI_MATH (pop_number)
#define LpiPopLfloat8   LPI_MATH (pop_double)
#define LpiPopLsLong    LPI_MATH (pop_long)
#define LpiPopLsShort   LPI_MATH (pop_integer)
#define LpiPow          LPI_MATH (op_pow)
#define LpiPushErr      LPI_MATH (push_type_err)
#define LpiPushLfloat10 LPI_MATH (push_number_value)
#define LpiPushLfloat8  LPI_MATH (push_double)
#define LpiPushLsLong   LPI_MATH (push_long)
#define LpiPushLsShort  LPI_MATH (push_integer)
#define LpiPushNa       LPI_MATH (push_na)
#define LpiPushOne      LPI_MATH (push_one)
#define LpiPushPi       LPI_MATH (push_pi)
#define LpiPushZero     LPI_MATH (push_zero)
#define LpiRand()       LPI_MATH_1ARG (at_rand)
#define LpiSin()        LPI_MATH_1ARG (at_sin)
#define LpiSqrt()       LPI_MATH_1ARG (at_sqrt)
#define LpiStackDepth   LPI_MATH (stack_depth)
#define LpiSub          LPI_MATH (op_sub)
#define LpiSwap         LPI_MATH (swap_TOS)
#define LpiSwapNth      LPI_MATH (swap_nth)
#define LpiTan()        LPI_MATH_1ARG (at_tan)
#define LpiTosCompare() LPI_MATH_1ARG (tos_compare)
#define LpiTosType      LPI_MATH (tos_type)

/********************************************************************
**             END OF FILE
*/
#endif   /* if !defined(LPIXPORT_T) */
