Hello Juanjo:

I've been running ECL in slime to experiment with some CLX test code.

In a fresh instance of slime, the first compilation of the code produces:

;;; Compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;;
;;; Loading "/usr/local/lib/ecl-11.1.1/clx.asd"
;;; Loading "/usr/local/lib/ecl-11.1.1/clx.fas"
;;; End of Pass 1.
;;; Note:
;;;   Unknown type (VALUES NUMBER). Assuming it is T.
;;; Note:
;;;   Unknown type (VALUES REAL). Assuming it is T.
;;; Note:
;;;   Invoking external command:
;;; gcc -I. -I/usr/local/include/ -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O2 -w -c LispCode/XLibStuff/xlib-test-ecl.c -o LispCode/XLibStuff/xlib-test-ecl.o
;;; Note:
;;;   Invoking external command:
;;; gcc -o LispCode/XLibStuff/xlib-test-ecl.fas -L/usr/local/lib/ /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.o -Wl,--rpath,/usr/local/lib/ -shared -lecl -ldl -lm ;;; Finished compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;;
;;;
;;; Compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;; OPTIMIZE levels: Safety=3, Space=0, Speed=3, Debug=3
;;;
;;; End of Pass 1.
;;; Note:
;;;   Invoking external command:
;;; gcc -I. -I/usr/local/include/ -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O2 -w -c LispCode/XLibStuff/xlib-test-ecl.c -o LispCode/XLibStuff/xlib-test-ecl.o
;;; Note:
;;;   Invoking external command:
;;; gcc -o LispCode/XLibStuff/xlib-test-ecl.fas -L/usr/local/lib/ /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.o -Wl,--rpath,/usr/local/lib/ -shared -lecl -ldl -lm ;;; Finished compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;;

The 2nd compilation produces:

;;;
;;; Compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;; OPTIMIZE levels: Safety=3, Space=0, Speed=3, Debug=3
;;;
;;; End of Pass 1.
;;; Note:
;;;   Invoking external command:
;;; gcc -I. -I/usr/local/include/ -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O2 -w -c LispCode/XLibStuff/xlib-test-ecl.c -o LispCode/XLibStuff/xlib-test-ecl.o
;;; Note:
;;;   Invoking external command:
;;; gcc -o LispCode/XLibStuff/xlib-test-ecl.fas -L/usr/local/lib/ /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.o -Wl,--rpath,/usr/local/lib/ -shared -lecl -ldl -lm ;;; Finished compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;;
;;;
;;; Compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;; OPTIMIZE levels: Safety=3, Space=0, Speed=3, Debug=3
;;;
;;; End of Pass 1.
;;; Note:
;;;   Invoking external command:
;;; gcc -I. -I/usr/local/include/ -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O2 -w -c LispCode/XLibStuff/xlib-test-ecl.c -o LispCode/XLibStuff/xlib-test-ecl.o
;;; Note:
;;;   Invoking external command:
;;; gcc -o LispCode/XLibStuff/xlib-test-ecl.fas -L/usr/local/lib/ /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.o -Wl,--rpath,/usr/local/lib/ -shared -lecl -ldl -lm ;;; Finished compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;;

Then the command to compile and load produces:

;;;
;;; Compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;; OPTIMIZE levels: Safety=3, Space=0, Speed=3, Debug=3
;;;
;;; End of Pass 1.
;;; Note:
;;;   Invoking external command:
;;; gcc -I. -I/usr/local/include/ -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O2 -w -c LispCode/XLibStuff/xlib-test-ecl.c -o LispCode/XLibStuff/xlib-test-ecl.o
;;; Note:
;;;   Invoking external command:
;;; gcc -o LispCode/XLibStuff/xlib-test-ecl.fas -L/usr/local/lib/ /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.o -Wl,--rpath,/usr/local/lib/ -shared -lecl -ldl -lm ;;; Finished compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;;
;;;
;;; Compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;; OPTIMIZE levels: Safety=3, Space=0, Speed=3, Debug=3
;;;
;;; End of Pass 1.
;;; Note:
;;;   Invoking external command:
;;; gcc -I. -I/usr/local/include/ -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O2 -w -c LispCode/XLibStuff/xlib-test-ecl.c -o LispCode/XLibStuff/xlib-test-ecl.o
;;; Note:
;;;   Invoking external command:
;;; gcc -o LispCode/XLibStuff/xlib-test-ecl.fas -L/usr/local/lib/ /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.o -Wl,--rpath,/usr/local/lib/ -shared -lecl -ldl -lm ;;; Finished compiling /home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.lisp.
;;;
;;; Loading "/home/pfb/Documents/LispCode/XLibStuff/xlib-test-ecl.fas"


Running the code with (xapp:main) produces an error:
Asynchronous ID-CHOICE-ERROR in request 11 (last request was 13) Code 55.0 [CreateGC] ID #x1
   [Condition of type XLIB:ID-CHOICE-ERROR]

and I get the following from the describe output in the code:

#<gcontext :0 1> is an instance of class GCONTEXT
XLIB::ID :    1
XLIB:DISPLAY :    #<display :0 (The X.Org Foundation R96)>
XLIB:DRAWABLE :    #<window :0 ad>
XLIB::CACHE-P :    T
XLIB::SERVER-STATE : #(3 4294967295 255 0 0 0 1 0 0 0 NIL NIL 0 0 NIL 0 1 0 0 0
                       0 4 1 NIL NIL NIL 1)
XLIB::LOCAL-STATE : #(3 4294967295 255 0 0 0 1 0 0 0 NIL NIL 0 0 NIL 0 1 0 0 0
                      0 4 1 NIL NIL NIL 1)
