]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/srecode/dictionary.el
Merge from emacs-24; up to 2012-12-29T12:57:49Z!fgallina@gnu.org
[gnu-emacs] / lisp / cedet / srecode / dictionary.el
index 7d20d72c2d37ca48b163135f3aa8ff8e335eb419..bbc791f09d871d96c01a863ec60d7e3a9e243746 100644 (file)
@@ -1,6 +1,6 @@
-;;; srecode-dictionary.el --- Dictionary code for the semantic recoder.
+;;; srecode/dictionary.el --- Dictionary code for the semantic recoder.
 
-;; Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
 
@@ -117,8 +117,8 @@ Makes sure that :value is compiled."
                              (cons (car fields) newfields))))
       (setq fields (cdr (cdr fields))))
 
-    (when (not state)
-      (error "Cannot create compound variable without :state"))
+    ;;(when (not state)
+    ;;  (error "Cannot create compound variable outside of sectiondictionary"))
 
     (call-next-method this (nreverse newfields))
     (when (not (slot-boundp this 'compiled))
@@ -175,7 +175,7 @@ associated with a buffer or parent."
        ((srecode-dictionary-child-p buffer-or-parent)
        (setq parent buffer-or-parent
              buffer (oref buffer-or-parent buffer)
-             origin (concat (object-name buffer-or-parent) " in "
+             origin (concat (eieio-object-name buffer-or-parent) " in "
                             (if buffer (buffer-name buffer)
                               "no buffer")))
        (when buffer
@@ -202,7 +202,7 @@ associated with a buffer or parent."
                                              :size 20)
                   :origin   origin)))
        ;; Only set up the default variables if we are being built
-       ;; directroy for a particular buffer.
+       ;; directly for a particular buffer.
        (when initfrombuff
          ;; Variables from the table we are inserting from.
          ;; @todo - get a better tree of tables.
@@ -220,7 +220,10 @@ associated with a buffer or parent."
   "Insert into DICT the variables found in table TPL.
 TPL is an object representing a compiled template file."
   (when tpl
-    (let ((tabs (oref tpl :tables)))
+    ;; Tables are sorted with highest priority first, useful for looking
+    ;; up templates, but this means we need to install the variables in
+    ;; reverse order so higher priority variables override lower ones.
+    (let ((tabs (reverse (oref tpl :tables))))
       (require 'srecode/find) ; For srecode-template-table-in-project-p
       (while tabs
        (when (srecode-template-table-in-project-p (car tabs))
@@ -280,7 +283,7 @@ inserted dictionaries."
          (progn
            (srecode-dictionary-show-section new "FIRST")
            (srecode-dictionary-show-section new "LAST"))
-       ;; Not the very first one.  Lets clean up CAR.
+       ;; Not the very first one.  Let's clean up CAR.
        (let ((tail (car (last ov))))
          (srecode-dictionary-hide-section tail "LAST")
          (srecode-dictionary-show-section tail "NOTLAST")
@@ -436,8 +439,8 @@ The root dictionary is usually for a current or active insertion."
 
 ;;; COMPOUND VALUE METHODS
 ;;
-;; Compound values must provide at least the toStriong method
-;; for use in converting the compound value into sometehing insertable.
+;; Compound values must provide at least the toString method
+;; for use in converting the compound value into something insertable.
 
 (defmethod srecode-compound-toString ((cp srecode-dictionary-compound-value)
                                      function
@@ -451,12 +454,12 @@ If you subclass `srecode-dictionary-compound-value' then this
 method could return nil, but if it does that, it must insert
 the value itself using `princ', or by detecting if the current
 standard out is a buffer, and using `insert'."
-  (object-name cp))
+  (eieio-object-name cp))
 
 (defmethod srecode-dump ((cp srecode-dictionary-compound-value)
                         &optional indent)
   "Display information about this compound value."
-  (princ (object-name cp))
+  (princ (eieio-object-name cp))
   )
 
 (defmethod srecode-compound-toString ((cp srecode-dictionary-compound-variable)
@@ -546,40 +549,6 @@ inserted with a new editable field.")
 \f
 ;;; Higher level dictionary functions
 ;;
-(defun srecode-create-section-dictionary (sectiondicts STATE)
-  "Create a dictionary with section entries for a template.
-The format for SECTIONDICTS is what is emitted from the template parsers.
-STATE is the current compiler state."
-  (when sectiondicts
-    (let ((new (srecode-create-dictionary t)))
-      ;; Loop over each section.  The section is a macro w/in the
-      ;; template.
-      (while sectiondicts
-       (let* ((sect (car (car sectiondicts)))
-              (entries (cdr (car sectiondicts)))
-              (subdict (srecode-dictionary-add-section-dictionary new sect))
-              )
-         ;; Loop over each entry.  This is one variable in the
-         ;; section dictionary.
-         (while entries
-           (let ((tname (semantic-tag-name (car entries)))
-                 (val (semantic-tag-variable-default (car entries))))
-             (if (eq val t)
-                 (srecode-dictionary-show-section subdict tname)
-               (cond
-                ((and (stringp (car val))
-                      (= (length val) 1))
-                 (setq val (car val)))
-                (t
-                 (setq val (srecode-dictionary-compound-variable
-                            tname :value val :state STATE))))
-               (srecode-dictionary-set-value
-                subdict tname val))
-             (setq entries (cdr entries))))
-         )
-       (setq sectiondicts (cdr sectiondicts)))
-      new)))
-
 (defun srecode-create-dictionaries-from-tags (tags state)
   "Create a dictionary with entries according to TAGS.
 
@@ -635,7 +604,6 @@ STATE is the current compiler state."
   "Run data-debug on this mode's dictionary."
   (interactive)
   (require 'eieio-datadebug)
-  (require 'semantic)
   (require 'srecode/find)
   (let* ((modesym major-mode)
         (start (current-time))
@@ -686,7 +654,7 @@ STATE is the current compiler state."
                                       4)))
                      (while entry
                        (princ " --> SUBDICTIONARY ")
-                       (princ (object-name dict))
+                       (princ (eieio-object-name dict))
                        (princ "\n")
                        (srecode-dump (car entry) newindent)
                        (setq entry (cdr entry))
@@ -708,5 +676,4 @@ STATE is the current compiler state."
 
 (provide 'srecode/dictionary)
 
-;; arch-tag: c664179c-171c-4709-9b56-d5a2fd30e457
 ;;; srecode/dictionary.el ends here