X-Git-Url: http://christophe.rhodes.io/gitweb/?p=swankr.git;a=blobdiff_plain;f=swank-presentations.R;h=22ce24c2b9a4d56dce5ef4f1f558896aac876a0b;hp=6ac0e75af1dd190a0998ec8d3d689c03bc3e1b6d;hb=bf3b2b6574042d5001c63bc3a54c82bcd0d29e86;hpb=e67ca7eaf514cf5dd5a2303a4d18ca02d0e1dbf4 diff --git a/swank-presentations.R b/swank-presentations.R index 6ac0e75..22ce24c 100644 --- a/swank-presentations.R +++ b/swank-presentations.R @@ -4,6 +4,8 @@ savePresentedObject <- function(slimeConnection, value) { if(!exists("idToObject", envir=slimeConnection)) { assign("idToObject", new.env(), envir=slimeConnection) } + ## FIXME this should check for value already being present in the + ## idToObject map presentationCounter <<- presentationCounter + 1 assign(as.character(presentationCounter), value, envir=slimeConnection$idToObject) presentationCounter @@ -20,8 +22,6 @@ presentReplResult <- function(slimeConnection, value) { list(quote(`:write-string`), "\n", quote(`:repl-result`))) } -sendReplResultFunction <- presentReplResult - `cl:nth-value` <- function(slimeConnection, sldbState, n, values) { values[[n+1]] } @@ -43,7 +43,12 @@ sendReplResultFunction <- presentReplResult stop(sprintf("attempt to access unrecorded object (id %d)", id)) } } - + +`swank:lookup-and-save-presented-object-or-lose` <- function(slimeConnection, sldbState, id) { + obj <- `swank:lookup-presented-object-or-lose`(slimeConnection, sldbState, id) + savePresentedObject(slimeConnection, obj) +} + `swank:clear-repl-results` <- function(slimeConnection, sldbState) { if(!exists("idToObject", envir=slimeConnection)) { assign("idToObject", new.env(), envir=slimeConnection) @@ -51,3 +56,8 @@ sendReplResultFunction <- presentReplResult rm(list=ls(slimeConnection$idToObject), envir=slimeConnection$idToObject) TRUE } + +`swank:init-presentations` <- function(slimeConnection, sldbState) { + sendReplResultFunction <<- presentReplResult + TRUE +}