1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
%% -*- emacs-lisp -*-
\typeout{
***** CppDoc package, Version 0.1, 2000/03/27 *****
}
\newcommand{\cpptheclass}[1]{\code{#1}}
\newcommand{\cpplabel}[1]{\label{class:#1}\CppAddClass{#1}}
\newcommand{\cppextras}{
\HlxEval{
(setq hyperlatex-additional-special-characters
(concat "|" hyperlatex-additional-special-characters))
(hyperlatex-update-special-chars)
}}
\HlxEval{
(put 'cppinclude 'hyperlatex 'hyperlatex-format-cppinclude)
(put 'cppclass 'hyperlatex 'hyperlatex-format-cppclass)
(put 'CppAddClass 'hyperlatex 'hyperlatex-format-cppaddclass)
(put '| 'hyperlatex-active 'hyperlatex-active-pipe)
(defvar hyperlatex-cpp-class-regexp "{\\|}\\|&")
(defun hyperlatex-format-cppaddclass ()
(let ((classname (hyperlatex-parse-required-argument)))
(if hyperlatex-final-pass
()
(setq hyperlatex-cpp-class-regexp
(concat "\\b" classname "\\b\\|" hyperlatex-cpp-class-regexp)))))
(defun hyperlatex-format-cppclass ()
(let* ((classname (hyperlatex-parse-required-argument))
(match (assoc (concat "class:" classname) hyperlatex-labels)))
(if (and hyperlatex-final-pass match)
(insert "\\link{\\cpptheclass{"
classname "}}{class:" classname "}")
(insert "\\cpptheclass{" classname "}"))
(goto-char hyperlatex-command-start)))
(defun hyperlatex-format-cppinclude ()
(let* ((arg (hyperlatex-parse-evaluated-argument
(concat "[\\\\%{}" hyperlatex-meta-| "]")))
(file-name
(if (file-readable-p (expand-file-name arg
hyperlatex-input-directory))
(expand-file-name arg hyperlatex-input-directory)
(error "I can't find the file %s" arg))))
(hyperlatex-insert-cpp-file file-name)))
(defun hyperlatex-insert-cpp-file (file-name)
(hyperlatex-message "Inserting cppdoc file %s..." file-name)
(goto-char (+ (point)
(car (cdr (insert-file-contents-literally file-name)))))
(narrow-to-region hyperlatex-command-start (point))
(hyperlatex-cppdoc-parse)
(hyperlatex-prelim-substitutions)
;;(print (buffer-substring (point-min) (point-max)))
(goto-char (point-min))
(widen)
(hyperlatex-message "Inserting cppdoc file %s...done" file-name))
(defun hyperlatex-cppdoc-parse ()
(let ((prev (point-min)))
(goto-char prev)
(while (re-search-forward "//\\+\\|///\\|/\\*\\*\\|//--" nil t)
(let ((token (match-string 0)))
(if (string= token "///")
(hyperlatex-handle-method)
(delete-region prev (point))
(cond ((string= token "//+")
(end-of-line))
((string= token "/**")
(search-forward "*/")
(replace-match ""))
((string= token "//--")
(insert "\\begin{cppenv}")
(let ((beg (point)))
(search-forward "//--")
(replace-match "")
(skip-chars-backward " \n\t")
(delete-region (point) (match-beginning 0))
(hyperlatex-cpp-make-links beg (point)))
(insert "\\end{cppenv}"))))
(setq prev (point))))
(delete-region (point) (point-max))))
(defun hyperlatex-handle-method ()
(replace-match "")
(beginning-of-line)
(delete-region prev (point))
(insert "\\cppmethod{")
(let ((beg (point)))
(re-search-forward "/\\*\\*\\|//+")
(goto-char (match-beginning 0))
(skip-chars-backward " \n\t;")
(hyperlatex-cpp-make-links beg (point))
(insert "}")))
(defun hyperlatex-cpp-make-links (beg end)
(save-restriction
(narrow-to-region beg end)
(goto-char (point-min))
(while (re-search-forward hyperlatex-cpp-class-regexp nil t)
(let ((classname (match-string 0)))
(cond ((string= classname "{")
(replace-match "\\{" t t))
((string= classname "}")
(replace-match "\\}" t t))
((string= classname "&")
(replace-match "\\&" t t))
(t
(replace-match (concat "\\cppclass{" classname "}") t t)))))
(goto-char (point-max))))
(defun hyperlatex-active-pipe ()
(let ((beg (point)))
(insert "\\cppclass{")
(search-forward "|")
(delete-char -1)
(insert "}")
(goto-char beg)))
}
|