Bitten by order of operations! The ? operator has weird precedence
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@186 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
86146c173b
commit
1dc18b6b2e
1 changed files with 15 additions and 14 deletions
|
|
@ -465,6 +465,9 @@ static DOH *Swig_Type_tag_str(DOH *o)
|
||||||
* Swig_Type_tag_hash(DOH *o);
|
* Swig_Type_tag_hash(DOH *o);
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* helpful macro */
|
||||||
|
#define SafeHashval(x) (x ? Hashval(x) : 0)
|
||||||
|
|
||||||
static int Swig_Type_tag_hash(DOH *o)
|
static int Swig_Type_tag_hash(DOH *o)
|
||||||
{
|
{
|
||||||
Swig_Type_tag *tag = TagData(o);
|
Swig_Type_tag *tag = TagData(o);
|
||||||
|
|
@ -513,39 +516,34 @@ static int Swig_Type_tag_hash(DOH *o)
|
||||||
tag->hashkey =
|
tag->hashkey =
|
||||||
Hashval(tag->name);
|
Hashval(tag->name);
|
||||||
break;
|
break;
|
||||||
#ifdef THIS_IS_BROKEN
|
|
||||||
/* Please do not use the ternary ? operator. It's too error prone, no one can read
|
|
||||||
it, and I don't like it. Plus, with it nested like this, I have no idea
|
|
||||||
what this code is supposed be doing. -- Dave */
|
|
||||||
case Swig_Type_Enum:
|
case Swig_Type_Enum:
|
||||||
tag->hashkey =
|
tag->hashkey =
|
||||||
(tag->name) ? Hashval(tag->name) : 0 +
|
SafeHashval(tag->name) +
|
||||||
(tag->attributes) ? Hashval(tag->attributes) : 0 + 5 << 10;
|
SafeHashval(tag->attributes) +
|
||||||
|
5 << 10;
|
||||||
break;
|
break;
|
||||||
case Swig_Type_Struct:
|
case Swig_Type_Struct:
|
||||||
tag->hashkey =
|
tag->hashkey =
|
||||||
(tag->name) ? Hashval(tag->name) : 0 +
|
SafeHashval(tag->name) +
|
||||||
(tag->attributes) ? Hashval(tag->attributes) : 0 +
|
SafeHashval(tag->attributes) +
|
||||||
6 << 10;
|
6 << 10;
|
||||||
break;
|
break;
|
||||||
case Swig_Type_Union:
|
case Swig_Type_Union:
|
||||||
tag->hashkey =
|
tag->hashkey =
|
||||||
(tag->name) ? Hashval(tag->name) : 0 +
|
SafeHashval(tag->name) +
|
||||||
(tag->attributes) ? Hashval(tag->attributes) : 0 +
|
SafeHashval(tag->attributes) +
|
||||||
7 << 10;
|
7 << 10;
|
||||||
break;
|
break;
|
||||||
case Swig_Type_Array:
|
case Swig_Type_Array:
|
||||||
tag->hashkey =
|
tag->hashkey =
|
||||||
(tag->attributes) ? Hashval(tag->attributes) : 0 +
|
SafeHashval(tag->attributes) +
|
||||||
8 << 10;
|
8 << 10;
|
||||||
break;
|
break;
|
||||||
case Swig_Type_Function:
|
case Swig_Type_Function:
|
||||||
tag->hashkey =
|
tag->hashkey =
|
||||||
(tag->attributes) ? Hashval(tag->attributes) : 0 +
|
SafeHashval(tag->attributes) +
|
||||||
9 << 10;
|
9 << 10;
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
case Swig_Type_Pointer:
|
case Swig_Type_Pointer:
|
||||||
tag->hashkey =
|
tag->hashkey =
|
||||||
(tag->is_const << 8) +
|
(tag->is_const << 8) +
|
||||||
|
|
@ -562,6 +560,9 @@ static int Swig_Type_tag_hash(DOH *o)
|
||||||
return tag->hashkey;
|
return tag->hashkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* no longer a helpful macro :) */
|
||||||
|
#undef SafeHashval
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------
|
/* -------------------------------------------------------------------------
|
||||||
* static int
|
* static int
|
||||||
* Swig_Type_tag_cmp(DOH *o1, DOH *o2);
|
* Swig_Type_tag_cmp(DOH *o1, DOH *o2);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue