Destructable.hh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. // $XConsortium: Destructable.hh /main/3 1996/06/11 16:50:40 cde-hal $
  24. #ifndef _Exceptions_hh_active
  25. #error "Include this file by including Exceptions.hh"
  26. #endif
  27. #ifdef C_API
  28. #include "new_delete_simple.h"
  29. #endif
  30. class Destructable
  31. {
  32. #ifndef NATIVE_EXCEPTIONS
  33. public:
  34. Destructable();
  35. // Copy and assignment constructors necessary to maintain proper
  36. // f_in_stack state variable.
  37. Destructable (const Destructable &);
  38. Destructable &operator = (const Destructable &);
  39. virtual ~Destructable();
  40. int in_stack();
  41. int in_stack_set_size();
  42. #ifdef C_API
  43. NEW_AND_DELETE_SIGNATURES(Destructable);
  44. #endif
  45. private:
  46. friend class Jump_Environment;
  47. friend class Exceptions;
  48. static int stack_grows_down()
  49. { return (g_size == 0); }
  50. // Need this special method since Cfront 2.1 doesn't allow direct
  51. // call to destructor from another class.
  52. void destruct();
  53. static void *g_stack_start;
  54. // We keep track of the size when the stack grows up.
  55. // This is copied over to the unwind stack for stack-based objects.
  56. static unsigned short g_size;
  57. #endif
  58. };