;; -*-Mode: Lisp-*- 
;; $Id: load-lisp.lsp,v 1.7 2001/04/02 20:42:17 moltmans Exp $
;; load.lsp -- 
;; Author: Michael Oltmans <moltmans@ai.mit.edu> 
;; Created: <Thu Jan 25 22:05:03 2001> 
;; Time-stamp: <2001-03-07 14:51:38 moltmans> 

(in-package :COMMON-LISP-USER)

(require :jlinker)
(defpackage :javatools.jlinker (:nicknames :jl))
;(load "c:/hal/source/rec/annotate/lisp/jl-config.cl")
(defvar *jlinker-magic-file* "lisp-to-java-magic-file.trp")
(defvar *jlinker-magic-port* 3383)

(defun start-jlinker ()
  (jl:jlinker-init :lisp-advertises :lisp-file *jlinker-magic-file*))

(defun start-listener ()
  (jl:jlinker-listen :init-args (list :lisp-file *jlinker-magic-file*)))

(defun stop-listener ()
  (jl:jlinker-listen :stop :all))

(defun read-eval-to-string (form)
  (format nil "~S" (eval (read-from-string form))))

(defun read-eval (form)
  (eval (read-from-string form)))

(defun make-java-list (form)
  "Return a reference to a java LinkedList object, whose elements are
all ~S string representations of form's elements."
  (let ((lst (jl:jnew (jl:jcons "java.util.LinkedList"))))
    (mapc
     #'(lambda (elt)
	 (let ((str (jl:jnew (jl:jcons "java.lang.String"
				       "java.lang.String")
			     (format nil "~S" elt))))
	   (jl:jcall (jl:jmeth "java.util.LinkedList" "add"
			       "java.lang.Object") lst str)))
     form)
    lst))

(defun set-java-result-list (java-list)
  (jl:jcall (jl:jmeth "rec.annotate.lisp.Lisp" "setResultList"
		      "java.util.LinkedList")
	    nil java-list :ignore))

(defun java-setq (var-string value)
  (setf (symbol-value (intern (string-upcase var-string))) value))

