Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-19 08:08:33

0001 // Symbols.
0002 
0003 #ifndef _CL_SYMBOL_H
0004 #define _CL_SYMBOL_H
0005 
0006 #include "cln/string.h"
0007 
0008 namespace cln {
0009 
0010 // Symbols are just strings, uniquified through a global hash table.
0011 
0012 struct cl_symbol : public cl_rcpointer {
0013 public:
0014     // Conversion to string.
0015     operator cl_string () const;
0016     // Constructors.
0017     cl_symbol (const cl_string&); // create or lookup a symbol from its name
0018     cl_symbol (const cl_symbol&);
0019     // Assignment operators.
0020     cl_symbol& operator= (const cl_symbol&);
0021     // Private pointer manipulations.
0022     cl_symbol (cl_private_thing p) : cl_rcpointer (p) {}
0023 public: /* ugh */
0024     // Create a new symbol given its name.
0025     cl_symbol (struct hashuniq * null, const cl_string& s);
0026 };
0027 CL_DEFINE_COPY_CONSTRUCTOR2(cl_symbol,cl_rcpointer)
0028 CL_DEFINE_ASSIGNMENT_OPERATOR(cl_symbol,cl_symbol)
0029 
0030 // A symbol points to a string, so to convert cl_symbol -> cl_string, we just
0031 // take the pointer and put it into a cl_string.
0032 inline cl_symbol::operator cl_string () const
0033 {
0034     return cl_string(_as_cl_private_thing());
0035 }
0036 
0037 // Comparison.
0038 inline bool equal (const cl_symbol& s1, const cl_symbol& s2)
0039 {
0040     return (s1.pointer == s2.pointer);
0041 }
0042 
0043 // Hash code.
0044 extern uintptr_t hashcode (const cl_symbol& s);
0045 
0046 }  // namespace cln
0047 
0048 #endif /* _CL_SYMBOL_H */