New nstr_mksymval() to create symbolic values
This commit is contained in:
parent
da8a1daeef
commit
d1a193ff07
5 changed files with 23 additions and 23 deletions
|
@ -212,9 +212,10 @@ typedef unsigned char nsc_flags;
|
||||||
* ca_len is zero), or an array of ca_len elements of that type.
|
* ca_len is zero), or an array of ca_len elements of that type.
|
||||||
* If ca_get is not null, the selector is virtual. Values can be
|
* If ca_get is not null, the selector is virtual. Values can be
|
||||||
* obtained by calling ca_get(VAL, CNUM, CTXO), where VAL has been
|
* obtained by calling ca_get(VAL, CNUM, CTXO), where VAL has been
|
||||||
* initialized from the selector and an index, CNUM is the country to
|
* initialized my from the selector and an index by nstr_mksymval(),
|
||||||
* use for coordinate translation and access control, and CTXO is the
|
* CNUM is the country to use for coordinate translation and access
|
||||||
* context object. See struct valstr for details.
|
* control, and CTXO is the context object. See struct valstr for
|
||||||
|
* details.
|
||||||
* If flag NSC_DEITY is set, only to deities can use this selector.
|
* If flag NSC_DEITY is set, only to deities can use this selector.
|
||||||
* If flag NSC_EXTRA is set, xdump ignores this selector.
|
* If flag NSC_EXTRA is set, xdump ignores this selector.
|
||||||
* If flag NSC_CONST is set, the datum can't be changed from its
|
* If flag NSC_CONST is set, the datum can't be changed from its
|
||||||
|
@ -291,6 +292,7 @@ extern char *nstr_comp_val(char *, struct valstr*, int);
|
||||||
extern int nstr_coerce_val(struct valstr *, nsc_type, char *);
|
extern int nstr_coerce_val(struct valstr *, nsc_type, char *);
|
||||||
extern int nstr_exec(struct nscstr *, int, void *);
|
extern int nstr_exec(struct nscstr *, int, void *);
|
||||||
/* src/lib/common/nstreval.c */
|
/* src/lib/common/nstreval.c */
|
||||||
|
extern struct valstr *nstr_mksymval(struct valstr *, struct castr *, int);
|
||||||
extern struct valstr *nstr_exec_val(struct valstr *, natid, void *, nsc_type);
|
extern struct valstr *nstr_exec_val(struct valstr *, natid, void *, nsc_type);
|
||||||
extern int nstr_promote(int);
|
extern int nstr_promote(int);
|
||||||
extern char *symbol_by_value(int, struct symbol *);
|
extern char *symbol_by_value(int, struct symbol *);
|
||||||
|
|
|
@ -94,12 +94,7 @@
|
||||||
static struct valstr *
|
static struct valstr *
|
||||||
xdeval(struct valstr *val, struct castr *ca, void *ptr, int idx)
|
xdeval(struct valstr *val, struct castr *ca, void *ptr, int idx)
|
||||||
{
|
{
|
||||||
val->val_type = ca->ca_type;
|
nstr_mksymval(val, ca, idx);
|
||||||
val->val_cat = NSC_OFF;
|
|
||||||
val->val_as.sym.off = ca->ca_off;
|
|
||||||
val->val_as.sym.len = ca->ca_len;
|
|
||||||
val->val_as.sym.idx = idx;
|
|
||||||
val->val_as.sym.get = ca->ca_get;
|
|
||||||
return nstr_exec_val(val, player->cnum, ptr, NSC_NOTYPE);
|
return nstr_exec_val(val, player->cnum, ptr, NSC_NOTYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,13 +101,7 @@ verify_row(int type, int row)
|
||||||
do {
|
do {
|
||||||
if (ca[i].ca_table == EF_BAD)
|
if (ca[i].ca_table == EF_BAD)
|
||||||
continue;
|
continue;
|
||||||
/* FIXME use xdeval() */
|
nstr_mksymval(&val, &ca[i], j);
|
||||||
val.val_type = ca[i].ca_type;
|
|
||||||
val.val_cat = NSC_OFF;
|
|
||||||
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);
|
nstr_exec_val(&val, 0, row_ref, NSC_NOTYPE);
|
||||||
if (val.val_type != NSC_LONG)
|
if (val.val_type != NSC_LONG)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -42,6 +42,21 @@
|
||||||
#include "nsc.h"
|
#include "nsc.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize VAL to symbolic value for selector CA with index IDX.
|
||||||
|
* Return VAL.
|
||||||
|
*/
|
||||||
|
struct valstr *
|
||||||
|
nstr_mksymval(struct valstr *val, struct castr *ca, int idx)
|
||||||
|
{
|
||||||
|
val->val_type = ca->ca_type;
|
||||||
|
val->val_cat = NSC_OFF;
|
||||||
|
val->val_as.sym.off = ca->ca_off;
|
||||||
|
val->val_as.sym.len = ca->ca_len;
|
||||||
|
val->val_as.sym.idx = idx;
|
||||||
|
val->val_as.sym.get = ca->ca_get;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Evaluate VAL.
|
* Evaluate VAL.
|
||||||
|
|
|
@ -427,13 +427,7 @@ nstr_resolve_sel(struct valstr *val, struct castr *ca)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
val->val_type = ca->ca_type;
|
return nstr_mksymval(val, ca, 0);
|
||||||
val->val_cat = NSC_OFF;
|
|
||||||
val->val_as.sym.off = ca->ca_off;
|
|
||||||
val->val_as.sym.len = ca->ca_len;
|
|
||||||
val->val_as.sym.idx = 0;
|
|
||||||
val->val_as.sym.get = ca->ca_get;
|
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue