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.

52 lines
1.3 KiB

25 years ago
25 years ago
25 years ago
  1. // Symbols.
  2. #ifndef _CL_SYMBOL_H
  3. #define _CL_SYMBOL_H
  4. #include "cln/string.h"
  5. namespace cln {
  6. // Symbols are just strings, uniquified through a global hash table.
  7. #if (defined(__alpha__) && !defined(__GNUC__))
  8. struct hashuniq;
  9. #endif
  10. struct cl_symbol : public cl_rcpointer {
  11. public:
  12. // Conversion to string.
  13. operator cl_string () const;
  14. // Constructors.
  15. cl_symbol (const cl_string&); // create or lookup a symbol from its name
  16. cl_symbol (const cl_symbol&);
  17. // Assignment operators.
  18. cl_symbol& operator= (const cl_symbol&);
  19. // Private pointer manipulations.
  20. cl_symbol (cl_private_thing p) : cl_rcpointer (p) {}
  21. public: /* ugh */
  22. // Create a new symbol given its name.
  23. cl_symbol (struct hashuniq * null, const cl_string& s);
  24. };
  25. CL_DEFINE_COPY_CONSTRUCTOR2(cl_symbol,cl_rcpointer)
  26. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_symbol,cl_symbol)
  27. // A symbol points to a string, so to convert cl_symbol -> cl_string, we just
  28. // take the pointer and put it into a cl_string.
  29. inline cl_symbol::operator cl_string () const
  30. {
  31. return cl_string(_as_cl_private_thing());
  32. }
  33. // Comparison.
  34. inline bool equal (const cl_symbol& s1, const cl_symbol& s2)
  35. {
  36. return (s1.pointer == s2.pointer);
  37. }
  38. // Hash code.
  39. extern unsigned long hashcode (const cl_symbol& s);
  40. } // namespace cln
  41. #endif /* _CL_SYMBOL_H */