Add is_double and is_short

This commit is contained in:
rdb 2013-11-08 10:25:45 +00:00
parent a9992e3c07
commit c3e862a842
2 changed files with 97 additions and 8 deletions

View File

@ -807,24 +807,52 @@ is_unsigned_integer(CPPType *type) {
}
////////////////////////////////////////////////////////////////////
// Function: TypeManager::is_unsigned_longlong
// Function: TypeManager::is_short
// Access: Public, Static
// Description: Returns true if the indicated type is an unsigned
// "long long" type or larger, or at least a 64-bit
// unsigned integer.
// Description: Returns true if the indicated type is the "short"
// type, whether signed or unsigned.
////////////////////////////////////////////////////////////////////
bool TypeManager::
is_unsigned_longlong(CPPType *type) {
is_short(CPPType *type) {
switch (type->get_subtype()) {
case CPPDeclaration::ST_const:
return is_unsigned_longlong(type->as_const_type()->_wrapped_around);
return is_short(type->as_const_type()->_wrapped_around);
case CPPDeclaration::ST_simple:
{
CPPSimpleType *simple_type = type->as_simple_type();
if (simple_type != (CPPSimpleType *)NULL) {
return (simple_type->_type == CPPSimpleType::T_int &&
(simple_type->_flags & (CPPSimpleType::F_longlong | CPPSimpleType::F_unsigned)) == (CPPSimpleType::F_longlong | CPPSimpleType::F_unsigned));
(simple_type->_flags & CPPSimpleType::F_short) != 0);
}
}
break;
default:
break;
}
return false;
}
////////////////////////////////////////////////////////////////////
// Function: TypeManager::is_unsigned_short
// Access: Public, Static
// Description: Returns true if the indicated type is an unsigned
// "short" type.
////////////////////////////////////////////////////////////////////
bool TypeManager::
is_unsigned_short(CPPType *type) {
switch (type->get_subtype()) {
case CPPDeclaration::ST_const:
return is_unsigned_short(type->as_const_type()->_wrapped_around);
case CPPDeclaration::ST_simple:
{
CPPSimpleType *simple_type = type->as_simple_type();
if (simple_type != (CPPSimpleType *)NULL) {
return (simple_type->_type == CPPSimpleType::T_int &&
(simple_type->_flags & (CPPSimpleType::F_short | CPPSimpleType::F_unsigned)) == (CPPSimpleType::F_short | CPPSimpleType::F_unsigned));
}
}
break;
@ -866,6 +894,64 @@ is_longlong(CPPType *type) {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: TypeManager::is_unsigned_longlong
// Access: Public, Static
// Description: Returns true if the indicated type is an unsigned
// "long long" type or larger, or at least a 64-bit
// unsigned integer.
////////////////////////////////////////////////////////////////////
bool TypeManager::
is_unsigned_longlong(CPPType *type) {
switch (type->get_subtype()) {
case CPPDeclaration::ST_const:
return is_unsigned_longlong(type->as_const_type()->_wrapped_around);
case CPPDeclaration::ST_simple:
{
CPPSimpleType *simple_type = type->as_simple_type();
if (simple_type != (CPPSimpleType *)NULL) {
return (simple_type->_type == CPPSimpleType::T_int &&
(simple_type->_flags & (CPPSimpleType::F_longlong | CPPSimpleType::F_unsigned)) == (CPPSimpleType::F_longlong | CPPSimpleType::F_unsigned));
}
}
break;
default:
break;
}
return false;
}
////////////////////////////////////////////////////////////////////
// Function: TypeManager::is_double
// Access: Public, Static
// Description: Returns true if the indicated type is the "double"
// type.
////////////////////////////////////////////////////////////////////
bool TypeManager::
is_double(CPPType *type) {
switch (type->get_subtype()) {
case CPPDeclaration::ST_const:
return is_float(type->as_const_type()->_wrapped_around);
case CPPDeclaration::ST_simple:
{
CPPSimpleType *simple_type = type->as_simple_type();
if (simple_type != (CPPSimpleType *)NULL) {
return (simple_type->_type == CPPSimpleType::T_double);
}
}
break;
default:
break;
}
return false;
}
////////////////////////////////////////////////////////////////////
// Function: TypeManager::is_float
// Access: Public, Static

View File

@ -80,8 +80,11 @@ public:
static bool is_bool(CPPType *type);
static bool is_integer(CPPType *type);
static bool is_unsigned_integer(CPPType *type);
static bool is_unsigned_longlong(CPPType *type);
static bool is_short(CPPType *type);
static bool is_unsigned_short(CPPType *type);
static bool is_longlong(CPPType *type);
static bool is_unsigned_longlong(CPPType *type);
static bool is_double(CPPType *type);
static bool is_float(CPPType *type);
static bool is_void(CPPType *type);
static bool is_reference_count(CPPType *type);