]> git.pond.sub.org Git - empserver/commitdiff
New nstr_mksymval() to create symbolic values
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 4 Mar 2008 09:29:49 +0000 (10:29 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 14 Mar 2008 19:25:41 +0000 (20:25 +0100)
include/nsc.h
src/lib/commands/xdump.c
src/lib/common/ef_verify.c
src/lib/common/nstreval.c
src/lib/subs/nstr.c

index de29c3ac49683c4511659e22e962d99784c4e084..59aa813a9b280e8dd2da7b1dec4e9eb6852d6a81 100644 (file)
@@ -212,9 +212,10 @@ typedef unsigned char nsc_flags;
  * 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
  * obtained by calling ca_get(VAL, CNUM, CTXO), where VAL has been
- * initialized from the selector and an index, CNUM is the country to
- * use for coordinate translation and access control, and CTXO is the
- * context object.  See struct valstr for details.
+ * initialized my from the selector and an index by nstr_mksymval(),
+ * CNUM is the country to use for coordinate translation and access
+ * 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_EXTRA is set, xdump ignores this selector.
  * 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_exec(struct nscstr *, int, void *);
 /* 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 int nstr_promote(int);
 extern char *symbol_by_value(int, struct symbol *);
index 31e651aeaeb3a66161edffe1c5b8927a55948ac2..0d247de27b9657b361df438394c2d542e59845ad 100644 (file)
 static struct valstr *
 xdeval(struct valstr *val, struct castr *ca, void *ptr, 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;
+    nstr_mksymval(val, ca, idx);
     return nstr_exec_val(val, player->cnum, ptr, NSC_NOTYPE);
 }
 
index 3ecaeaa0a9374eeccd005382f728396de3609ab8..8369a6aa6f57c8e303591a01387501f282f3b397 100644 (file)
@@ -101,13 +101,7 @@ verify_row(int type, int row)
        do {
            if (ca[i].ca_table == EF_BAD)
                continue;
-           /* FIXME use xdeval() */
-           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_mksymval(&val, &ca[i], j);
            nstr_exec_val(&val, 0, row_ref, NSC_NOTYPE);
            if (val.val_type != NSC_LONG)
                continue;
index ab49f84196c80f2ab0f65aa689858baef7aafe98..72269112eea42ebdbe3ba43b4fed1b6c4b078f4d 100644 (file)
 #include "nsc.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.
index b4fb7828b7bf5855e52ef64cd89ece113473c8df..493894b6d788b5669507f04f51c3584c17481c20 100644 (file)
@@ -427,13 +427,7 @@ nstr_resolve_sel(struct valstr *val, struct castr *ca)
        return NULL;
     }
 
-    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 = 0;
-    val->val_as.sym.get = ca->ca_get;
-    return val;
+    return nstr_mksymval(val, ca, 0);
 }
 
 /*