ソースを参照

nassert_raise

David Rose 21 年 前
コミット
14765e6fc4
2 ファイル変更26 行追加0 行削除
  1. 20 0
      dtool/src/dconfig/notify.cxx
  2. 6 0
      dtool/src/dconfig/notify.h

+ 20 - 0
dtool/src/dconfig/notify.cxx

@@ -393,6 +393,26 @@ ptr() {
   return _global_ptr;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: Notify::assert_failure
+//       Access: Public
+//  Description: This function is not intended to be called directly
+//               by user code.  It's called from the nassertr() and
+//               assertv() macros when an assertion test fails; it
+//               handles the job of printing the warning message and
+//               deciding what to do about it.
+//
+//               If this function returns true, the calling function
+//               should return out of its function; if it returns
+//               false, the calling function should ignore the
+//               assertion.
+////////////////////////////////////////////////////////////////////
+bool Notify::
+assert_failure(const string &expression, int line,
+               const char *source_file) {
+  return assert_failure(expression.c_str(), line, source_file);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: Notify::assert_failure
 //       Access: Public

+ 6 - 0
dtool/src/dconfig/notify.h

@@ -77,6 +77,8 @@ PUBLISHED:
 public:
   static ios_fmtflags get_literal_flag();
 
+  bool assert_failure(const string &expression, int line,
+                      const char *source_file);
   bool assert_failure(const char *expression, int line,
                       const char *source_file);
 
@@ -151,6 +153,8 @@ private:
     } \
   }
 
+#define nassert_raise(message) 
+
 #else   // NDEBUG
 
 #define nassertr(condition, return_value) \
@@ -178,6 +182,8 @@ private:
 #define nassertr_always(condition, return_value) nassertr(condition, return_value)
 #define nassertv_always(condition) nassertv(condition)
 
+#define nassert_raise(message) Notify::ptr()->assert_failure(message, __LINE__, __FILE__)
+
 
 #endif  // NDEBUG