[Roxygen-commits] r145 - in pkg: R sandbox

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Aug 2 09:21:31 CEST 2008


Author: pcd
Date: 2008-08-02 09:21:31 +0200 (Sat, 02 Aug 2008)
New Revision: 145

Modified:
   pkg/R/callgraph.R
   pkg/R/roxygenize.R
   pkg/sandbox/classGraph.R
Log:
compress globals in callgraph; resort to ls instead of calls; the more intuitive < depth; thanks; TODO options; namespace out for classGraph


Modified: pkg/R/callgraph.R
===================================================================
--- pkg/R/callgraph.R	2008-08-02 07:21:27 UTC (rev 144)
+++ pkg/R/callgraph.R	2008-08-02 07:21:31 UTC (rev 145)
@@ -23,9 +23,11 @@
                                   verbose=TRUE) {
   DEFAULT.DEPTH <- 2
 
-  do.callgraph <- FALSE
-  do.callgraph.primitives <- FALSE
-  depth <- DEFAULT.DEPTH
+  do.callgraph <- NULL
+  do.callgraph.primitives <- NULL
+  depth <- NULL
+  call.stack <- NULL
+  subcalls <- NULL
   name <- NULL
 
   load.dependencies <- function() {
@@ -44,15 +46,12 @@
                               Map(sQuote, dependencies[!successes]))))
   }
   
-  parse.default <- function(key, expression) NULL
-
   reset.state <- function(partitum) {
     do.callgraph <<- FALSE
     do.callgraph.primitives <<- FALSE
     depth <<- DEFAULT.DEPTH
     call.stack <<- make.stack()
     subcalls <<- new.env(parent=emptyenv())
-    calls <<- NULL
     name <<- guess.name(partitum)
   }
 
@@ -94,10 +93,6 @@
     stack
   }
 
-  call.stack <- make.stack()
-  subcalls <- new.env(parent=emptyenv())
-  calls <- NULL
-
   is.callable <- function(name, include.primitives) {
     f <- tryCatch(get(name, mode='function'), error=function(e) NULL)
     !is.null(f) && ifelse(include.primitives, TRUE, !is.primitive(f))
@@ -107,7 +102,7 @@
     if (is.name(exprofundum)) {
       subcall <- as.character(exprofundum)
       if (is.callable(subcall, do.callgraph.primitives) &&
-          call.stack$top <= depth) {
+          call.stack$top < depth) {
         supercall <-
           if (call.stack$is.empty())
             name
@@ -119,9 +114,8 @@
             subcalls[[supercall]] <<-
               append(subsupercalls, subcall)
         }
-        if (!subcall %in% calls) {
+        if (!subcall %in% ls(subcalls, all.names=TRUE)) {
           call.stack$push(subcall)
-          calls <<- append(subcall, calls)
           subcalls[[subcall]] <<- NULL
           body <- tryCatch(body(subcall), error=function(e) NULL)
           if (!is.null(body))
@@ -136,6 +130,7 @@
 
   PHI <- (1 + sqrt(5)) / 2
 
+  #' @TODO Use svn version of Rgraphviz to de-necessitate formals-hack.
   formals(toFile) <- alist(graph=,
                            layoutType=c("dot", "neato", "twopi",
                              "circo", "fdp"),
@@ -148,6 +143,7 @@
 
   OUTFILE <- '%s-callgraph.pdf'
 
+  #' @note Thanks to Manuel for suggesting the all.names fix.
   graphviz <- function(subcalls) {
     supercalls <- ls(subcalls, all.names=TRUE)
     if (length(supercalls) < 1 || is.null(supercalls))
@@ -178,8 +174,7 @@
     }
   }
 
-  roclet <- make.roclet(parse.default,
-                        pre.parse=reset.state,
+  roclet <- make.roclet(pre.parse=reset.state,
                         post.parse=post.parse)
 
   parse.callgraph <- function(key, expression)

Modified: pkg/R/roxygenize.R
===================================================================
--- pkg/R/roxygenize.R	2008-08-02 07:21:27 UTC (rev 144)
+++ pkg/R/roxygenize.R	2008-08-02 07:21:31 UTC (rev 145)
@@ -63,6 +63,8 @@
 #' @return \code{NULL}
 #' @callGraph
 #' @callGraphDepth 1
+#' @TODO Options to enable/disable specific roclet (--no-callgraphs,
+#' etc.)
 roxygenize <- function(package.dir,
                        copy.package=TRUE) {
   roxygen.dir <- sprintf(ROXYGEN.DIR, package.dir)

Modified: pkg/sandbox/classGraph.R
===================================================================
--- pkg/sandbox/classGraph.R	2008-08-02 07:21:27 UTC (rev 144)
+++ pkg/sandbox/classGraph.R	2008-08-02 07:21:31 UTC (rev 145)
@@ -47,8 +47,8 @@
   }
 
   ## No default parser
-  roclet <- roxygen:::make.roclet(pre.parse=pre.parse,
-                                  post.parse=post.parse)
+  roclet <- make.roclet(pre.parse=pre.parse,
+                        post.parse=post.parse)
 
   roclet$register.parser('classGraph', parse.classGraph)
 



More information about the Roxygen-commits mailing list