XLIB::PLIST :    NIL
XLIB::NEXT :    NIL

I configured ECL thusly when I buiilt it:
./configure --prefix=/usr/local --enable-shared=yes --enable-boehm=included --with-clx=builtin

It seems like I'm not able to access the CLX functions even though the code compiles, although I don't know what the initial Unknown type messages are all about. Do I need to take more steps to access the CLX functions?

Thanks,

Paul

;;;See if clx works even a little

(require 'asdf)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (asdf:oos 'asdf:load-op :clx)
  )

(defpackage :xapp
  (:use :common-lisp :xlib)
  (:export :main))

(in-package :xapp)

(defun |x,f(x)| (points x-min x-max f)
  "Call f repeatly to build an array tabulating f from
   x-min to x-max inclusive. Uses CLX representation so
   array is twice as long as the number of points evaluated" 
  (let ((a (make-array (* 2 points))))
    (dotimes (index points)
      (let ((x (+ x-min
                  (/ (* (- x-max x-min) index)
                     (- points 1)))))        
        (setf (aref a (* 2 index))
              x
              (aref a (+ (* 2 index ) 1))
              (funcall f x))))
    a))

(defun |x(t),y(t)| (points t-min t-max x y)
  (let ((a (make-array (* 2 points))))
    (dotimes (index points)
      (let ((tau (+ t-min
                    (/ (* (- t-max t-min) index)
                       (- points 1)))))      
        (setf (aref a (* 2 index))
              (funcall x tau)
              (aref a (+ (* 2 index ) 1))
              (funcall y tau))))
    a))

(defun |z(t)| (points t-min t-max z)
  (let ((a (make-array (* 2 points))))
    (dotimes (index points)
      (let ((z (funcall z
                        (+ t-min
                           (/ (* (- t-max t-min) index)
                              (- points 1))))))
        (setf (aref a (* 2 index))
              (realpart z)
              (aref a (+ (* 2 index) 1))
              (imagpart z))))
    a))
        
(defun cycloid(loop1 size1 loop2 size2)
  #'(lambda(x)(+ (* size1 (exp (* (complex 0f0 loop1) x)))
                 (* size2 (exp (* (complex 0f0 loop2) x))))))
        
        
                 
(defun bound-xy-vec(xys)
  (do ((index 0 (+ index 2))
       (x-min (aref xys 0)
              (min x-min (aref xys index)))
       (x-max (aref xys 0)
              (max x-max (aref xys index)))
       (y-min (aref xys 1)
              (min y-min (aref xys (+ index 1))))
       (y-max (aref xys 1)
              (max y-max (aref xys (+ index 1)))))
      ((>= index (length xys))
       (values x-min x-max y-min y-max))))

(defun fit-xy-to-window (xy-vec width height)
  (let ((a (make-array (length xy-vec))))
    (multiple-value-bind (x-min x-max y-min y-max)
        (bound-xy-vec xy-vec)
      (loop for i from 0 below (length xy-vec) do
        (setf (aref a i)
              (if (evenp i)
                  (round  (* width (- (aref xy-vec i) x-min))
                          (- x-max x-min))
                  (round (* height (- y-max (aref xy-vec i)))
                         (- y-max y-min)))))
      a)))
                
(defun normalised-graph(points width height)
  (single-graph (fit-xy-to-window points width height)
                width
                height))


(defun single-graph (points width height &optional (host ""))

  (let* ((display (xlib:open-display host))
         (screen (first (xlib:display-roots display)))
         (black (xlib:screen-black-pixel screen))
         (white (xlib:screen-white-pixel screen))
         (root-window (xlib:screen-root screen))

         (grackon (xlib:create-gcontext
                   :drawable root-window
                   :foreground white
                   :background black))

         (my-window (xlib:create-window
                     :parent root-window
                     :x 0
                     :y 0
                     :width width
                     :height height
                     :background black
                     :event-mask (xlib:make-event-mask :exposure
                                                       :button-press))))

    (describe grackon)
    (xlib:map-window my-window)

    (xlib:event-case (display :force-output-p t
                              :discard-p t)
      (:exposure ()
                 (xlib:draw-lines my-window  grackon  points)
                 nil)
      (:button-press () t))

    (xlib:destroy-window my-window)
    (xlib:close-display display)))



(defun main ()
  
  (progn
    (single-graph #(0 0 100 100 200 300 300 0) 400 400)
#|
    (normalised-graph #(0 0 100 100 200 300 300 0) 400 400)
    (normalised-graph (|x,f(x)| 100 (- pi) (* 3 pi) #'sin) 400 200)
    (normalised-graph (|x,f(x)| 100 -3 3
                                #'(lambda(x)(* x x)))
                      400 400)
    (normalised-graph (|x(t),y(t)| 100 0 (* 2 pi) #'cos #'sin)
                      400 400)
    (normalised-graph (|x(t),y(t)| 100 0 (* 2 pi)
                                   #'(lambda(x)(sin (* 2 x))) #'sin)
                      400 400)
    (normalised-graph (|z(t)| 100 0 (* 2 pi)
                              #'(lambda(theta)(exp (* #c(0 1) theta))))
                      400 400)
    (normalised-graph (|z(t)| 100 0 (* 3 pi)
                              #'(lambda(theta)
                                  (+ theta 
                                     (exp (* #c(0 1)
                                             (- (* 3/2 pi) 
                                                theta))))))
                      800 200)
    (normalised-graph (|z(t)| 1000 0 (* 2 pi)
                              (cycloid 3 10 13 5))
                      400 400)
|#
    ) ;;End progn
  
  )
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Ecls-list mailing list
Ecls-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list

Reply via email to