[rkward-cvs] rkward/rkward/rbackend/rpackages/rkward/R internal.R, 1.26, 1.27

Thomas Friedrichsmeier tfry at users.sourceforge.net
Tue Jun 20 14:25:31 UTC 2006


Update of /cvsroot/rkward/rkward/rkward/rbackend/rpackages/rkward/R
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv10586/rpackages/rkward/R

Modified Files:
	internal.R 
Log Message:
Add first version of functions to track assignments to R objects (so we can update our information automatically

Index: internal.R
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rpackages/rkward/R/internal.R,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** internal.R	28 Apr 2006 13:36:33 -0000	1.26
--- internal.R	20 Jun 2006 14:25:29 -0000	1.27
***************
*** 201,202 ****
--- 201,248 ----
  	eval (substitute (class (x) <<- classes))
  }
+ 
+ # these functions (not fully functional, yet) can be used to track assignments to R objects. The main interfaces are .rk.watch.symbol (k) and .rk.unwatch.symbol (k). This works by copying the symbol to a backup location, removing it, and replacing it by an active binding to the backup location
+ .rk.watched.value.change <- function (k, value) {
+ 	print ("set")
+ 	.rk.watched.symbols[[as.character(k)]] <<- value
+ }
+ 
+ .rk.watched.value.retrieve <- function (k) {
+ 	print ("ret")
+ 	.rk.watched.symbols[[as.character(k)]]
+ }
+ 
+ .rk.make.watch.f <- function (k) {
+ 	function (value) {
+ 		if (!missing (value)) {
+ 			.rk.watched.value.change (k, value)
+ 			invisible (value)
+ 		}
+ 		else {
+ 			.rk.watched.value.retrieve (k)
+ 		}
+ 	}
+ }
+ 
+ .rk.watch.symbol <- function (k) {
+ 	f <- .rk.make.watch.f (substitute (k))
+ 	if (!exists (".rk.watched.symbols")) .rk.watched.symbols <<- list ()
+ 	.rk.watched.symbols[as.character (substitute (k))] <<- k
+ 	lst <- c (substitute (k))
+ 	rm (list=as.character (lst), envir=parent.frame ())
+ 
+ 	makeActiveBinding (substitute (k), f, parent.frame ())
+ 
+ 	invisible (TRUE)
+ }
+ 
+ .rk.unwatch.symbol <- function (k) {
+ 	lst <- c (substitute (k))
+ 	rm (list=as.character (lst), envir=parent.frame ())
+ 
+ 	eval (substitute (k <<- .rk.watched.symbols[[as.character (substitute (k))]]))
+ 
+ 	.rk.watched.symbols[as.character(substitute (k))] <<- NULL
+ 
+ 	invisible (TRUE)
+ }





More information about the rkward-tracker mailing list