Browse Source

unsigned integer

Dave Schuyler 20 years ago
parent
commit
d8d6ee4593
2 changed files with 33 additions and 0 deletions
  1. 32 0
      dtool/src/interrogate/typeManager.cxx
  2. 1 0
      dtool/src/interrogate/typeManager.h

+ 32 - 0
dtool/src/interrogate/typeManager.cxx

@@ -536,6 +536,38 @@ is_integer(CPPType *type) {
   return false;
   return false;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: TypeManager::is_unsigned_integer
+//       Access: Public, Static
+//  Description: Returns true if the indicated type is one of the
+//               basic integer types, but only the unsigned varieties.
+////////////////////////////////////////////////////////////////////
+bool TypeManager::
+is_unsigned_integer(CPPType *type) {
+  switch (type->get_subtype()) {
+  case CPPDeclaration::ST_const:
+    return is_unsigned_integer(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_bool ||
+            simple_type->_type == CPPSimpleType::T_char ||
+            simple_type->_type == CPPSimpleType::T_int) &&
+           (simple_type->_flags & CPPSimpleType::F_unsigned) != 0);
+      }
+    }
+    break;
+
+  default:
+    break;
+  }
+
+  return false;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: TypeManager::is_unsigned_longlong
 //     Function: TypeManager::is_unsigned_longlong
 //       Access: Public, Static
 //       Access: Public, Static

+ 1 - 0
dtool/src/interrogate/typeManager.h

@@ -70,6 +70,7 @@ public:
   static bool is_const_ref_to_basic_string_char(CPPType *type);
   static bool is_const_ref_to_basic_string_char(CPPType *type);
   static bool is_bool(CPPType *type);
   static bool is_bool(CPPType *type);
   static bool is_integer(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_unsigned_longlong(CPPType *type);
   static bool is_longlong(CPPType *type);
   static bool is_longlong(CPPType *type);
   static bool is_float(CPPType *type);
   static bool is_float(CPPType *type);