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.

78 lines
2.2 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. // Concrete class of single float numbers.
  2. #ifndef _CL_FFLOAT_CLASS_H
  3. #define _CL_FFLOAT_CLASS_H
  4. #include "cln/number.h"
  5. #include "cln/float_class.h"
  6. namespace cln {
  7. class cl_FF : public cl_F {
  8. public:
  9. // Default constructor.
  10. cl_FF ();
  11. // Assignment operators.
  12. cl_FF& operator= (const cl_FF&);
  13. // Optimization of method pointer_p().
  14. bool pointer_p() const
  15. #if defined(CL_WIDE_POINTERS)
  16. { return false; }
  17. #else
  18. { return true; }
  19. #endif
  20. // Faster pointer_p() gives a faster copy constructor (but not destructor!!!).
  21. cl_FF (const cl_FF& x);
  22. // Constructors and assignment operators from C numeric types.
  23. cl_FF (const float);
  24. cl_FF& operator= (const float);
  25. // Other constructors.
  26. cl_FF (const char *);
  27. // Private constructor.
  28. cl_FF (cl_private_thing);
  29. #if defined(CL_WIDE_POINTERS)
  30. cl_FF (struct cl_heap_ffloat * /* NULL! */, cl_uint);
  31. #else
  32. cl_FF (struct cl_heap_ffloat *);
  33. // Private pointer manipulations.
  34. operator struct cl_heap_ffloat * () const;
  35. #endif
  36. public: // Ability to place an object at a given address.
  37. void* operator new (size_t size) { return malloc_hook(size); }
  38. void* operator new (size_t size, void* ptr) { (void)size; return ptr; }
  39. void operator delete (void* ptr) { free_hook(ptr); }
  40. };
  41. // Private constructors.
  42. inline cl_FF::cl_FF (cl_private_thing ptr) : cl_F (ptr) {}
  43. // The assignment operators:
  44. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_FF, cl_FF)
  45. // The default constructors.
  46. #if defined(CL_WIDE_POINTERS)
  47. inline cl_FF::cl_FF ()
  48. : cl_F ((cl_private_thing) cl_combine(cl_FF_tag,0)) {}
  49. #else
  50. // Private pointer manipulations. Never throw away a `struct cl_heap_ffloat *'!
  51. inline cl_FF::operator struct cl_heap_ffloat * () const
  52. {
  53. struct cl_heap_ffloat * hpointer = (struct cl_heap_ffloat *) pointer;
  54. cl_inc_refcount(*this);
  55. return hpointer;
  56. }
  57. extern const cl_FF cl_FF_0;
  58. inline cl_FF::cl_FF ()
  59. : cl_F ((cl_private_thing) (struct cl_heap_ffloat *) cl_FF_0) {}
  60. CL_REQUIRE(cl_FF_globals)
  61. #if 0 // see cl_FF.h
  62. inline cl_FF::cl_FF (struct cl_heap_ffloat * ptr)
  63. : cl_F ((cl_private_thing) ptr) {}
  64. #endif
  65. #endif
  66. // The copy constructors.
  67. CL_DEFINE_COPY_CONSTRUCTOR2(cl_FF,cl_F)
  68. // Constructors and assignment operators from C numeric types.
  69. CL_DEFINE_FLOAT_CONSTRUCTOR(cl_FF)
  70. } // namespace cln
  71. #endif /* _CL_FFLOAT_CLASS_H */