[Roxygen-commits] r238 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jul 28 10:19:51 CEST 2009
Author: manuel
Date: 2009-07-28 10:19:49 +0200 (Tue, 28 Jul 2009)
New Revision: 238
Modified:
pkg/R/namespace.R
Log:
add "namespace collection" to collect all directives and export and import only once per "thing" (really important for equal imports for different functions, methods, etc.)
Modified: pkg/R/namespace.R
===================================================================
--- pkg/R/namespace.R 2009-07-27 16:31:31 UTC (rev 237)
+++ pkg/R/namespace.R 2009-07-28 08:19:49 UTC (rev 238)
@@ -85,11 +85,28 @@
#' importMethodsFrom export
make.namespace.roclet <- function(outfile='',
verbose=TRUE) {
- parse.directive <- function(proc, parms)
- cat(sprintf('%s(%s)\n', proc, strmap(Identity, ', ', parms)),
- file=outfile,
- append=TRUE)
+
+ namespace <- list()
+
+ namespace.reset <- function()
+ namespace <<- list()
+ namespace.exists <- function(proc, parms)
+ parms %in% namespace[[proc]]
+
+ namespace.register <- function(proc, parms)
+ namespace[[proc]] <<- append(namespace[[proc]], parms)
+
+ parse.directive <- function(proc, parms) {
+ parms <- strmap(Identity, ', ', parms)
+ if ( !namespace.exists(proc, parms) ) {
+ cat(sprintf('%s(%s)\n', proc, parms),
+ file=outfile,
+ append=TRUE)
+ namespace.register(proc, parms)
+ }
+ }
+
exportee <- NULL
pre.parse <- function(partitum)
@@ -103,6 +120,7 @@
if (verbose && !is.null.string(outfile))
cat(sprintf('Writing namespace directives to %s', outfile), '\n')
unlink(outfile)
+ namespace.reset()
}
roclet <- make.roclet(parse.directive,
More information about the Roxygen-commits
mailing list