[R-gregmisc-users] SF.net SVN: r-gregmisc:[1612] trunk/namespace/R
Brought to you by:
warnes
From: <wa...@us...> - 2012-09-19 16:57:18
|
Revision: 1612 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1612&view=rev Author: warnes Date: 2012-09-19 16:57:08 +0000 (Wed, 19 Sep 2012) Log Message: ----------- Move makeNamespace function into a separate file and include the original copyright notice. Modified Paths: -------------- trunk/namespace/R/namespace.R Added Paths: ----------- trunk/namespace/R/makeNamespace.R Added: trunk/namespace/R/makeNamespace.R =================================================================== --- trunk/namespace/R/makeNamespace.R (rev 0) +++ trunk/namespace/R/makeNamespace.R 2012-09-19 16:57:08 UTC (rev 1612) @@ -0,0 +1,46 @@ +# Copy of function defined inside of base::loadNamespace() in +# The R package source at src/library/base/R/namespace.R, +# Part of the R package, http://www.R-project.org +# +# Copyright (C) 1995-2012 The R Core Team +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License is available at +# http://www.r-project.org/Licenses/ + +# [NB: Other comments and code omitted] + +makeNamespace <- function(name, version = NULL, lib = NULL) { + impenv <- new.env(parent = .BaseNamespaceEnv, hash = TRUE) + attr(impenv, "name") <- paste("imports", name, sep=":") + env <- new.env(parent = impenv, hash = TRUE) + name <- as.character(as.name(name)) + version <- as.character(version) + info <- new.env(hash = TRUE, parent = baseenv()) + assign(".__NAMESPACE__.", info, envir = env) + assign("spec", c(name = name,version = version), envir = info) + setNamespaceInfo(env, "exports", new.env(hash = TRUE, parent = baseenv())) + dimpenv <- new.env(parent = baseenv(), hash = TRUE) + attr(dimpenv, "name") <- paste("lazydata", name, sep=":") + setNamespaceInfo(env, "lazydata", dimpenv) + setNamespaceInfo(env, "imports", list("base" = TRUE)) + ## this should be an absolute path + setNamespaceInfo(env, "path", + normalizePath(file.path(lib, name), "/", TRUE)) + setNamespaceInfo(env, "dynlibs", NULL) + setNamespaceInfo(env, "S3methods", matrix(NA_character_, 0L, 3L)) + assign(".__S3MethodsTable__.", + new.env(hash = TRUE, parent = baseenv()), + envir = env) + registerNamespace(name, env) + env +} Modified: trunk/namespace/R/namespace.R =================================================================== --- trunk/namespace/R/namespace.R 2012-09-13 23:54:38 UTC (rev 1611) +++ trunk/namespace/R/namespace.R 2012-09-19 16:57:08 UTC (rev 1612) @@ -56,30 +56,3 @@ return(getNamespace(name)) } } - -## Copy of function defined inside of base::loadNamespace -makeNamespace <- function(name, version = NULL, lib = NULL) { - impenv <- new.env(parent = .BaseNamespaceEnv, hash = TRUE) - attr(impenv, "name") <- paste("imports", name, sep=":") - env <- new.env(parent = impenv, hash = TRUE) - name <- as.character(as.name(name)) - version <- as.character(version) - info <- new.env(hash = TRUE, parent = baseenv()) - assign(".__NAMESPACE__.", info, envir = env) - assign("spec", c(name = name,version = version), envir = info) - setNamespaceInfo(env, "exports", new.env(hash = TRUE, parent = baseenv())) - dimpenv <- new.env(parent = baseenv(), hash = TRUE) - attr(dimpenv, "name") <- paste("lazydata", name, sep=":") - setNamespaceInfo(env, "lazydata", dimpenv) - setNamespaceInfo(env, "imports", list("base" = TRUE)) - ## this should be an absolute path - setNamespaceInfo(env, "path", - normalizePath(file.path(lib, name), "/", TRUE)) - setNamespaceInfo(env, "dynlibs", NULL) - setNamespaceInfo(env, "S3methods", matrix(NA_character_, 0L, 3L)) - assign(".__S3MethodsTable__.", - new.env(hash = TRUE, parent = baseenv()), - envir = env) - registerNamespace(name, env) - env -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |