2011-10-28
2011-10-28 13:04:55 by Henrik Grubbström (Grubba) <grubba@grubba.org>
-
017b5735499ea38f2d5a92b61b4ff99740dd0d52
(134 lines)
(+56/-78)
[
Show
| Annotate
]
Branch: 7.9
Atomic megapatch: Use svalue accessor macros everywhere.
130: Inside #if defined(PIKE_DEBUG)
md = m->data;
NEW_MAPPING_LOOP(md)
{
- if (k->val.type > MAX_TYPE)
+ if (TYPEOF(k->val) > MAX_TYPE)
Pike_fatal("Invalid mapping keypair value type: %s\n",
- get_name_of_type(k->val.type));
- val_types |= 1 << k->val.type;
- if (k->ind.type > MAX_TYPE)
+ get_name_of_type(TYPEOF(k->val)));
+ val_types |= 1 << TYPEOF(k->val);
+ if (TYPEOF(k->ind) > MAX_TYPE)
Pike_fatal("Invalid maping keypair index type: %s\n",
- get_name_of_type(k->ind.type));
- ind_types |= 1 << k->ind.type;
+ get_name_of_type(TYPEOF(k->ind)));
+ ind_types |= 1 << TYPEOF(k->ind);
}
if(val_types & ~(m->data->val_types))
335:
md->hash[h]=k;
/* update */
- md->ind_types |= 1<< (k->ind.type);
- md->val_types |= 1<< (k->val.type);
+ md->ind_types |= 1<< (TYPEOF(k->ind));
+ md->val_types |= 1<< (TYPEOF(k->val));
md->size++;
/* Reverse */
390:
md->hash[h]=k;
/* update */
- md->ind_types |= 1<< (k->ind.type);
- md->val_types |= 1<< (k->val.type);
+ md->ind_types |= 1<< (TYPEOF(k->ind));
+ md->val_types |= 1<< (TYPEOF(k->val));
md->size++;
/* Reverse */
545:
{ \
h=h2 & (md->hashsize - 1); \
DO_IF_DEBUG( if(d_flag > 1) check_mapping_type_fields(m); ) \
- if(md->ind_types & ((1 << key->type) | BIT_OBJECT)) \
+ if(md->ind_types & ((1 << TYPEOF(*key)) | BIT_OBJECT)) \
{ \
for(prev= md->hash + h;(k=*prev);prev=&k->next) \
{ \
568:
{ \
h=h2 & (md->hashsize-1); \
DO_IF_DEBUG( if(d_flag > 1) check_mapping_type_fields(m); ) \
- if(md->ind_types & ((1 << key->type) | BIT_OBJECT)) \
+ if(md->ind_types & ((1 << TYPEOF(*key)) | BIT_OBJECT)) \
{ \
k2=omd->hash[h2 & (omd->hashsize - 1)]; \
prev= md->hash + h; \
671:
NEW_MAPPING_LOOP(m->data)
{
- val_types |= 1 << k->val.type;
- ind_types |= 1 << k->ind.type;
+ val_types |= 1 << TYPEOF(k->val);
+ ind_types |= 1 << TYPEOF(k->ind);
}
#ifdef PIKE_DEBUG
762:
if(!overwrite) return;
PREPARE_FOR_DATA_CHANGE2();
PROPAGATE(); /* propagate after preparing */
- md->val_types |= 1 << val->type;
- if (overwrite == 2 && key->type == T_OBJECT)
+ md->val_types |= 1 << TYPEOF(*val);
+ if (overwrite == 2 && TYPEOF(*key) == T_OBJECT)
/* Should replace the index too. It's only for objects that it's
* possible to tell the difference. */
assign_svalue (&k->ind, key);
805:
#endif /* !PIKE_MAPPING_KEYPAIR_LOOP */
k->next=md->hash[h];
md->hash[h]=k;
- md->ind_types |= 1 << key->type;
- md->val_types |= 1 << val->type;
+ md->ind_types |= 1 << TYPEOF(*key);
+ md->val_types |= 1 << TYPEOF(*val);
assign_svalue_no_free(& k->ind, key);
assign_svalue_no_free(& k->val, val);
k->hval = h2;
883:
check_mapping(m);
#endif
free_mapping_data(md);
- if(k->val.type == t)
+ if(TYPEOF(k->val) == t)
{
PREPARE_FOR_DATA_CHANGE2();
PROPAGATE(); /* prepare then propagate */
928:
k->next=md->hash[h];
md->hash[h]=k;
assign_svalue_no_free(& k->ind, key);
- k->val.type=T_INT;
- k->val.subtype=NUMBER_NUMBER;
- k->val.u.integer=0;
+ SET_SVAL(k->val, T_INT, NUMBER_NUMBER, integer, 0);
k->hval = h2;
- md->ind_types |= 1 << key->type;
+ md->ind_types |= 1 << TYPEOF(*key);
md->val_types |= BIT_INT;
md->size++;
#ifdef MAPPING_SIZE_DEBUG
980:
free_mapping_data(md);
if(to)
{
- to->type=T_INT;
- to->subtype=NUMBER_UNDEFINED;
- to->u.integer=0;
+ SET_SVAL(*to, T_INT, NUMBER_UNDEFINED, integer, 0);
}
return;
1058:
{
check_destructed(& k->val);
- if((k->ind.type == T_OBJECT || k->ind.type == T_FUNCTION) &&
+ if((TYPEOF(k->ind) == T_OBJECT || TYPEOF(k->ind) == T_FUNCTION) &&
!k->ind.u.object->prog)
{
debug_malloc_touch(m);
1081:
#endif
debug_malloc_touch(md);
}else{
- val_types |= 1 << k->val.type;
- ind_types |= 1 << k->ind.type;
+ val_types |= 1 << TYPEOF(k->val);
+ ind_types |= 1 << TYPEOF(k->ind);
prev=&k->next;
}
}
1133:
struct pike_string *p)
{
struct svalue tmp;
- tmp.type=T_STRING;
- tmp.u.string=p;
+ SET_SVAL(tmp, T_STRING, 0, string, p);
return low_mapping_lookup(m, &tmp);
}
1143:
const struct svalue *val)
{
struct svalue tmp;
- tmp.type=T_STRING;
- tmp.u.string=p;
+ SET_SVAL(tmp, T_STRING, 0, string, p);
mapping_insert(m, &tmp, val);
}
1153:
struct pike_string *val)
{
struct svalue tmp;
- tmp.type=T_STRING;
- tmp.u.string=val;
+ SET_SVAL(tmp, T_STRING, 0, string, val);
mapping_string_insert(m, p, &tmp);
}
1183:
Pike_fatal("Zero refs in mapping->data\n");
#endif
- if(!s || !s->type==T_MAPPING)
+ if(!s || TYPEOF(*s) != T_MAPPING)
{
if(!create) return 0;
- tmp.u.mapping=allocate_mapping(5);
- tmp.type=T_MAPPING;
+ SET_SVAL(tmp, T_MAPPING, 0, mapping, allocate_mapping(5));
mapping_insert(m, key1, &tmp);
debug_malloc_touch(m);
debug_malloc_touch(tmp.u.mapping);
1201:
if(s) return s;
if(!create) return 0;
- tmp.type=T_INT;
- tmp.subtype=NUMBER_UNDEFINED;
- tmp.u.integer=0;
+ SET_SVAL(tmp, T_INT, NUMBER_UNDEFINED, integer, 0);
mapping_insert(m2, key2, &tmp);
debug_malloc_touch(m2);
1218:
int create)
{
struct svalue k1,k2;
- k1.type=T_STRING;
- k1.u.string=key1;
- k2.type=T_STRING;
- k2.u.string=key2;
+ SET_SVAL(k1, T_STRING, 0, string, key1);
+ SET_SVAL(k2, T_STRING, 0, string, key2);
return mapping_mapping_lookup(m,&k1,&k2,create);
}
1241:
/* Note: There is code that counts on storing UNDEFINED in mapping
* values (using e.g. low_mapping_lookup to get them), so we have
* to fix the subtype here rather than in mapping_insert. */
- if(p->type==T_INT)
- dest->subtype=NUMBER_NUMBER;
+ if(TYPEOF(*p) == T_INT)
+ SET_SVAL_SUBTYPE(*dest, NUMBER_NUMBER);
}else{
- dest->type=T_INT;
- dest->u.integer=0;
- dest->subtype=NUMBER_UNDEFINED;
+ SET_SVAL(*dest, T_INT, NUMBER_UNDEFINED, integer, 0);
}
}
1329:
struct array *b=allocate_array(2);
assign_svalue(b->item+0, & k->ind);
assign_svalue(b->item+1, & k->val);
- b->type_field = (1 << k->ind.type) | (1 << k->val.type);
- s->u.array=b;
- s->type=T_ARRAY;
+ b->type_field = (1 << TYPEOF(k->ind)) | (1 << TYPEOF(k->val));
+ SET_SVAL(*s, T_ARRAY, 0, array, b);
s++;
}
a->type_field = BIT_ARRAY;
1360:
{
PREPARE_FOR_DATA_CHANGE();
assign_svalue(& k->val, to);
- md->val_types|=1<<to->type;
+ md->val_types |= 1<<TYPEOF(*to);
}
}
free_mapping_data(md);
2098:
if(!m->data->size)
return mkefuncallnode("aggregate_mapping",0);
- s.type=T_MAPPING;
- s.subtype=0;
- s.u.mapping=m;
+ SET_SVAL(s, T_MAPPING, 0, mapping, m);
return mkconstantsvaluenode(&s);
}
}
2168:
if (p) {
struct svalue aa, bb;
- aa.type = T_MAPPING;
- aa.u.mapping = m;
- bb.type = T_MAPPING;
- bb.u.mapping = ret;
+ SET_SVAL(aa, T_MAPPING, 0, mapping, m);
+ SET_SVAL(bb, T_MAPPING, 0, mapping, ret);
mapping_insert(p, &aa, &bb);
}
2234:
if(!k)
{
- to->type=T_INT;
- to->subtype=NUMBER_UNDEFINED;
- to->u.integer=0;
+ SET_SVAL(*to, T_INT, NUMBER_UNDEFINED, integer, 0);
return;
}
k=k->next;
2277:
free_mapping_data(md);
}
- to->type=T_INT;
- to->subtype=NUMBER_UNDEFINED;
- to->u.integer=0;
+ SET_SVAL(*to, T_INT, NUMBER_UNDEFINED, integer, 0);
}
#ifdef PIKE_DEBUG
2375: Inside #if defined(PIKE_DEBUG)
{
num++;
- if (k->ind.type > MAX_TYPE)
+ if (TYPEOF(k->ind) > MAX_TYPE)
Pike_fatal("Invalid maping keypair index type: %s\n",
- get_name_of_type(k->ind.type));
- if(! ( (1 << k->ind.type) & (md->ind_types) ))
+ get_name_of_type(TYPEOF(k->ind)));
+ if(! ( (1 << TYPEOF(k->ind)) & (md->ind_types) ))
Pike_fatal("Mapping indices type field lies.\n");
- if (k->val.type > MAX_TYPE)
+ if (TYPEOF(k->val) > MAX_TYPE)
Pike_fatal("Invalid mapping keypair value type: %s\n",
- get_name_of_type(k->val.type));
- if(! ( (1 << k->val.type) & (md->val_types) ))
+ get_name_of_type(TYPEOF(k->val)));
+ if(! ( (1 << TYPEOF(k->val)) & (md->val_types) ))
Pike_fatal("Mapping values type field lies.\n");
check_svalue(& k->ind);
2475:
DO_IF_DEBUG(Pike_fatal("Didn't expect an svalue zapping now.\n")); \
} \
RECURSE_FN(&k->val, 1); \
- VAL_TYPES |= 1 << k->val.type; \
+ VAL_TYPES |= 1 << TYPEOF(k->val); \
} \
} while (0)
2520:
M->debug_size--; \
); \
} else { \
- VAL_TYPES |= 1 << k->val.type; \
- IND_TYPES |= 1 << k->ind.type; \
+ VAL_TYPES |= 1 << TYPEOF(k->val); \
+ IND_TYPES |= 1 << TYPEOF(k->ind); \
k++; \
} \
} \
2553:
M->debug_size--; \
); \
}else{ \
- VAL_TYPES |= 1 << k->val.type; \
- IND_TYPES |= 1 << k->ind.type; \
+ VAL_TYPES |= 1 << TYPEOF(k->val); \
+ IND_TYPES |= 1 << TYPEOF(k->ind); \
prev=&k->next; \
} \
} \