You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. // Conditions (a.k.a. exceptions)
  2. #ifndef _CL_CONDITION_H
  3. #define _CL_CONDITION_H
  4. #include "cln/malloc.h"
  5. #include "cln/io.h"
  6. namespace cln {
  7. struct cl_condition {
  8. // Allocation.
  9. void* operator new (size_t size) { return malloc_hook(size); }
  10. // Deallocation.
  11. void operator delete (void* ptr) { free_hook(ptr); }
  12. // Name.
  13. virtual const char * name () const = 0;
  14. // Print.
  15. virtual void print (cl_ostream) const = 0;
  16. // Virtual destructor.
  17. virtual ~cl_condition () = 0;
  18. private:
  19. virtual void dummy ();
  20. };
  21. #define SUBCLASS_cl_condition() \
  22. public: \
  23. /* Allocation. */ \
  24. void* operator new (size_t size) { return malloc_hook(size); } \
  25. /* Deallocation. */ \
  26. void operator delete (void* ptr) { free_hook(ptr); }
  27. // Functions which want to raise a condition return a `cl_condition*'.
  28. // The caller checks this value. NULL means no condition. The one who
  29. // disposes the condition (handles it without resignalling it) should
  30. // call `delete' on the condition pointer.
  31. } // namespace cln
  32. #endif /* _CL_CONDITION_H */