44 #ifndef CCXX_SCRIPT3_H_
45 #define CCXX_SCRIPT3_H_
55 #ifndef CCXX_BUFFER_H_
59 #define TRAP_BITS (sizeof(unsigned long) * 8)
60 #define SCRIPT_INDEX_SIZE KEYDATA_INDEX_SIZE
61 #define SCRIPT_MAX_ARGS 250
62 #define SCRIPT_TEMP_SPACE 16
63 #define SCRIPT_STACK_SIZE 32
64 #define SCRIPT_ROUTE_SLOTS 16
65 #define SCRIPT_EXEC_WRAPPER
66 #define SCRIPT_APPS_WRAPPER
67 #define SCRIPT_RIPPLE_LEVEL 2
68 #define SCRIPT_RIPPLE_KEYDATA
69 #define SCRIPT_BINDER_SELECT
70 #define SCRIPT_SERVER_PREFIX
71 #define SCRIPT_DEFINE_TOKENS
76 #elif !defined(__hpux) && !defined(_AIX)
108 typedef long (*Function)(
long *args,
unsigned prec);
111 typedef void (*Init)(void);
160 unsigned short head,
tail, rec, count;
179 unsigned short loop, line, lnum;
263 static bool isScript(
Name *scr);
264 static bool isSymbol(
const char *
id);
265 static bool use(
const char *name);
266 static unsigned getIndex(
const char *
id);
268 static bool commit(
Symbol *sym,
const char *value);
269 static bool append(
Symbol *sym,
const char *value);
270 static bool symindex(
Symbol *sym,
short offset);
271 static const char *extract(
Symbol *sym);
272 static unsigned count(
Symbol *sym);
273 static unsigned storage(
Symbol *sym);
274 static void clear(
Symbol *sym);
298 static void addFunction(
const char *name,
unsigned count, Function i);
299 static void addConditional(
const char *name, Cond test);
301 static bool isPrivate(
Name *scr);
302 static bool isFunction(
Name *scr);
324 unsigned gathertype(Symbol **idx,
unsigned max,
const char *prefix, symType group);
325 unsigned gather(Symbol **idx,
unsigned max,
const char *prefix,
const char *suffix);
326 Symbol *
find(
const char *
id,
unsigned short size = 0);
327 Symbol *make(
const char *
id,
unsigned short size);
329 Symbol *setReference(
const char *
id, Symbol *target);
382 virtual const char *getExternal(
const char *opt);
392 virtual bool isInput(
Line *line);
401 Method getHandler(
const char *keyword);
410 bool control(
char **args);
426 const char *getTrapName(
unsigned id);
434 void aliasModule(
const char *
id,
const char *use);
443 bool isInitial(
const char *keyword);
453 const char *check(
char *command, Line *line,
ScriptImage *img);
461 virtual unsigned getTrapId(
const char *name);
468 virtual unsigned long getTrapDefault(
void);
475 virtual unsigned long getTrapHandler(Name *script);
484 virtual unsigned long getTrapMask(
unsigned id);
494 virtual unsigned long getTrapModifier(
const char *name);
504 virtual unsigned long getTrapMask(
const char *name);
512 static bool hasKeywords(Line *line);
522 static const char *findKeyword(Line *line,
const char *keyword);
532 static const char *findKeyword(
ScriptImage *img, Line *line,
const char *keyword);
540 virtual void errlog(
const char *level,
const char *text);
550 static bool useKeywords(Line *line,
const char *list);
558 static unsigned getCount(Line *line);
566 static const char *getMember(Line *line);
577 static bool useMember(Line *line,
const char *list);
586 static const char *getOption(Line *line,
unsigned *index);
606 int trap(
const char *name,
bool inherited =
true);
614 {
return trap_count;};
619 bool isInherited(
unsigned id);
629 virtual const char *check(Check chk, Line *line,
ScriptImage *img);
670 virtual bool control(
ScriptImage *img,
char **args);
671 virtual void down(
void);
680 static void shutdown(
void);
944 {
return cmds->getHandler(keyword);};
953 void *getMemory(
size_t size);
981 void addSelect(Line *line);
988 void addRegistration(Line *line);
1003 void addRoute(Line *line,
unsigned pri);
1019 {
return registration;};
1027 {
return advertising[pri];};
1076 void initial(
const char *keyword,
const char *value,
unsigned size = 0);
1084 virtual Name *getScript(
const char *name);
1100 {
return cmds->ripple;};
1110 unsigned gather(
const char *suffix, Name **array,
unsigned size);
1130 {
return (
bool)(refcount > 0);};
1161 const char *incfiles[256];
1174 virtual bool checkSegment(
Name *scr);
1177 char *getToken(
char **pre = NULL);
1201 Name *include(
const char *name);
1211 int compile(
const char *file);
1221 int compile(
const char *file,
char *name);
1230 int compileDefinitions(
const char *file);
1240 int compile(std::istream *stream,
char *name,
const char *file = NULL);
1255 virtual const char *getDefined(
const char *token);
1263 const char *preproc(
const char *token);
1272 {
return (std::istream *)&scrSource;};
1295 unsigned decimal : 4;
1299 static long getRealValue(
double val,
unsigned prec);
1300 static double getDouble(
long value,
unsigned prec);
1301 static long getInteger(
long value,
unsigned prec);
1302 static long getTens(
unsigned prec);
1303 long getIntValue(
const char *text,
unsigned prec,
ScriptProperty *property = NULL);
1304 int numericExpression(
long *list,
int max,
unsigned prec,
ScriptProperty *property = NULL);
1305 bool conditionalExpression(
void);
1306 bool conditional(
void);
1323 virtual unsigned getId(
void);
1333 virtual const char *getExternal(
const char *opt);
1344 const char *getMember(
void);
1345 const char *getKeyword(
const char *kw);
1346 const char *getKeyoption(
const char *kw);
1347 const char *getValue(
const char *def = NULL);
1348 const char *getOption(
const char *def = NULL);
1349 const char *hasOption(
void);
1350 const char *getContent(
const char *opt);
1351 const char *getSymContent(
const char *opt);
1352 Symbol *getKeysymbol(
const char *kw,
unsigned size = 0);
1353 Symbol *getSymbol(
unsigned short size = 0);
1354 char getPackToken(
void);
1360 void initRuntime(Name *name);
1366 virtual void initialize(
void);
1370 {
return &frame[stack];};
1373 {
return frame[stack].
line;};
1375 void setFrame(
void);
1378 {
return frame[stack].script;};
1390 bool execute(Method method);
1410 void clearStack(
void);
1440 bool scriptEvent(
const char *name,
bool inhereted =
true);
1447 void gotoEvent(NamedEvent *event);
1456 void trap(
unsigned id);
1464 bool tryCatch(
const char *
id);
1472 void trap(
const char *name);
1475 virtual void logmissing(
const char *
id,
const char *level =
"undefined",
const char *group =
"symbol");
1476 virtual void logerror(
const char *msg,
const char *name = NULL);
1478 Symbol *mapSymbol(
const char *
id,
unsigned short = 0);
1479 Symbol *mapDirect(
const char *
id,
unsigned short = 0);
1482 virtual bool isLocked(
const char *
id);
1483 virtual const char *remapLocal(
void);
1484 virtual bool exit(
void);
1486 virtual void exitThread(
const char *msg);
1487 virtual void waitThread(
void);
1488 virtual void startThread(
void);
1490 bool eventThread(
const char *evt,
bool flag =
true);
1492 bool redirect(
const char *scr);
1496 bool redirect(
bool evflag);
1498 unsigned long getMask(
void);
1501 bool setNumber(
const char *
id,
const char *value = NULL,
unsigned dec = 0);
1502 bool setSymbol(
const char *
id,
const char *value = NULL,
unsigned short size = 0);
1503 bool setConst(
const char *
id,
const char *value);
1504 bool putSymbol(
const char *
id,
const char *value,
unsigned short size = 0);
1505 bool getSymbol(
const char *
id,
char *buffer,
unsigned short max);
1506 bool catSymbol(
const char *
id,
const char *value,
unsigned short size = 0);
1508 const char *getSymbol(
const char *
id);
1510 Name *getScript(
const char *name);
1533 bool signal(
const char *name);
1542 bool signal(
unsigned id);
1553 virtual void branching(
void);
1556 {
return (image != NULL) && initialized;};
1561 char *getTemp(
void);
1563 unsigned getTempSize(
void);
1570 bool scrError(
void);
1572 bool scrDecimal(
void);
1573 bool scrDefine(
void);
1576 bool scrNumber(
void);
1579 bool scrIndex(
void);
1580 bool scrOffset(
void);
1582 bool scrRestart(
void);
1587 bool scrReturn(
void);
1588 bool scrBegin(
void);
1590 bool scrConst(
void);
1591 bool scrSequence(
void);
1593 bool scrArray(
void);
1594 bool scrClear(
void);
1595 bool scrConstruct(
void);
1596 bool scrDeconstruct(
void);
1598 bool scrUnpack(
void);
1600 bool scrSession(
void);
1601 bool scrSignal(
void);
1602 bool scrThrow(
void);
1603 bool scrInvoke(
void);
1604 bool scrCounter(
void);
1605 bool scrTimer(
void);
1607 bool scrEndcase(
void);
1608 bool scrRemove(
void);
1610 bool scrRepeat(
void);
1612 bool scrForeach(
void);
1614 bool scrContinue(
void);
1615 bool scrBreak(
void);
1617 bool scrIfThen(
void);
1620 bool scrEndif(
void);
1634 void exit(
const char *errmsg = NULL);
1636 void exitEvent(
const char *evt,
bool inherited =
true);
1641 inline bool putSymbol(
const char *
id,
const char *value,
unsigned short size = 0)
1642 {
return interp->putSymbol(
id, value, size);};
1644 inline bool getSymbol(
const char *
id,
char *buffer,
unsigned short max)
1645 {
return interp->getSymbol(
id, buffer, max);};
1647 inline bool addSymbol(
const char *
id,
char *buffer,
unsigned short max)
1648 {
return interp->getSymbol(
id, buffer, max);};
1662 {
return stacksize;};
1709 virtual void set(
const char *data,
char *temp,
unsigned size) = 0;
1716 virtual unsigned prec(
void);
1725 virtual void setValue(
char *data,
unsigned short size,
long value);
1733 virtual bool isProperty(
const char *data);
1742 virtual void clear(
char *data,
unsigned size = 0);
1749 virtual char token(
void);
1758 virtual void adjust(
char *data,
size_t size,
long adjustment);
1766 virtual long adjustValue(
long value);
1774 virtual long getValue(
const char *data);
const char * cstring(const char *str)
unsigned getCount(void)
Get count of active traps.
std::istream * getSource(void)
Used by embedded interpreters to fetch script from the current source file.
static bool use_definitions
static const char * apps_prefix
class __EXPORT ScriptSymbols
bool putSymbol(const char *id, const char *value, unsigned short size=0)
#define SCRIPT_INDEX_SIZE
Memory management, configuration keydata objects and string tokenizer.
ScriptImage * getImage(void)
virtual const char * getLogname(void)
unsigned long getSequence(void)
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Method getHandler(const char *keyword)
Get the interpreter method pointer for a given keyword.
static unsigned fastStepping
This class is used for DSO modules that impliment property extensions for scripting objects...
#define SCRIPT_STACK_SIZE
This class is used for registering scripts with an external registry.
ScriptRegistry * registry
The Mutex class is used to protect a section of code so that at any given time only a single thread c...
Files and dynamic loader services.
This class is used to associate (object) pointers with named strings.
Line * getSelect(void)
Get the selection list from the image.
__EXPORT char * find(const char *cs, char *str, size_t len=0)
static ScriptProperty * first
Name * getCurrent(void)
Get current entity being compiled...
unsigned long getInstance(void)
Get the session instance of the image.
bool addSymbol(const char *id, char *buffer, unsigned short max)
A derivable class to hold compiled script images for active processes.
class __EXPORT ScriptThread
bool getSymbol(const char *id, char *buffer, unsigned short max)
Keydata objects are used to load and hold "configuration" data for a given application.
static unsigned autoStepping
A linkable list of objects that can be destroyed when a script image is removed from memory...
#define SCRIPT_ROUTE_SLOTS
A derivable class to hold compiled script images for active processes.
static const char * exec_token
static const char * apps_extensions
#define SCRIPT_TEMP_SPACE
Somewhat generic queue processing class to establish a producer consumer queue.
static unsigned long serial
static const char * plugins
static const char * exec_extensions
static const char * exit_token
Generic script class to hold master data types and various useful class encpasulated friend functions...
static const char * access_host
class __EXPORT ScriptCommand
static const char * access_user
unsigned getActivity(void)
Get activity counter.
bool isRipple(void)
Get the ripple flag for the current image.
static const char * etc_prefix
static const char * log_prefix
ScriptCommand * getCommand(void)
Get the command object associated with the image.
const char *(ScriptCommand::* Check)(Line *line, ScriptImage *img)
static const char * altplugins
object passing services between threads.
The DSO dynamic loader class is used to load object files.
static const char * var_prefix
Every thread of execution in an application is created by instantiating an object of a class derived ...
bool isRef(void)
See if the image is referenced...
struct timespec * getTimeout(struct timespec *spec, timeout_t timeout)
ScriptImage * getActive(void)
Get the active image from command.
char * dupString(const char *src, size_t size=0)
Timer ports are used to provide synchronized timing events when managed under a "service thread" such...
class __EXPORT ScriptCompiler
class __EXPORT ScriptProperty
Line * getRegistration(void)
Get the registration list from the image.
void decRef(void)
dec the reference count.
class __EXPORT ScriptInterp
void incRef(void)
inc the reference count.
ScriptImage * getActive(void)
Get the active script.
Line * getRoute(unsigned pri)
Get an advertised priority record from the image.
static ScriptBinder * first
This class holds the bound keyword set for a given Bayonne style script interpreter.
class __EXPORT ScriptImage
static ScriptCommand * runtime
static const char * access_pass
static const char * exec_prefix