2
0
Эх сурвалжийг харах

The "null" ButtonHandle and TypeHandle now evaluate to false

rdb 11 жил өмнө
parent
commit
24d705b031

+ 11 - 1
dtool/src/dtoolbase/typeHandle.I

@@ -275,6 +275,17 @@ none() {
   return _none;
   return _none;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: TypeHandle::operator bool
+//       Access: Published
+//  Description: TypeHandle::none() evaluates to false, everything
+//               else evaluates to true.
+////////////////////////////////////////////////////////////////////
+INLINE TypeHandle::
+operator bool () const {
+  return (_index != 0);
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: get_best_parent_from_Set
 //     Function: get_best_parent_from_Set
 //       Access: Published
 //       Access: Published
@@ -295,4 +306,3 @@ INLINE  int TypeHandle::get_best_parent_from_Set(const std::set< int > &legal_va
     }
     }
     return -1;
     return -1;
 }
 }
-

+ 1 - 0
dtool/src/dtoolbase/typeHandle.h

@@ -146,6 +146,7 @@ PUBLISHED:
   INLINE int get_index() const;
   INLINE int get_index() const;
   INLINE void output(ostream &out) const;
   INLINE void output(ostream &out) const;
   INLINE static TypeHandle none();
   INLINE static TypeHandle none();
+  INLINE operator bool () const;
 
 
 private:
 private:
   int _index;
   int _index;

+ 12 - 1
panda/src/putil/buttonHandle.I

@@ -135,7 +135,7 @@ get_index() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ButtonHandle::output
 //     Function: ButtonHandle::output
 //       Access: Published
 //       Access: Published
-//  Description: 
+//  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void ButtonHandle::
 INLINE void ButtonHandle::
 output(ostream &out) const {
 output(ostream &out) const {
@@ -152,3 +152,14 @@ INLINE ButtonHandle ButtonHandle::
 none() {
 none() {
   return _none;
   return _none;
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: ButtonHandle::operator bool
+//       Access: Published
+//  Description: ButtonHandle::none() evaluates to false, everything
+//               else evaluates to true.
+////////////////////////////////////////////////////////////////////
+INLINE ButtonHandle::
+operator bool () const {
+  return (_index != 0);
+}

+ 2 - 0
panda/src/putil/buttonHandle.h

@@ -51,6 +51,8 @@ PUBLISHED:
   INLINE void output(ostream &out) const;
   INLINE void output(ostream &out) const;
   INLINE static ButtonHandle none();
   INLINE static ButtonHandle none();
 
 
+  INLINE operator bool () const;
+
 private:
 private:
   int _index;
   int _index;
   static ButtonHandle _none;
   static ButtonHandle _none;