Update CEDET from upstream.
[bpt/emacs.git] / lisp / cedet / srecode / dictionary.el
index 521532b..6262383 100644 (file)
@@ -1,6 +1,6 @@
 ;;; srecode/dictionary.el --- Dictionary code for the semantic recoder.
 
-;; Copyright (C) 2007-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2012 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))
@@ -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
@@ -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.