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.

57 lines
1.7 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. // Abstract class of integers.
  2. #ifndef _CL_INTEGER_CLASS_H
  3. #define _CL_INTEGER_CLASS_H
  4. #include "cln/number.h"
  5. #include "cln/rational_class.h"
  6. namespace cln {
  7. class cl_I : public cl_RA {
  8. public:
  9. // Default constructor.
  10. cl_I ();
  11. // Copy constructor.
  12. cl_I (const cl_I&);
  13. // Assignment operators.
  14. cl_I& operator= (const cl_I&);
  15. // Constructors and assignment operators from C numeric types.
  16. cl_I (const int); // |argument| must be < 2^29
  17. cl_I (const unsigned int); // argument must be < 2^29
  18. cl_I (const long);
  19. cl_I (const unsigned long);
  20. cl_I& operator= (const int); // |argument| must be < 2^29
  21. cl_I& operator= (const unsigned int); // argument must be < 2^29
  22. cl_I& operator= (const long);
  23. cl_I& operator= (const unsigned long);
  24. // Other constructors.
  25. cl_I (const char *);
  26. // Private constructor.
  27. cl_I (cl_private_thing);
  28. cl_I (struct cl_fixnum * /* NULL! */, cl_uint);
  29. cl_I (struct cl_heap_bignum *);
  30. public: // Ability to place an object at a given address.
  31. void* operator new (size_t size) { return malloc_hook(size); }
  32. void* operator new (size_t size, cl_I* ptr) { (void)size; return ptr; }
  33. void operator delete (void* ptr) { free_hook(ptr); }
  34. };
  35. // Private constructors.
  36. inline cl_I::cl_I (cl_private_thing ptr) : cl_RA (ptr) {}
  37. // The assignment operators:
  38. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_I, cl_I)
  39. // The default constructors.
  40. inline cl_I::cl_I ()
  41. : cl_RA ((cl_private_thing) cl_combine(cl_FN_tag,0)) {}
  42. // The copy constructors.
  43. CL_DEFINE_COPY_CONSTRUCTOR2(cl_I,cl_RA)
  44. // Constructors and assignment operators from C numeric types.
  45. CL_DEFINE_INT_CONSTRUCTORS(cl_I)
  46. CL_DEFINE_INT_ASSIGNMENT_OPERATORS(cl_I)
  47. CL_DEFINE_LONG_CONSTRUCTORS(cl_I)
  48. CL_DEFINE_LONG_ASSIGNMENT_OPERATORS(cl_I)
  49. } // namespace cln
  50. #endif /* _CL_INTEGER_CLASS_H */