Virtual selectors
Where ordinary selectors specify a value stored in some object, virtual selectors specify a function to call to compute a value associated with some object. Use them to replace the special case xdump ver by new table EF_VERSION. Move configkeys[] to lib/common because nsc_init() needs it to initialize empfile[EF_VERSION].cadef.
This commit is contained in:
parent
38047a62f7
commit
da8a1daeef
12 changed files with 541 additions and 482 deletions
|
@ -107,6 +107,7 @@ verify_row(int type, int row)
|
|||
val.val_as.sym.off = ca[i].ca_off;
|
||||
val.val_as.sym.len = ca[i].ca_len;
|
||||
val.val_as.sym.idx = j;
|
||||
val.val_as.sym.get = ca[i].ca_get;
|
||||
nstr_exec_val(&val, 0, row_ref, NSC_NOTYPE);
|
||||
if (val.val_type != NSC_LONG)
|
||||
continue;
|
||||
|
|
|
@ -55,16 +55,6 @@
|
|||
#include "optlist.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
/* Dummy one */
|
||||
static int emp_config_dummy;
|
||||
|
||||
/* things that can be changed */
|
||||
struct keymatch configkeys[] = {
|
||||
#define EMP_CONFIG_C_OUTPUT
|
||||
#include "econfig-spec.h"
|
||||
#undef EMP_CONFIG_C_OUTPUT
|
||||
};
|
||||
|
||||
static struct keymatch *keylookup(char *key, struct keymatch tbl[]);
|
||||
static int set_paths(char *);
|
||||
|
||||
|
|
|
@ -69,6 +69,17 @@ nstr_exec_val(struct valstr *val, natid cnum, void *ptr, nsc_type want)
|
|||
valtype = val->val_type;
|
||||
break;
|
||||
case NSC_OFF:
|
||||
if (val->val_as.sym.get) {
|
||||
do {
|
||||
ptr = val->val_as.sym.get(val, cnum, ptr);
|
||||
} while (ptr && val->val_as.sym.get);
|
||||
if (!ptr) {
|
||||
valtype = val->val_type;
|
||||
val->val_cat = NSC_VAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
valtype = NSC_LONG;
|
||||
memb_ptr = ptr;
|
||||
memb_ptr += val->val_as.sym.off;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue