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.

65 lines
2.0 KiB

25 years ago
  1. // Concrete class of double float numbers.
  2. #ifndef _CL_DFLOAT_CLASS_H
  3. #define _CL_DFLOAT_CLASS_H
  4. #include "cl_number.h"
  5. #include "cl_float_class.h"
  6. class cl_DF : public cl_F {
  7. public:
  8. // Default constructor.
  9. cl_DF ();
  10. // Assignment operators.
  11. cl_DF& operator= (const cl_DF&);
  12. // Optimization of method pointer_p().
  13. cl_boolean pointer_p() const
  14. { return cl_true; }
  15. // Faster pointer_p() gives a faster copy constructor (but not destructor!!!).
  16. cl_DF (const cl_DF& x);
  17. // Constructors and assignment operators from C numeric types.
  18. cl_DF (const double);
  19. cl_DF& operator= (const double);
  20. // Other constructors.
  21. cl_DF (const char *);
  22. // Private constructor.
  23. cl_DF (cl_private_thing);
  24. cl_DF (struct cl_heap_dfloat *);
  25. // Private pointer manipulations.
  26. operator struct cl_heap_dfloat * () const;
  27. public: // Ability to place an object at a given address.
  28. void* operator new (size_t size) { return cl_malloc_hook(size); }
  29. void* operator new (size_t size, cl_DF* ptr) { (void)size; return ptr; }
  30. void operator delete (void* ptr) { cl_free_hook(ptr); }
  31. private:
  32. // Friend declarations. They are for the compiler. Just ignore them.
  33. };
  34. // Private constructors.
  35. inline cl_DF::cl_DF (cl_private_thing ptr) : cl_F (ptr) {}
  36. // The assignment operators:
  37. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_DF, cl_DF)
  38. // The default constructors.
  39. // Private pointer manipulations. Never throw away a `struct cl_heap_dfloat *'!
  40. inline cl_DF::operator struct cl_heap_dfloat * () const
  41. {
  42. struct cl_heap_dfloat * hpointer = (struct cl_heap_dfloat *) pointer;
  43. cl_inc_refcount(*this);
  44. return hpointer;
  45. }
  46. extern const cl_DF cl_DF_0;
  47. inline cl_DF::cl_DF ()
  48. : cl_F ((cl_private_thing) (struct cl_heap_dfloat *) cl_DF_0) {}
  49. CL_REQUIRE(cl_DF_globals)
  50. #if 0 // see cl_DF.h
  51. inline cl_DF::cl_DF (struct cl_heap_dfloat * ptr)
  52. : cl_F ((cl_private_thing) ptr) {}
  53. #endif
  54. // The copy constructors.
  55. CL_DEFINE_COPY_CONSTRUCTOR2(cl_DF,cl_F)
  56. // Constructors and assignment operators from C numeric types.
  57. CL_DEFINE_DOUBLE_CONSTRUCTOR(cl_DF)
  58. #endif /* _CL_DFLOAT_CLASS_H */