Permalink
Browse files

add *r-interactive* variable -- set to 1 if working interactively in …

…Common Lisp

Signed-off-by: AJ Rossini <blindglobe@gmail.com>
  • Loading branch information...
1 parent e52f34e commit f37e5a92b2c7a7406d58909a627a774d42c66204 @blindglobe committed Apr 17, 2009
Showing with 17 additions and 10 deletions.
  1. +9 −2 src/rclg-foreigns.lisp
  2. +8 −8 src/rclg-init.lisp
View
@@ -54,7 +54,8 @@
:%rf-mkchar :%set-string-elt
:%string-elt :%r-char :%r-check-activity :%r-run-handlers
:*r-names-symbol* :*r-dims-symbol* :*r-global-env*
- :*r-unbound-value* :*r-nil-value* :*r-input-handlers*))
+ :*r-unbound-value* :*r-nil-value* :*r-input-handlers*
+ :*r-interactive*))
(in-package :rclg-foreigns)
@@ -112,11 +113,15 @@
(defcfun ("Rf_unprotect_ptr" %rf-unprotect-ptr) :void
(s sexp))
-;; Call this to initialize
+;; Initialization/Finalization mgmt
+
(defcfun ("Rf_initEmbeddedR" %rf-init-embedded-r) :int
(argc :int)
(argv :pointer))
+(defcfun ("Rf_endEmbeddedR" %rf-end-embedded-r) :void
+ (fatal :int))
+
(defcfun ("Rf_initialize_R" %rf-initialize-r) :int
(argc :int)
(argv :pointer))
@@ -191,6 +196,8 @@
(def-r-var "R_NilValue" *r-nil-value*)
(def-r-var "R_InputHandlers" *r-input-handlers*)
+(defcvar ( "R_Interactive" *r-interactive* :read-only nil) :int)
+
;;; data to R conversion functions -- found in ../c/rclg-helpers.c
;; will only work if shared libraries are loaded.
View
@@ -1,7 +1,6 @@
;;; RCLG: R-CommonLisp Gateway
-
-;;; Copyright (c) 2005--2008, <rif@mit.edu>
+;;; Copyright (c) 2005--2009, <rif@mit.edu>
;;; AJ Rossini <blindglobe@gmail.com>
;;; All rights reserved.
;;;
@@ -43,8 +42,8 @@
;;; Basic Usage:
;; (start-rclg) ;; initializes RCLG functions.
-;; (update-R) ;; sync all threads
-;;
+;; (update-R) ;; sync all threads (SBCL only, need to include others).
+
(defpackage :rclg-init
(:use :common-lisp :rclg-foreigns :cffi)
@@ -59,6 +58,9 @@
'("rclg" "-q" "--vanilla" "--max-ppsize=50000")) ; last term incr stack
(defvar *r-started* nil)
+
+(setf *r-interactive* 1) ; nil?
+
;; thread management
(defvar *do-rclg-updates-p* nil)
(defvar *rclg-update-sleep-time* .1)
@@ -172,12 +174,10 @@ need to check."
(with-foreign-string-array (foreign-argv n argv)
(%rf-initialize-r n foreign-argv)
(r-turn-off-stack-checking)
+ (setf *r-interactive* 1) ; nil? Test?
(%setup-r-main-loop)
#+sbcl(start-rclg-update-thread)))))))
-;; FIXME:AJR: Do we really want to force this, or should we wait and
-;; let the user do this when appropriate?
-;; We let the user do it when ready.
-
+;;; Commented out, since we let the user do it when ready.
;;(eval-when (:load-toplevel)
;; (start-rclg))

0 comments on commit f37e5a9

Please sign in to comment.