make h_cast a family of macros, add H_ASSERT family, make h_assert_type a macro

This commit is contained in:
Sven M. Hallberg 2013-01-25 21:52:11 +01:00
parent 18fbf6fd69
commit 7149260a13
4 changed files with 40 additions and 63 deletions

View file

@ -77,36 +77,6 @@ HParsedToken *h_make_uint(HArena *arena, uint64_t val)
return ret;
}
void * h_cast(HTokenType type, const HParsedToken *p)
{
assert(p->token_type == type);
return p->user;
}
HCountedArray *h_cast_seq(const HParsedToken *p)
{
assert(p->token_type == TT_SEQUENCE);
return p->seq;
}
HBytes h_cast_bytes(const HParsedToken *p)
{
assert(p->token_type == TT_BYTES);
return p->bytes;
}
int64_t h_cast_sint(const HParsedToken *p)
{
assert(p->token_type == TT_SINT);
return p->sint;
}
uint64_t h_cast_uint(const HParsedToken *p)
{
assert(p->token_type == TT_UINT);
return p->uint;
}
// XXX -> internal
HParsedToken *h_carray_index(const HCountedArray *a, size_t i)
{