Next: , Previous: , Up: Dictionaries   [Index]

6.3 Compound Dictionary Values

If you want to associate a non-string value with a dictionary variable, then you will need to use a compound value. Compound dictionary values are derived using EIEIO from a base class for handling arbitrary data in a macro.

Type: srecode-dictionary-compound-value

A compound dictionary value. Values stored in a dictionary must be a string, a dictionary for showing sections, or an instance of a subclass of this class.

Compound dictionary values derive from this class, and must provide a sequence of method implementations to convert into a string.

Your new subclass of the compound value needs to implement these methods:

Function: srecode-compound-toString cp function dictionary

Convert the compound dictionary value cp to a string. If function is non-nil, then function is somehow applied to an aspect of the compound value. The function could be a fraction of some function symbol with a logical prefix excluded.

The next method is for dumping out tables during debugging.

Function: srecode-dump cp &optional indent

Display information about this compound value.

Here is an example of wrapping a semantic tag in a compound value:

(defclass srecode-semantic-tag (srecode-dictionary-compound-value)
  ((prime :initarg :prime
          :type semantic-tag
          "This is the primary insertion tag.")
  "Wrap up a collection of semantic tag information.
This class will be used to derive dictionary values.")

(defmethod srecode-compound-toString((cp srecode-semantic-tag)
  "Convert the compound dictionary value CP to a string.
If FUNCTION is non-nil, then FUNCTION is somehow applied to an
aspect of the compound value."
  (if (not function)
      ;; Just format it in some handy dandy way.
      (semantic-format-tag-prototype (oref cp :prime))
    ;; Otherwise, apply the function to the tag itself.
    (funcall function (oref cp :prime))

Next: , Previous: , Up: Dictionaries   [Index]