Added support for expression parameters to be added to a device

class during setup, for the purpose of generating some derived
value that is used for merging and sorting, such as area = l*w.
Note that this likely needs adjusting so that the expression is
evaluated but not replaced for the purpose of sorting, since the
values to the parameter may change after parallel and series
merging.
This commit is contained in:
Tim Edwards 2021-05-19 16:27:52 -04:00
parent 4aa8a72769
commit 476da015f0
4 changed files with 556 additions and 529 deletions

View File

@ -4298,7 +4298,7 @@ void parallel_sort(struct objlist *ob1, struct nlist *tp1, int idx1, int run)
else if (kl->merge & (MERGE_P_ADD | MERGE_P_PAR)) {
if ((vl->type == PROP_STRING || vl->type == PROP_EXPRESSION) &&
(kl->type != vl->type))
PromoteProperty(kl, vl);
PromoteProperty(kl, vl, obp, tp1);
if (vl->type == PROP_INTEGER) {
tval = (double)vl->value.ival;
tslop = (double)kl->slop.ival;
@ -4827,12 +4827,12 @@ int PropertyOptimize(struct objlist *ob, struct nlist *tp, int run, int series,
else if (vl == NULL || vl2 == NULL) {
if (vl == NULL) {
if (kl->type != vlist[p][j]->type)
PromoteProperty(kl, vl2);
PromoteProperty(kl, vl2, ob2, tp);
vl = &dfltvl;
}
else {
if (kl->type != vlist[p][i]->type)
PromoteProperty(kl, vl);
PromoteProperty(kl, vl, ob2, tp);
vl2 = &dfltvl;
}
dfltvl.type = kl->type;
@ -5307,8 +5307,8 @@ PropertyCheckMismatch(struct objlist *tp1, struct nlist *tc1,
}
/* Promote properties as necessary to make sure they all match */
if (kl1->type != vl1->type) PromoteProperty(kl1, vl1);
if (kl2->type != vl2->type) PromoteProperty(kl2, vl2);
if (kl1->type != vl1->type) PromoteProperty(kl1, vl1, tc1, tp1);
if (kl2->type != vl2->type) PromoteProperty(kl2, vl2, tc2, tp2);
/* If kl1 and kl2 types differ, choose one type to target. Prefer */
/* double if either type is double, otherwise string. */
@ -5328,8 +5328,8 @@ PropertyCheckMismatch(struct objlist *tp1, struct nlist *tc1,
else
klt = kl1;
if (vl2->type != klt->type) PromoteProperty(klt, vl2);
if (vl1->type != klt->type) PromoteProperty(klt, vl1);
if (vl2->type != klt->type) PromoteProperty(klt, vl2, tc2, tp2);
if (vl1->type != klt->type) PromoteProperty(klt, vl1, tc1, tp1);
if (vl1->type != vl2->type) {
if (do_print && (vl1->type != vl2->type)) {

File diff suppressed because it is too large Load Diff

View File

@ -43,7 +43,8 @@ extern int PropertyMerge(char *name, int fnum, char *key, int merge_type,
int merge_mask);
extern void ResolveProperties(char *name1, int file1, char *name2, int file2);
extern void CopyProperties(struct objlist *obj_to, struct objlist *obj_from);
extern int PromoteProperty(struct property *, struct valuelist *);
extern int PromoteProperty(struct property *, struct valuelist *,
struct objlist *, struct nlist *);
extern int SetPropertyDefault(struct property *, struct valuelist *);
extern struct objlist *LinkProperties(char *model, struct keyvalue *topptr);
extern int ReduceExpressions(struct objlist *instprop, struct objlist *parprops,

View File

@ -3343,10 +3343,10 @@ _netcmp_property(ClientData clientData,
int result, index, idx2;
char *suboptions[] = {
"integer", "double", "value", "string", NULL
"integer", "double", "value", "string", "expression", NULL
};
enum SubOptionIdx {
INTEGER_IDX, DOUBLE_IDX, VALUE_IDX, STRING_IDX
INTEGER_IDX, DOUBLE_IDX, VALUE_IDX, STRING_IDX, EXPRESSION_IDX
};
/* Note: "merge" has been deprecated, but kept for backwards compatibility. */
@ -3735,6 +3735,11 @@ _netcmp_property(ClientData clientData,
PropertyString(tp->name, fnum,
Tcl_GetString(tobj1), ival, NULL);
break;
case EXPRESSION_IDX:
PropertyString(tp->name, fnum,
Tcl_GetString(tobj1), 0,
Tcl_GetString(tobj3));
break;
}
break;
}