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.

40 lines
1.1 KiB

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