From f37e5a92b2c7a7406d58909a627a774d42c66204 Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Fri, 17 Apr 2009 20:32:59 +0200 Subject: [PATCH] add *r-interactive* variable -- set to 1 if working interactively in Common Lisp Signed-off-by: AJ Rossini --- src/rclg-foreigns.lisp | 11 +++++++++-- src/rclg-init.lisp | 16 ++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/rclg-foreigns.lisp b/src/rclg-foreigns.lisp index a6982c8..b6b671f 100644 --- a/src/rclg-foreigns.lisp +++ b/src/rclg-foreigns.lisp @@ -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. diff --git a/src/rclg-init.lisp b/src/rclg-init.lisp index 6026aae..f4b0b3b 100644 --- a/src/rclg-init.lisp +++ b/src/rclg-init.lisp @@ -1,7 +1,6 @@ ;;; RCLG: R-CommonLisp Gateway - -;;; Copyright (c) 2005--2008, +;;; Copyright (c) 2005--2009, ;;; AJ Rossini ;;; 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)) -- 2.11.4.GIT