Sunday, December 30, 2018

No header needed when one snippet talks to another

Below is my tester snippet, it creates a command for xchars, snippet then has the console loop tokenize it, then directly calls for command search.

So tester is freely talking across the Bus and all it knows is what it read in the Xchars user manual, it puts that in plain text, tokenizes and the rest is the miracle of fast symbol look up and universal bus interface.   No headers, no interface conflict, got a problem? Check version match, but skip the friggen header stuff. 

The only information console loop needs to share is NOTFOUND=0 and CONTINUE=1;  If snippets know those two return codes, then anything can talk to them. The snippet is given the search command (Exec) entry point when loaded, every snippet has an Init. So, don't look anywhere, just start writing your snippet, it will work, no need to explain except the plain text part.

The system goal is to get all the symbol look up down to Log2(symbol size), then five step test and jumps get you 32 entry points per snippet. That set up is often faster than formatting the argument stack. Argc  and args can generally be optimized out of the call set up from one snippet to the other.

EntryType * Exec;
enum { NOTFOUND=0,CONTINUE,EXIT,QUIT,SUCCESS,ERROR};
int exec_cmd(int *argc,void * args[] ,char * src) {
char str[40];
strcpy(str,src);
memset(args[0],0,40);
int status;
args[0] = "Tokenize";
args[1] = str;
status=Exec(argc,args);
status=Exec(argc,args);
return(status);
}
int Test(int *argc,void * args[]) {
exec_cmd(argc,args,"NewConn conn;NewWin conn win");
return(SUCCESS);
}

No comments: