cx.h revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2002-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* C expression library interface
*
* Glenn Fowler
* AT&T Research
*/
#ifndef _CX_H
#define _CX_H
#include <ast.h>
#include <math.h>
#include <dt.h>
#include <vmalloc.h>
#define CX_ID "cx"
#define CX_VERSION 20110811L
/* Cx_t.flags */
/* _CX_HEADER_.flags */
#define CX_NORMALIZED 0x0001
#define CX_INITIALIZED 0x0002
#define CX_REFERENCED 0x0004
#define CX_DEPRECATED 0x0008
#define CX_IGNORECASE 0x0100
/* Cxpart_t.flags */
#define CX_ALL 0x0001
/* Cxtype_t.representation */
#define CX_void 0
#define CX_number 1
#define CX_string 2
#define CX_pointer 3
#define CX_reference 4
#define CX_type 6
/* Cxformat_t.flags */
#define CX_STRING 0x0001
#define CX_INTEGER 0x0002
#define CX_UNSIGNED 0x0004
#define CX_FLOAT 0x0008
#define CX_BUFFER 0x0010
#define CX_BINARY 0x0020
#define CX_MULTIPLE 0x0100
#define CX_FREE 0x0200
#define CX_NUL 0x0400
#define CX_VARIABLE 0x0800
#define CX_QUOTEALL 0x1000
#define CX_LONG 0x2000
#define CX_ASSIGN 01
#define CX_X2 02
#define CX_UNARY 04
#define CX_ATTR 3
#define CX_OPNAME "0+&/>~<~%*!|-^CDeGLnpRJSst"
#define CX_NOP (( 0))
#define CX_NOMATCH (CX_MAT)
#define CX_CTYPE_ALPHA (1<<0)
#define CXMIN(a,b) (((a)<(b))?(a):(b))
#define CXMAX(a,b) (((a)>(b))?(a):(b))
#define CXINTEGER(n) ((Cxinteger_t)(n))
#define CXDETAILS(d,f,t,v) \
#define CX_HEADER_INIT {{0},0}
#define cxrepresentation(t) ((t)->representation)
#if ! _ast_fltmax_double
#endif
typedef _ast_fltmax_t Cxnumber_t;
typedef intmax_t Cxinteger_t;
typedef uintmax_t Cxunsigned_t;
{
int code; /* op code */
};
#define _CX_HEADER_ \
const char* name; /* key name */ \
const char* description; /* description */
#define _CX_HEADER_LINK_ \
#define _CX_NAME_HEADER_ \
struct \
{ \
} header;
#define _CX_LIST_HEADER_ \
struct \
{ \
} header;
#define _CX_CODE_HEADER_ \
typedef struct Cxheader_s /* name/description header */
{
} Cxheader_t;
typedef struct Cxnameheader_s /* name key dict element header */
{
typedef struct Cxlistheader_s /* list key dict element header */
{
typedef struct Cxcodeheader_s /* code key dict element header */
{
typedef struct Cxbuffer_s /* buffer type */
{
void* data; /* data pointer */
} Cxbuffer_t;
typedef struct Cxstring_s /* string type */
{
char* data; /* data pointer */
} Cxstring_t;
typedef union Cxvalue_u /* fundamental types */
{
void* pointer; /* generic pointer */
} Cxvalue_t;
Cxoperand_t*, int, void*, Cxdisc_t*);
Cxdisc_t*);
Cxinstruction_t*, Cxinstruction_t*, void*,
Cxdisc_t*);
struct Cxoperand_s /* expression operand */
{
int refs; /* reference count */
};
struct Cxitem_s /* map item */
{
const char* name; /* item name */
#ifdef _CX_ITEM_PRIVATE_
#endif
};
struct Cxedit_s /* edit list element */
{
void* data; /* private data */
#ifdef _CX_EDIT_PRIVATE_
#endif
};
struct Cxpart_s /* map part */
{
};
struct Cxmap_s /* str<=>num map */
{
};
struct Cxconstraint_s /* value constraints */
{
const char* expression; /* expression on ``.'' */
const char* pattern; /* string match pattern */
void* data; /* private data */
#ifdef _CX_CONSTRAINT_PRIVATE_
#endif
};
struct Cxformat_s /* format info */
{
const char* description; /* external details description */
char* details; /* default external details */
unsigned short flags; /* flags */
short width; /* width in bytes */
short print; /* print width hint */
short base; /* base */
short fill; /* fill character */
short code; /* code set */
short delimiter; /* delimiter */
short escape; /* escape */
short quotebegin; /* quotebegin */
short quoteend; /* quoteend */
short fixedpoint; /* fixed point width */
short unused; /* not used */
};
struct Cxreference_s /* member reference */
{
};
struct Cxarray_s /* array info */
{
short delimiter; /* value delimiter */
};
struct Cxstructure_s /* structure info */
{
int level; /* structure level */
};
struct Cxvariable_s /* variable info */
{
const char* prototype; /* (proto)type name */
unsigned long index; /* caller defined index */
void* data; /* caller defined data */
};
struct Cxmatch_s /* type match info */
{
};
struct Cxmember_s /* type member info */
{
};
struct Cxtype_s /* type info */
{
unsigned short representation; /* fundamental type index */
unsigned short index; /* caller defined index */
unsigned short size; /* sizeof() size in bytes */
unsigned short element; /* element size in bytes */
void* data; /* private data */
};
typedef struct Cxcallout_s /* op code callout */
{
} Cxcallout_t;
typedef struct Cxrecode_s /* recode callout */
{
} Cxrecode_t;
struct Cxinstruction_s /* parsed instruction */
{
int op; /* op code */
int pp; /* stack push(>0) pop(<0) count */
};
struct Cxdisc_s /* user discipline */
{
unsigned long version; /* interface version */
const char* ps1; /* primary prompt */
const char* ps2; /* secondary prompt */
const char* map; /* map file */
};
struct Cxquery_s /* query */
{
const char* method; /* caller specific method match */
#ifdef _CX_QUERY_PRIVATE_
#endif
};
struct Cxlib_s /* Cxdisc_t.loadf library info */
{
const char** libraries; /* library list */
/* the remaining are set by Cxdisc_t.loadf */
const char* path; /* library path name */
};
struct Cxexpr_s /* compiled expression node */
{
const char* file; /* output file */
void* data; /* query private data */
char** argv; /* query argv */
#ifdef _CX_EXPR_PRIVATE_
#endif
};
struct Cxstate_s /* cx library global state */
{
#ifdef _CX_STATE_PRIVATE_
#endif
};
struct Cx_s /* interface handle */
{
const char* id; /* interface id */
int eof; /* input at eof */
int error; /* error occurred */
int interactive; /* interactive input */
void* caller; /* caller defined handle */
unsigned char* ctype; /* ctype table */
#ifdef _CX_PRIVATE_
#endif
};
#define cxinit(d,e) (memset(d,0,sizeof(Cxdisc_t)),(d)->version=CX_VERSION,(d)->errorf=(Error_f)(e),cxstate(d))
#if _BLD_cx && defined(__EXPORT__)
#define extern __EXPORT__
#endif
extern char* cxlocation(Cx_t*, void*);
extern void cxcodetrace(Cx_t*, const char*, Cxinstruction_t*, unsigned int, Cxoperand_t*, Cxoperand_t*);
extern char* cxcodename(int);
#undef extern
#endif