[Roxygen-commits] r46 - in pkg: R sandbox
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jun 19 09:12:16 CEST 2008
Author: pcd
Date: 2008-06-19 09:12:16 +0200 (Thu, 19 Jun 2008)
New Revision: 46
Added:
pkg/R/namespace.R
pkg/sandbox/namespace.R
Modified:
pkg/sandbox/main.R
Log:
namespace roclet POC
Added: pkg/R/namespace.R
===================================================================
--- pkg/R/namespace.R (rev 0)
+++ pkg/R/namespace.R 2008-06-19 07:12:16 UTC (rev 46)
@@ -0,0 +1,44 @@
+namespace <- function(partita) {
+ parse.default <- function(procedure, parameters)
+ sprintf('%s(%s)', procedure, gsub(' {2,}', ', ', parameters))
+
+ parse.exportClass <- function(procedure, parameters)
+ parse.default('exportClasses', parameters)
+
+ parse.exportMethod <- function(procedure, parameters)
+ parse.default('exportMethods', parameters)
+
+ parsers <- list(exportClass=parse.exportClass,
+ exportMethod=parse.exportMethod)
+
+ relevators <- c('export',
+ 'exportClass',
+ 'exportMethod',
+ 'exportPattern',
+ 'S3method',
+ 'import',
+ 'importFrom',
+ 'importClassesFrom',
+ 'importMethodsFrom')
+ relevata <-
+ Reduce(append,
+ Map(function(partitum)
+ Filter(function(key.value) car(key.value) %in% relevators,
+ zip.list(attributes(partitum)$names,
+ partitum)),
+ partita),
+ NULL)
+ directives <-
+ Map(function(relevatum) {
+ procedure <- car(relevatum)
+ parameters <- cadr(relevatum)
+ parser <- parsers[[procedure]]
+ if (is.null(parser))
+ parse.default(procedure, parameters)
+ else
+ parser(procedure, parameters)
+ },
+ relevata)
+ for (directive in directives)
+ cat(directive, "\n")
+}
Modified: pkg/sandbox/main.R
===================================================================
--- pkg/sandbox/main.R 2008-06-19 05:51:01 UTC (rev 45)
+++ pkg/sandbox/main.R 2008-06-19 07:12:16 UTC (rev 46)
@@ -2,7 +2,7 @@
source('../R/list.R')
source('../R/parse.R')
-FILE <- 'example.R'
+FILE <- 'example-S3-mcpi.R'
argv <- commandArgs(trailingOnly=T)
argc <- length(argv)
Added: pkg/sandbox/namespace.R
===================================================================
--- pkg/sandbox/namespace.R (rev 0)
+++ pkg/sandbox/namespace.R 2008-06-19 07:12:16 UTC (rev 46)
@@ -0,0 +1,14 @@
+source('../R/functional.R')
+source('../R/list.R')
+source('../R/parse.R')
+source('../R/namespace.R')
+
+FILES <- list('example-function-mcpi.R',
+ 'example-S3-mcpi.R',
+ 'example-S4-person.R')
+
+argv <- commandArgs(trailingOnly=T)
+argc <- length(argv)
+files <- if (argc > 0) as.list(argv) else FILES
+
+namespace(do.call(parse.files, files))
More information about the Roxygen-commits
mailing list