id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
sequencelengths
1
47
21,589
robot.lisp
rheaplex_minara/lib/cl-opengl/examples/redbook/robot.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; robot.lisp --- Lisp version of robot.c (Red Book examples) ;;; ;;; Original C version contains the following copyright notice: ;;; Copyright (c) 1993-1997, Silicon Graphics, Inc. ;;; ALL RIGHTS RESERVED ;;; This program shows how to composite modeling transformations ;;; to draw translated and rotated hierarchical models. ;;; Interaction: pressing the s and e keys (shoulder and elbow) ;;; alters the rotation of the robot arm. (in-package #:cl-glut-examples) (defclass robot-window (glut:window) ((shoulder :accessor shoulder :initform 0) (elbow :accessor elbow :initform 0)) (:default-initargs :pos-x 100 :pos-y 100 :width 500 :height 500 :mode '(:double :rgb) :title "robot.lisp")) (defmethod glut:display-window :before ((w robot-window)) (gl:clear-color 0 0 0 0) (gl:shade-model :flat)) (defmethod glut:display ((w robot-window)) (gl:clear :color-buffer) (gl:with-pushed-matrix ;; first cube (gl:translate -1 0 0) (gl:rotate (shoulder w) 0 0 1) (gl:translate 1 0 0) (gl:with-pushed-matrix (gl:scale 2 0.4 1) (glut:wire-cube 1)) ;; second cube (gl:translate 1 0 0) (gl:rotate (elbow w) 0 0 1) (gl:translate 1 0 0) (gl:with-pushed-matrix (gl:scale 2 0.4 1) (glut:wire-cube 1))) (glut:swap-buffers)) (defmethod glut:reshape ((w robot-window) width height) (gl:viewport 0 0 width height) (gl:matrix-mode :projection) (gl:load-identity) (glu:perspective 65 (/ width height) 1 20) (gl:matrix-mode :modelview) (gl:load-identity) (gl:translate 0 0 -5)) (defmethod glut:keyboard ((w robot-window) key x y) (declare (ignore x y)) (flet ((update (slot n) (setf (slot-value w slot) (mod (+ (slot-value w slot) n) 360)) (glut:post-redisplay))) (case key (#\s (update 'shoulder 10)) (#\S (update 'shoulder -10)) (#\e (update 'elbow 5)) (#\E (update 'elbow -5)) (#\Esc (glut:destroy-current-window))))) (defun rb-robot () (glut:display-window (make-instance 'robot-window)))
2,094
Common Lisp
.lisp
59
31.59322
73
0.659595
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
1dfa5600a97b4ace68825292d2f8c6f3e56170ca6e93dc1fcc56464aadda0f65
21,589
[ 120290 ]
21,590
extensions.lisp
rheaplex_minara/lib/cl-opengl/gl/extensions.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; extensions.lisp --- OpenGL extensions. ;;; ;;; Copyright (c) 2006, Oliver Markovic <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-opengl) ;;; ;;; EXT_framebuffer_object ;;; (import-export %gl:is-renderbuffer-ext %gl:bind-renderbuffer-ext) (defun delete-renderbuffers-ext (renderbuffers) (with-opengl-sequence (array '%gl:uint renderbuffers) (%gl:delete-renderbuffers-ext (length renderbuffers) array))) (defun gen-renderbuffers-ext (count) (with-foreign-object (renderbuffer-array '%gl:uint count) (%gl:gen-renderbuffers-ext count renderbuffer-array) (loop for i below count collecting (mem-aref renderbuffer-array '%gl:uint i)))) (import-export %gl:renderbuffer-storage-ext) #+nil (defun get-renderbuffer-parameter-ext (target pname) ) (import-export %gl:is-framebuffer-ext %gl:bind-framebuffer-ext) (defun delete-framebuffers-ext (framebuffers) (with-opengl-sequence (array '%gl:uint framebuffers) (%gl:delete-framebuffers-ext (length framebuffers) array))) (defun gen-framebuffers-ext (count) (with-foreign-object (framebuffer-array '%gl:uint count) (%gl:gen-framebuffers-ext count framebuffer-array) (loop for i below count collecting (mem-aref framebuffer-array '%gl:uint i)))) (import-export %gl:check-framebuffer-status-ext %gl:framebuffer-texture-1d-ext %gl:framebuffer-texture-2d-ext %gl:framebuffer-texture-3d-ext %gl:framebuffer-renderbuffer-ext) #+nil (defun get-framebuffer-attachment-parameter-ext (target attachment pname) (ecase pname (:framebuffer ))) (import-export %gl:generate-mipmap-ext)
3,272
Common Lisp
.lisp
69
44.057971
75
0.738871
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
4accef250bd99549ef287ca9c434b1ae16f635b18f14f65963fe60f9865a1e2d
21,590
[ 408427 ]
21,591
opengl.lisp
rheaplex_minara/lib/cl-opengl/gl/opengl.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; Copyright (c) 2004, Oliver Markovic <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions are met: ;;; ;;; o Redistributions of source code must retain the above copyright notice, ;;; this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may be ;;; used to endorse or promote products derived from this software without ;;; specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;;; POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-opengl) ;;; ;;; Chapter 2 - OpenGL Operation ;;; ;;; 2.5 GL Errors ;;; (define-condition opengl-error (simple-error) ((error-code :initarg :error-code :reader opengl-error.error-code)) (:report (lambda (c s) (format s "OpenGL signalled ~A." (opengl-error.error-code c))))) (import-export %gl:get-error) (defun check-error () (let ((error-code (get-error))) (unless (eql error-code :zero) (error 'opengl-error :error-code error-code)))) ;;; ;;; 2.6 Begin/End Paradigm ;;; ;;; 2.6.1 Begin and End (import-export %gl:begin %gl:end) (defmacro with-primitives (mode &body body) `(prog2 (begin ,mode) (progn ,@body) (end))) ;;; synonym for with-primitives. (defmacro with-primitive (mode &body body) `(prog2 (begin ,mode) (progn ,@body) (end))) ;;; 2.6.2 Polygon Edges (import-export %gl:edge-flag) ;;; ;;; 2.7 Vertex Specification ;;; (definline vertex (x y &optional (z 0.0) (w 1.0)) (%gl:vertex-4f x y z w)) (definline tex-coord (s &optional (r 0.0) (t* 0.0) (q 1.0)) (%gl:tex-coord-4f s r t* q)) (definline multi-tex-coord (texture s &optional (t* 0.0) (r 0.0) (q 1.0)) (%gl:multi-tex-coord-4f texture s t* r q)) (definline normal (x y z) (%gl:normal-3f x y z)) (definline fog-coord (coord) (%gl:fog-coord-f coord)) (definline color (r g b &optional (a 1.0)) (%gl:color-4f r g b a)) (definline secondary-color (r g b) (%gl:secondary-color-3f r g b)) (definline index (index) (%gl:index-i index)) (definline vertex-attrib (index x &optional (y 0.0) (z 0.0) (w 1.0)) (%gl:vertex-attrib-4f index x y z w)) ;;; ;;; 2.8 Vertex Arrays ;;; (import-export %gl:array-element %gl:enable-client-state %gl:disable-client-state %gl:client-active-texture %gl:enable-vertex-attrib-array %gl:disable-vertex-attrib-array %gl:draw-arrays) (definline draw-elements (mode array &key (count (gl-array-size array)) (offset 0)) ;; fix count to whole array size? ;; bounds checking? (%gl:draw-elements mode count (cffi-type-to-gl (gl-array-type array)) (gl-array-pointer-offset array offset))) ;;; ;;; 2.9 Buffer Objects ;;; (import-export %gl:bind-buffer) (defun delete-buffers (buffers) (with-opengl-sequence (array '%gl:uint buffers) (%gl:delete-buffers (length buffers) array))) (defun gen-buffers (count) (with-foreign-object (buffer-array '%gl:uint count) (%gl:gen-buffers count buffer-array) (loop for i below count collecting (mem-aref buffer-array '%gl:uint i)))) (import-export %gl:map-buffer %gl:unmap-buffer) (define-get-function get-buffer-parameter (target pname) (%gl:get-buffer-parameter-iv :int int) (%gl:get-buffer-pointer-v :pointer)) ;;; Offset is offset in array, buffer-offset in VBO. (definline buffer-sub-data (target array &key (offset 0) (buffer-offset 0) (size (gl-array-byte-size array))) (%gl:buffer-sub-data target buffer-offset size (gl-array-pointer-offset array offset))) ;;; NOTE: arguments are flipped compared to gl function to allow ;;; optional offset. (definline buffer-data (target usage array &key (offset 0) (size (gl-array-byte-size array))) (%gl:buffer-data target size (gl-array-pointer-offset array offset) usage)) ;;; Returns a CFFI:DEFCSTRUCT fragment for CLAUSE. (defun emit-gl-array-struct-clause (clause) (destructuring-bind (array-type &key type components &allow-other-keys) clause (declare (ignore array-type)) (loop for c in components collect `(,c ,type)))) ;;; Returns a binding form for CLAUSE. This function extracts needed ;;; parameters from CLAUSE and uses OFFSET and STRIDE as memory layout ;;; informations. PSYM is used as symbol for the pointer in the form. (defun emit-gl-array-bind-clause (clause offset stride psym) (destructuring-bind (array-type &rest rest &key type components &allow-other-keys) clause (let ((func-name (symbolicate-package "%GL" array-type "-POINTER")) (gl-type (cffi-type-to-gl type)) (address-expr `(inc-pointer ,psym ,offset)) (size (length components))) (ecase array-type ((vertex color secondary-color) `(,func-name ,size ,gl-type ,stride ,address-expr)) ((normal index fog-coord) `(,func-name ,gl-type ,stride ,address-expr)) (tex-coord (destructuring-bind (&key (stage :texture0) &allow-other-keys) rest `(progn (client-active-texture ,stage) (tex-coord-pointer ,size ,gl-type ,stride ,address-expr)))) (edge-flag ; type is fixed `(edge-flag-pointer ,stride ,address-expr)) (vertex-attrib (destructuring-bind (&key (index 0) (normalized nil) &allow-other-keys) rest `(vertex-attrib-pointer ,index ,size ,type ,normalized ,stride ,address-expr))))))) (defmacro define-gl-array-format (name &body clauses) "Defines a vertex array format spcification. Each clause has the format (array-type parameter*) where array-type can currently be one of VERTEX, COLOR, SECONDARY-COLOR, NORMAL, INDEX, FOG-COORD, TEX-COORD, EDGE-FLAG OR VERTEX-ATTRIB. Parameters are keyword arguments for the corresponding array type. The following parameters are supported: :TYPE -- array element type (all array types) :COMPONENTS -- list of component (slot) names for this array (all types) :STAGE -- active texture for the array (TEX-COORD type) :INDEX -- vertex attribute index (VERTEX-ATTRIB type) :NORMALIZED -- whether values should be normalized (VERTEX-ATTRIB) " `(progn (defcstruct ,name ,@(mapcan #'emit-gl-array-struct-clause clauses)) (setf (get ',name 'vertex-array-binder) (compile nil `(lambda (p) ,,@(loop with stride = `(foreign-type-size ',name) for c in clauses for offset = `(foreign-slot-offset ',name ',(caadr (member :components c))) collect `(emit-gl-array-bind-clause ',c ,offset ,stride 'p))))) ',name)) ;;; Returns the vertex array binder for SYMBOL-OR-FUNCTION. This ;;; function is idempotent. (defun find-vertex-array-binder (symbol-or-function &optional (errorp t)) (ctypecase symbol-or-function (function symbol-or-function) (symbol (or (get symbol-or-function 'vertex-array-binder) (when errorp (error "Vertex array format ~A not defined." symbol-or-function)))))) ;;; Sets the vertex array binder of SYMBOL to VALUE. VALUE must be a ;;; function of one argument, the array pointer. (defun (setf find-vertex-array-binder) (value symbol) (check-type value function) (setf (get symbol 'vertex-array-binder) value)) (defstruct (gl-array (:copier nil)) "Pointer to C array with size and type information attached." (pointer (null-pointer)) (size 0 :type unsigned-byte) (type nil :type symbol)) (defstruct (gl-vertex-array (:copier nil) (:include gl-array)) "Like GL-ARRAY, but with an aditional vertex array binder." (binder #'identity :type function)) (defun alloc-gl-array (type count) (if (get type 'vertex-array-binder) (make-gl-vertex-array :pointer (foreign-alloc type :count count) :size count :type type :binder (get type 'vertex-array-binder)) (make-gl-array :pointer (foreign-alloc type :count count) :size count :type type))) (declaim (inline make-gl-array-from-pointer)) (defun make-gl-array-from-pointer (ptr type count) "Same as ALLOC-GL-ARRAY but uses a supplied pointer instead of allocating new memory." (let ((binder (find-vertex-array-binder type nil))) (if binder (make-gl-vertex-array :pointer ptr :size count :type type :binder binder) (make-gl-array :pointer ptr :size count :type type)))) (defun free-gl-array (array) "Frees an array allocated by ALLOC-GL-ARRAY." (foreign-free (gl-array-pointer array))) (defun make-null-gl-array (type) "Returns a GL-ARRAY with a size of 0, a null pointer and of type TYPE." (make-gl-array-from-pointer (null-pointer) 0 type)) ;;; Returns a pointer to the OFFSET-th element in ARRAY. I think this ;;; is different from mem-aref for simple types. (declaim (inline gl-array-pointer-offset)) (defun gl-array-pointer-offset (array offset) (inc-pointer (gl-array-pointer array) (* (foreign-type-size (gl-array-type array)) offset))) ;;; Returns the number of bytes in the array. (declaim (inline gl-array-byte-size)) (defun gl-array-byte-size (array) (* (gl-array-size array) (foreign-type-size (gl-array-type array)))) (defun bind-gl-vertex-array (array &optional (offset 0)) "Binds ARRAY starting at the OFFSET-th element." (funcall (gl-vertex-array-binder array) (gl-array-pointer-offset array offset))) (defmacro with-gl-array ((var type &key count) &body forms) "Allocates a fresh GL-ARRAY of type TYPE and COUNT elements. The array will be bound to VAR and is freed when execution moves outside WITH-GL-ARRAY." (with-unique-names (ptr) `(with-foreign-object (,ptr ,type ,count) (let ((,var (make-gl-array-from-pointer ,ptr ,type ,count))) (declare (dynamic-extent ,var)) ,@forms)))) ;;; TODO: find a better name. I keep reading this as ;;; glare-f. [2007-03-14 LO] (declaim (inline glaref)) (defun glaref (array index &optional (component nil c-p)) "Returns the INDEX-th component of ARRAY. If COMPONENT is supplied and ARRAY is of a compound type the component named COMPONENT is returned." (if c-p (foreign-slot-value (mem-aref (gl-array-pointer array) (gl-array-type array) index) (gl-array-type array) component) (mem-aref (gl-array-pointer array) (gl-array-type array) index))) (declaim (inline (setf glaref))) (defun (setf glaref) (value array index &optional (component nil c-p)) "Sets the place (GLAREF ARRAY INDEX [COMPONENT]) to VALUE." (if c-p (setf (foreign-slot-value (mem-aref (gl-array-pointer array) (gl-array-type array) index) (gl-array-type array) component) value) (setf (mem-aref (gl-array-pointer array) (gl-array-type array) index) value))) (declaim (inline map-buffer-to-gl-array)) (defun map-buffer-to-gl-array (target access type) "This is like MAP-BUFFER but returns a GL-ARRAY instead of a plain pointer. Note that you must not call FREE-GL-ARRAY but UNMAP-BUFFER on the return value." (make-gl-array-from-pointer (map-buffer target access) type (floor (get-buffer-parameter target :buffer-size :int) (foreign-type-size type)))) (defmacro with-mapped-buffer ((p target access) &body body) "Maps the buffer currently bound to TARGET with ACCESS storing the returned pointer in P. The buffer is unmapped when execution leaves WITH-MAPPED-BUFFER. Note that this will break when another buffer is bound within FORMS." (once-only (target) `(let ((,p (map-buffer ,target ,access))) (unwind-protect (progn ,@body) (unmap-buffer ,target))))) (defmacro with-gl-mapped-buffer ((a target access type) &body body) "This is like WITH-MAPPED-BUFFER, but maps to a GL-ARRAY instead." (with-unique-names (p) `(with-mapped-buffer (,p ,target ,access) (let ((,a (make-gl-array-from-pointer ,p ,type))) (declare (dynamic-extent ,a)) ,@body)))) ;;; ;;; 2.10 Rectangles ;;; (definline rect (x1 y1 x2 y2) (%gl:rect-f x1 y1 x2 y2)) ;;; ;;; 2.11 Coordinate Transformations ;;; ;;; 2.11.1 Controlling the Viewport (import-export %gl:depth-range %gl:viewport) ;;; 2.11.2 Matrices (import-export %gl:matrix-mode) (defmacro with-foreign-matrix ((sym matrix) &body body) `(with-foreign-object (,sym '%gl:float 16) (dotimes (i 16) (setf (mem-aref ,sym '%gl:float i) (row-major-aref ,matrix i))) ,@body)) (defun load-matrix (matrix) (with-foreign-matrix (foreign-matrix matrix) (%gl:load-matrix-f foreign-matrix))) (defun mult-matrix (matrix) (with-foreign-matrix (foreign-matrix matrix) (%gl:mult-matrix-f foreign-matrix))) (defun load-transpose-matrix (matrix) (with-foreign-matrix (foreign-matrix matrix) (%gl:load-transpose-matrix-f foreign-matrix))) (defun mult-transpose-matrix (matrix) (with-foreign-matrix (foreign-matrix matrix) (%gl:mult-transpose-matrix-f foreign-matrix))) (definline rotate (theta x y z) (%gl:rotate-f theta x y z)) (definline translate (x y z) (%gl:translate-f x y z)) (definline scale (x y z) (%gl:scale-f x y z)) (import-export %gl:frustum %gl:ortho %gl:active-texture %gl:load-identity %gl:push-matrix %gl:pop-matrix) (defmacro with-pushed-matrix (&body body) `(progn (push-matrix) (multiple-value-prog1 (progn ,@body) (pop-matrix)))) ;;; ;;; 2.11.4 Generating Texture Coordinates ;;; (defun tex-gen (coord pname param) (ecase pname (:texture-gen-mode (%gl:tex-gen-i coord pname (foreign-enum-value '%gl:enum param))) ((:object-plane :eye-plane) (with-foreign-object (plane '%gl:float 4) (dotimes (i 4) (setf (mem-aref plane '%gl:float i) (float (elt param i)))) (%gl:tex-gen-fv coord pname plane))))) ;;; ;;; 2.12 Clipping ;;; (defun clip-plane (plane eqn) (when (< (length eqn) 4) (error "EQN must have 4 coefficents.")) (with-opengl-sequence (p '%gl:double eqn) (%gl:clip-plane plane p))) ;;; ;;; 2.13 Current Raster Position ;;; (definline raster-pos (x y &optional (z 0.0) (w 1.0)) (%gl:raster-pos-4f x y z w)) (definline window-pos (x y &optional (z 0.0)) (%gl:window-pos-3f x y z)) ;;; ;;; 2.14 Colors and Coloring ;;; ;;; 2.14.1 Lighting (import-export %gl:front-face) ;;; 2.14.2 Lighting Parameter Specification (defun material (face pname param) (ecase pname ((:ambient :diffuse :ambient-and-diffuse :specular :emission) (with-foreign-object (p '%gl:float 4) (dotimes (i 4) (setf (mem-aref p '%gl:float i) (float (elt param i)))) (%gl:material-fv face pname p))) (:shininess (%gl:material-f face pname (float param))) (:color-indexes (with-foreign-object (p '%gl:int 3) (dotimes (i 3) (setf (mem-aref p '%gl:int i) (elt param i))) (%gl:material-iv face pname p))))) (defun light (light pname value) (ecase pname ((:ambient :diffuse :specular :position) (with-foreign-object (p '%gl:float 4) (dotimes (i 4) (setf (mem-aref p '%gl:float i) (float (elt value i)))) (%gl:light-fv light pname p))) (:spot-direction (with-foreign-object (p '%gl:float 3) (dotimes (i 3) (setf (mem-aref p '%gl:float i) (float (elt value i)))) (%gl:light-fv light pname p))) ((:spot-exponent :spot-cutoff :constant-attenuation :linear-attenuation :quadratic-attenuation) (%gl:light-f light pname (float value))))) (defun light-model (pname value) (ecase pname (:light-model-ambient (with-foreign-object (p '%gl:float 4) (dotimes (i 4) (setf (mem-aref p '%gl:float i) (float (elt value i)))) (%gl:light-model-fv pname p))) (:light-model-color-control (%gl:light-model-i pname (foreign-enum-value '%gl:enum value))) ((:light-model-local-viewer :light-model-two-side) (%gl:light-model-i pname (if value 1 0))))) ;;; 2.14.3 ColorMaterial (import-export %gl:color-material) ;;; 2.14.7 Flatshading (import-export %gl:shade-model) ;;; ;;; 2.15 Vertex Shaders ;;; ;;; 2.15.1 Shader Objects (import-export %gl:create-shader) (defun shader-source (shader string-list) (let ((num-lines (length string-list))) (with-foreign-object (string-array :pointer num-lines) ;; copy the list of Lisp strings into an array of C strings (loop for line in string-list count line into i do (setf (mem-aref string-array :pointer (1- i)) (foreign-string-alloc line))) ;; set the source (%gl:shader-source shader num-lines string-array (null-pointer)) ;; free all allocated strings (dotimes (i num-lines) (foreign-string-free (mem-aref string-array :pointer i))))) string-list) (import-export %gl:compile-shader %gl:delete-shader) ;;; 2.15.2 Program Objects (import-export %gl:create-program %gl:attach-shader %gl:detach-shader %gl:link-program %gl:use-program %gl:delete-program) ;;; 2.15.3 Shader Variables (defun get-active-attrib (program index) "Returns information about the active attribute variable at index INDEX in program PROGRAM as multiple values. 1: Size of attribute. 2: Type of attribute. 3: Name of attribute" (let ((attrib-max-length (get-program program :active-attribute-max-length))) (with-foreign-objects ((characters-written '%gl:sizei) (size '%gl:int) (type :long) (name '%gl:char attrib-max-length)) (%gl:get-active-attrib program index attrib-max-length characters-written size type name) (when (< 0 (mem-ref characters-written '%gl:sizei)) (values (mem-ref size '%gl:int) (foreign-enum-keyword '%gl:enum (mem-ref type :long)) (foreign-string-to-lisp name)))))) ;;; TODO: make these use :STRING (defun get-attrib-location (program name) (with-foreign-string (s name) (%gl:get-attrib-location program s))) (defun bind-attrib-location (program index name) (with-foreign-string (s name) (%gl:bind-attrib-location program index s))) (defun get-uniform-location (program name) (with-foreign-string (s name) (%gl:get-uniform-location program s))) (defun get-active-uniform (program index) "Returns information about the active uniform attribute at index INDEX in program PROGRAM as multiple values. 1: Size of attribute. 2: Type of attribute. 3: Name of attribute" (let ((uniform-max-length (get-program program :active-uniform-max-length))) (with-foreign-objects ((characters-written '%gl:sizei) (size '%gl:int) (type :long) (name '%gl:char uniform-max-length)) (%gl:get-active-uniform program index uniform-max-length characters-written size type name) (when (< 0 (mem-ref characters-written '%gl:sizei)) (values (mem-ref size '%gl:int) (foreign-enum-keyword '%gl:enum (mem-ref type :long)) (foreign-string-to-lisp name)))))) (defun uniformi (location x &optional y z w) (cond (w (%gl:uniform-4i location x y z w)) (z (%gl:uniform-3i location x y z)) (y (%gl:uniform-2i location x y)) (x (%gl:uniform-1i location x)))) (define-compiler-macro uniformi (&whole form location x &optional y z w) (declare (ignore form)) (cond (w `(%gl:uniform-4i ,location ,x ,y ,z ,w)) (z `(%gl:uniform-3i ,location ,x ,y ,z)) (y `(%gl:uniform-2i ,location ,x ,y)) (x `(%gl:uniform-1i ,location ,x)))) (defun uniformf (location x &optional y z w) (cond (w (%gl:uniform-4f location (float x) (float y) (float z) (float w))) (z (%gl:uniform-3f location (float x) (float y) (float z))) (y (%gl:uniform-2f location (float x) (float y))) (x (%gl:uniform-1f location (float x))))) (define-compiler-macro uniformf (&whole form location x &optional y z w) (declare (ignore form)) (cond (w `(%gl:uniform-4f ,location ,(float x) ,(float y) ,(float z) ,(float w))) (z `(%gl:uniform-3f ,location ,(float x) ,(float y) ,(float z))) (y `(%gl:uniform-2f ,location ,(float x) ,(float y))) (x `(%gl:uniform-1f ,location ,(float x))))) (defun uniform-matrix (location dim matrices &optional (transpose t)) (check-type dim (integer 2 4)) (let ((matrix-count (length matrices)) (matrix-size (* dim dim))) (with-foreign-object (array '%gl:float (* matrix-count matrix-size)) (dotimes (i matrix-count) (let ((matrix (aref matrices i))) (dotimes (j matrix-size) (setf (mem-aref array '%gl:float (* i j)) (row-major-aref matrix j))))) (case dim (2 (%gl:uniform-matrix-2fv location matrix-count (if transpose 1 0) array)) (3 (%gl:uniform-matrix-3fv location matrix-count (if transpose 1 0) array)) (4 (%gl:uniform-matrix-4fv location matrix-count (if transpose 1 0) array)))))) ;;; 2.15.4 Shader Execution (import-export %gl:validate-program)
23,099
Common Lisp
.lisp
548
35.757299
80
0.644248
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
45aeb4203bd558c3ee3018bfe2f0560dcaef05373e067b89591692100e16bf9a
21,591
[ -1 ]
21,592
package.lisp
rheaplex_minara/lib/cl-opengl/gl/package.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; Copyright (c) 2004, Oliver Markovic <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions are met: ;;; ;;; o Redistributions of source code must retain the above copyright notice, ;;; this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may be ;;; used to endorse or promote products derived from this software without ;;; specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;;; POSSIBILITY OF SUCH DAMAGE. (defpackage #:cl-opengl (:use #:cl #:cffi) (:nicknames #:opengl #:gl) (:export ;; 2.5 GL Errors #:get-error #:opengl-error #:opengl-error.error-code #:check-error ;; 2.6 Begin/End Paradigm ;; 2.6.1 Begin and End #:begin #:end #:with-primitive #:with-primitives ;; 2.6.2 Polygon Edges #:edge-flag ;; 2.7 Vertex Specification #:vertex #:tex-coord #:multi-tex-coord #:normal #:fog-coord #:color #:secondary-color #:index #:vertex-attrib ;; 2.8 Vertex Arrays #:draw-elements #:alloc-gl-array #:free-gl-array #:define-gl-array-format #:gl-array #:gl-vertex-array #:bind-gl-vertex-array #:with-gl-array #:glaref #:map-buffer-to-gl-array #:with-gl-mapped-buffer #:with-mapped-buffer #:make-null-gl-array #:gl-array-byte-size ;; 2.9 Buffer Objects #:bind-buffer #:delete-buffers #:gen-buffers #:buffer-data #:buffer-sub-data #:map-buffer #:unmap-buffer ;; 2.10 Rectangles #:rect ;; 2.11.1 Controlling the Viewport #:depth-range #:viewport ;; 2.11.2 Matrices #:matrix-mode #:load-matrix #:mult-matrix #:load-transpose-matrix #:mult-transpose-matrix #:rotate #:translate #:scale #:frustum #:ortho #:active-texture #:load-identity #:push-matrix #:pop-matrix #:with-pushed-matrix ;; 2.11.4 Generating Texture Coordinates #:tex-gen ;; 2.12 Clipping #:clip-plane ;; 2.13 Current Raster Position #:raster-pos #:window-pos ;; 2.14.1 Lighting #:front-face ;; 2.14.2 Lighting Parameter Specification #:material #:light #:light-model ;; 2.14.3 ColorMaterial #:color-material ;; 2.14.7 Flatshading #:shade-model ;; 2.15.1 Shader Objects #:create-shader #:shader-source #:compile-shader #:delete-shader ;; 2.15.2 Program Objects #:create-program #:attach-shader #:detach-shader #:link-program #:use-program #:delete-program ;; 2.15.3 Shader Variables #:get-active-attrib #:get-attrib-location #:bind-attrib-location #:get-uniform-location #:get-active-uniform #:uniformi #:uniformf #:uniform-matrix ;; 2.15.4 Shader Execution #:validate-program ;; 3.3 Points #:point-size #:point-parameter ;; 3.4 Line Segments #:line-width #:line-stipple ;; 3.5 Polygons ;; 3.5.1 Basic Polygon Rasterization #:cull-face ;; 3.5.2 Stippling #:polygon-stipple ;; 3.5.4 Options Controlling Polygon Rasterization #:polygon-mode #:polygon-offset ;; 3.6.1 Pixel Storage Modes #:pixel-store ;; 3.6.3 Pixel Transfer Modes #:pixel-transfer #:pixel-map ;; 3.6.4 Pixel Rasterization #:draw-pixels ;; 3.8.1 Texture Image Specification #:tex-image-1d #:tex-image-2d #:tex-image-3d ;; 3.8.2 Alternate Texture Image Specification Commands #:copy-tex-image-1d #:copy-tex-image-2d #:tex-sub-image-1d #:tex-sub-image-2d #:tex-sub-image-3d #:copy-tex-sub-image-1d #:copy-tex-sub-image-2d #:copy-tex-sub-image-3d ;; 3.8.3 Compressed Texture Images #:compressed-tex-image-1d #:compressed-tex-image-2d #:compressed-tex-image-3d #:compressed-tex-sub-image-1d #:compressed-tex-sub-image-2d #:compressed-tex-sub-image-3d ;; 3.8.4 Texture Parameters #:tex-parameter ;; 3.8.12 Texture Objects #:bind-texture #:delete-textures #:gen-textures #:are-textures-resident #:prioritize-textures #:texture-resident-p #:prioritize-texture ;; 3.8.13 Texture Environments and Texture Functions #:tex-env ;; 3.10 Fog #:fog ;; 5.4 Display Lists #:new-list #:end-list #:with-new-list #:call-list #:call-lists #:list-base #:gen-lists #:display-list-p #:delete-lists ;; 4.1.2 Scissor Test #:scissor ;; 4.1.3 Multisample Fragment Operations #:sample-coverage ;; 4.1.4 Alpha Test #:alpha-func ;; 4.1.5 Stencil Test #:stencil-func #:stencil-func-separate #:stencil-op #:stencil-op-separate ;; 4.1.6 Depth Buffer Test #:depth-func ;; 4.1.7 Occlusion Queries #:begin-query #:end-query #:gen-queries #:delete-queries ;; 4.1.8 Blending #:blend-equation #:blend-equation-separate #:blend-func #:blend-func-separate #:blend-color ;; 4.1.10 Logical Operation #:logic-op ;; 4.2.1 Selecting a Buffer for Writing #:draw-buffer #:draw-buffers ;; 4.2.2 Fine Control of Buffer Updates #:index-mask #:color-mask #:depth-mask #:stencil-mask #:stencil-mask-separate ;; 4.2.3 Clearing the Buffers #:clear #:clear-color #:clear-index #:clear-depth #:clear-stencil #:clear-accum ;; 4.2.4 The Accumulation Buffer #:accum ;; 4.3.2 Reading Pixels #:read-pixels #:read-buffer ;; 4.3.3 Copying Pixels #:copy-pixels ;; 5.1 Evaluation #:map1 #:map2 #:eval-coord-1 #:eval-coord-2 #:map-grid-1 #:map-grid-2 #:eval-mesh-1 #:eval-mesh-2 #:eval-point-1 #:eval-point-2 ;; 5.2 Selection #:init-names #:pop-name #:push-name #:load-name #:render-mode #:select-buffer ;; 5.3 Feedback #:feedback-buffer #:pass-through ;; 5.4 Display Lists #:new-list #:end-list #:call-list #:list-base #:gen-lists #:is-list #:delete-lists ;; 5.5 Flush and Finish #:flush #:finish ;; 5.6 Hints #:hint ;; 6.1.1 Simple Queries #:get-boolean #:get-integer #:get-float #:get-double #:get-enum #:enable #:disable #:enabledp ;; 6.1.11 Pointer and String Queries #:get-string #:major-version #:minor-version #:extension-present-p ;; 6.1.14 Shader and Program Queries #:is-shader #:get-shader #:is-program #:get-program #:get-attached-shaders #:get-shader-info-log #:get-program-info-log #:get-shader-source ;; 6.1.15 Saving and Restoring State #:push-attrib #:push-client-attrib #:with-pushed-attrib #:pop-attrib #:pop-client-attrib #:with-pushed-client-attrib ;; Extensions #:is-renderbuffer-ext #:bind-renderbuffer-ext #:delete-renderbuffers-ext #:gen-renderbuffers-ext #:renderbuffer-storage-ext #:is-framebuffer-ext #:bind-framebuffer-ext #:delete-framebuffers-ext #:gen-framebuffers-ext #:check-framebuffer-status-ext #:framebuffer-texture-1d-ext #:framebuffer-texture-2d-ext #:framebuffer-texture-3d-ext #:framebuffer-renderbuffer-ext #:generate-mipmap-ext ))
8,194
Common Lisp
.lisp
334
20.799401
79
0.673495
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
518a71b9c519a33939eaeb4cfa9067c93240db0d3fc41b99675618e6a45c67e0
21,592
[ -1 ]
21,593
util.lisp
rheaplex_minara/lib/cl-opengl/gl/util.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; Copyright (c) 2004, Oliver Markovic <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions are met: ;;; ;;; o Redistributions of source code must retain the above copyright notice, ;;; this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may be ;;; used to endorse or promote products derived from this software without ;;; specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;;; POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-opengl) ;;; the following three where taken from CFFI (defun starts-with (list x) "Is x a list whose first element is x?" (and (consp list) (eql (first list) x))) (defun side-effect-free? (exp) "Is exp a constant, variable, or function, or of the form (THE type x) where x is side-effect-free?" (or (atom exp) (constantp exp) (starts-with exp 'function) (and (starts-with exp 'the) (side-effect-free? (third exp))))) (defmacro once-only (variables &rest body) "Returns the code built by BODY. If any of VARIABLES might have side effects, they are evaluated once and stored in temporary variables that are then passed to BODY." (assert (every #'symbolp variables)) (let ((temps nil)) (dotimes (i (length variables)) (push (gensym "ONCE") temps)) `(if (every #'side-effect-free? (list .,variables)) (progn .,body) (list 'let ,`(list ,@(mapcar #'(lambda (tmp var) `(list ',tmp ,var)) temps variables)) (let ,(mapcar #'(lambda (var tmp) `(,var ',tmp)) variables temps) .,body))))) (defun symbolic-type->real-type (type) (ecase type (:byte '%gl:byte) (:unsigned-byte '%gl:ubyte) (:bitmap '%gl:ubyte) (:short '%gl:short) (:unsigned-short '%gl:ushort) (:int '%gl:int) (:unsigned-int '%gl:uint) (:float '%gl:float) (:unsigned-byte-3-3-2 '%gl:ubyte) (:unsigned-byte-2-3-3-rev '%gl:ubyte) (:unsigned-short-5-6-5 '%gl:ushort) (:unsigned-short-5-6-5-rev '%gl:ushort) (:unsigned-short-4-4-4-4 '%gl:ushort) (:unsigned-short-4-4-4-4-rev '%gl:ushort) (:unsigned-short-5-5-5-1 '%gl:ushort) (:unsigned-short-1-5-5-5-rev '%gl:ushort) (:unsigned-int-8-8-8-8 '%gl:uint) (:unsigned-int-8-8-8-8-rev '%gl:uint) (:unsigned-int-10-10-10-2 '%gl:uint) (:unsigned-int-2-10-10-10-rev '%gl:uint))) ;;; Converts a CFFI type to the appropriate GL enum. (defun cffi-type-to-gl (type) (ecase type (:signed-char :byte) (:unsigned-char :unsigned-byte) ((:short :signed-short) :short) (:unsigned-short :unsigned-short) ((:int :signed-int) :int) (:unsigned-int :unsigned-int) (:float :float) (:double :double))) (defmacro with-opengl-array ((var type lisp-array) &body body) (check-type var symbol) (let ((count (gensym "COUNT")) (array (gensym "ARRAY"))) (once-only (type) `(let* ((,array ,lisp-array) (,count (length ,array))) (with-foreign-object (,var ,type ,count) ;; we need type to be a constant within the loop so cffi can ;; optimize it, so check type outside the loop, and make a ;; copy of the loop for any types we care about (case ,type ,@(loop for ctype in '(%gl:byte %gl:ubyte %gl:short %gl:ushort %gl:int %gl:uint %gl:float) collect `(,ctype (loop for i below ,count do (setf (mem-aref ,var ',ctype i) (aref ,array i))))) (t (loop for i below ,count do (setf (mem-aref ,var ,type i) (aref ,array i))))) ,@body))))) (defmacro with-opengl-arrays (bindings &body body) (if (null bindings) `(let nil ,@body) `(with-opengl-array ,(car bindings) (with-opengl-arrays ,(cdr bindings) ,@body)))) (defmacro with-pixel-array ((var type lisp-array) &body body) `(with-opengl-array (,var (symbolic-type->real-type ,type) ,lisp-array) ,@body)) ;;; TODO: maybe define opengl-sequence as a CFFI type. possibly something ;;; that would enforce a given length and type. (defmacro with-opengl-sequence ((var type lisp-sequence) &body body) (check-type var symbol) (flet ((converting (form) ; um, assuming type is constant (case (eval type) ; silly hack.. FIXME (float `(float ,form)) (double `(float ,form 1.0d0)) (t form)))) (let ((count (gensym "COUNT"))) (once-only (type lisp-sequence) `(let ((,count (length ,lisp-sequence))) (with-foreign-object (,var ,type ,count) (loop for i below ,count do (setf (mem-aref ,var ,type i) ,(converting `(elt ,lisp-sequence i)))) ,@body)))))) ;;; The following utils were taken from SBCL's ;;; src/code/*-extensions.lisp (defun symbolicate-package (package &rest things) "Concatenate together the names of some strings and symbols, producing a symbol in the current package." (let* ((length (reduce #'+ things :key (lambda (x) (length (string x))))) (name (make-array length :element-type 'character))) (let ((index 0)) (dolist (thing things (values (intern name package))) (let* ((x (string thing)) (len (length x))) (replace name x :start1 index) (incf index len)))))) (defun symbolicate (&rest things) (apply #'symbolicate-package *package* things)) ;;; Automate an idiom often found in macros: ;;; (LET ((FOO (GENSYM "FOO")) ;;; (MAX-INDEX (GENSYM "MAX-INDEX-"))) ;;; ...) ;;; ;;; "Good notation eliminates thought." -- Eric Siggia ;;; ;;; Incidentally, this is essentially the same operator which ;;; _On Lisp_ calls WITH-GENSYMS. (defmacro with-unique-names (symbols &body body) `(let ,(mapcar (lambda (symbol) (let* ((symbol-name (symbol-name symbol)) (stem (if (every #'alpha-char-p symbol-name) symbol-name (concatenate 'string symbol-name "-")))) `(,symbol (gensym ,stem)))) symbols) ,@body)) ;;; Yes, this is somewhat silly since package.lisp interns and exports ;;; the symbols then we unintern, import from %GL and re-export. It, ;;; however, (a) avoids importing the %GL package which shadows some ;;; CL symbols, (b) allows us to keep a full list of exported symbols ;;; in package.lisp, (c) serves as documentation regarding which ;;; functions are being exposed directly and (d) avoids that dreaded ;;; SBCL PACKAGE-AT-VARIANCE warning. (defmacro import-export (&rest symbols) `(eval-when (:compile-toplevel :load-toplevel :execute) ;; Unintern first to avoid conflicts. (dolist (sym ',symbols) (let ((s (find-symbol (symbol-name sym)))) (when s (unintern s)))) ;; Import and re-export. (import ',symbols) (export ',symbols))) (defmacro definline (name args &body body) `(progn (declaim (inline ,name)) (defun ,name ,args ,@body))) ;;; A generic generator for all kinds of OpenGL get functions ;;; (define-get-function NAME (ARG1 ARG2 ... ARGn) ;;; (TYPE1 FUNC1) ;;; (TYPE2 FUNC2) ;;; ...) ;;; ;;; defines a function (NAME ARG1 ... ARGn TYPE [COUNT]) which calls ;;; the right FUNCi where TYPEi equals TYPE like (FUNCi ARG1 ... ARGn ;;; P) where P is a pointer to COUNT values of TYPE. when COUNT is ;;; odmitted or 1 a simple value is returned, a list of values ;;; otherwise. ;;; ;;; NOTE: should we drop this function or extend define-query-function ;;; to allow more than one argument? Do we want one function per ;;; return type or the return type as argument (with sane ;;; default? per hashtable lookup? also for count?) (defmacro define-get-function (name (&rest head-args) &body clauses) (with-unique-names (return-type return-count p) `(defun ,name (,@head-args ,return-type &optional (,return-count 1)) (with-foreign-object (,p ,return-type ,return-count) (ecase ,return-type ,@(loop for (func . types) in clauses collect `((,@types) (,func ,@head-args ,p)))) (if (= ,return-count 1) (mem-aref ,p ,return-type 0) (loop for i from 0 to (1- ,return-count) collect (mem-aref ,p ,return-type i))))))) ;;; (define-array-pointer NAME BUILTIN-NAME ARG*) defines a very thin ;;; wrapper over BUILTIN-NAME to allow passing a GL-ARRAY,[OFFSET] ;;; last arguments to glFooPointer insteand of a pointer. (defmacro define-array-pointer (name builtin-name &rest head-args) (with-unique-names (array offset) `(definline ,name (,@head-args ,array ,offset) (,builtin-name ,@head-args (gl-array-pointer-offset ,array ,offset)))))
10,141
Common Lisp
.lisp
225
38.906667
79
0.632616
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e5d36b14ea0705825c5bcb4ce1ab368311b89af1a84fb6a51d69bd02577d7947
21,593
[ 489825 ]
21,594
framebuffer.lisp
rheaplex_minara/lib/cl-opengl/gl/framebuffer.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; Copyright (c) 2004, Oliver Markovic <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions are met: ;;; ;;; o Redistributions of source code must retain the above copyright notice, ;;; this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may be ;;; used to endorse or promote products derived from this software without ;;; specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;;; POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-opengl) ;;; ;;; Chapter 4 - Per-fragment Operations and the Framebuffer ;;; ;;; ;;; 4.1 Per-fragment Operations ;;; ;;; 4.1.2 Scissor Test (import-export %gl:scissor) ;;; 4.1.3 Multisample Fragment Operations (import-export %gl:sample-coverage) ;;; 4.1.4 Alpha Test (import-export %gl:alpha-func) ;;; 4.1.5 Stencil Test (import-export %gl:stencil-func %gl:stencil-func-separate %gl:stencil-op %gl:stencil-op-separate) ;;; 4.1.6 Depth Buffer Test (import-export %gl:depth-func) ;;; 4.1.7 Occlusion Queries (import-export %gl:begin-query %gl:end-query) (defun gen-queries (n) "Returns N previously unused query object names in a list. These names are marked as used, but no object is associated with them until the first time they are used by BEGIN-QUERY." (with-foreign-object (ids '%gl:uint n) (%gl:gen-queries n ids) (loop for i below n collecting (mem-aref ids '%gl:uint i)))) (defun delete-queries (ids) "Deletes the names of the query objects contained in the sequence IDS." (let ((count (length ids))) (with-foreign-object (id-array '%gl:uint count) (loop for id in ids counting id into i do (setf (mem-aref id-array '%gl:uint (1- i)) id)) (%gl:delete-queries count id-array)))) ;;; 4.1.8 Blending (import-export %gl:blend-equation %gl:blend-equation-separate %gl:blend-func %gl:blend-func-separate %gl:blend-color) ;;; 4.1.10 Logical Operation (import-export %gl:logic-op) ;;; ;;; 4.2 Whole Framebuffer Operation ;;; ;;; 4.2.1 Selecting a Buffer for Writing (import-export %gl:draw-buffer) (defun draw-buffers (buffers) (with-opengl-sequence (seq '%gl:enum buffers) (%gl:draw-buffers (length buffers) seq))) ;;; 4.2.2 Fine Control of Buffer Updates (import-export %gl:index-mask %gl:color-mask %gl:depth-mask %gl:stencil-mask %gl:stencil-mask-separate) ;;; 4.2.3 Clearing the Buffers (definline clear (&rest bufs) (%gl:clear (make-bitfield '%gl:enum bufs))) (define-compiler-macro clear (&whole form &rest bufs) (if (every #'keywordp bufs) `(%gl:clear ,(make-bitfield '%gl:enum bufs)) form)) (import-export %gl:clear-color %gl:clear-index %gl:clear-depth %gl:clear-stencil %gl:clear-accum) ;;; 4.2.4 The Accumulation Buffer (import-export %gl:accum) ;;; ;;; 4.3 Drawing, Reading and Copying Pixels ;;; ;;; 4.3.2 Reading Pixels (defun read-pixels (x y width height format type) (let* ((mult (ecase format ((:red :green :blue :alpha :luminance) 1) ((:depth-component :color-index :stencil-index) 1) (:luminance-alpha 2) ((:rgb :bgr) 3) ((:rgba :bgra) 4))) (size (* width height mult)) (result-data (make-sequence 'vector size)) (real-type (symbolic-type->real-type type))) (with-foreign-object (array real-type size) (%gl:read-pixels x y width height format type array) (dotimes (i size result-data) (setf (svref result-data i) (mem-aref array real-type i)))))) (import-export %gl:read-buffer) ;;; 4.3.3 Copying Pixels (import-export %gl:copy-pixels)
5,041
Common Lisp
.lisp
125
35.272
79
0.674256
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
7bb76703439188c8a03fc2cca6ef8d75fd6f2e5d7af24c0ff0e8544ed83a8571
21,594
[ 424195 ]
21,595
types.lisp
rheaplex_minara/lib/cl-opengl/gl/types.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; Copyright (c) 2004, Oliver Markovic <[email protected]> ;;; Copyright (c) 2007, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions are met: ;;; ;;; o Redistributions of source code must retain the above copyright notice, ;;; this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may be ;;; used to endorse or promote products derived from this software without ;;; specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;;; POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-opengl-bindings) ;;;; GL types. ;;; Note: the symbols BOOLEAN, BYTE, FLOAT, CHAR and STRING have been ;;; shadowed from the CL package. (define-foreign-type ensure-integer () () (:actual-type :int) (:simple-parser ensure-integer)) (defmethod translate-to-foreign (value (type ensure-integer)) (truncate value)) (defmethod expand-to-foreign (value (type ensure-integer)) (if (constantp value) (truncate (eval value)) `(truncate ,value))) (define-foreign-type ensure-float () () (:actual-type :float) (:simple-parser ensure-float)) (defmethod translate-to-foreign (value (type ensure-float)) (cl:float value 1.0)) (defmethod expand-to-foreign (value (type ensure-float)) (if (constantp value) (cl:float (eval value) 1.0) `(cl:float ,value 1.0))) (define-foreign-type ensure-double () () (:actual-type :double) (:simple-parser ensure-double)) (defmethod translate-to-foreign (value (type ensure-double)) (cl:float value 1.0d0)) (defmethod expand-to-foreign (value (type ensure-double)) (if (constantp value) (cl:float (eval value) 1.0d0) `(cl:float ,value 1.0d0))) ;;;; Deftypes (defctype boolean (:boolean :unsigned-char)) (defctype bitfield :unsigned-int) (defctype char :char) (defctype char-arb :char) (defctype handle-arb :unsigned-int) (defctype byte :char) (defctype short :short) (defctype int ensure-integer) (defctype sizei ensure-integer) (defctype ubyte :unsigned-char) (defctype ushort :unsigned-short) (defctype uint :unsigned-int) (defctype half :unsigned-short) (defctype half-arb :unsigned-short) (defctype half-nv :unsigned-short) (defctype int64 :int64) (defctype uint64 :uint64) (defctype void :void) (defctype string :string) ;;; XXX these will be broken on 64-bit systems that do not have 64-bit ;;; longs, such as Win64. Need to define this type in CFFI and it may ;;; require some sort of grovelling or guessing. (defctype ptrdiff-t :unsigned-long) (defctype intptr ptrdiff-t) (defctype intptr-arb ptrdiff-t) (defctype sizeiptr ptrdiff-t) (defctype sizeiptr-arb ptrdiff-t) (defctype float ensure-float) (defctype clampf ensure-float) (defctype double ensure-double) (defctype clampd ensure-double)
3,949
Common Lisp
.lisp
95
39.684211
79
0.751303
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
614b1ab05bd1b5ed952fa62e44afdf3c32c0f8e53c79efe5f31a3972c38a34f5
21,595
[ 291337 ]
21,596
library.lisp
rheaplex_minara/lib/cl-opengl/gl/library.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; library.lisp --- Foreign library definition ;;; ;;; Copyright (C) 2006-2007, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-opengl-bindings) (define-foreign-library opengl (:darwin (:framework "OpenGL")) (:windows "opengl32.dll" :calling-convention :stdcall) (:unix (:or "libGL.so" "libGL.so.2" "libGL.so.1"))) (use-foreign-library opengl)
1,972
Common Lisp
.lisp
37
52.054054
75
0.753106
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
690b45689f6489dcb4c37fd72077b364d0b9307717a3cf7264845bf6b63f976e
21,596
[ 367878 ]
21,598
bindings.lisp
rheaplex_minara/lib/cl-opengl/gl/bindings.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; Copyright (c) 2004, Oliver Markovic <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions are met: ;;; ;;; o Redistributions of source code must retain the above copyright notice, ;;; this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may be ;;; used to endorse or promote products derived from this software without ;;; specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;;; POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-opengl-bindings) ;;; Helper macro to define a GL API function and declare it inline. (defmacro defglfun ((cname lname) result-type &body body) `(progn (declaim (inline ,lname)) (defcfun (,cname ,lname :library opengl) ,result-type ,@body))) ;;;; Extensions ;;; TODO: need to handle multiple contexts. ;;; ;;; TODO: probably should have the option of using directly exported ;;; functions on platforms that have them, but that would need ;;; to deal with the possibility of a core being loaded on a ;;; system with different functions exported than the one on ;;; which the core was saved. ;;; Set this to a function which knows how to get a GL extension ;;; pointer from the OS: glutGetProcAddress(), SDL_GL_GetProcAddress(), ;;; wglGetProcAddress(), etc. (defparameter *gl-get-proc-address* nil) (defun gl-get-proc-address (name) (funcall *gl-get-proc-address* name)) (eval-when (:load-toplevel :execute) #+clisp (pushnew 'reset-gl-pointers custom:*fini-hooks*) #+sbcl (pushnew 'reset-gl-pointers sb-ext:*save-hooks*) #+cmu (pushnew 'reset-gl-pointers ext:*before-save-initializations*) #-(or clisp sbcl cmu) (warn "Don't know how to setup a hook before saving cores on this Lisp.")) ;;;; Bart's version of DEFGLEXTFUN. #-(and) (defparameter *gl-extension-resetter-list* nil) ;;; FIXME? There's a possible race condition here, but this function ;;; is intended to be called while saving an image, so if someone is ;;; still calling GL functions we lose anyway... #-(and) (defun reset-gl-pointers () (format t "~&;; resetting extension pointers...~%") (mapc #'funcall *gl-extension-resetter-list*) (setf *gl-extension-resetter-list* nil)) #-(and) (defmacro defglextfun ((cname lname) return-type &body args) (with-unique-names (pointer) `(let ((,pointer (null-pointer))) (defun ,lname ,(mapcar #'car args) (when (null-pointer-p ,pointer) (setf ,pointer (%gl-get-proc-address ,cname)) (assert (not (null-pointer-p ,pointer)) () "Couldn't load symbol ~A~%" ,cname) (format t "Loaded function pointer for ~A: ~A~%" ,cname ,pointer) (push (lambda () (setf ,pointer (null-pointer))) *gl-extension-resetter-list*)) (foreign-funcall-pointer ,pointer (:library opengl) ,@(loop for arg in args collect (second arg) collect (first arg)) ,return-type))))) ;;;; Thomas's version of DEFGLEXTFUN. (defun reset-gl-pointers () (do-external-symbols (sym (find-package '#:%gl)) (let ((dummy (get sym 'proc-address-dummy))) (when dummy (setf (fdefinition sym) dummy))))) (defun generate-gl-function (foreign-name lisp-name result-type body &rest args) (let ((address (gl-get-proc-address foreign-name)) (arg-list (mapcar #'first body))) (when (or (not (pointerp address)) (null-pointer-p address)) (error "Couldn't find function ~A" foreign-name)) (compile lisp-name `(lambda ,arg-list (foreign-funcall-pointer ,address (:library opengl) ,@(loop for i in body collect (second i) collect (first i)) ,result-type))) (apply lisp-name args))) (defmacro defglextfun ((foreign-name lisp-name) result-type &rest body) (let ((args-list (mapcar #'first body))) `(progn (declaim (notinline ,lisp-name)) (defun ,lisp-name ,args-list (generate-gl-function ,foreign-name ',lisp-name ',result-type ',body ,@args-list)) (setf (get ',lisp-name 'proc-address-dummy) #',lisp-name) ',lisp-name)))
5,428
Common Lisp
.lisp
112
43.3125
80
0.676476
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
fc67be476451fd46d14768beb566d4c064eb1e6f33c01eac2e7fe11823b0e35e
21,598
[ 121306 ]
21,599
special.lisp
rheaplex_minara/lib/cl-opengl/gl/special.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; Copyright (c) 2004, Oliver Markovic <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions are met: ;;; ;;; o Redistributions of source code must retain the above copyright notice, ;;; this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may be ;;; used to endorse or promote products derived from this software without ;;; specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;;; POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-opengl) ;;; ;;; Chapter 5 - Special Functions ;;; ;;; ;;; 5.1 Evaluators ;;; (defun map1 (target u1 u2 points) (let* ((stride (array-dimension points 1)) (order (array-dimension points 0)) (count (* stride order))) (with-foreign-object (array '%gl:float count) (dotimes (i count) (setf (mem-aref array '%gl:float i) (float (row-major-aref points i)))) (%gl:map-1f target (float u1) (float u2) stride order array)))) (defun map2 (target u1 u2 v1 v2 points) (let* ((ustride (array-dimension points 2)) (uorder (array-dimension points 1)) (vstride (* ustride uorder)) (vorder (array-dimension points 0)) (count (* vorder ustride uorder))) (with-foreign-object (array '%gl:float count) (dotimes (i count) (setf (mem-aref array '%gl:float i) (float (row-major-aref points i)))) (%gl:map-2f target (float u1) (float u2) ustride uorder (float v1) (float v2) vstride vorder array)))) (definline eval-coord-1 (x) (%gl:eval-coord-1f x)) (definline eval-coord-2 (x y) (%gl:eval-coord-2f x y)) (definline map-grid-1 (n u1 u2) (%gl:map-grid-1f n u1 u2)) (definline map-grid-2 (nu u1 u2 nv v1 v2) (%gl:map-grid-2f nu u1 u2 nv v1 v2)) (import-export %gl:eval-mesh-1 %gl:eval-mesh-2 %gl:eval-point-1 %gl:eval-point-2) ;;; ;;; 5.2 Selection ;;; (import-export %gl:init-names %gl:pop-name %gl:push-name %gl:load-name %gl:render-mode) (defun select-buffer (array) (declare (ignore array)) (error "not implemented")) ;;; ;;; 5.3 Feedback ;;; (defun feedback-buffer (array) (declare (ignore array)) (error "not implemented")) (import-export %gl:pass-through) ;;; ;;; 5.4 Display Lists ;;; (import-export %gl:new-list %gl:end-list %gl:call-list) ;;; Maybe we could optimize some more here if LISTS is vector ;;; with a suitable element-type. (defun call-lists (lists) (with-opengl-sequence (array '%gl:uint lists) (%gl:call-lists (length lists) #.(foreign-enum-value '%gl:enum :unsigned-int) array))) (import-export %gl:list-base %gl:gen-lists ;; to be consistent we probably should rename this ;; LISTP but it'd conflict with CL:LISTP %gl:is-list %gl:delete-lists) ;;; Maybe UNWIND-PROTECT instead of PROG2? (defmacro with-new-list ((id mode) &body body) `(prog2 (new-list ,id ',mode) (progn ,@body) (end-list))) ;;; ;;; 5.5 Flush and Finish ;;; (import-export %gl:flush %gl:finish) ;;; ;;; 5.6 Hints ;;; (import-export %gl:hint)
4,464
Common Lisp
.lisp
119
32.512605
79
0.656019
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
1e757aaeb45420e8cedb527fbec806c9a002ee2c7bf32500cc387d64a345db36
21,599
[ -1 ]
21,600
bindings-package.lisp
rheaplex_minara/lib/cl-opengl/gl/bindings-package.lisp
;;; generated file, do not edit ;;; glext version 40 ( 2008/03/24 ) (defpackage #:cl-opengl-bindings (:nicknames #:%gl) (:use #:common-lisp #:cffi) (:shadow #:char #:float #:byte #:boolean #:string) (:export #:enum #:*glext-version* #:*glext-last-updated* #:*gl-get-proc-address* ;; Types. #:char #:char-arb #:intptr #:sizeiptr #:intptr-arb #:sizeiptr-arb #:handle-arb #:half #:half-arb #:half-nv #:int64 #:uint64 #:clampd #:double #:clampf #:float #:sizei #:uint #:ushort #:ubyte #:int #:short #:byte #:void #:bitfield #:boolean #:string #:int64-ext #:uint64-ext ;; Functions. #:new-list #:end-list #:call-list #:call-lists #:delete-lists #:gen-lists #:list-base #:begin #:bitmap #:color-3b #:color-3bv #:color-3d #:color-3dv #:color-3f #:color-3fv #:color-3i #:color-3iv #:color-3s #:color-3sv #:color-3ub #:color-3ubv #:color-3ui #:color-3uiv #:color-3us #:color-3usv #:color-4b #:color-4bv #:color-4d #:color-4dv #:color-4f #:color-4fv #:color-4i #:color-4iv #:color-4s #:color-4sv #:color-4ub #:color-4ubv #:color-4ui #:color-4uiv #:color-4us #:color-4usv #:edge-flag #:edge-flag-v #:end #:index-d #:index-dv #:index-f #:index-fv #:index-i #:index-iv #:index-s #:index-sv #:normal-3b #:normal-3bv #:normal-3d #:normal-3dv #:normal-3f #:normal-3fv #:normal-3i #:normal-3iv #:normal-3s #:normal-3sv #:raster-pos-2d #:raster-pos-2dv #:raster-pos-2f #:raster-pos-2fv #:raster-pos-2i #:raster-pos-2iv #:raster-pos-2s #:raster-pos-2sv #:raster-pos-3d #:raster-pos-3dv #:raster-pos-3f #:raster-pos-3fv #:raster-pos-3i #:raster-pos-3iv #:raster-pos-3s #:raster-pos-3sv #:raster-pos-4d #:raster-pos-4dv #:raster-pos-4f #:raster-pos-4fv #:raster-pos-4i #:raster-pos-4iv #:raster-pos-4s #:raster-pos-4sv #:rect-d #:rect-dv #:rect-f #:rect-fv #:rect-i #:rect-iv #:rect-s #:rect-sv #:tex-coord-1d #:tex-coord-1dv #:tex-coord-1f #:tex-coord-1fv #:tex-coord-1i #:tex-coord-1iv #:tex-coord-1s #:tex-coord-1sv #:tex-coord-2d #:tex-coord-2dv #:tex-coord-2f #:tex-coord-2fv #:tex-coord-2i #:tex-coord-2iv #:tex-coord-2s #:tex-coord-2sv #:tex-coord-3d #:tex-coord-3dv #:tex-coord-3f #:tex-coord-3fv #:tex-coord-3i #:tex-coord-3iv #:tex-coord-3s #:tex-coord-3sv #:tex-coord-4d #:tex-coord-4dv #:tex-coord-4f #:tex-coord-4fv #:tex-coord-4i #:tex-coord-4iv #:tex-coord-4s #:tex-coord-4sv #:vertex-2d #:vertex-2dv #:vertex-2f #:vertex-2fv #:vertex-2i #:vertex-2iv #:vertex-2s #:vertex-2sv #:vertex-3d #:vertex-3dv #:vertex-3f #:vertex-3fv #:vertex-3i #:vertex-3iv #:vertex-3s #:vertex-3sv #:vertex-4d #:vertex-4dv #:vertex-4f #:vertex-4fv #:vertex-4i #:vertex-4iv #:vertex-4s #:vertex-4sv #:clip-plane #:color-material #:cull-face #:fog-f #:fog-fv #:fog-i #:fog-iv #:front-face #:hint #:light-f #:light-fv #:light-i #:light-iv #:light-model-f #:light-model-fv #:light-model-i #:light-model-iv #:line-stipple #:line-width #:material-f #:material-fv #:material-i #:material-iv #:point-size #:polygon-mode #:polygon-stipple #:scissor #:shade-model #:tex-parameter-f #:tex-parameter-fv #:tex-parameter-i #:tex-parameter-iv #:tex-image-1d #:tex-image-2d #:tex-env-f #:tex-env-fv #:tex-env-i #:tex-env-iv #:tex-gen-d #:tex-gen-dv #:tex-gen-f #:tex-gen-fv #:tex-gen-i #:tex-gen-iv #:feedback-buffer #:select-buffer #:render-mode #:init-names #:load-name #:pass-through #:pop-name #:push-name #:draw-buffer #:clear #:clear-accum #:clear-index #:clear-color #:clear-stencil #:clear-depth #:stencil-mask #:color-mask #:depth-mask #:index-mask #:accum #:disable #:enable #:finish #:flush #:pop-attrib #:push-attrib #:map-1d #:map-1f #:map-2d #:map-2f #:map-grid-1d #:map-grid-1f #:map-grid-2d #:map-grid-2f #:eval-coord-1d #:eval-coord-1dv #:eval-coord-1f #:eval-coord-1fv #:eval-coord-2d #:eval-coord-2dv #:eval-coord-2f #:eval-coord-2fv #:eval-mesh-1 #:eval-point-1 #:eval-mesh-2 #:eval-point-2 #:alpha-func #:blend-func #:logic-op #:stencil-func #:stencil-op #:depth-func #:pixel-zoom #:pixel-transfer-f #:pixel-transfer-i #:pixel-store-f #:pixel-store-i #:pixel-map-fv #:pixel-map-uiv #:pixel-map-usv #:read-buffer #:copy-pixels #:read-pixels #:draw-pixels #:get-boolean-v #:get-clip-plane #:get-double-v #:get-error #:get-float-v #:get-integer-v #:get-light-fv #:get-light-iv #:get-map-dv #:get-map-fv #:get-map-iv #:get-material-fv #:get-material-iv #:get-pixel-map-fv #:get-pixel-map-uiv #:get-pixel-map-usv #:get-polygon-stipple #:get-string #:get-tex-env-fv #:get-tex-env-iv #:get-tex-gen-dv #:get-tex-gen-fv #:get-tex-gen-iv #:get-tex-image #:get-tex-parameter-fv #:get-tex-parameter-iv #:get-tex-level-parameter-fv #:get-tex-level-parameter-iv #:is-enabled #:is-list #:depth-range #:frustum #:load-identity #:load-matrix-f #:load-matrix-d #:matrix-mode #:mult-matrix-f #:mult-matrix-d #:ortho #:pop-matrix #:push-matrix #:rotate-d #:rotate-f #:scale-d #:scale-f #:translate-d #:translate-f #:viewport #:array-element #:color-pointer #:disable-client-state #:draw-arrays #:draw-elements #:edge-flag-pointer #:enable-client-state #:get-pointer-v #:index-pointer #:interleaved-arrays #:normal-pointer #:tex-coord-pointer #:vertex-pointer #:polygon-offset #:copy-tex-image-1d #:copy-tex-image-2d #:copy-tex-sub-image-1d #:copy-tex-sub-image-2d #:tex-sub-image-1d #:tex-sub-image-2d #:are-textures-resident #:bind-texture #:delete-textures #:gen-textures #:is-texture #:prioritize-textures #:index-ub #:index-ubv #:pop-client-attrib #:push-client-attrib #:blend-color #:blend-equation #:draw-range-elements #:color-table #:color-table-parameter-fv #:color-table-parameter-iv #:copy-color-table #:get-color-table #:get-color-table-parameter-fv #:get-color-table-parameter-iv #:color-sub-table #:copy-color-sub-table #:convolution-filter-1d #:convolution-filter-2d #:convolution-parameter-f #:convolution-parameter-fv #:convolution-parameter-i #:convolution-parameter-iv #:copy-convolution-filter-1d #:copy-convolution-filter-2d #:get-convolution-filter #:get-convolution-parameter-fv #:get-convolution-parameter-iv #:get-separable-filter #:separable-filter-2d #:get-histogram #:get-histogram-parameter-fv #:get-histogram-parameter-iv #:get-minmax #:get-minmax-parameter-fv #:get-minmax-parameter-iv #:histogram #:minmax #:reset-histogram #:reset-minmax #:tex-image-3d #:tex-sub-image-3d #:copy-tex-sub-image-3d #:active-texture #:client-active-texture #:multi-tex-coord-1d #:multi-tex-coord-1dv #:multi-tex-coord-1f #:multi-tex-coord-1fv #:multi-tex-coord-1i #:multi-tex-coord-1iv #:multi-tex-coord-1s #:multi-tex-coord-1sv #:multi-tex-coord-2d #:multi-tex-coord-2dv #:multi-tex-coord-2f #:multi-tex-coord-2fv #:multi-tex-coord-2i #:multi-tex-coord-2iv #:multi-tex-coord-2s #:multi-tex-coord-2sv #:multi-tex-coord-3d #:multi-tex-coord-3dv #:multi-tex-coord-3f #:multi-tex-coord-3fv #:multi-tex-coord-3i #:multi-tex-coord-3iv #:multi-tex-coord-3s #:multi-tex-coord-3sv #:multi-tex-coord-4d #:multi-tex-coord-4dv #:multi-tex-coord-4f #:multi-tex-coord-4fv #:multi-tex-coord-4i #:multi-tex-coord-4iv #:multi-tex-coord-4s #:multi-tex-coord-4sv #:load-transpose-matrix-f #:load-transpose-matrix-d #:mult-transpose-matrix-f #:mult-transpose-matrix-d #:sample-coverage #:compressed-tex-image-3d #:compressed-tex-image-2d #:compressed-tex-image-1d #:compressed-tex-sub-image-3d #:compressed-tex-sub-image-2d #:compressed-tex-sub-image-1d #:get-compressed-tex-image #:blend-func-separate #:fog-coord-f #:fog-coord-fv #:fog-coord-d #:fog-coord-dv #:fog-coord-pointer #:multi-draw-arrays #:multi-draw-elements #:point-parameter-f #:point-parameter-fv #:point-parameter-i #:point-parameter-iv #:secondary-color-3b #:secondary-color-3bv #:secondary-color-3d #:secondary-color-3dv #:secondary-color-3f #:secondary-color-3fv #:secondary-color-3i #:secondary-color-3iv #:secondary-color-3s #:secondary-color-3sv #:secondary-color-3ub #:secondary-color-3ubv #:secondary-color-3ui #:secondary-color-3uiv #:secondary-color-3us #:secondary-color-3usv #:secondary-color-pointer #:window-pos-2d #:window-pos-2dv #:window-pos-2f #:window-pos-2fv #:window-pos-2i #:window-pos-2iv #:window-pos-2s #:window-pos-2sv #:window-pos-3d #:window-pos-3dv #:window-pos-3f #:window-pos-3fv #:window-pos-3i #:window-pos-3iv #:window-pos-3s #:window-pos-3sv #:gen-queries #:delete-queries #:is-query #:begin-query #:end-query #:get-query-iv #:get-query-object-iv #:get-query-object-uiv #:bind-buffer #:delete-buffers #:gen-buffers #:is-buffer #:buffer-data #:buffer-sub-data #:get-buffer-sub-data #:map-buffer #:unmap-buffer #:get-buffer-parameter-iv #:get-buffer-pointer-v #:blend-equation-separate #:draw-buffers #:stencil-op-separate #:stencil-func-separate #:stencil-mask-separate #:attach-shader #:bind-attrib-location #:compile-shader #:create-program #:create-shader #:delete-program #:delete-shader #:detach-shader #:disable-vertex-attrib-array #:enable-vertex-attrib-array #:get-active-attrib #:get-active-uniform #:get-attached-shaders #:get-attrib-location #:get-program-iv #:get-program-info-log #:get-shader-iv #:get-shader-info-log #:get-shader-source #:get-uniform-location #:get-uniform-fv #:get-uniform-iv #:get-vertex-attrib-dv #:get-vertex-attrib-fv #:get-vertex-attrib-iv #:get-vertex-attrib-pointer-v #:is-program #:is-shader #:link-program #:shader-source #:use-program #:uniform-1f #:uniform-2f #:uniform-3f #:uniform-4f #:uniform-1i #:uniform-2i #:uniform-3i #:uniform-4i #:uniform-1fv #:uniform-2fv #:uniform-3fv #:uniform-4fv #:uniform-1iv #:uniform-2iv #:uniform-3iv #:uniform-4iv #:uniform-matrix-2fv #:uniform-matrix-3fv #:uniform-matrix-4fv #:validate-program #:vertex-attrib-1d #:vertex-attrib-1dv #:vertex-attrib-1f #:vertex-attrib-1fv #:vertex-attrib-1s #:vertex-attrib-1sv #:vertex-attrib-2d #:vertex-attrib-2dv #:vertex-attrib-2f #:vertex-attrib-2fv #:vertex-attrib-2s #:vertex-attrib-2sv #:vertex-attrib-3d #:vertex-attrib-3dv #:vertex-attrib-3f #:vertex-attrib-3fv #:vertex-attrib-3s #:vertex-attrib-3sv #:vertex-attrib-4nbv #:vertex-attrib-4niv #:vertex-attrib-4nsv #:vertex-attrib-4nub #:vertex-attrib-4nubv #:vertex-attrib-4nuiv #:vertex-attrib-4nusv #:vertex-attrib-4bv #:vertex-attrib-4d #:vertex-attrib-4dv #:vertex-attrib-4f #:vertex-attrib-4fv #:vertex-attrib-4iv #:vertex-attrib-4s #:vertex-attrib-4sv #:vertex-attrib-4ubv #:vertex-attrib-4uiv #:vertex-attrib-4usv #:vertex-attrib-pointer #:uniform-matrix-2x3-fv #:uniform-matrix-3x2-fv #:uniform-matrix-2x4-fv #:uniform-matrix-4x2-fv #:uniform-matrix-3x4-fv #:uniform-matrix-4x3-fv #:active-texture-arb #:client-active-texture-arb #:multi-tex-coord-1d-arb #:multi-tex-coord-1dv-arb #:multi-tex-coord-1f-arb #:multi-tex-coord-1fv-arb #:multi-tex-coord-1i-arb #:multi-tex-coord-1iv-arb #:multi-tex-coord-1s-arb #:multi-tex-coord-1sv-arb #:multi-tex-coord-2d-arb #:multi-tex-coord-2dv-arb #:multi-tex-coord-2f-arb #:multi-tex-coord-2fv-arb #:multi-tex-coord-2i-arb #:multi-tex-coord-2iv-arb #:multi-tex-coord-2s-arb #:multi-tex-coord-2sv-arb #:multi-tex-coord-3d-arb #:multi-tex-coord-3dv-arb #:multi-tex-coord-3f-arb #:multi-tex-coord-3fv-arb #:multi-tex-coord-3i-arb #:multi-tex-coord-3iv-arb #:multi-tex-coord-3s-arb #:multi-tex-coord-3sv-arb #:multi-tex-coord-4d-arb #:multi-tex-coord-4dv-arb #:multi-tex-coord-4f-arb #:multi-tex-coord-4fv-arb #:multi-tex-coord-4i-arb #:multi-tex-coord-4iv-arb #:multi-tex-coord-4s-arb #:multi-tex-coord-4sv-arb #:load-transpose-matrix-f-arb #:load-transpose-matrix-d-arb #:mult-transpose-matrix-f-arb #:mult-transpose-matrix-d-arb #:sample-coverage-arb #:compressed-tex-image-3d-arb #:compressed-tex-image-2d-arb #:compressed-tex-image-1d-arb #:compressed-tex-sub-image-3d-arb #:compressed-tex-sub-image-2d-arb #:compressed-tex-sub-image-1d-arb #:get-compressed-tex-image-arb #:point-parameter-f-arb #:point-parameter-fv-arb #:weight-bv-arb #:weight-sv-arb #:weight-iv-arb #:weight-fv-arb #:weight-dv-arb #:weight-ubv-arb #:weight-usv-arb #:weight-uiv-arb #:weight-pointer-arb #:vertex-blend-arb #:current-palette-matrix-arb #:matrix-index-ubv-arb #:matrix-index-usv-arb #:matrix-index-uiv-arb #:matrix-index-pointer-arb #:window-pos-2d-arb #:window-pos-2dv-arb #:window-pos-2f-arb #:window-pos-2fv-arb #:window-pos-2i-arb #:window-pos-2iv-arb #:window-pos-2s-arb #:window-pos-2sv-arb #:window-pos-3d-arb #:window-pos-3dv-arb #:window-pos-3f-arb #:window-pos-3fv-arb #:window-pos-3i-arb #:window-pos-3iv-arb #:window-pos-3s-arb #:window-pos-3sv-arb #:vertex-attrib-1d-arb #:vertex-attrib-1dv-arb #:vertex-attrib-1f-arb #:vertex-attrib-1fv-arb #:vertex-attrib-1s-arb #:vertex-attrib-1sv-arb #:vertex-attrib-2d-arb #:vertex-attrib-2dv-arb #:vertex-attrib-2f-arb #:vertex-attrib-2fv-arb #:vertex-attrib-2s-arb #:vertex-attrib-2sv-arb #:vertex-attrib-3d-arb #:vertex-attrib-3dv-arb #:vertex-attrib-3f-arb #:vertex-attrib-3fv-arb #:vertex-attrib-3s-arb #:vertex-attrib-3sv-arb #:vertex-attrib-4nbv-arb #:vertex-attrib-4niv-arb #:vertex-attrib-4nsv-arb #:vertex-attrib-4nub-arb #:vertex-attrib-4nubv-arb #:vertex-attrib-4nuiv-arb #:vertex-attrib-4nusv-arb #:vertex-attrib-4bv-arb #:vertex-attrib-4d-arb #:vertex-attrib-4dv-arb #:vertex-attrib-4f-arb #:vertex-attrib-4fv-arb #:vertex-attrib-4iv-arb #:vertex-attrib-4s-arb #:vertex-attrib-4sv-arb #:vertex-attrib-4ubv-arb #:vertex-attrib-4uiv-arb #:vertex-attrib-4usv-arb #:vertex-attrib-pointer-arb #:enable-vertex-attrib-array-arb #:disable-vertex-attrib-array-arb #:program-string-arb #:bind-program-arb #:delete-programs-arb #:gen-programs-arb #:program-env-parameter-4d-arb #:program-env-parameter-4dv-arb #:program-env-parameter-4f-arb #:program-env-parameter-4fv-arb #:program-local-parameter-4d-arb #:program-local-parameter-4dv-arb #:program-local-parameter-4f-arb #:program-local-parameter-4fv-arb #:get-program-env-parameter-dv-arb #:get-program-env-parameter-fv-arb #:get-program-local-parameter-dv-arb #:get-program-local-parameter-fv-arb #:get-program-iv-arb #:get-program-string-arb #:get-vertex-attrib-dv-arb #:get-vertex-attrib-fv-arb #:get-vertex-attrib-iv-arb #:get-vertex-attrib-pointer-v-arb #:is-program-arb #:bind-buffer-arb #:delete-buffers-arb #:gen-buffers-arb #:is-buffer-arb #:buffer-data-arb #:buffer-sub-data-arb #:get-buffer-sub-data-arb #:map-buffer-arb #:unmap-buffer-arb #:get-buffer-parameter-iv-arb #:get-buffer-pointer-v-arb #:gen-queries-arb #:delete-queries-arb #:is-query-arb #:begin-query-arb #:end-query-arb #:get-query-iv-arb #:get-query-object-iv-arb #:get-query-object-uiv-arb #:delete-object-arb #:get-handle-arb #:detach-object-arb #:create-shader-object-arb #:shader-source-arb #:compile-shader-arb #:create-program-object-arb #:attach-object-arb #:link-program-arb #:use-program-object-arb #:validate-program-arb #:uniform-1f-arb #:uniform-2f-arb #:uniform-3f-arb #:uniform-4f-arb #:uniform-1i-arb #:uniform-2i-arb #:uniform-3i-arb #:uniform-4i-arb #:uniform-1fv-arb #:uniform-2fv-arb #:uniform-3fv-arb #:uniform-4fv-arb #:uniform-1iv-arb #:uniform-2iv-arb #:uniform-3iv-arb #:uniform-4iv-arb #:uniform-matrix-2fv-arb #:uniform-matrix-3fv-arb #:uniform-matrix-4fv-arb #:get-object-parameter-fv-arb #:get-object-parameter-iv-arb #:get-info-log-arb #:get-attached-objects-arb #:get-uniform-location-arb #:get-active-uniform-arb #:get-uniform-fv-arb #:get-uniform-iv-arb #:get-shader-source-arb #:bind-attrib-location-arb #:get-active-attrib-arb #:get-attrib-location-arb #:draw-buffers-arb #:clamp-color-arb #:blend-color-ext #:polygon-offset-ext #:tex-image-3d-ext #:tex-sub-image-3d-ext #:get-tex-filter-func-sgis #:tex-filter-func-sgis #:tex-sub-image-1d-ext #:tex-sub-image-2d-ext #:copy-tex-image-1d-ext #:copy-tex-image-2d-ext #:copy-tex-sub-image-1d-ext #:copy-tex-sub-image-2d-ext #:copy-tex-sub-image-3d-ext #:get-histogram-ext #:get-histogram-parameter-fv-ext #:get-histogram-parameter-iv-ext #:get-minmax-ext #:get-minmax-parameter-fv-ext #:get-minmax-parameter-iv-ext #:histogram-ext #:minmax-ext #:reset-histogram-ext #:reset-minmax-ext #:convolution-filter-1d-ext #:convolution-filter-2d-ext #:convolution-parameter-f-ext #:convolution-parameter-fv-ext #:convolution-parameter-i-ext #:convolution-parameter-iv-ext #:copy-convolution-filter-1d-ext #:copy-convolution-filter-2d-ext #:get-convolution-filter-ext #:get-convolution-parameter-fv-ext #:get-convolution-parameter-iv-ext #:get-separable-filter-ext #:separable-filter-2d-ext #:color-table-sgi #:color-table-parameter-fv-sgi #:color-table-parameter-iv-sgi #:copy-color-table-sgi #:get-color-table-sgi #:get-color-table-parameter-fv-sgi #:get-color-table-parameter-iv-sgi #:pixel-tex-gen-sgix #:pixel-tex-gen-parameter-i-sgis #:pixel-tex-gen-parameter-iv-sgis #:pixel-tex-gen-parameter-f-sgis #:pixel-tex-gen-parameter-fv-sgis #:get-pixel-tex-gen-parameter-iv-sgis #:get-pixel-tex-gen-parameter-fv-sgis #:tex-image-4d-sgis #:tex-sub-image-4d-sgis #:are-textures-resident-ext #:bind-texture-ext #:delete-textures-ext #:gen-textures-ext #:is-texture-ext #:prioritize-textures-ext #:detail-tex-func-sgis #:get-detail-tex-func-sgis #:sharpen-tex-func-sgis #:get-sharpen-tex-func-sgis #:sample-mask-sgis #:sample-pattern-sgis #:array-element-ext #:color-pointer-ext #:draw-arrays-ext #:edge-flag-pointer-ext #:get-pointer-v-ext #:index-pointer-ext #:normal-pointer-ext #:tex-coord-pointer-ext #:vertex-pointer-ext #:blend-equation-ext #:sprite-parameter-f-sgix #:sprite-parameter-fv-sgix #:sprite-parameter-i-sgix #:sprite-parameter-iv-sgix #:point-parameter-f-ext #:point-parameter-fv-ext #:point-parameter-f-sgis #:point-parameter-fv-sgis #:get-instruments-sgix #:instruments-buffer-sgix #:poll-instruments-sgix #:read-instruments-sgix #:start-instruments-sgix #:stop-instruments-sgix #:frame-zoom-sgix #:tag-sample-buffer-sgix #:deformation-map-3d-sgix #:deformation-map-3f-sgix #:deform-sgix #:load-identity-deformation-map-sgix #:reference-plane-sgix #:flush-raster-sgix #:fog-func-sgis #:get-fog-func-sgis #:image-transform-parameter-i-hp #:image-transform-parameter-f-hp #:image-transform-parameter-iv-hp #:image-transform-parameter-fv-hp #:get-image-transform-parameter-iv-hp #:get-image-transform-parameter-fv-hp #:color-sub-table-ext #:copy-color-sub-table-ext #:hint-pgi #:color-table-ext #:get-color-table-ext #:get-color-table-parameter-iv-ext #:get-color-table-parameter-fv-ext #:get-list-parameter-fv-sgix #:get-list-parameter-iv-sgix #:list-parameter-f-sgix #:list-parameter-fv-sgix #:list-parameter-i-sgix #:list-parameter-iv-sgix #:index-material-ext #:index-func-ext #:lock-arrays-ext #:unlock-arrays-ext #:cull-parameter-dv-ext #:cull-parameter-fv-ext #:fragment-color-material-sgix #:fragment-light-f-sgix #:fragment-light-fv-sgix #:fragment-light-i-sgix #:fragment-light-iv-sgix #:fragment-light-model-f-sgix #:fragment-light-model-fv-sgix #:fragment-light-model-i-sgix #:fragment-light-model-iv-sgix #:fragment-material-f-sgix #:fragment-material-fv-sgix #:fragment-material-i-sgix #:fragment-material-iv-sgix #:get-fragment-light-fv-sgix #:get-fragment-light-iv-sgix #:get-fragment-material-fv-sgix #:get-fragment-material-iv-sgix #:light-env-i-sgix #:draw-range-elements-ext #:apply-texture-ext #:texture-light-ext #:texture-material-ext #:async-marker-sgix #:finish-async-sgix #:poll-async-sgix #:gen-async-markers-sgix #:delete-async-markers-sgix #:is-async-marker-sgix #:vertex-pointer-v-intel #:normal-pointer-v-intel #:color-pointer-v-intel #:tex-coord-pointer-v-intel #:pixel-transform-parameter-i-ext #:pixel-transform-parameter-f-ext #:pixel-transform-parameter-iv-ext #:pixel-transform-parameter-fv-ext #:secondary-color-3b-ext #:secondary-color-3bv-ext #:secondary-color-3d-ext #:secondary-color-3dv-ext #:secondary-color-3f-ext #:secondary-color-3fv-ext #:secondary-color-3i-ext #:secondary-color-3iv-ext #:secondary-color-3s-ext #:secondary-color-3sv-ext #:secondary-color-3ub-ext #:secondary-color-3ubv-ext #:secondary-color-3ui-ext #:secondary-color-3uiv-ext #:secondary-color-3us-ext #:secondary-color-3usv-ext #:secondary-color-pointer-ext #:texture-normal-ext #:multi-draw-arrays-ext #:multi-draw-elements-ext #:fog-coord-f-ext #:fog-coord-fv-ext #:fog-coord-d-ext #:fog-coord-dv-ext #:fog-coord-pointer-ext #:tangent-3b-ext #:tangent-3bv-ext #:tangent-3d-ext #:tangent-3dv-ext #:tangent-3f-ext #:tangent-3fv-ext #:tangent-3i-ext #:tangent-3iv-ext #:tangent-3s-ext #:tangent-3sv-ext #:binormal-3b-ext #:binormal-3bv-ext #:binormal-3d-ext #:binormal-3dv-ext #:binormal-3f-ext #:binormal-3fv-ext #:binormal-3i-ext #:binormal-3iv-ext #:binormal-3s-ext #:binormal-3sv-ext #:tangent-pointer-ext #:binormal-pointer-ext #:finish-texture-sunx #:global-alpha-factor-b-sun #:global-alpha-factor-s-sun #:global-alpha-factor-i-sun #:global-alpha-factor-f-sun #:global-alpha-factor-d-sun #:global-alpha-factor-ub-sun #:global-alpha-factor-us-sun #:global-alpha-factor-ui-sun #:replacement-code-ui-sun #:replacement-code-us-sun #:replacement-code-ub-sun #:replacement-code-uiv-sun #:replacement-code-usv-sun #:replacement-code-ubv-sun #:replacement-code-pointer-sun #:color-4ub-vertex-2f-sun #:color-4ub-vertex-2fv-sun #:color-4ub-vertex-3f-sun #:color-4ub-vertex-3fv-sun #:color-3f-vertex-3f-sun #:color-3f-vertex-3fv-sun #:normal-3f-vertex-3f-sun #:normal-3f-vertex-3fv-sun #:color-4f-normal-3f-vertex-3f-sun #:color-4f-normal-3f-vertex-3fv-sun #:tex-coord-2f-vertex-3f-sun #:tex-coord-2f-vertex-3fv-sun #:tex-coord-4f-vertex-4f-sun #:tex-coord-4f-vertex-4fv-sun #:tex-coord-2f-color-4ub-vertex-3f-sun #:tex-coord-2f-color-4ub-vertex-3fv-sun #:tex-coord-2f-color-3f-vertex-3f-sun #:tex-coord-2f-color-3f-vertex-3fv-sun #:tex-coord-2f-normal-3f-vertex-3f-sun #:tex-coord-2f-normal-3f-vertex-3fv-sun #:tex-coord-2f-color-4f-normal-3f-vertex-3f-sun #:tex-coord-2f-color-4f-normal-3f-vertex-3fv-sun #:tex-coord-4f-color-4f-normal-3f-vertex-4f-sun #:tex-coord-4f-color-4f-normal-3f-vertex-4fv-sun #:replacement-code-ui-vertex-3f-sun #:replacement-code-ui-vertex-3fv-sun #:replacement-code-ui-color-4ub-vertex-3f-sun #:replacement-code-ui-color-4ub-vertex-3fv-sun #:replacement-code-ui-color-3f-vertex-3f-sun #:replacement-code-ui-color-3f-vertex-3fv-sun #:replacement-code-ui-normal-3f-vertex-3f-sun #:replacement-code-ui-normal-3f-vertex-3fv-sun #:replacement-code-ui-color-4f-normal-3f-vertex-3f-sun #:replacement-code-ui-color-4f-normal-3f-vertex-3fv-sun #:replacement-code-ui-tex-coord-2f-vertex-3f-sun #:replacement-code-ui-tex-coord-2f-vertex-3fv-sun #:replacement-code-ui-tex-coord-2f-normal-3f-vertex-3f-sun #:replacement-code-ui-tex-coord-2f-normal-3f-vertex-3fv-sun #:replacement-code-ui-tex-coord-2f-color-4f-normal-3f-vertex-3f-sun #:replacement-code-ui-tex-coord-2f-color-4f-normal-3f-vertex-3fv-sun #:blend-func-separate-ext #:blend-func-separate-ingr #:vertex-weight-f-ext #:vertex-weight-fv-ext #:vertex-weight-pointer-ext #:flush-vertex-array-range-nv #:vertex-array-range-nv #:combiner-parameter-fv-nv #:combiner-parameter-f-nv #:combiner-parameter-iv-nv #:combiner-parameter-i-nv #:combiner-input-nv #:combiner-output-nv #:final-combiner-input-nv #:get-combiner-input-parameter-fv-nv #:get-combiner-input-parameter-iv-nv #:get-combiner-output-parameter-fv-nv #:get-combiner-output-parameter-iv-nv #:get-final-combiner-input-parameter-fv-nv #:get-final-combiner-input-parameter-iv-nv #:resize-buffers-mesa #:window-pos-2d-mesa #:window-pos-2dv-mesa #:window-pos-2f-mesa #:window-pos-2fv-mesa #:window-pos-2i-mesa #:window-pos-2iv-mesa #:window-pos-2s-mesa #:window-pos-2sv-mesa #:window-pos-3d-mesa #:window-pos-3dv-mesa #:window-pos-3f-mesa #:window-pos-3fv-mesa #:window-pos-3i-mesa #:window-pos-3iv-mesa #:window-pos-3s-mesa #:window-pos-3sv-mesa #:window-pos-4d-mesa #:window-pos-4dv-mesa #:window-pos-4f-mesa #:window-pos-4fv-mesa #:window-pos-4i-mesa #:window-pos-4iv-mesa #:window-pos-4s-mesa #:window-pos-4sv-mesa #:multi-mode-draw-arrays-ibm #:multi-mode-draw-elements-ibm #:color-pointer-list-ibm #:secondary-color-pointer-list-ibm #:edge-flag-pointer-list-ibm #:fog-coord-pointer-list-ibm #:index-pointer-list-ibm #:normal-pointer-list-ibm #:tex-coord-pointer-list-ibm #:vertex-pointer-list-ibm #:tbuffer-mask-3dfx #:sample-mask-ext #:sample-pattern-ext #:texture-color-mask-sgis #:igloo-interface-sgix #:delete-fences-nv #:gen-fences-nv #:is-fence-nv #:test-fence-nv #:get-fence-iv-nv #:finish-fence-nv #:set-fence-nv #:map-control-points-nv #:map-parameter-iv-nv #:map-parameter-fv-nv #:get-map-control-points-nv #:get-map-parameter-iv-nv #:get-map-parameter-fv-nv #:get-map-attrib-parameter-iv-nv #:get-map-attrib-parameter-fv-nv #:eval-maps-nv #:combiner-stage-parameter-fv-nv #:get-combiner-stage-parameter-fv-nv #:are-programs-resident-nv #:bind-program-nv #:delete-programs-nv #:execute-program-nv #:gen-programs-nv #:get-program-parameter-dv-nv #:get-program-parameter-fv-nv #:get-program-iv-nv #:get-program-string-nv #:get-track-matrix-iv-nv #:get-vertex-attrib-dv-nv #:get-vertex-attrib-fv-nv #:get-vertex-attrib-iv-nv #:get-vertex-attrib-pointer-v-nv #:is-program-nv #:load-program-nv #:program-parameter-4d-nv #:program-parameter-4dv-nv #:program-parameter-4f-nv #:program-parameter-4fv-nv #:program-parameters-4dv-nv #:program-parameters-4fv-nv #:request-resident-programs-nv #:track-matrix-nv #:vertex-attrib-pointer-nv #:vertex-attrib-1d-nv #:vertex-attrib-1dv-nv #:vertex-attrib-1f-nv #:vertex-attrib-1fv-nv #:vertex-attrib-1s-nv #:vertex-attrib-1sv-nv #:vertex-attrib-2d-nv #:vertex-attrib-2dv-nv #:vertex-attrib-2f-nv #:vertex-attrib-2fv-nv #:vertex-attrib-2s-nv #:vertex-attrib-2sv-nv #:vertex-attrib-3d-nv #:vertex-attrib-3dv-nv #:vertex-attrib-3f-nv #:vertex-attrib-3fv-nv #:vertex-attrib-3s-nv #:vertex-attrib-3sv-nv #:vertex-attrib-4d-nv #:vertex-attrib-4dv-nv #:vertex-attrib-4f-nv #:vertex-attrib-4fv-nv #:vertex-attrib-4s-nv #:vertex-attrib-4sv-nv #:vertex-attrib-4ub-nv #:vertex-attrib-4ubv-nv #:vertex-attribs-1dv-nv #:vertex-attribs-1fv-nv #:vertex-attribs-1sv-nv #:vertex-attribs-2dv-nv #:vertex-attribs-2fv-nv #:vertex-attribs-2sv-nv #:vertex-attribs-3dv-nv #:vertex-attribs-3fv-nv #:vertex-attribs-3sv-nv #:vertex-attribs-4dv-nv #:vertex-attribs-4fv-nv #:vertex-attribs-4sv-nv #:vertex-attribs-4ubv-nv #:tex-bump-parameter-iv-ati #:tex-bump-parameter-fv-ati #:get-tex-bump-parameter-iv-ati #:get-tex-bump-parameter-fv-ati #:gen-fragment-shaders-ati #:bind-fragment-shader-ati #:delete-fragment-shader-ati #:begin-fragment-shader-ati #:end-fragment-shader-ati #:pass-tex-coord-ati #:sample-map-ati #:color-fragment-op-1-ati #:color-fragment-op-2-ati #:color-fragment-op-3-ati #:alpha-fragment-op-1-ati #:alpha-fragment-op-2-ati #:alpha-fragment-op-3-ati #:set-fragment-shader-constant-ati #:pntriangles-i-ati #:pntriangles-f-ati #:new-object-buffer-ati #:is-object-buffer-ati #:update-object-buffer-ati #:get-object-buffer-fv-ati #:get-object-buffer-iv-ati #:free-object-buffer-ati #:array-object-ati #:get-array-object-fv-ati #:get-array-object-iv-ati #:variant-array-object-ati #:get-variant-array-object-fv-ati #:get-variant-array-object-iv-ati #:begin-vertex-shader-ext #:end-vertex-shader-ext #:bind-vertex-shader-ext #:gen-vertex-shaders-ext #:delete-vertex-shader-ext #:shader-op-1-ext #:shader-op-2-ext #:shader-op-3-ext #:swizzle-ext #:write-mask-ext #:insert-component-ext #:extract-component-ext #:gen-symbols-ext #:set-invariant-ext #:set-local-constant-ext #:variant-bv-ext #:variant-sv-ext #:variant-iv-ext #:variant-fv-ext #:variant-dv-ext #:variant-ubv-ext #:variant-usv-ext #:variant-uiv-ext #:variant-pointer-ext #:enable-variant-client-state-ext #:disable-variant-client-state-ext #:bind-light-parameter-ext #:bind-material-parameter-ext #:bind-tex-gen-parameter-ext #:bind-texture-unit-parameter-ext #:bind-parameter-ext #:is-variant-enabled-ext #:get-variant-boolean-v-ext #:get-variant-integer-v-ext #:get-variant-float-v-ext #:get-variant-pointer-v-ext #:get-invariant-boolean-v-ext #:get-invariant-integer-v-ext #:get-invariant-float-v-ext #:get-local-constant-boolean-v-ext #:get-local-constant-integer-v-ext #:get-local-constant-float-v-ext #:vertex-stream-1s-ati #:vertex-stream-1sv-ati #:vertex-stream-1i-ati #:vertex-stream-1iv-ati #:vertex-stream-1f-ati #:vertex-stream-1fv-ati #:vertex-stream-1d-ati #:vertex-stream-1dv-ati #:vertex-stream-2s-ati #:vertex-stream-2sv-ati #:vertex-stream-2i-ati #:vertex-stream-2iv-ati #:vertex-stream-2f-ati #:vertex-stream-2fv-ati #:vertex-stream-2d-ati #:vertex-stream-2dv-ati #:vertex-stream-3s-ati #:vertex-stream-3sv-ati #:vertex-stream-3i-ati #:vertex-stream-3iv-ati #:vertex-stream-3f-ati #:vertex-stream-3fv-ati #:vertex-stream-3d-ati #:vertex-stream-3dv-ati #:vertex-stream-4s-ati #:vertex-stream-4sv-ati #:vertex-stream-4i-ati #:vertex-stream-4iv-ati #:vertex-stream-4f-ati #:vertex-stream-4fv-ati #:vertex-stream-4d-ati #:vertex-stream-4dv-ati #:normal-stream-3b-ati #:normal-stream-3bv-ati #:normal-stream-3s-ati #:normal-stream-3sv-ati #:normal-stream-3i-ati #:normal-stream-3iv-ati #:normal-stream-3f-ati #:normal-stream-3fv-ati #:normal-stream-3d-ati #:normal-stream-3dv-ati #:client-active-vertex-stream-ati #:vertex-blend-env-i-ati #:vertex-blend-env-f-ati #:element-pointer-ati #:draw-element-array-ati #:draw-range-element-array-ati #:draw-mesh-arrays-sun #:gen-occlusion-queries-nv #:delete-occlusion-queries-nv #:is-occlusion-query-nv #:begin-occlusion-query-nv #:end-occlusion-query-nv #:get-occlusion-query-iv-nv #:get-occlusion-query-uiv-nv #:point-parameter-i-nv #:point-parameter-iv-nv #:active-stencil-face-ext #:element-pointer-apple #:draw-element-array-apple #:draw-range-element-array-apple #:multi-draw-element-array-apple #:multi-draw-range-element-array-apple #:gen-fences-apple #:delete-fences-apple #:set-fence-apple #:is-fence-apple #:test-fence-apple #:finish-fence-apple #:test-object-apple #:finish-object-apple #:bind-vertex-array-apple #:delete-vertex-arrays-apple #:gen-vertex-arrays-apple #:is-vertex-array-apple #:vertex-array-range-apple #:flush-vertex-array-range-apple #:vertex-array-parameter-i-apple #:draw-buffers-ati #:program-named-parameter-4f-nv #:program-named-parameter-4d-nv #:program-named-parameter-4fv-nv #:program-named-parameter-4dv-nv #:get-program-named-parameter-fv-nv #:get-program-named-parameter-dv-nv #:vertex-2h-nv #:vertex-2hv-nv #:vertex-3h-nv #:vertex-3hv-nv #:vertex-4h-nv #:vertex-4hv-nv #:normal-3h-nv #:normal-3hv-nv #:color-3h-nv #:color-3hv-nv #:color-4h-nv #:color-4hv-nv #:tex-coord-1h-nv #:tex-coord-1hv-nv #:tex-coord-2h-nv #:tex-coord-2hv-nv #:tex-coord-3h-nv #:tex-coord-3hv-nv #:tex-coord-4h-nv #:tex-coord-4hv-nv #:multi-tex-coord-1h-nv #:multi-tex-coord-1hv-nv #:multi-tex-coord-2h-nv #:multi-tex-coord-2hv-nv #:multi-tex-coord-3h-nv #:multi-tex-coord-3hv-nv #:multi-tex-coord-4h-nv #:multi-tex-coord-4hv-nv #:fog-coord-h-nv #:fog-coord-hv-nv #:secondary-color-3h-nv #:secondary-color-3hv-nv #:vertex-weight-h-nv #:vertex-weight-hv-nv #:vertex-attrib-1h-nv #:vertex-attrib-1hv-nv #:vertex-attrib-2h-nv #:vertex-attrib-2hv-nv #:vertex-attrib-3h-nv #:vertex-attrib-3hv-nv #:vertex-attrib-4h-nv #:vertex-attrib-4hv-nv #:vertex-attribs-1hv-nv #:vertex-attribs-2hv-nv #:vertex-attribs-3hv-nv #:vertex-attribs-4hv-nv #:pixel-data-range-nv #:flush-pixel-data-range-nv #:primitive-restart-nv #:primitive-restart-index-nv #:map-object-buffer-ati #:unmap-object-buffer-ati #:stencil-op-separate-ati #:stencil-func-separate-ati #:vertex-attrib-array-object-ati #:get-vertex-attrib-array-object-fv-ati #:get-vertex-attrib-array-object-iv-ati #:depth-bounds-ext #:blend-equation-separate-ext #:is-renderbuffer-ext #:bind-renderbuffer-ext #:delete-renderbuffers-ext #:gen-renderbuffers-ext #:renderbuffer-storage-ext #:get-renderbuffer-parameter-iv-ext #:is-framebuffer-ext #:bind-framebuffer-ext #:delete-framebuffers-ext #:gen-framebuffers-ext #:check-framebuffer-status-ext #:framebuffer-texture-1d-ext #:framebuffer-texture-2d-ext #:framebuffer-texture-3d-ext #:framebuffer-renderbuffer-ext #:get-framebuffer-attachment-parameter-iv-ext #:generate-mipmap-ext #:string-marker-gremedy #:stencil-clear-tag-ext #:blit-framebuffer-ext #:renderbuffer-storage-multisample-ext #:get-query-object-i64v-ext #:get-query-object-ui64v-ext #:program-env-parameters-4fv-ext #:program-local-parameters-4fv-ext #:buffer-parameter-i-apple #:flush-mapped-buffer-range-apple #:program-local-parameter-i4i-nv #:program-local-parameter-i4iv-nv #:program-local-parameters-i4iv-nv #:program-local-parameter-i4ui-nv #:program-local-parameter-i4uiv-nv #:program-local-parameters-i4uiv-nv #:program-env-parameter-i4i-nv #:program-env-parameter-i4iv-nv #:program-env-parameters-i4iv-nv #:program-env-parameter-i4ui-nv #:program-env-parameter-i4uiv-nv #:program-env-parameters-i4uiv-nv #:get-program-local-parameter-iiv-nv #:get-program-local-parameter-iuiv-nv #:get-program-env-parameter-iiv-nv #:get-program-env-parameter-iuiv-nv #:program-vertex-limit-nv #:framebuffer-texture-ext #:framebuffer-texture-layer-ext #:framebuffer-texture-face-ext #:program-parameter-i-ext #:vertex-attrib-i1i-ext #:vertex-attrib-i2i-ext #:vertex-attrib-i3i-ext #:vertex-attrib-i4i-ext #:vertex-attrib-i1ui-ext #:vertex-attrib-i2ui-ext #:vertex-attrib-i3ui-ext #:vertex-attrib-i4ui-ext #:vertex-attrib-i1iv-ext #:vertex-attrib-i2iv-ext #:vertex-attrib-i3iv-ext #:vertex-attrib-i4iv-ext #:vertex-attrib-i1uiv-ext #:vertex-attrib-i2uiv-ext #:vertex-attrib-i3uiv-ext #:vertex-attrib-i4uiv-ext #:vertex-attrib-i4bv-ext #:vertex-attrib-i4sv-ext #:vertex-attrib-i4ubv-ext #:vertex-attrib-i4usv-ext #:vertex-attrib-ipointer-ext #:get-vertex-attrib-iiv-ext #:get-vertex-attrib-iuiv-ext #:get-uniform-uiv-ext #:bind-frag-data-location-ext #:get-frag-data-location-ext #:uniform-1ui-ext #:uniform-2ui-ext #:uniform-3ui-ext #:uniform-4ui-ext #:uniform-1uiv-ext #:uniform-2uiv-ext #:uniform-3uiv-ext #:uniform-4uiv-ext #:draw-arrays-instanced-ext #:draw-elements-instanced-ext #:tex-buffer-ext #:depth-range-d-nv #:clear-depth-d-nv #:depth-bounds-d-nv #:renderbuffer-storage-multisample-coverage-nv #:program-buffer-parameters-fv-nv #:program-buffer-parameters-iiv-nv #:program-buffer-parameters-iuiv-nv #:color-mask-indexed-ext #:get-boolean-indexed-v-ext #:get-integer-indexed-v-ext #:enable-indexed-ext #:disable-indexed-ext #:is-enabled-indexed-ext #:begin-transform-feedback-nv #:end-transform-feedback-nv #:transform-feedback-attribs-nv #:bind-buffer-range-nv #:bind-buffer-offset-nv #:bind-buffer-base-nv #:transform-feedback-varyings-nv #:active-varying-nv #:get-varying-location-nv #:get-active-varying-nv #:get-transform-feedback-varying-nv #:uniform-buffer-ext #:get-uniform-buffer-size-ext #:get-uniform-offset-ext #:tex-parameter-iiv-ext #:tex-parameter-iuiv-ext #:get-tex-parameter-iiv-ext #:get-tex-parameter-iuiv-ext #:clear-color-ii-ext #:clear-color-iui-ext #:frame-terminator-gremedy ))
36,303
Common Lisp
.lisp
638
52.920063
71
0.715684
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
af7f0098a7ebf948f31f6abc9ec97f86b13aa6c97528258aa97c7be4ad4c601c
21,600
[ -1 ]
21,601
state.lisp
rheaplex_minara/lib/cl-opengl/gl/state.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; Copyright (c) 2004, Oliver Markovic <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions are met: ;;; ;;; o Redistributions of source code must retain the above copyright notice, ;;; this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may be ;;; used to endorse or promote products derived from this software without ;;; specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;;; POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-opengl) ;;; ;;; Chapter 6 - State and State Requests ;;; ;;; 6.1 Querying GL State ;;; ;;; 6.1.1 Simple queries ;;; Association list mapping enums for known queries to the number of ;;; values returned by the query. To perform a query that is not ;;; known in this table, the number of return values must be specified ;;; explicitly in the call to GET-*. (defparameter *query-enum-sizes* '((:accum-alpha-bits . 1) (:accum-blue-bits . 1) (:accum-clear-value . 4) (:accum-green-bits . 1) (:accum-red-bits . 1) (:active-texture . 1) (:aliased-point-size-range . 2) (:aliased-line-width-range . 2) (:alpha-bias . 1) (:alpha-bits . 1) (:alpha-scale . 1) (:alpha-test . 1) (:alpha-test-func . 1) (:alpha-test-ref . 1) (:attrib-stack-depth . 1) (:auto-normal . 1) (:aux-buffers . 1) (:blend . 1) (:blend-color . 4) (:blend-equation . 1) (:blue-bias . 1) (:blue-bits . 1) (:blue-scale . 1) (:client-active-texture . 1) (:client-attrib-stack-depth . 1) (:clip-plane0 . 1) (:clip-plane1 . 1) (:clip-plane2 . 1) (:clip-plane3 . 1) (:clip-plane4 . 1) (:clip-plane5 . 1) (:color-array . 1) (:color-array-size . 1) (:color-array-stride . 1) (:color-array-type . 1) (:color-clear-value . 4) (:color-logic-op . 1) (:color-material . 1) (:color-material-face . 1) (:color-material-parameter . 1) (:color-matrix . 16) (:color-matrix-stack-depth . 1) (:color-table . 1) (:color-writemask . 4) (:compressed-texture . 1) (:convolution-1d . 1) (:convolution-2d . 1) (:cull-face . 1) (:cull-face-mode . 1) (:current-color . 4) (:current-index . 1) (:current-normal . 3) (:current-raster-color . 4) (:current-raster-distance . 1) (:current-raster-index . 1) (:current-raster-position . 4) (:current-raster-position-valid . 1) (:current-raster-texture-coords . 4) (:current-texture-coords . 4) (:depth-bias . 1) (:depth-bits . 1) (:depth-clear-value . 1) (:depth-func . 1) (:depth-range . 2) (:depth-scale . 1) (:depth-test . 1) (:depth-writemask . 1) (:dither . 1) (:doublebuffer . 1) (:draw-buffer . 1) (:edge-flag . 1) (:edge-flag-array . 1) (:edge-flag-array-stride . 1) (:feedback-buffer-size . 1) (:feedback-buffer-type . 1) (:fog . 1) (:fog-color . 4) (:fog-density . 1) (:fog-end . 1) (:fog-hint . 1) (:fog-index . 1) (:fog-mode . 1) (:fog-start . 1) (:front-face . 1) (:generate-mipmap-hint . 1) (:green-bias . 1) (:green-bits . 1) (:green-scale . 1) (:histogram . 1) (:index-array . 1) (:index-array-stride . 1) (:index-array-type . 1) (:index-bits . 1) (:index-clear-value . 1) (:index-logic-op . 1) (:index-mode . 1) (:index-offset . 1) (:index-shift . 1) (:index-writemask . 1) (:light0 . 1) (:light1 . 1) (:light2 . 1) (:light3 . 1) (:light4 . 1) (:light5 . 1) (:light6 . 1) (:light7 . 1) (:lighting . 1) (:light-model-ambient . 4) (:light-model-color-control . 1) (:light-model-local-viewer . 1) (:light-model-two-side . 1) (:line-smooth . 1) (:line-smooth-hint . 1) (:line-stipple . 1) (:line-stipple-pattern . 1) (:line-stipple-repeat . 1) (:line-width . 1) (:line-width-granularity . 1) (:line-width-range . 2) (:list-base . 1) (:list-index . 1) (:list-mode . 1) (:logic-op-mode . 1) (:map1-color-4 . 1) (:map1-grid-domain . 2) (:map1-grid-segments . 1) (:map1-index . 1) (:map1-normal . 1) (:map1-texture-coord-1 . 1) (:map1-texture-coord-2 . 1) (:map1-texture-coord-3 . 1) (:map1-texture-coord-4 . 1) (:map1-vertex-3 . 1) (:map1-vertex-4 . 1) (:map2-color-4 . 1) (:map2-grid-domain . 4) (:map2-grid-segments . 2) (:map2-index . 1) (:map2-normal . 1) (:map2-texture-coord-1 . 1) (:map2-texture-coord-2 . 1) (:map2-texture-coord-3 . 1) (:map2-texture-coord-4 . 1) (:map2-vertex-3 . 1) (:map2-vertex-4 . 1) (:map-color . 1) (:map-stencil . 1) (:matrix-mode . 1) (:max-3d-texture-size . 1) (:max-client-attrib-stack-depth . 1) (:max-attrib-stack-depth . 1) (:max-clip-planes . 1) (:max-color-matrix-stack-depth . 1) (:max-cube-map-texture-size . 1) (:max-elements-indices . 1) (:max-elements-vertices . 1) (:max-eval-order . 1) (:max-lights . 1) (:max-list-nesting . 1) (:max-modelview-stack-depth . 1) (:max-name-stack-depth . 1) (:max-pixel-map-table . 1) (:max-projection-stack-depth . 1) (:max-texture-size . 1) (:max-texture-stack-depth . 1) (:max-texture-units . 1) (:max-viewport-dims . 1) (:minmax . 1) (:modelview-matrix . 16) (:modelview-stack-depth . 1) (:name-stack-depth . 1) (:normal-array . 1) (:normal-array-stride . 1) (:normal-array-type . 1) (:normalize . 1) (:num-compressed-texture-format . 1) (:pack-alignment . 1) (:pack-image-height . 1) (:pack-lsb-first . 1) (:pack-row-length . 1) (:pack-skip-images . 1) (:pack-skip-pixels . 1) (:pack-skip-rows . 1) (:pack-swap-bytes . 1) (:perspective-correction-hint . 1) (:pixel-map-a-to-a-size . 1) (:pixel-map-b-to-b-size . 1) (:pixel-map-g-to-g-size . 1) (:pixel-map-i-to-a-size . 1) (:pixel-map-i-to-b-size . 1) (:pixel-map-i-to-g-size . 1) (:pixel-map-i-to-i-size . 1) (:pixel-map-i-to-r-size . 1) (:pixel-map-r-to-r-size . 1) (:pixel-map-s-to-s-size . 1) (:point-size . 1) (:point-size-granularity . 1) (:point-size-range . 2) (:point-smooth . 1) (:point-smooth-hint . 1) (:polygon-mode . 2) (:polygon-offset-factor . 1) (:polygon-offset-units . 1) (:polygon-offset-fill . 1) (:polygon-offset-line . 1) (:polygon-offset-point . 1) (:polygon-smooth . 1) (:polygon-smooth-hint . 1) (:polygon-stipple . 1) (:post-color-matrix-color-table . 1) (:post-color-matrix-red-bias . 1) (:post-color-matrix-green-bias . 1) (:post-color-matrix-blue-bias . 1) (:post-color-matrix-alpha-bias . 1) (:post-color-matrix-red-scale . 1) (:post-color-matrix-green-scale . 1) (:post-color-matrix-blue-scale . 1) (:post-color-matrix-alpha-scale . 1) (:post-convolution-color-table . 1) (:post-convolution-red-bias . 1) (:post-convolution-green-bias . 1) (:post-convolution-blue-bias . 1) (:post-convolution-alpha-bias . 1) (:post-convolution-red-scale . 1) (:post-convolution-green-scale . 1) (:post-convolution-blue-scale . 1) (:post-convolution-alpha-scale . 1) (:projection-matrix . 16) (:projection-stack-depth . 1) (:read-buffer . 1) (:red-bias . 1) (:red-bits . 1) (:red-scale . 1) (:render-mode . 1) (:rescale-normal . 1) (:rgba-mode . 1) (:sample-buffers . 1) (:sample-coverage-value . 1) (:sample-coverage-invert . 1) (:samples . 1) (:scissor-box . 4) (:scissor-test . 1) (:selection-buffer-size . 1) (:separable-2d . 1) (:shade-model . 1) (:smooth-line-width-range . 2) (:smooth-line-width-granularity . 1) (:smooth-point-size-range . 2) (:smooth-point-size-granularity . 1) (:stencil-bits . 1) (:stencil-clear-value . 1) (:stencil-fail . 1) (:stencil-func . 1) (:stencil-pass-depth-fail . 1) (:stencil-pass-depth-pass . 1) (:stencil-ref . 1) (:stencil-test . 1) (:stencil-value-mask . 1) (:stencil-writemask . 1) (:stereo . 1) (:subpixel-bits . 1) (:texture-1d . 1) (:texture-binding-1d . 1) (:texture-2d . 1) (:texture-binding-2d . 1) (:texture-3d . 1) (:texture-binding-3d . 1) (:texture-binding-cube-map . 1) (:texture-compression-hint . 1) (:texture-coord-array . 1) (:texture-coord-array-size . 1) (:texture-coord-array-stride . 1) (:texture-coord-array-type . 1) (:texture-cube-map . 1) (:texture-gen-q . 1) (:texture-gen-r . 1) (:texture-gen-s . 1) (:texture-gen-t . 1) (:texture-matrix . 16) (:texture-stack-depth . 1) (:transpose-color-matrix . 16) (:transpose-modelview-matrix . 16) (:transpose-projection-matrix . 16) (:transpose-texture-matrix . 16) (:unpack-alignment . 1) (:unpack-image-height . 1) (:unpack-lsb-first . 1) (:unpack-row-length . 1) (:unpack-skip-images . 1) (:unpack-skip-pixels . 1) (:unpack-skip-rows . 1) (:unpack-swap-bytes . 1) (:vertex-array . 1) (:vertex-array-size . 1) (:vertex-array-stride . 1) (:vertex-array-type . 1) (:viewport . 4) (:zoom-x . 1) (:zoom-y . 1))) ;;; Return the default array size for a state query enum. (defun query-enum-size (value) (or (cdr (assoc value *query-enum-sizes*)) (error "Unknown query enum: ~A" value))) ;;; Define a query function NAME that calls the OpenGL function FN, ;;; passing an array of foreign type TYPE. The elements of the ;;; foreign array are converted back to Lisp values by first ;;; dereferencing the buffer. (defmacro define-query-function (name fn type) `(defun ,name (value &optional (count (query-enum-size value))) (declare (fixnum count)) (with-foreign-object (buf ',type count) (,fn value buf) (if (> count 1) (let ((result (make-array count))) (dotimes (i count) (setf (aref result i) (mem-aref buf ',type i))) result) (mem-ref buf ',type))))) ;;; Define query functions for the basic types. (define-query-function get-boolean %gl:get-boolean-v %gl:boolean) (define-query-function get-integer %gl:get-integer-v %gl:int) (define-query-function get-float %gl:get-float-v %gl:float) (define-query-function get-double %gl:get-double-v %gl:double) ;;; Wrapper around GET-INTEGER when the result should be interpreted ;;; as an enumerated constant. (defun get-enum (value &optional (count (query-enum-size value))) (let ((result (get-integer value count))) (if (vectorp result) (map 'vector (lambda (x) (foreign-enum-keyword 'enum x)) result) (foreign-enum-keyword 'enum result)))) ;;; FIXME: Enable/Disable do not belong here, but I can't find the proper ;;; place to put them. They appear the first time in 2.11.3, but that's ;;; about normal transformations. ;; external (defun enable (&rest caps) (declare (dynamic-extent caps)) (dolist (cap caps) (%gl:enable cap))) ;; external (defun disable (&rest caps) (declare (dynamic-extent caps)) (dolist (cap caps) (%gl:disable cap))) ;; external (definline enabledp (cap) (%gl:is-enabled cap)) ;;; 6.1.11 Pointer and String Queries ;;; FIXME: missing glGetPointer (import-export %gl:get-string) ;; external (defun major-version () (multiple-value-bind (num characters-read) (parse-integer (get-string :version) :end 1) (declare (ignore characters-read)) num)) ;; external (defun minor-version () (multiple-value-bind (num characters-read) (parse-integer (get-string :version) :start 2 :end 3) (declare (ignore characters-read)) num)) ;; external (defun extension-present-p (name) (search name (%gl:get-string :extensions))) ;;; 6.1.14 Shader and Program Queries (import-export %gl:is-shader) (define-get-function get-shader-aux (shader pname) (%gl:get-shader-iv :int int)) (defun get-shader (shader pname) (case pname ((:delete-status :compile-status) ;; Return a boolean for these. (plusp (get-shader-aux shader pname :int))) (otherwise (get-shader-aux shader pname :int)))) (import-export %gl:is-program) (define-get-function get-program-aux (program pname) (%gl:get-program-iv :int int)) (defun get-program (program pname) (case pname ((:delete-status :link-status :validate-status) ;; Return a boolean for these. (plusp (get-program-aux program pname :int))) (otherwise (get-program-aux program pname :int)))) (defun get-attached-shaders (program) "Returns a list of the shaders attached to PROGRAM" (let ((max-shaders (get-program program :attached-shaders))) (with-foreign-object (shaders '%gl:uint max-shaders) (%gl:get-attached-shaders program max-shaders (null-pointer) shaders) (loop for i below max-shaders collecting (mem-aref shaders '%gl:uint i))))) (defun get-shader-info-log (shader) "Returns as a string the entire info log for SHADER" (let ((info-log-length (get-shader shader :info-log-length))) (with-foreign-object (info-log '%gl:char info-log-length) (%gl:get-shader-info-log shader info-log-length (null-pointer) info-log) (foreign-string-to-lisp info-log)))) (defun get-program-info-log (program) "Returns as a string the entire info log for PROGRAM" (let ((info-log-length (get-program program :info-log-length))) (with-foreign-object (info-log '%gl:char info-log-length) (%gl:get-program-info-log program info-log-length (null-pointer) info-log) (foreign-string-to-lisp info-log)))) (defun get-shader-source (shader) "Returns as a string the entire source of SHADER" (let ((source-length (get-shader shader :shader-source-length))) (with-foreign-object (source '%gl:char source-length) (%gl:get-shader-source shader source-length (null-pointer) source) (foreign-string-to-lisp source)))) ;;; 6.1.15 Saving and Restoring State (defun make-bitfield (enum-name attributes) (apply #'logior 0 (mapcar (lambda (x) (foreign-enum-value enum-name x)) attributes))) ;; external (defun push-attrib (&rest attributes) (declare (dynamic-extent attributes)) (%gl:push-attrib (make-bitfield '%gl:enum attributes))) (define-compiler-macro push-attrib (&whole form &rest attributes) (if (every #'keywordp attributes) `(%gl:push-attrib ,(make-bitfield '%gl:enum attributes)) form)) (import-export %gl:pop-attrib) (defmacro with-pushed-attrib ((&rest attributes) &body body) `(progn (push-attrib ,@attributes) (multiple-value-prog1 (progn ,@body) (pop-attrib)))) ;; external (defun push-client-attrib (&rest attributes) (declare (dynamic-extent attributes)) (%gl:push-client-attrib (make-bitfield '%gl:enum attributes))) (define-compiler-macro push-client-attrib (&whole form &rest attributes) (if (every #'keywordp attributes) `(%gl:push-client-attrib ,(make-bitfield '%gl:enum attributes)) form)) (import-export %gl:pop-client-attrib) (defmacro with-pushed-client-attrib ((&rest attributes) &body body) `(progn (push-client-attrib ,@attributes) (multiple-value-prog1 (progn ,@body) (pop-client-attrib))))
16,573
Common Lisp
.lisp
484
29.754132
80
0.635826
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
38abdc1b3b214c62fd26f58932352e24ecf6202dda5a1125752a163ab3df643c
21,601
[ -1 ]
21,602
funcs.lisp
rheaplex_minara/lib/cl-opengl/gl/funcs.lisp
;;; generated file, do not edit ;;; generated from files with following copyright: ;;; ;;; License Applicability. Except to the extent portions of this file are ;;; made subject to an alternative license as permitted in the SGI Free ;;; Software License B, Version 1.1 (the "License"), the contents of this ;;; file are subject only to the provisions of the License. You may not use ;;; this file except in compliance with the License. You may obtain a copy ;;; of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 ;;; Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: ;;; ;;; http://oss.sgi.com/projects/FreeB ;;; ;;; Note that, as provided in the License, the Software is distributed on an ;;; "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS ;;; DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND ;;; CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A ;;; PARTICULAR PURPOSE, AND NON-INFRINGEMENT. ;;; ;;; Original Code. The Original Code is: OpenGL Sample Implementation, ;;; Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, ;;; Inc. The Original Code is Copyright (c) 1991-2002 Silicon Graphics, Inc. ;;; Copyright in any portions created by third parties is as indicated ;;; elsewhere herein. All Rights Reserved. ;;; ;;; Additional Notice Provisions: This software was created using the ;;; OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has ;;; not been independently verified as being compliant with the OpenGL(R) ;;; version 1.2.1 Specification. ;;; ;;; glext version 40 ( 2008/03/24 ) (in-package #:cl-opengl-bindings) (defparameter *glext-version* 40) (defparameter *glext-last-updated* "2008/03/24") ;;; GL version: 1.0, display-list (defglfun ("glNewList" new-list) :void (list uint) (mode enum)) ;;; GL version: 1.0, display-list (defglfun ("glEndList" end-list) :void) ;;; GL version: 1.0, display-list (defglfun ("glCallList" call-list) :void (list uint)) ;;; GL version: 1.0, display-list (defglfun ("glCallLists" call-lists) :void (n sizei) (type enum) (lists (:pointer void))) ;;; GL version: 1.0, display-list (defglfun ("glDeleteLists" delete-lists) :void (list uint) (range sizei)) ;;; GL version: 1.0, display-list (defglfun ("glGenLists" gen-lists) uint (range sizei)) ;;; GL version: 1.0, display-list (defglfun ("glListBase" list-base) :void (base uint)) ;;; GL version: 1.0, drawing (defglfun ("glBegin" begin) :void (mode enum)) ;;; GL version: 1.0, drawing (defglfun ("glBitmap" bitmap) :void (width sizei) (height sizei) (xorig float) (yorig float) (xmove float) (ymove float) (bitmap (:pointer ubyte))) ;;; GL version: 1.0, drawing (defglfun ("glColor3b" color-3b) :void (red byte) (green byte) (blue byte)) ;;; GL version: 1.0, drawing (defglfun ("glColor3bv" color-3bv) :void (v (:pointer byte))) ;;; GL version: 1.0, drawing (defglfun ("glColor3d" color-3d) :void (red double) (green double) (blue double)) ;;; GL version: 1.0, drawing (defglfun ("glColor3dv" color-3dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glColor3f" color-3f) :void (red float) (green float) (blue float)) ;;; GL version: 1.0, drawing (defglfun ("glColor3fv" color-3fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glColor3i" color-3i) :void (red int) (green int) (blue int)) ;;; GL version: 1.0, drawing (defglfun ("glColor3iv" color-3iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glColor3s" color-3s) :void (red short) (green short) (blue short)) ;;; GL version: 1.0, drawing (defglfun ("glColor3sv" color-3sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glColor3ub" color-3ub) :void (red ubyte) (green ubyte) (blue ubyte)) ;;; GL version: 1.0, drawing (defglfun ("glColor3ubv" color-3ubv) :void (v (:pointer ubyte))) ;;; GL version: 1.0, drawing (defglfun ("glColor3ui" color-3ui) :void (red uint) (green uint) (blue uint)) ;;; GL version: 1.0, drawing (defglfun ("glColor3uiv" color-3uiv) :void (v (:pointer uint))) ;;; GL version: 1.0, drawing (defglfun ("glColor3us" color-3us) :void (red ushort) (green ushort) (blue ushort)) ;;; GL version: 1.0, drawing (defglfun ("glColor3usv" color-3usv) :void (v (:pointer ushort))) ;;; GL version: 1.0, drawing (defglfun ("glColor4b" color-4b) :void (red byte) (green byte) (blue byte) (alpha byte)) ;;; GL version: 1.0, drawing (defglfun ("glColor4bv" color-4bv) :void (v (:pointer byte))) ;;; GL version: 1.0, drawing (defglfun ("glColor4d" color-4d) :void (red double) (green double) (blue double) (alpha double)) ;;; GL version: 1.0, drawing (defglfun ("glColor4dv" color-4dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glColor4f" color-4f) :void (red float) (green float) (blue float) (alpha float)) ;;; GL version: 1.0, drawing (defglfun ("glColor4fv" color-4fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glColor4i" color-4i) :void (red int) (green int) (blue int) (alpha int)) ;;; GL version: 1.0, drawing (defglfun ("glColor4iv" color-4iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glColor4s" color-4s) :void (red short) (green short) (blue short) (alpha short)) ;;; GL version: 1.0, drawing (defglfun ("glColor4sv" color-4sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glColor4ub" color-4ub) :void (red ubyte) (green ubyte) (blue ubyte) (alpha ubyte)) ;;; GL version: 1.0, drawing (defglfun ("glColor4ubv" color-4ubv) :void (v (:pointer ubyte))) ;;; GL version: 1.0, drawing (defglfun ("glColor4ui" color-4ui) :void (red uint) (green uint) (blue uint) (alpha uint)) ;;; GL version: 1.0, drawing (defglfun ("glColor4uiv" color-4uiv) :void (v (:pointer uint))) ;;; GL version: 1.0, drawing (defglfun ("glColor4us" color-4us) :void (red ushort) (green ushort) (blue ushort) (alpha ushort)) ;;; GL version: 1.0, drawing (defglfun ("glColor4usv" color-4usv) :void (v (:pointer ushort))) ;;; GL version: 1.0, drawing (defglfun ("glEdgeFlag" edge-flag) :void (flag boolean)) ;;; GL version: 1.0, drawing (defglfun ("glEdgeFlagv" edge-flag-v) :void (flag (:pointer boolean))) ;;; GL version: 1.0, drawing (defglfun ("glEnd" end) :void) ;;; GL version: 1.0, drawing (defglfun ("glIndexd" index-d) :void (c double)) ;;; GL version: 1.0, drawing (defglfun ("glIndexdv" index-dv) :void (c (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glIndexf" index-f) :void (c float)) ;;; GL version: 1.0, drawing (defglfun ("glIndexfv" index-fv) :void (c (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glIndexi" index-i) :void (c int)) ;;; GL version: 1.0, drawing (defglfun ("glIndexiv" index-iv) :void (c (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glIndexs" index-s) :void (c short)) ;;; GL version: 1.0, drawing (defglfun ("glIndexsv" index-sv) :void (c (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glNormal3b" normal-3b) :void (nx byte) (ny byte) (nz byte)) ;;; GL version: 1.0, drawing (defglfun ("glNormal3bv" normal-3bv) :void (v (:pointer byte))) ;;; GL version: 1.0, drawing (defglfun ("glNormal3d" normal-3d) :void (nx double) (ny double) (nz double)) ;;; GL version: 1.0, drawing (defglfun ("glNormal3dv" normal-3dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glNormal3f" normal-3f) :void (nx float) (ny float) (nz float)) ;;; GL version: 1.0, drawing (defglfun ("glNormal3fv" normal-3fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glNormal3i" normal-3i) :void (nx int) (ny int) (nz int)) ;;; GL version: 1.0, drawing (defglfun ("glNormal3iv" normal-3iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glNormal3s" normal-3s) :void (nx short) (ny short) (nz short)) ;;; GL version: 1.0, drawing (defglfun ("glNormal3sv" normal-3sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos2d" raster-pos-2d) :void (x double) (y double)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos2dv" raster-pos-2dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos2f" raster-pos-2f) :void (x float) (y float)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos2fv" raster-pos-2fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos2i" raster-pos-2i) :void (x int) (y int)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos2iv" raster-pos-2iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos2s" raster-pos-2s) :void (x short) (y short)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos2sv" raster-pos-2sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos3d" raster-pos-3d) :void (x double) (y double) (z double)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos3dv" raster-pos-3dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos3f" raster-pos-3f) :void (x float) (y float) (z float)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos3fv" raster-pos-3fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos3i" raster-pos-3i) :void (x int) (y int) (z int)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos3iv" raster-pos-3iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos3s" raster-pos-3s) :void (x short) (y short) (z short)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos3sv" raster-pos-3sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos4d" raster-pos-4d) :void (x double) (y double) (z double) (w double)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos4dv" raster-pos-4dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos4f" raster-pos-4f) :void (x float) (y float) (z float) (w float)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos4fv" raster-pos-4fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos4i" raster-pos-4i) :void (x int) (y int) (z int) (w int)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos4iv" raster-pos-4iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos4s" raster-pos-4s) :void (x short) (y short) (z short) (w short)) ;;; GL version: 1.0, drawing (defglfun ("glRasterPos4sv" raster-pos-4sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glRectd" rect-d) :void (x1 double) (y1 double) (x2 double) (y2 double)) ;;; GL version: 1.0, drawing (defglfun ("glRectdv" rect-dv) :void (v1 (:pointer double)) (v2 (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glRectf" rect-f) :void (x1 float) (y1 float) (x2 float) (y2 float)) ;;; GL version: 1.0, drawing (defglfun ("glRectfv" rect-fv) :void (v1 (:pointer float)) (v2 (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glRecti" rect-i) :void (x1 int) (y1 int) (x2 int) (y2 int)) ;;; GL version: 1.0, drawing (defglfun ("glRectiv" rect-iv) :void (v1 (:pointer int)) (v2 (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glRects" rect-s) :void (x1 short) (y1 short) (x2 short) (y2 short)) ;;; GL version: 1.0, drawing (defglfun ("glRectsv" rect-sv) :void (v1 (:pointer short)) (v2 (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord1d" tex-coord-1d) :void (s double)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord1dv" tex-coord-1dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord1f" tex-coord-1f) :void (s float)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord1fv" tex-coord-1fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord1i" tex-coord-1i) :void (s int)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord1iv" tex-coord-1iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord1s" tex-coord-1s) :void (s short)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord1sv" tex-coord-1sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord2d" tex-coord-2d) :void (s double) (tee double)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord2dv" tex-coord-2dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord2f" tex-coord-2f) :void (s float) (tee float)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord2fv" tex-coord-2fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord2i" tex-coord-2i) :void (s int) (tee int)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord2iv" tex-coord-2iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord2s" tex-coord-2s) :void (s short) (tee short)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord2sv" tex-coord-2sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord3d" tex-coord-3d) :void (s double) (tee double) (r double)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord3dv" tex-coord-3dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord3f" tex-coord-3f) :void (s float) (tee float) (r float)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord3fv" tex-coord-3fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord3i" tex-coord-3i) :void (s int) (tee int) (r int)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord3iv" tex-coord-3iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord3s" tex-coord-3s) :void (s short) (tee short) (r short)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord3sv" tex-coord-3sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord4d" tex-coord-4d) :void (s double) (tee double) (r double) (q double)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord4dv" tex-coord-4dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord4f" tex-coord-4f) :void (s float) (tee float) (r float) (q float)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord4fv" tex-coord-4fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord4i" tex-coord-4i) :void (s int) (tee int) (r int) (q int)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord4iv" tex-coord-4iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord4s" tex-coord-4s) :void (s short) (tee short) (r short) (q short)) ;;; GL version: 1.0, drawing (defglfun ("glTexCoord4sv" tex-coord-4sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glVertex2d" vertex-2d) :void (x double) (y double)) ;;; GL version: 1.0, drawing (defglfun ("glVertex2dv" vertex-2dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glVertex2f" vertex-2f) :void (x float) (y float)) ;;; GL version: 1.0, drawing (defglfun ("glVertex2fv" vertex-2fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glVertex2i" vertex-2i) :void (x int) (y int)) ;;; GL version: 1.0, drawing (defglfun ("glVertex2iv" vertex-2iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glVertex2s" vertex-2s) :void (x short) (y short)) ;;; GL version: 1.0, drawing (defglfun ("glVertex2sv" vertex-2sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glVertex3d" vertex-3d) :void (x double) (y double) (z double)) ;;; GL version: 1.0, drawing (defglfun ("glVertex3dv" vertex-3dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glVertex3f" vertex-3f) :void (x float) (y float) (z float)) ;;; GL version: 1.0, drawing (defglfun ("glVertex3fv" vertex-3fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glVertex3i" vertex-3i) :void (x int) (y int) (z int)) ;;; GL version: 1.0, drawing (defglfun ("glVertex3iv" vertex-3iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glVertex3s" vertex-3s) :void (x short) (y short) (z short)) ;;; GL version: 1.0, drawing (defglfun ("glVertex3sv" vertex-3sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing (defglfun ("glVertex4d" vertex-4d) :void (x double) (y double) (z double) (w double)) ;;; GL version: 1.0, drawing (defglfun ("glVertex4dv" vertex-4dv) :void (v (:pointer double))) ;;; GL version: 1.0, drawing (defglfun ("glVertex4f" vertex-4f) :void (x float) (y float) (z float) (w float)) ;;; GL version: 1.0, drawing (defglfun ("glVertex4fv" vertex-4fv) :void (v (:pointer float))) ;;; GL version: 1.0, drawing (defglfun ("glVertex4i" vertex-4i) :void (x int) (y int) (z int) (w int)) ;;; GL version: 1.0, drawing (defglfun ("glVertex4iv" vertex-4iv) :void (v (:pointer int))) ;;; GL version: 1.0, drawing (defglfun ("glVertex4s" vertex-4s) :void (x short) (y short) (z short) (w short)) ;;; GL version: 1.0, drawing (defglfun ("glVertex4sv" vertex-4sv) :void (v (:pointer short))) ;;; GL version: 1.0, drawing-control (defglfun ("glClipPlane" clip-plane) :void (plane enum) (equation (:pointer double))) ;;; GL version: 1.0, drawing-control (defglfun ("glColorMaterial" color-material) :void (face enum) (mode enum)) ;;; GL version: 1.0, drawing-control (defglfun ("glCullFace" cull-face) :void (mode enum)) ;;; GL version: 1.0, drawing-control (defglfun ("glFogf" fog-f) :void (pname enum) (param float)) ;;; GL version: 1.0, drawing-control (defglfun ("glFogfv" fog-fv) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.0, drawing-control (defglfun ("glFogi" fog-i) :void (pname enum) (param int)) ;;; GL version: 1.0, drawing-control (defglfun ("glFogiv" fog-iv) :void (pname enum) (params (:pointer int))) ;;; GL version: 1.0, drawing-control (defglfun ("glFrontFace" front-face) :void (mode enum)) ;;; GL version: 1.0, drawing-control (defglfun ("glHint" hint) :void (target enum) (mode enum)) ;;; GL version: 1.0, drawing-control (defglfun ("glLightf" light-f) :void (light enum) (pname enum) (param float)) ;;; GL version: 1.0, drawing-control (defglfun ("glLightfv" light-fv) :void (light enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, drawing-control (defglfun ("glLighti" light-i) :void (light enum) (pname enum) (param int)) ;;; GL version: 1.0, drawing-control (defglfun ("glLightiv" light-iv) :void (light enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, drawing-control (defglfun ("glLightModelf" light-model-f) :void (pname enum) (param float)) ;;; GL version: 1.0, drawing-control (defglfun ("glLightModelfv" light-model-fv) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.0, drawing-control (defglfun ("glLightModeli" light-model-i) :void (pname enum) (param int)) ;;; GL version: 1.0, drawing-control (defglfun ("glLightModeliv" light-model-iv) :void (pname enum) (params (:pointer int))) ;;; GL version: 1.0, drawing-control (defglfun ("glLineStipple" line-stipple) :void (factor int) (pattern ushort)) ;;; GL version: 1.0, drawing-control (defglfun ("glLineWidth" line-width) :void (width float)) ;;; GL version: 1.0, drawing-control (defglfun ("glMaterialf" material-f) :void (face enum) (pname enum) (param float)) ;;; GL version: 1.0, drawing-control (defglfun ("glMaterialfv" material-fv) :void (face enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, drawing-control (defglfun ("glMateriali" material-i) :void (face enum) (pname enum) (param int)) ;;; GL version: 1.0, drawing-control (defglfun ("glMaterialiv" material-iv) :void (face enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, drawing-control (defglfun ("glPointSize" point-size) :void (size float)) ;;; GL version: 1.0, drawing-control (defglfun ("glPolygonMode" polygon-mode) :void (face enum) (mode enum)) ;;; GL version: 1.0, drawing-control (defglfun ("glPolygonStipple" polygon-stipple) :void (mask (:pointer ubyte))) ;;; GL version: 1.0, drawing-control (defglfun ("glScissor" scissor) :void (x int) (y int) (width sizei) (height sizei)) ;;; GL version: 1.0, drawing-control (defglfun ("glShadeModel" shade-model) :void (mode enum)) ;;; GL version: 1.0, drawing-control (defglfun ("glTexParameterf" tex-parameter-f) :void (target enum) (pname enum) (param float)) ;;; GL version: 1.0, drawing-control (defglfun ("glTexParameterfv" tex-parameter-fv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, drawing-control (defglfun ("glTexParameteri" tex-parameter-i) :void (target enum) (pname enum) (param int)) ;;; GL version: 1.0, drawing-control (defglfun ("glTexParameteriv" tex-parameter-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, drawing-control (defglfun ("glTexImage1D" tex-image-1d) :void (target enum) (level int) (internalformat int) (width sizei) (border int) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.0, drawing-control (defglfun ("glTexImage2D" tex-image-2d) :void (target enum) (level int) (internalformat int) (width sizei) (height sizei) (border int) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.0, drawing-control (defglfun ("glTexEnvf" tex-env-f) :void (target enum) (pname enum) (param float)) ;;; GL version: 1.0, drawing-control (defglfun ("glTexEnvfv" tex-env-fv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, drawing-control (defglfun ("glTexEnvi" tex-env-i) :void (target enum) (pname enum) (param int)) ;;; GL version: 1.0, drawing-control (defglfun ("glTexEnviv" tex-env-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, drawing-control (defglfun ("glTexGend" tex-gen-d) :void (coord enum) (pname enum) (param double)) ;;; GL version: 1.0, drawing-control (defglfun ("glTexGendv" tex-gen-dv) :void (coord enum) (pname enum) (params (:pointer double))) ;;; GL version: 1.0, drawing-control (defglfun ("glTexGenf" tex-gen-f) :void (coord enum) (pname enum) (param float)) ;;; GL version: 1.0, drawing-control (defglfun ("glTexGenfv" tex-gen-fv) :void (coord enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, drawing-control (defglfun ("glTexGeni" tex-gen-i) :void (coord enum) (pname enum) (param int)) ;;; GL version: 1.0, drawing-control (defglfun ("glTexGeniv" tex-gen-iv) :void (coord enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, feedback (defglfun ("glFeedbackBuffer" feedback-buffer) :void (size sizei) (type enum) (buffer (:pointer float))) ;;; GL version: 1.0, feedback (defglfun ("glSelectBuffer" select-buffer) :void (size sizei) (buffer (:pointer uint))) ;;; GL version: 1.0, feedback (defglfun ("glRenderMode" render-mode) int (mode enum)) ;;; GL version: 1.0, feedback (defglfun ("glInitNames" init-names) :void) ;;; GL version: 1.0, feedback (defglfun ("glLoadName" load-name) :void (name uint)) ;;; GL version: 1.0, feedback (defglfun ("glPassThrough" pass-through) :void (token float)) ;;; GL version: 1.0, feedback (defglfun ("glPopName" pop-name) :void) ;;; GL version: 1.0, feedback (defglfun ("glPushName" push-name) :void (name uint)) ;;; GL version: 1.0, framebuf (defglfun ("glDrawBuffer" draw-buffer) :void (mode enum)) ;;; GL version: 1.0, framebuf (defglfun ("glClear" clear) :void (mask bitfield)) ;;; GL version: 1.0, framebuf (defglfun ("glClearAccum" clear-accum) :void (red float) (green float) (blue float) (alpha float)) ;;; GL version: 1.0, framebuf (defglfun ("glClearIndex" clear-index) :void (c float)) ;;; GL version: 1.0, framebuf (defglfun ("glClearColor" clear-color) :void (red clampf) (green clampf) (blue clampf) (alpha clampf)) ;;; GL version: 1.0, framebuf (defglfun ("glClearStencil" clear-stencil) :void (s int)) ;;; GL version: 1.0, framebuf (defglfun ("glClearDepth" clear-depth) :void (depth clampd)) ;;; GL version: 1.0, framebuf (defglfun ("glStencilMask" stencil-mask) :void (mask uint)) ;;; GL version: 1.0, framebuf (defglfun ("glColorMask" color-mask) :void (red boolean) (green boolean) (blue boolean) (alpha boolean)) ;;; GL version: 1.0, framebuf (defglfun ("glDepthMask" depth-mask) :void (flag boolean)) ;;; GL version: 1.0, framebuf (defglfun ("glIndexMask" index-mask) :void (mask uint)) ;;; GL version: 1.0, misc (defglfun ("glAccum" accum) :void (op enum) (value float)) ;;; GL version: 1.0, misc (defglfun ("glDisable" disable) :void (cap enum)) ;;; GL version: 1.0, misc (defglfun ("glEnable" enable) :void (cap enum)) ;;; GL version: 1.0, misc (defglfun ("glFinish" finish) :void) ;;; GL version: 1.0, misc (defglfun ("glFlush" flush) :void) ;;; GL version: 1.0, misc (defglfun ("glPopAttrib" pop-attrib) :void) ;;; GL version: 1.0, misc (defglfun ("glPushAttrib" push-attrib) :void (mask bitfield)) ;;; GL version: 1.0, modeling (defglfun ("glMap1d" map-1d) :void (target enum) (u1 double) (u2 double) (stride int) (order int) (points (:pointer double))) ;;; GL version: 1.0, modeling (defglfun ("glMap1f" map-1f) :void (target enum) (u1 float) (u2 float) (stride int) (order int) (points (:pointer float))) ;;; GL version: 1.0, modeling (defglfun ("glMap2d" map-2d) :void (target enum) (u1 double) (u2 double) (ustride int) (uorder int) (v1 double) (v2 double) (vstride int) (vorder int) (points (:pointer double))) ;;; GL version: 1.0, modeling (defglfun ("glMap2f" map-2f) :void (target enum) (u1 float) (u2 float) (ustride int) (uorder int) (v1 float) (v2 float) (vstride int) (vorder int) (points (:pointer float))) ;;; GL version: 1.0, modeling (defglfun ("glMapGrid1d" map-grid-1d) :void (un int) (u1 double) (u2 double)) ;;; GL version: 1.0, modeling (defglfun ("glMapGrid1f" map-grid-1f) :void (un int) (u1 float) (u2 float)) ;;; GL version: 1.0, modeling (defglfun ("glMapGrid2d" map-grid-2d) :void (un int) (u1 double) (u2 double) (vn int) (v1 double) (v2 double)) ;;; GL version: 1.0, modeling (defglfun ("glMapGrid2f" map-grid-2f) :void (un int) (u1 float) (u2 float) (vn int) (v1 float) (v2 float)) ;;; GL version: 1.0, modeling (defglfun ("glEvalCoord1d" eval-coord-1d) :void (u double)) ;;; GL version: 1.0, modeling (defglfun ("glEvalCoord1dv" eval-coord-1dv) :void (u (:pointer double))) ;;; GL version: 1.0, modeling (defglfun ("glEvalCoord1f" eval-coord-1f) :void (u float)) ;;; GL version: 1.0, modeling (defglfun ("glEvalCoord1fv" eval-coord-1fv) :void (u (:pointer float))) ;;; GL version: 1.0, modeling (defglfun ("glEvalCoord2d" eval-coord-2d) :void (u double) (v double)) ;;; GL version: 1.0, modeling (defglfun ("glEvalCoord2dv" eval-coord-2dv) :void (u (:pointer double))) ;;; GL version: 1.0, modeling (defglfun ("glEvalCoord2f" eval-coord-2f) :void (u float) (v float)) ;;; GL version: 1.0, modeling (defglfun ("glEvalCoord2fv" eval-coord-2fv) :void (u (:pointer float))) ;;; GL version: 1.0, modeling (defglfun ("glEvalMesh1" eval-mesh-1) :void (mode enum) (i1 int) (i2 int)) ;;; GL version: 1.0, modeling (defglfun ("glEvalPoint1" eval-point-1) :void (i int)) ;;; GL version: 1.0, modeling (defglfun ("glEvalMesh2" eval-mesh-2) :void (mode enum) (i1 int) (i2 int) (j1 int) (j2 int)) ;;; GL version: 1.0, modeling (defglfun ("glEvalPoint2" eval-point-2) :void (i int) (j int)) ;;; GL version: 1.0, pixel-op (defglfun ("glAlphaFunc" alpha-func) :void (func enum) (ref clampf)) ;;; GL version: 1.0, pixel-op (defglfun ("glBlendFunc" blend-func) :void (sfactor enum) (dfactor enum)) ;;; GL version: 1.0, pixel-op (defglfun ("glLogicOp" logic-op) :void (opcode enum)) ;;; GL version: 1.0, pixel-op (defglfun ("glStencilFunc" stencil-func) :void (func enum) (ref int) (mask uint)) ;;; GL version: 1.0, pixel-op (defglfun ("glStencilOp" stencil-op) :void (fail enum) (zfail enum) (zpass enum)) ;;; GL version: 1.0, pixel-op (defglfun ("glDepthFunc" depth-func) :void (func enum)) ;;; GL version: 1.0, pixel-rw (defglfun ("glPixelZoom" pixel-zoom) :void (xfactor float) (yfactor float)) ;;; GL version: 1.0, pixel-rw (defglfun ("glPixelTransferf" pixel-transfer-f) :void (pname enum) (param float)) ;;; GL version: 1.0, pixel-rw (defglfun ("glPixelTransferi" pixel-transfer-i) :void (pname enum) (param int)) ;;; GL version: 1.0, pixel-rw (defglfun ("glPixelStoref" pixel-store-f) :void (pname enum) (param float)) ;;; GL version: 1.0, pixel-rw (defglfun ("glPixelStorei" pixel-store-i) :void (pname enum) (param int)) ;;; GL version: 1.0, pixel-rw (defglfun ("glPixelMapfv" pixel-map-fv) :void (map enum) (mapsize int) (values (:pointer float))) ;;; GL version: 1.0, pixel-rw (defglfun ("glPixelMapuiv" pixel-map-uiv) :void (map enum) (mapsize int) (values (:pointer uint))) ;;; GL version: 1.0, pixel-rw (defglfun ("glPixelMapusv" pixel-map-usv) :void (map enum) (mapsize int) (values (:pointer ushort))) ;;; GL version: 1.0, pixel-rw (defglfun ("glReadBuffer" read-buffer) :void (mode enum)) ;;; GL version: 1.0, pixel-rw (defglfun ("glCopyPixels" copy-pixels) :void (x int) (y int) (width sizei) (height sizei) (type enum)) ;;; GL version: 1.0, pixel-rw (defglfun ("glReadPixels" read-pixels) :void (x int) (y int) (width sizei) (height sizei) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.0, pixel-rw (defglfun ("glDrawPixels" draw-pixels) :void (width sizei) (height sizei) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.0, state-req (defglfun ("glGetBooleanv" get-boolean-v) :void (pname enum) (params (:pointer boolean))) ;;; GL version: 1.0, state-req (defglfun ("glGetClipPlane" get-clip-plane) :void (plane enum) (equation (:pointer double))) ;;; GL version: 1.0, state-req (defglfun ("glGetDoublev" get-double-v) :void (pname enum) (params (:pointer double))) ;;; GL version: 1.0, state-req (defglfun ("glGetError" get-error) enum) ;;; GL version: 1.0, state-req (defglfun ("glGetFloatv" get-float-v) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.0, state-req (defglfun ("glGetIntegerv" get-integer-v) :void (pname enum) (params (:pointer int))) ;;; GL version: 1.0, state-req (defglfun ("glGetLightfv" get-light-fv) :void (light enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, state-req (defglfun ("glGetLightiv" get-light-iv) :void (light enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, state-req (defglfun ("glGetMapdv" get-map-dv) :void (target enum) (query enum) (v (:pointer double))) ;;; GL version: 1.0, state-req (defglfun ("glGetMapfv" get-map-fv) :void (target enum) (query enum) (v (:pointer float))) ;;; GL version: 1.0, state-req (defglfun ("glGetMapiv" get-map-iv) :void (target enum) (query enum) (v (:pointer int))) ;;; GL version: 1.0, state-req (defglfun ("glGetMaterialfv" get-material-fv) :void (face enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, state-req (defglfun ("glGetMaterialiv" get-material-iv) :void (face enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, state-req (defglfun ("glGetPixelMapfv" get-pixel-map-fv) :void (map enum) (values (:pointer float))) ;;; GL version: 1.0, state-req (defglfun ("glGetPixelMapuiv" get-pixel-map-uiv) :void (map enum) (values (:pointer uint))) ;;; GL version: 1.0, state-req (defglfun ("glGetPixelMapusv" get-pixel-map-usv) :void (map enum) (values (:pointer ushort))) ;;; GL version: 1.0, state-req (defglfun ("glGetPolygonStipple" get-polygon-stipple) :void (mask (:pointer ubyte))) ;;; GL version: 1.0, state-req (defglfun ("glGetString" get-string) string (name enum)) ;;; GL version: 1.0, state-req (defglfun ("glGetTexEnvfv" get-tex-env-fv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, state-req (defglfun ("glGetTexEnviv" get-tex-env-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, state-req (defglfun ("glGetTexGendv" get-tex-gen-dv) :void (coord enum) (pname enum) (params (:pointer double))) ;;; GL version: 1.0, state-req (defglfun ("glGetTexGenfv" get-tex-gen-fv) :void (coord enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, state-req (defglfun ("glGetTexGeniv" get-tex-gen-iv) :void (coord enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, state-req (defglfun ("glGetTexImage" get-tex-image) :void (target enum) (level int) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.0, state-req (defglfun ("glGetTexParameterfv" get-tex-parameter-fv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, state-req (defglfun ("glGetTexParameteriv" get-tex-parameter-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, state-req (defglfun ("glGetTexLevelParameterfv" get-tex-level-parameter-fv) :void (target enum) (level int) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, state-req (defglfun ("glGetTexLevelParameteriv" get-tex-level-parameter-iv) :void (target enum) (level int) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, state-req (defglfun ("glIsEnabled" is-enabled) boolean (cap enum)) ;;; GL version: 1.0, state-req (defglfun ("glIsList" is-list) boolean (list uint)) ;;; GL version: 1.0, xform (defglfun ("glDepthRange" depth-range) :void (near clampd) (far clampd)) ;;; GL version: 1.0, xform (defglfun ("glFrustum" frustum) :void (left double) (right double) (bottom double) (top double) (zNear double) (zFar double)) ;;; GL version: 1.0, xform (defglfun ("glLoadIdentity" load-identity) :void) ;;; GL version: 1.0, xform (defglfun ("glLoadMatrixf" load-matrix-f) :void (m (:pointer float))) ;;; GL version: 1.0, xform (defglfun ("glLoadMatrixd" load-matrix-d) :void (m (:pointer double))) ;;; GL version: 1.0, xform (defglfun ("glMatrixMode" matrix-mode) :void (mode enum)) ;;; GL version: 1.0, xform (defglfun ("glMultMatrixf" mult-matrix-f) :void (m (:pointer float))) ;;; GL version: 1.0, xform (defglfun ("glMultMatrixd" mult-matrix-d) :void (m (:pointer double))) ;;; GL version: 1.0, xform (defglfun ("glOrtho" ortho) :void (left double) (right double) (bottom double) (top double) (zNear double) (zFar double)) ;;; GL version: 1.0, xform (defglfun ("glPopMatrix" pop-matrix) :void) ;;; GL version: 1.0, xform (defglfun ("glPushMatrix" push-matrix) :void) ;;; GL version: 1.0, xform (defglfun ("glRotated" rotate-d) :void (angle double) (x double) (y double) (z double)) ;;; GL version: 1.0, xform (defglfun ("glRotatef" rotate-f) :void (angle float) (x float) (y float) (z float)) ;;; GL version: 1.0, xform (defglfun ("glScaled" scale-d) :void (x double) (y double) (z double)) ;;; GL version: 1.0, xform (defglfun ("glScalef" scale-f) :void (x float) (y float) (z float)) ;;; GL version: 1.0, xform (defglfun ("glTranslated" translate-d) :void (x double) (y double) (z double)) ;;; GL version: 1.0, xform (defglfun ("glTranslatef" translate-f) :void (x float) (y float) (z float)) ;;; GL version: 1.0, xform (defglfun ("glViewport" viewport) :void (x int) (y int) (width sizei) (height sizei)) ;;; GL version: 1.1, 1_1 (defglfun ("glArrayElement" array-element) :void (i int)) ;;; GL version: 1.1, 1_1 (defglfun ("glColorPointer" color-pointer) :void (size int) (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, 1_1 (defglfun ("glDisableClientState" disable-client-state) :void (array enum)) ;;; GL version: 1.1, 1_1 (defglfun ("glDrawArrays" draw-arrays) :void (mode enum) (first int) (count sizei)) ;;; GL version: 1.1, 1_1 (defglfun ("glDrawElements" draw-elements) :void (mode enum) (count sizei) (type enum) (indices (:pointer void))) ;;; GL version: 1.1, 1_1 (defglfun ("glEdgeFlagPointer" edge-flag-pointer) :void (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, 1_1 (defglfun ("glEnableClientState" enable-client-state) :void (array enum)) ;;; GL version: 1.1, 1_1 (defglfun ("glGetPointerv" get-pointer-v) :void (pname enum) (params (:pointer (:pointer void)))) ;;; GL version: 1.1, 1_1 (defglfun ("glIndexPointer" index-pointer) :void (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, 1_1 (defglfun ("glInterleavedArrays" interleaved-arrays) :void (format enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, 1_1 (defglfun ("glNormalPointer" normal-pointer) :void (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, 1_1 (defglfun ("glTexCoordPointer" tex-coord-pointer) :void (size int) (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, 1_1 (defglfun ("glVertexPointer" vertex-pointer) :void (size int) (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, 1_1 (defglfun ("glPolygonOffset" polygon-offset) :void (factor float) (units float)) ;;; GL version: 1.1, 1_1 (defglfun ("glCopyTexImage1D" copy-tex-image-1d) :void (target enum) (level int) (internalformat enum) (x int) (y int) (width sizei) (border int)) ;;; GL version: 1.1, 1_1 (defglfun ("glCopyTexImage2D" copy-tex-image-2d) :void (target enum) (level int) (internalformat enum) (x int) (y int) (width sizei) (height sizei) (border int)) ;;; GL version: 1.1, 1_1 (defglfun ("glCopyTexSubImage1D" copy-tex-sub-image-1d) :void (target enum) (level int) (xoffset int) (x int) (y int) (width sizei)) ;;; GL version: 1.1, 1_1 (defglfun ("glCopyTexSubImage2D" copy-tex-sub-image-2d) :void (target enum) (level int) (xoffset int) (yoffset int) (x int) (y int) (width sizei) (height sizei)) ;;; GL version: 1.1, 1_1 (defglfun ("glTexSubImage1D" tex-sub-image-1d) :void (target enum) (level int) (xoffset int) (width sizei) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.1, 1_1 (defglfun ("glTexSubImage2D" tex-sub-image-2d) :void (target enum) (level int) (xoffset int) (yoffset int) (width sizei) (height sizei) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.1, 1_1 (defglfun ("glAreTexturesResident" are-textures-resident) boolean (n sizei) (textures (:pointer uint)) (residences (:pointer boolean))) ;;; GL version: 1.1, 1_1 (defglfun ("glBindTexture" bind-texture) :void (target enum) (texture uint)) ;;; GL version: 1.1, 1_1 (defglfun ("glDeleteTextures" delete-textures) :void (n sizei) (textures (:pointer uint))) ;;; GL version: 1.1, 1_1 (defglfun ("glGenTextures" gen-textures) :void (n sizei) (textures (:pointer uint))) ;;; GL version: 1.1, 1_1 (defglfun ("glIsTexture" is-texture) boolean (texture uint)) ;;; GL version: 1.1, 1_1 (defglfun ("glPrioritizeTextures" prioritize-textures) :void (n sizei) (textures (:pointer uint)) (priorities (:pointer clampf))) ;;; GL version: 1.1, 1_1 (defglfun ("glIndexub" index-ub) :void (c ubyte)) ;;; GL version: 1.1, 1_1 (defglfun ("glIndexubv" index-ubv) :void (c (:pointer ubyte))) ;;; GL version: 1.1, 1_1 (defglfun ("glPopClientAttrib" pop-client-attrib) :void) ;;; GL version: 1.1, 1_1 (defglfun ("glPushClientAttrib" push-client-attrib) :void (mask bitfield)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glBlendColor" blend-color) :void (red clampf) (green clampf) (blue clampf) (alpha clampf)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glBlendEquation" blend-equation) :void (mode enum)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glDrawRangeElements" draw-range-elements) :void (mode enum) (start uint) (end uint) (count sizei) (type enum) (indices (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glColorTable" color-table) :void (target enum) (internalformat enum) (width sizei) (format enum) (type enum) (table (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glColorTableParameterfv" color-table-parameter-fv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glColorTableParameteriv" color-table-parameter-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glCopyColorTable" copy-color-table) :void (target enum) (internalformat enum) (x int) (y int) (width sizei)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetColorTable" get-color-table) :void (target enum) (format enum) (type enum) (table (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetColorTableParameterfv" get-color-table-parameter-fv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetColorTableParameteriv" get-color-table-parameter-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glColorSubTable" color-sub-table) :void (target enum) (start sizei) (count sizei) (format enum) (type enum) (data (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glCopyColorSubTable" copy-color-sub-table) :void (target enum) (start sizei) (x int) (y int) (width sizei)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glConvolutionFilter1D" convolution-filter-1d) :void (target enum) (internalformat enum) (width sizei) (format enum) (type enum) (image (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glConvolutionFilter2D" convolution-filter-2d) :void (target enum) (internalformat enum) (width sizei) (height sizei) (format enum) (type enum) (image (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glConvolutionParameterf" convolution-parameter-f) :void (target enum) (pname enum) (params float)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glConvolutionParameterfv" convolution-parameter-fv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glConvolutionParameteri" convolution-parameter-i) :void (target enum) (pname enum) (params int)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glConvolutionParameteriv" convolution-parameter-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glCopyConvolutionFilter1D" copy-convolution-filter-1d) :void (target enum) (internalformat enum) (x int) (y int) (width sizei)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glCopyConvolutionFilter2D" copy-convolution-filter-2d) :void (target enum) (internalformat enum) (x int) (y int) (width sizei) (height sizei)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetConvolutionFilter" get-convolution-filter) :void (target enum) (format enum) (type enum) (image (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetConvolutionParameterfv" get-convolution-parameter-fv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetConvolutionParameteriv" get-convolution-parameter-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetSeparableFilter" get-separable-filter) :void (target enum) (format enum) (type enum) (row (:pointer void)) (column (:pointer void)) (span (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glSeparableFilter2D" separable-filter-2d) :void (target enum) (internalformat enum) (width sizei) (height sizei) (format enum) (type enum) (row (:pointer void)) (column (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetHistogram" get-histogram) :void (target enum) (reset boolean) (format enum) (type enum) (values (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetHistogramParameterfv" get-histogram-parameter-fv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetHistogramParameteriv" get-histogram-parameter-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetMinmax" get-minmax) :void (target enum) (reset boolean) (format enum) (type enum) (values (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetMinmaxParameterfv" get-minmax-parameter-fv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glGetMinmaxParameteriv" get-minmax-parameter-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glHistogram" histogram) :void (target enum) (width sizei) (internalformat enum) (sink boolean)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glMinmax" minmax) :void (target enum) (internalformat enum) (sink boolean)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glResetHistogram" reset-histogram) :void (target enum)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glResetMinmax" reset-minmax) :void (target enum)) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glTexImage3D" tex-image-3d) :void (target enum) (level int) (internalformat int) (width sizei) (height sizei) (depth sizei) (border int) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glTexSubImage3D" tex-sub-image-3d) :void (target enum) (level int) (xoffset int) (yoffset int) (zoffset int) (width sizei) (height sizei) (depth sizei) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.2, VERSION_1_2 (defglextfun ("glCopyTexSubImage3D" copy-tex-sub-image-3d) :void (target enum) (level int) (xoffset int) (yoffset int) (zoffset int) (x int) (y int) (width sizei) (height sizei)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glActiveTexture" active-texture) :void (texture enum)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glClientActiveTexture" client-active-texture) :void (texture enum)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord1d" multi-tex-coord-1d) :void (target enum) (s double)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord1dv" multi-tex-coord-1dv) :void (target enum) (v (:pointer double))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord1f" multi-tex-coord-1f) :void (target enum) (s float)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord1fv" multi-tex-coord-1fv) :void (target enum) (v (:pointer float))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord1i" multi-tex-coord-1i) :void (target enum) (s int)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord1iv" multi-tex-coord-1iv) :void (target enum) (v (:pointer int))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord1s" multi-tex-coord-1s) :void (target enum) (s short)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord1sv" multi-tex-coord-1sv) :void (target enum) (v (:pointer short))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord2d" multi-tex-coord-2d) :void (target enum) (s double) (tee double)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord2dv" multi-tex-coord-2dv) :void (target enum) (v (:pointer double))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord2f" multi-tex-coord-2f) :void (target enum) (s float) (tee float)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord2fv" multi-tex-coord-2fv) :void (target enum) (v (:pointer float))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord2i" multi-tex-coord-2i) :void (target enum) (s int) (tee int)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord2iv" multi-tex-coord-2iv) :void (target enum) (v (:pointer int))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord2s" multi-tex-coord-2s) :void (target enum) (s short) (tee short)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord2sv" multi-tex-coord-2sv) :void (target enum) (v (:pointer short))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord3d" multi-tex-coord-3d) :void (target enum) (s double) (tee double) (r double)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord3dv" multi-tex-coord-3dv) :void (target enum) (v (:pointer double))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord3f" multi-tex-coord-3f) :void (target enum) (s float) (tee float) (r float)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord3fv" multi-tex-coord-3fv) :void (target enum) (v (:pointer float))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord3i" multi-tex-coord-3i) :void (target enum) (s int) (tee int) (r int)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord3iv" multi-tex-coord-3iv) :void (target enum) (v (:pointer int))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord3s" multi-tex-coord-3s) :void (target enum) (s short) (tee short) (r short)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord3sv" multi-tex-coord-3sv) :void (target enum) (v (:pointer short))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord4d" multi-tex-coord-4d) :void (target enum) (s double) (tee double) (r double) (q double)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord4dv" multi-tex-coord-4dv) :void (target enum) (v (:pointer double))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord4f" multi-tex-coord-4f) :void (target enum) (s float) (tee float) (r float) (q float)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord4fv" multi-tex-coord-4fv) :void (target enum) (v (:pointer float))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord4i" multi-tex-coord-4i) :void (target enum) (s int) (tee int) (r int) (q int)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord4iv" multi-tex-coord-4iv) :void (target enum) (v (:pointer int))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord4s" multi-tex-coord-4s) :void (target enum) (s short) (tee short) (r short) (q short)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultiTexCoord4sv" multi-tex-coord-4sv) :void (target enum) (v (:pointer short))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glLoadTransposeMatrixf" load-transpose-matrix-f) :void (m (:pointer float))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glLoadTransposeMatrixd" load-transpose-matrix-d) :void (m (:pointer double))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultTransposeMatrixf" mult-transpose-matrix-f) :void (m (:pointer float))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glMultTransposeMatrixd" mult-transpose-matrix-d) :void (m (:pointer double))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glSampleCoverage" sample-coverage) :void (value clampf) (invert boolean)) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glCompressedTexImage3D" compressed-tex-image-3d) :void (target enum) (level int) (internalformat enum) (width sizei) (height sizei) (depth sizei) (border int) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glCompressedTexImage2D" compressed-tex-image-2d) :void (target enum) (level int) (internalformat enum) (width sizei) (height sizei) (border int) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glCompressedTexImage1D" compressed-tex-image-1d) :void (target enum) (level int) (internalformat enum) (width sizei) (border int) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glCompressedTexSubImage3D" compressed-tex-sub-image-3d) :void (target enum) (level int) (xoffset int) (yoffset int) (zoffset int) (width sizei) (height sizei) (depth sizei) (format enum) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glCompressedTexSubImage2D" compressed-tex-sub-image-2d) :void (target enum) (level int) (xoffset int) (yoffset int) (width sizei) (height sizei) (format enum) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glCompressedTexSubImage1D" compressed-tex-sub-image-1d) :void (target enum) (level int) (xoffset int) (width sizei) (format enum) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.3, VERSION_1_3 (defglextfun ("glGetCompressedTexImage" get-compressed-tex-image) :void (target enum) (level int) (img (:pointer void))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glBlendFuncSeparate" blend-func-separate) :void (sfactorRGB enum) (dfactorRGB enum) (sfactorAlpha enum) (dfactorAlpha enum)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glFogCoordf" fog-coord-f) :void (coord float)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glFogCoordfv" fog-coord-fv) :void (coord (:pointer float))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glFogCoordd" fog-coord-d) :void (coord double)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glFogCoorddv" fog-coord-dv) :void (coord (:pointer double))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glFogCoordPointer" fog-coord-pointer) :void (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glMultiDrawArrays" multi-draw-arrays) :void (mode enum) (first (:pointer int)) (count (:pointer sizei)) (primcount sizei)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glMultiDrawElements" multi-draw-elements) :void (mode enum) (count (:pointer sizei)) (type enum) (indices (:pointer (:pointer void))) (primcount sizei)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glPointParameterf" point-parameter-f) :void (pname enum) (param float)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glPointParameterfv" point-parameter-fv) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glPointParameteri" point-parameter-i) :void (pname enum) (param int)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glPointParameteriv" point-parameter-iv) :void (pname enum) (params (:pointer int))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3b" secondary-color-3b) :void (red byte) (green byte) (blue byte)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3bv" secondary-color-3bv) :void (v (:pointer byte))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3d" secondary-color-3d) :void (red double) (green double) (blue double)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3dv" secondary-color-3dv) :void (v (:pointer double))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3f" secondary-color-3f) :void (red float) (green float) (blue float)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3fv" secondary-color-3fv) :void (v (:pointer float))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3i" secondary-color-3i) :void (red int) (green int) (blue int)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3iv" secondary-color-3iv) :void (v (:pointer int))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3s" secondary-color-3s) :void (red short) (green short) (blue short)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3sv" secondary-color-3sv) :void (v (:pointer short))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3ub" secondary-color-3ub) :void (red ubyte) (green ubyte) (blue ubyte)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3ubv" secondary-color-3ubv) :void (v (:pointer ubyte))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3ui" secondary-color-3ui) :void (red uint) (green uint) (blue uint)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3uiv" secondary-color-3uiv) :void (v (:pointer uint))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3us" secondary-color-3us) :void (red ushort) (green ushort) (blue ushort)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColor3usv" secondary-color-3usv) :void (v (:pointer ushort))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glSecondaryColorPointer" secondary-color-pointer) :void (size int) (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos2d" window-pos-2d) :void (x double) (y double)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos2dv" window-pos-2dv) :void (v (:pointer double))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos2f" window-pos-2f) :void (x float) (y float)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos2fv" window-pos-2fv) :void (v (:pointer float))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos2i" window-pos-2i) :void (x int) (y int)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos2iv" window-pos-2iv) :void (v (:pointer int))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos2s" window-pos-2s) :void (x short) (y short)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos2sv" window-pos-2sv) :void (v (:pointer short))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos3d" window-pos-3d) :void (x double) (y double) (z double)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos3dv" window-pos-3dv) :void (v (:pointer double))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos3f" window-pos-3f) :void (x float) (y float) (z float)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos3fv" window-pos-3fv) :void (v (:pointer float))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos3i" window-pos-3i) :void (x int) (y int) (z int)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos3iv" window-pos-3iv) :void (v (:pointer int))) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos3s" window-pos-3s) :void (x short) (y short) (z short)) ;;; GL version: 1.4, VERSION_1_4 (defglextfun ("glWindowPos3sv" window-pos-3sv) :void (v (:pointer short))) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glGenQueries" gen-queries) :void (n sizei) (ids (:pointer uint))) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glDeleteQueries" delete-queries) :void (n sizei) (ids (:pointer uint))) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glIsQuery" is-query) boolean (id uint)) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glBeginQuery" begin-query) :void (target enum) (id uint)) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glEndQuery" end-query) :void (target enum)) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glGetQueryiv" get-query-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glGetQueryObjectiv" get-query-object-iv) :void (id uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glGetQueryObjectuiv" get-query-object-uiv) :void (id uint) (pname enum) (params (:pointer uint))) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glBindBuffer" bind-buffer) :void (target enum) (buffer uint)) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glDeleteBuffers" delete-buffers) :void (n sizei) (buffers (:pointer uint))) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glGenBuffers" gen-buffers) :void (n sizei) (buffers (:pointer uint))) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glIsBuffer" is-buffer) boolean (buffer uint)) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glBufferData" buffer-data) :void (target enum) (size sizeiptr) (data (:pointer void)) (usage enum)) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glBufferSubData" buffer-sub-data) :void (target enum) (offset intptr) (size sizeiptr) (data (:pointer void))) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glGetBufferSubData" get-buffer-sub-data) :void (target enum) (offset intptr) (size sizeiptr) (data (:pointer void))) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glMapBuffer" map-buffer) (:pointer void) (target enum) (access enum)) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glUnmapBuffer" unmap-buffer) boolean (target enum)) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glGetBufferParameteriv" get-buffer-parameter-iv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.5, VERSION_1_5 (defglextfun ("glGetBufferPointerv" get-buffer-pointer-v) :void (target enum) (pname enum) (params (:pointer (:pointer void)))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glBlendEquationSeparate" blend-equation-separate) :void (modeRGB enum) (modeAlpha enum)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glDrawBuffers" draw-buffers) :void (n sizei) (bufs (:pointer enum))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glStencilOpSeparate" stencil-op-separate) :void (face enum) (sfail enum) (dpfail enum) (dppass enum)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glStencilFuncSeparate" stencil-func-separate) :void (frontfunc enum) (backfunc enum) (ref int) (mask uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glStencilMaskSeparate" stencil-mask-separate) :void (face enum) (mask uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glAttachShader" attach-shader) :void (program uint) (shader uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glBindAttribLocation" bind-attrib-location) :void (program uint) (index uint) (name (:pointer char))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glCompileShader" compile-shader) :void (shader uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glCreateProgram" create-program) uint) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glCreateShader" create-shader) uint (type enum)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glDeleteProgram" delete-program) :void (program uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glDeleteShader" delete-shader) :void (shader uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glDetachShader" detach-shader) :void (program uint) (shader uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glDisableVertexAttribArray" disable-vertex-attrib-array) :void (index uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glEnableVertexAttribArray" enable-vertex-attrib-array) :void (index uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetActiveAttrib" get-active-attrib) :void (program uint) (index uint) (bufSize sizei) (length (:pointer sizei)) (size (:pointer int)) (type (:pointer enum)) (name (:pointer char))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetActiveUniform" get-active-uniform) :void (program uint) (index uint) (bufSize sizei) (length (:pointer sizei)) (size (:pointer int)) (type (:pointer enum)) (name (:pointer char))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetAttachedShaders" get-attached-shaders) :void (program uint) (maxCount sizei) (count (:pointer sizei)) (obj (:pointer uint))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetAttribLocation" get-attrib-location) int (program uint) (name (:pointer char))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetProgramiv" get-program-iv) :void (program uint) (pname enum) (params (:pointer int))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetProgramInfoLog" get-program-info-log) :void (program uint) (bufSize sizei) (length (:pointer sizei)) (infoLog (:pointer char))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetShaderiv" get-shader-iv) :void (shader uint) (pname enum) (params (:pointer int))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetShaderInfoLog" get-shader-info-log) :void (shader uint) (bufSize sizei) (length (:pointer sizei)) (infoLog (:pointer char))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetShaderSource" get-shader-source) :void (shader uint) (bufSize sizei) (length (:pointer sizei)) (source (:pointer char))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetUniformLocation" get-uniform-location) int (program uint) (name (:pointer char))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetUniformfv" get-uniform-fv) :void (program uint) (location int) (params (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetUniformiv" get-uniform-iv) :void (program uint) (location int) (params (:pointer int))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetVertexAttribdv" get-vertex-attrib-dv) :void (index uint) (pname enum) (params (:pointer double))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetVertexAttribfv" get-vertex-attrib-fv) :void (index uint) (pname enum) (params (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetVertexAttribiv" get-vertex-attrib-iv) :void (index uint) (pname enum) (params (:pointer int))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glGetVertexAttribPointerv" get-vertex-attrib-pointer-v) :void (index uint) (pname enum) (pointer (:pointer (:pointer void)))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glIsProgram" is-program) boolean (program uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glIsShader" is-shader) boolean (shader uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glLinkProgram" link-program) :void (program uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glShaderSource" shader-source) :void (shader uint) (count sizei) (string (:pointer (:pointer char))) (length (:pointer int))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUseProgram" use-program) :void (program uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform1f" uniform-1f) :void (location int) (v0 float)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform2f" uniform-2f) :void (location int) (v0 float) (v1 float)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform3f" uniform-3f) :void (location int) (v0 float) (v1 float) (v2 float)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform4f" uniform-4f) :void (location int) (v0 float) (v1 float) (v2 float) (v3 float)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform1i" uniform-1i) :void (location int) (v0 int)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform2i" uniform-2i) :void (location int) (v0 int) (v1 int)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform3i" uniform-3i) :void (location int) (v0 int) (v1 int) (v2 int)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform4i" uniform-4i) :void (location int) (v0 int) (v1 int) (v2 int) (v3 int)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform1fv" uniform-1fv) :void (location int) (count sizei) (value (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform2fv" uniform-2fv) :void (location int) (count sizei) (value (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform3fv" uniform-3fv) :void (location int) (count sizei) (value (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform4fv" uniform-4fv) :void (location int) (count sizei) (value (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform1iv" uniform-1iv) :void (location int) (count sizei) (value (:pointer int))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform2iv" uniform-2iv) :void (location int) (count sizei) (value (:pointer int))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform3iv" uniform-3iv) :void (location int) (count sizei) (value (:pointer int))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniform4iv" uniform-4iv) :void (location int) (count sizei) (value (:pointer int))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniformMatrix2fv" uniform-matrix-2fv) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniformMatrix3fv" uniform-matrix-3fv) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glUniformMatrix4fv" uniform-matrix-4fv) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glValidateProgram" validate-program) :void (program uint)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib1d" vertex-attrib-1d) :void (index uint) (x double)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib1dv" vertex-attrib-1dv) :void (index uint) (v (:pointer double))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib1f" vertex-attrib-1f) :void (index uint) (x float)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib1fv" vertex-attrib-1fv) :void (index uint) (v (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib1s" vertex-attrib-1s) :void (index uint) (x short)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib1sv" vertex-attrib-1sv) :void (index uint) (v (:pointer short))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib2d" vertex-attrib-2d) :void (index uint) (x double) (y double)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib2dv" vertex-attrib-2dv) :void (index uint) (v (:pointer double))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib2f" vertex-attrib-2f) :void (index uint) (x float) (y float)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib2fv" vertex-attrib-2fv) :void (index uint) (v (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib2s" vertex-attrib-2s) :void (index uint) (x short) (y short)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib2sv" vertex-attrib-2sv) :void (index uint) (v (:pointer short))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib3d" vertex-attrib-3d) :void (index uint) (x double) (y double) (z double)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib3dv" vertex-attrib-3dv) :void (index uint) (v (:pointer double))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib3f" vertex-attrib-3f) :void (index uint) (x float) (y float) (z float)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib3fv" vertex-attrib-3fv) :void (index uint) (v (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib3s" vertex-attrib-3s) :void (index uint) (x short) (y short) (z short)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib3sv" vertex-attrib-3sv) :void (index uint) (v (:pointer short))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4Nbv" vertex-attrib-4nbv) :void (index uint) (v (:pointer byte))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4Niv" vertex-attrib-4niv) :void (index uint) (v (:pointer int))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4Nsv" vertex-attrib-4nsv) :void (index uint) (v (:pointer short))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4Nub" vertex-attrib-4nub) :void (index uint) (x ubyte) (y ubyte) (z ubyte) (w ubyte)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4Nubv" vertex-attrib-4nubv) :void (index uint) (v (:pointer ubyte))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4Nuiv" vertex-attrib-4nuiv) :void (index uint) (v (:pointer uint))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4Nusv" vertex-attrib-4nusv) :void (index uint) (v (:pointer ushort))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4bv" vertex-attrib-4bv) :void (index uint) (v (:pointer byte))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4d" vertex-attrib-4d) :void (index uint) (x double) (y double) (z double) (w double)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4dv" vertex-attrib-4dv) :void (index uint) (v (:pointer double))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4f" vertex-attrib-4f) :void (index uint) (x float) (y float) (z float) (w float)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4fv" vertex-attrib-4fv) :void (index uint) (v (:pointer float))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4iv" vertex-attrib-4iv) :void (index uint) (v (:pointer int))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4s" vertex-attrib-4s) :void (index uint) (x short) (y short) (z short) (w short)) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4sv" vertex-attrib-4sv) :void (index uint) (v (:pointer short))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4ubv" vertex-attrib-4ubv) :void (index uint) (v (:pointer ubyte))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4uiv" vertex-attrib-4uiv) :void (index uint) (v (:pointer uint))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttrib4usv" vertex-attrib-4usv) :void (index uint) (v (:pointer ushort))) ;;; GL version: 2.0, VERSION_2_0 (defglextfun ("glVertexAttribPointer" vertex-attrib-pointer) :void (index uint) (size int) (type enum) (normalized boolean) (stride sizei) (pointer (:pointer void))) ;;; GL version: 2.1, VERSION_2_1 (defglextfun ("glUniformMatrix2x3fv" uniform-matrix-2x3-fv) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 2.1, VERSION_2_1 (defglextfun ("glUniformMatrix3x2fv" uniform-matrix-3x2-fv) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 2.1, VERSION_2_1 (defglextfun ("glUniformMatrix2x4fv" uniform-matrix-2x4-fv) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 2.1, VERSION_2_1 (defglextfun ("glUniformMatrix4x2fv" uniform-matrix-4x2-fv) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 2.1, VERSION_2_1 (defglextfun ("glUniformMatrix3x4fv" uniform-matrix-3x4-fv) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 2.1, VERSION_2_1 (defglextfun ("glUniformMatrix4x3fv" uniform-matrix-4x3-fv) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glActiveTextureARB" active-texture-arb) :void (texture enum)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glClientActiveTextureARB" client-active-texture-arb) :void (texture enum)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord1dARB" multi-tex-coord-1d-arb) :void (target enum) (s double)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord1dvARB" multi-tex-coord-1dv-arb) :void (target enum) (v (:pointer double))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord1fARB" multi-tex-coord-1f-arb) :void (target enum) (s float)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord1fvARB" multi-tex-coord-1fv-arb) :void (target enum) (v (:pointer float))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord1iARB" multi-tex-coord-1i-arb) :void (target enum) (s int)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord1ivARB" multi-tex-coord-1iv-arb) :void (target enum) (v (:pointer int))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord1sARB" multi-tex-coord-1s-arb) :void (target enum) (s short)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord1svARB" multi-tex-coord-1sv-arb) :void (target enum) (v (:pointer short))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord2dARB" multi-tex-coord-2d-arb) :void (target enum) (s double) (tee double)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord2dvARB" multi-tex-coord-2dv-arb) :void (target enum) (v (:pointer double))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord2fARB" multi-tex-coord-2f-arb) :void (target enum) (s float) (tee float)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord2fvARB" multi-tex-coord-2fv-arb) :void (target enum) (v (:pointer float))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord2iARB" multi-tex-coord-2i-arb) :void (target enum) (s int) (tee int)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord2ivARB" multi-tex-coord-2iv-arb) :void (target enum) (v (:pointer int))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord2sARB" multi-tex-coord-2s-arb) :void (target enum) (s short) (tee short)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord2svARB" multi-tex-coord-2sv-arb) :void (target enum) (v (:pointer short))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord3dARB" multi-tex-coord-3d-arb) :void (target enum) (s double) (tee double) (r double)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord3dvARB" multi-tex-coord-3dv-arb) :void (target enum) (v (:pointer double))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord3fARB" multi-tex-coord-3f-arb) :void (target enum) (s float) (tee float) (r float)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord3fvARB" multi-tex-coord-3fv-arb) :void (target enum) (v (:pointer float))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord3iARB" multi-tex-coord-3i-arb) :void (target enum) (s int) (tee int) (r int)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord3ivARB" multi-tex-coord-3iv-arb) :void (target enum) (v (:pointer int))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord3sARB" multi-tex-coord-3s-arb) :void (target enum) (s short) (tee short) (r short)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord3svARB" multi-tex-coord-3sv-arb) :void (target enum) (v (:pointer short))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord4dARB" multi-tex-coord-4d-arb) :void (target enum) (s double) (tee double) (r double) (q double)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord4dvARB" multi-tex-coord-4dv-arb) :void (target enum) (v (:pointer double))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord4fARB" multi-tex-coord-4f-arb) :void (target enum) (s float) (tee float) (r float) (q float)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord4fvARB" multi-tex-coord-4fv-arb) :void (target enum) (v (:pointer float))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord4iARB" multi-tex-coord-4i-arb) :void (target enum) (s int) (tee int) (r int) (q int)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord4ivARB" multi-tex-coord-4iv-arb) :void (target enum) (v (:pointer int))) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord4sARB" multi-tex-coord-4s-arb) :void (target enum) (s short) (tee short) (r short) (q short)) ;;; GL version: 1.2, ARB_multitexture (defglextfun ("glMultiTexCoord4svARB" multi-tex-coord-4sv-arb) :void (target enum) (v (:pointer short))) ;;; GL version: 1.2, ARB_transpose_matrix (defglextfun ("glLoadTransposeMatrixfARB" load-transpose-matrix-f-arb) :void (m (:pointer float))) ;;; GL version: 1.2, ARB_transpose_matrix (defglextfun ("glLoadTransposeMatrixdARB" load-transpose-matrix-d-arb) :void (m (:pointer double))) ;;; GL version: 1.2, ARB_transpose_matrix (defglextfun ("glMultTransposeMatrixfARB" mult-transpose-matrix-f-arb) :void (m (:pointer float))) ;;; GL version: 1.2, ARB_transpose_matrix (defglextfun ("glMultTransposeMatrixdARB" mult-transpose-matrix-d-arb) :void (m (:pointer double))) ;;; GL version: 1.2, ARB_multisample (defglextfun ("glSampleCoverageARB" sample-coverage-arb) :void (value clampf) (invert boolean)) ;;; GL version: 1.2, ARB_texture_compression (defglextfun ("glCompressedTexImage3DARB" compressed-tex-image-3d-arb) :void (target enum) (level int) (internalformat enum) (width sizei) (height sizei) (depth sizei) (border int) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.2, ARB_texture_compression (defglextfun ("glCompressedTexImage2DARB" compressed-tex-image-2d-arb) :void (target enum) (level int) (internalformat enum) (width sizei) (height sizei) (border int) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.2, ARB_texture_compression (defglextfun ("glCompressedTexImage1DARB" compressed-tex-image-1d-arb) :void (target enum) (level int) (internalformat enum) (width sizei) (border int) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.2, ARB_texture_compression (defglextfun ("glCompressedTexSubImage3DARB" compressed-tex-sub-image-3d-arb) :void (target enum) (level int) (xoffset int) (yoffset int) (zoffset int) (width sizei) (height sizei) (depth sizei) (format enum) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.2, ARB_texture_compression (defglextfun ("glCompressedTexSubImage2DARB" compressed-tex-sub-image-2d-arb) :void (target enum) (level int) (xoffset int) (yoffset int) (width sizei) (height sizei) (format enum) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.2, ARB_texture_compression (defglextfun ("glCompressedTexSubImage1DARB" compressed-tex-sub-image-1d-arb) :void (target enum) (level int) (xoffset int) (width sizei) (format enum) (imageSize sizei) (data (:pointer void))) ;;; GL version: 1.2, ARB_texture_compression (defglextfun ("glGetCompressedTexImageARB" get-compressed-tex-image-arb) :void (target enum) (level int) (img (:pointer void))) ;;; GL version: 1.0, ARB_point_parameters (defglextfun ("glPointParameterfARB" point-parameter-f-arb) :void (pname enum) (param float)) ;;; GL version: 1.0, ARB_point_parameters (defglextfun ("glPointParameterfvARB" point-parameter-fv-arb) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.1, ARB_vertex_blend (defglextfun ("glWeightbvARB" weight-bv-arb) :void (size int) (weights (:pointer byte))) ;;; GL version: 1.1, ARB_vertex_blend (defglextfun ("glWeightsvARB" weight-sv-arb) :void (size int) (weights (:pointer short))) ;;; GL version: 1.1, ARB_vertex_blend (defglextfun ("glWeightivARB" weight-iv-arb) :void (size int) (weights (:pointer int))) ;;; GL version: 1.1, ARB_vertex_blend (defglextfun ("glWeightfvARB" weight-fv-arb) :void (size int) (weights (:pointer float))) ;;; GL version: 1.1, ARB_vertex_blend (defglextfun ("glWeightdvARB" weight-dv-arb) :void (size int) (weights (:pointer double))) ;;; GL version: 1.1, ARB_vertex_blend (defglextfun ("glWeightubvARB" weight-ubv-arb) :void (size int) (weights (:pointer ubyte))) ;;; GL version: 1.1, ARB_vertex_blend (defglextfun ("glWeightusvARB" weight-usv-arb) :void (size int) (weights (:pointer ushort))) ;;; GL version: 1.1, ARB_vertex_blend (defglextfun ("glWeightuivARB" weight-uiv-arb) :void (size int) (weights (:pointer uint))) ;;; GL version: 1.1, ARB_vertex_blend (defglextfun ("glWeightPointerARB" weight-pointer-arb) :void (size int) (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, ARB_vertex_blend (defglextfun ("glVertexBlendARB" vertex-blend-arb) :void (count int)) ;;; GL version: 1.1, ARB_matrix_palette (defglextfun ("glCurrentPaletteMatrixARB" current-palette-matrix-arb) :void (index int)) ;;; GL version: 1.1, ARB_matrix_palette (defglextfun ("glMatrixIndexubvARB" matrix-index-ubv-arb) :void (size int) (indices (:pointer ubyte))) ;;; GL version: 1.1, ARB_matrix_palette (defglextfun ("glMatrixIndexusvARB" matrix-index-usv-arb) :void (size int) (indices (:pointer ushort))) ;;; GL version: 1.1, ARB_matrix_palette (defglextfun ("glMatrixIndexuivARB" matrix-index-uiv-arb) :void (size int) (indices (:pointer uint))) ;;; GL version: 1.1, ARB_matrix_palette (defglextfun ("glMatrixIndexPointerARB" matrix-index-pointer-arb) :void (size int) (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos2dARB" window-pos-2d-arb) :void (x double) (y double)) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos2dvARB" window-pos-2dv-arb) :void (v (:pointer double))) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos2fARB" window-pos-2f-arb) :void (x float) (y float)) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos2fvARB" window-pos-2fv-arb) :void (v (:pointer float))) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos2iARB" window-pos-2i-arb) :void (x int) (y int)) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos2ivARB" window-pos-2iv-arb) :void (v (:pointer int))) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos2sARB" window-pos-2s-arb) :void (x short) (y short)) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos2svARB" window-pos-2sv-arb) :void (v (:pointer short))) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos3dARB" window-pos-3d-arb) :void (x double) (y double) (z double)) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos3dvARB" window-pos-3dv-arb) :void (v (:pointer double))) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos3fARB" window-pos-3f-arb) :void (x float) (y float) (z float)) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos3fvARB" window-pos-3fv-arb) :void (v (:pointer float))) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos3iARB" window-pos-3i-arb) :void (x int) (y int) (z int)) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos3ivARB" window-pos-3iv-arb) :void (v (:pointer int))) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos3sARB" window-pos-3s-arb) :void (x short) (y short) (z short)) ;;; GL version: 1.0, ARB_window_pos (defglextfun ("glWindowPos3svARB" window-pos-3sv-arb) :void (v (:pointer short))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib1dARB" vertex-attrib-1d-arb) :void (index uint) (x double)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib1dvARB" vertex-attrib-1dv-arb) :void (index uint) (v (:pointer double))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib1fARB" vertex-attrib-1f-arb) :void (index uint) (x float)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib1fvARB" vertex-attrib-1fv-arb) :void (index uint) (v (:pointer float))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib1sARB" vertex-attrib-1s-arb) :void (index uint) (x short)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib1svARB" vertex-attrib-1sv-arb) :void (index uint) (v (:pointer short))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib2dARB" vertex-attrib-2d-arb) :void (index uint) (x double) (y double)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib2dvARB" vertex-attrib-2dv-arb) :void (index uint) (v (:pointer double))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib2fARB" vertex-attrib-2f-arb) :void (index uint) (x float) (y float)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib2fvARB" vertex-attrib-2fv-arb) :void (index uint) (v (:pointer float))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib2sARB" vertex-attrib-2s-arb) :void (index uint) (x short) (y short)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib2svARB" vertex-attrib-2sv-arb) :void (index uint) (v (:pointer short))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib3dARB" vertex-attrib-3d-arb) :void (index uint) (x double) (y double) (z double)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib3dvARB" vertex-attrib-3dv-arb) :void (index uint) (v (:pointer double))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib3fARB" vertex-attrib-3f-arb) :void (index uint) (x float) (y float) (z float)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib3fvARB" vertex-attrib-3fv-arb) :void (index uint) (v (:pointer float))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib3sARB" vertex-attrib-3s-arb) :void (index uint) (x short) (y short) (z short)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib3svARB" vertex-attrib-3sv-arb) :void (index uint) (v (:pointer short))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4NbvARB" vertex-attrib-4nbv-arb) :void (index uint) (v (:pointer byte))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4NivARB" vertex-attrib-4niv-arb) :void (index uint) (v (:pointer int))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4NsvARB" vertex-attrib-4nsv-arb) :void (index uint) (v (:pointer short))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4NubARB" vertex-attrib-4nub-arb) :void (index uint) (x ubyte) (y ubyte) (z ubyte) (w ubyte)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4NubvARB" vertex-attrib-4nubv-arb) :void (index uint) (v (:pointer ubyte))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4NuivARB" vertex-attrib-4nuiv-arb) :void (index uint) (v (:pointer uint))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4NusvARB" vertex-attrib-4nusv-arb) :void (index uint) (v (:pointer ushort))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4bvARB" vertex-attrib-4bv-arb) :void (index uint) (v (:pointer byte))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4dARB" vertex-attrib-4d-arb) :void (index uint) (x double) (y double) (z double) (w double)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4dvARB" vertex-attrib-4dv-arb) :void (index uint) (v (:pointer double))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4fARB" vertex-attrib-4f-arb) :void (index uint) (x float) (y float) (z float) (w float)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4fvARB" vertex-attrib-4fv-arb) :void (index uint) (v (:pointer float))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4ivARB" vertex-attrib-4iv-arb) :void (index uint) (v (:pointer int))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4sARB" vertex-attrib-4s-arb) :void (index uint) (x short) (y short) (z short) (w short)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4svARB" vertex-attrib-4sv-arb) :void (index uint) (v (:pointer short))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4ubvARB" vertex-attrib-4ubv-arb) :void (index uint) (v (:pointer ubyte))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4uivARB" vertex-attrib-4uiv-arb) :void (index uint) (v (:pointer uint))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttrib4usvARB" vertex-attrib-4usv-arb) :void (index uint) (v (:pointer ushort))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glVertexAttribPointerARB" vertex-attrib-pointer-arb) :void (index uint) (size int) (type enum) (normalized boolean) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glEnableVertexAttribArrayARB" enable-vertex-attrib-array-arb) :void (index uint)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glDisableVertexAttribArrayARB" disable-vertex-attrib-array-arb) :void (index uint)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glProgramStringARB" program-string-arb) :void (target enum) (format enum) (len sizei) (string (:pointer void))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glBindProgramARB" bind-program-arb) :void (target enum) (program uint)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glDeleteProgramsARB" delete-programs-arb) :void (n sizei) (programs (:pointer uint))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glGenProgramsARB" gen-programs-arb) :void (n sizei) (programs (:pointer uint))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glProgramEnvParameter4dARB" program-env-parameter-4d-arb) :void (target enum) (index uint) (x double) (y double) (z double) (w double)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glProgramEnvParameter4dvARB" program-env-parameter-4dv-arb) :void (target enum) (index uint) (params (:pointer double))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glProgramEnvParameter4fARB" program-env-parameter-4f-arb) :void (target enum) (index uint) (x float) (y float) (z float) (w float)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glProgramEnvParameter4fvARB" program-env-parameter-4fv-arb) :void (target enum) (index uint) (params (:pointer float))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glProgramLocalParameter4dARB" program-local-parameter-4d-arb) :void (target enum) (index uint) (x double) (y double) (z double) (w double)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glProgramLocalParameter4dvARB" program-local-parameter-4dv-arb) :void (target enum) (index uint) (params (:pointer double))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glProgramLocalParameter4fARB" program-local-parameter-4f-arb) :void (target enum) (index uint) (x float) (y float) (z float) (w float)) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glProgramLocalParameter4fvARB" program-local-parameter-4fv-arb) :void (target enum) (index uint) (params (:pointer float))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glGetProgramEnvParameterdvARB" get-program-env-parameter-dv-arb) :void (target enum) (index uint) (params (:pointer double))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glGetProgramEnvParameterfvARB" get-program-env-parameter-fv-arb) :void (target enum) (index uint) (params (:pointer float))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glGetProgramLocalParameterdvARB" get-program-local-parameter-dv-arb) :void (target enum) (index uint) (params (:pointer double))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glGetProgramLocalParameterfvARB" get-program-local-parameter-fv-arb) :void (target enum) (index uint) (params (:pointer float))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glGetProgramivARB" get-program-iv-arb) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glGetProgramStringARB" get-program-string-arb) :void (target enum) (pname enum) (string (:pointer void))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glGetVertexAttribdvARB" get-vertex-attrib-dv-arb) :void (index uint) (pname enum) (params (:pointer double))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glGetVertexAttribfvARB" get-vertex-attrib-fv-arb) :void (index uint) (pname enum) (params (:pointer float))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glGetVertexAttribivARB" get-vertex-attrib-iv-arb) :void (index uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glGetVertexAttribPointervARB" get-vertex-attrib-pointer-v-arb) :void (index uint) (pname enum) (pointer (:pointer (:pointer void)))) ;;; GL version: 1.3, ARB_vertex_program (defglextfun ("glIsProgramARB" is-program-arb) boolean (program uint)) ;;; GL version: 1.2, ARB_vertex_buffer_object (defglextfun ("glBindBufferARB" bind-buffer-arb) :void (target enum) (buffer uint)) ;;; GL version: 1.2, ARB_vertex_buffer_object (defglextfun ("glDeleteBuffersARB" delete-buffers-arb) :void (n sizei) (buffers (:pointer uint))) ;;; GL version: 1.2, ARB_vertex_buffer_object (defglextfun ("glGenBuffersARB" gen-buffers-arb) :void (n sizei) (buffers (:pointer uint))) ;;; GL version: 1.2, ARB_vertex_buffer_object (defglextfun ("glIsBufferARB" is-buffer-arb) boolean (buffer uint)) ;;; GL version: 1.2, ARB_vertex_buffer_object (defglextfun ("glBufferDataARB" buffer-data-arb) :void (target enum) (size sizeiptr-arb) (data (:pointer void)) (usage enum)) ;;; GL version: 1.2, ARB_vertex_buffer_object (defglextfun ("glBufferSubDataARB" buffer-sub-data-arb) :void (target enum) (offset intptr-arb) (size sizeiptr-arb) (data (:pointer void))) ;;; GL version: 1.2, ARB_vertex_buffer_object (defglextfun ("glGetBufferSubDataARB" get-buffer-sub-data-arb) :void (target enum) (offset intptr-arb) (size sizeiptr-arb) (data (:pointer void))) ;;; GL version: 1.2, ARB_vertex_buffer_object (defglextfun ("glMapBufferARB" map-buffer-arb) (:pointer void) (target enum) (access enum)) ;;; GL version: 1.2, ARB_vertex_buffer_object (defglextfun ("glUnmapBufferARB" unmap-buffer-arb) boolean (target enum)) ;;; GL version: 1.2, ARB_vertex_buffer_object (defglextfun ("glGetBufferParameterivARB" get-buffer-parameter-iv-arb) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, ARB_vertex_buffer_object (defglextfun ("glGetBufferPointervARB" get-buffer-pointer-v-arb) :void (target enum) (pname enum) (params (:pointer (:pointer void)))) ;;; GL version: 1.5, ARB_occlusion_query (defglextfun ("glGenQueriesARB" gen-queries-arb) :void (n sizei) (ids (:pointer uint))) ;;; GL version: 1.5, ARB_occlusion_query (defglextfun ("glDeleteQueriesARB" delete-queries-arb) :void (n sizei) (ids (:pointer uint))) ;;; GL version: 1.5, ARB_occlusion_query (defglextfun ("glIsQueryARB" is-query-arb) boolean (id uint)) ;;; GL version: 1.5, ARB_occlusion_query (defglextfun ("glBeginQueryARB" begin-query-arb) :void (target enum) (id uint)) ;;; GL version: 1.5, ARB_occlusion_query (defglextfun ("glEndQueryARB" end-query-arb) :void (target enum)) ;;; GL version: 1.5, ARB_occlusion_query (defglextfun ("glGetQueryivARB" get-query-iv-arb) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.5, ARB_occlusion_query (defglextfun ("glGetQueryObjectivARB" get-query-object-iv-arb) :void (id uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.5, ARB_occlusion_query (defglextfun ("glGetQueryObjectuivARB" get-query-object-uiv-arb) :void (id uint) (pname enum) (params (:pointer uint))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glDeleteObjectARB" delete-object-arb) :void (obj handle-arb)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glGetHandleARB" get-handle-arb) handle-arb (pname enum)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glDetachObjectARB" detach-object-arb) :void (containerObj handle-arb) (attachedObj handle-arb)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glCreateShaderObjectARB" create-shader-object-arb) handle-arb (shaderType enum)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glShaderSourceARB" shader-source-arb) :void (shaderObj handle-arb) (count sizei) (string (:pointer (:pointer char-arb))) (length (:pointer int))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glCompileShaderARB" compile-shader-arb) :void (shaderObj handle-arb)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glCreateProgramObjectARB" create-program-object-arb) handle-arb) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glAttachObjectARB" attach-object-arb) :void (containerObj handle-arb) (obj handle-arb)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glLinkProgramARB" link-program-arb) :void (programObj handle-arb)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUseProgramObjectARB" use-program-object-arb) :void (programObj handle-arb)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glValidateProgramARB" validate-program-arb) :void (programObj handle-arb)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform1fARB" uniform-1f-arb) :void (location int) (v0 float)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform2fARB" uniform-2f-arb) :void (location int) (v0 float) (v1 float)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform3fARB" uniform-3f-arb) :void (location int) (v0 float) (v1 float) (v2 float)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform4fARB" uniform-4f-arb) :void (location int) (v0 float) (v1 float) (v2 float) (v3 float)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform1iARB" uniform-1i-arb) :void (location int) (v0 int)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform2iARB" uniform-2i-arb) :void (location int) (v0 int) (v1 int)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform3iARB" uniform-3i-arb) :void (location int) (v0 int) (v1 int) (v2 int)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform4iARB" uniform-4i-arb) :void (location int) (v0 int) (v1 int) (v2 int) (v3 int)) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform1fvARB" uniform-1fv-arb) :void (location int) (count sizei) (value (:pointer float))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform2fvARB" uniform-2fv-arb) :void (location int) (count sizei) (value (:pointer float))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform3fvARB" uniform-3fv-arb) :void (location int) (count sizei) (value (:pointer float))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform4fvARB" uniform-4fv-arb) :void (location int) (count sizei) (value (:pointer float))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform1ivARB" uniform-1iv-arb) :void (location int) (count sizei) (value (:pointer int))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform2ivARB" uniform-2iv-arb) :void (location int) (count sizei) (value (:pointer int))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform3ivARB" uniform-3iv-arb) :void (location int) (count sizei) (value (:pointer int))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniform4ivARB" uniform-4iv-arb) :void (location int) (count sizei) (value (:pointer int))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniformMatrix2fvARB" uniform-matrix-2fv-arb) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniformMatrix3fvARB" uniform-matrix-3fv-arb) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glUniformMatrix4fvARB" uniform-matrix-4fv-arb) :void (location int) (count sizei) (transpose boolean) (value (:pointer float))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glGetObjectParameterfvARB" get-object-parameter-fv-arb) :void (obj handle-arb) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glGetObjectParameterivARB" get-object-parameter-iv-arb) :void (obj handle-arb) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glGetInfoLogARB" get-info-log-arb) :void (obj handle-arb) (maxLength sizei) (length (:pointer sizei)) (infoLog (:pointer char-arb))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glGetAttachedObjectsARB" get-attached-objects-arb) :void (containerObj handle-arb) (maxCount sizei) (count (:pointer sizei)) (obj (:pointer handle-arb))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glGetUniformLocationARB" get-uniform-location-arb) int (programObj handle-arb) (name (:pointer char-arb))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glGetActiveUniformARB" get-active-uniform-arb) :void (programObj handle-arb) (index uint) (maxLength sizei) (length (:pointer sizei)) (size (:pointer int)) (type (:pointer enum)) (name (:pointer char-arb))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glGetUniformfvARB" get-uniform-fv-arb) :void (programObj handle-arb) (location int) (params (:pointer float))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glGetUniformivARB" get-uniform-iv-arb) :void (programObj handle-arb) (location int) (params (:pointer int))) ;;; GL version: 1.2, ARB_shader_objects (defglextfun ("glGetShaderSourceARB" get-shader-source-arb) :void (obj handle-arb) (maxLength sizei) (length (:pointer sizei)) (source (:pointer char-arb))) ;;; GL version: 1.2, ARB_vertex_shader (defglextfun ("glBindAttribLocationARB" bind-attrib-location-arb) :void (programObj handle-arb) (index uint) (name (:pointer char-arb))) ;;; GL version: 1.2, ARB_vertex_shader (defglextfun ("glGetActiveAttribARB" get-active-attrib-arb) :void (programObj handle-arb) (index uint) (maxLength sizei) (length (:pointer sizei)) (size (:pointer int)) (type (:pointer enum)) (name (:pointer char-arb))) ;;; GL version: 1.2, ARB_vertex_shader (defglextfun ("glGetAttribLocationARB" get-attrib-location-arb) int (programObj handle-arb) (name (:pointer char-arb))) ;;; GL version: 1.5, ARB_draw_buffers (defglextfun ("glDrawBuffersARB" draw-buffers-arb) :void (n sizei) (bufs (:pointer enum))) ;;; GL version: 1.5, ARB_color_buffer_float (defglextfun ("glClampColorARB" clamp-color-arb) :void (target enum) (clamp enum)) ;;; GL version: 1.0, EXT_blend_color (defglextfun ("glBlendColorEXT" blend-color-ext) :void (red clampf) (green clampf) (blue clampf) (alpha clampf)) ;;; GL version: 1.0, EXT_polygon_offset (defglextfun ("glPolygonOffsetEXT" polygon-offset-ext) :void (factor float) (bias float)) ;;; GL version: 1.0, EXT_texture3D (defglextfun ("glTexImage3DEXT" tex-image-3d-ext) :void (target enum) (level int) (internalformat enum) (width sizei) (height sizei) (depth sizei) (border int) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.0, EXT_texture3D (defglextfun ("glTexSubImage3DEXT" tex-sub-image-3d-ext) :void (target enum) (level int) (xoffset int) (yoffset int) (zoffset int) (width sizei) (height sizei) (depth sizei) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.0, SGIS_texture_filter4 (defglextfun ("glGetTexFilterFuncSGIS" get-tex-filter-func-sgis) :void (target enum) (filter enum) (weights (:pointer float))) ;;; GL version: 1.0, SGIS_texture_filter4 (defglextfun ("glTexFilterFuncSGIS" tex-filter-func-sgis) :void (target enum) (filter enum) (n sizei) (weights (:pointer float))) ;;; GL version: 1.0, EXT_subtexture (defglextfun ("glTexSubImage1DEXT" tex-sub-image-1d-ext) :void (target enum) (level int) (xoffset int) (width sizei) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.0, EXT_subtexture (defglextfun ("glTexSubImage2DEXT" tex-sub-image-2d-ext) :void (target enum) (level int) (xoffset int) (yoffset int) (width sizei) (height sizei) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.0, EXT_copy_texture (defglextfun ("glCopyTexImage1DEXT" copy-tex-image-1d-ext) :void (target enum) (level int) (internalformat enum) (x int) (y int) (width sizei) (border int)) ;;; GL version: 1.0, EXT_copy_texture (defglextfun ("glCopyTexImage2DEXT" copy-tex-image-2d-ext) :void (target enum) (level int) (internalformat enum) (x int) (y int) (width sizei) (height sizei) (border int)) ;;; GL version: 1.0, EXT_copy_texture (defglextfun ("glCopyTexSubImage1DEXT" copy-tex-sub-image-1d-ext) :void (target enum) (level int) (xoffset int) (x int) (y int) (width sizei)) ;;; GL version: 1.0, EXT_copy_texture (defglextfun ("glCopyTexSubImage2DEXT" copy-tex-sub-image-2d-ext) :void (target enum) (level int) (xoffset int) (yoffset int) (x int) (y int) (width sizei) (height sizei)) ;;; GL version: 1.0, EXT_copy_texture (defglextfun ("glCopyTexSubImage3DEXT" copy-tex-sub-image-3d-ext) :void (target enum) (level int) (xoffset int) (yoffset int) (zoffset int) (x int) (y int) (width sizei) (height sizei)) ;;; GL version: 1.0, EXT_histogram (defglextfun ("glGetHistogramEXT" get-histogram-ext) :void (target enum) (reset boolean) (format enum) (type enum) (values (:pointer void))) ;;; GL version: 1.0, EXT_histogram (defglextfun ("glGetHistogramParameterfvEXT" get-histogram-parameter-fv-ext) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, EXT_histogram (defglextfun ("glGetHistogramParameterivEXT" get-histogram-parameter-iv-ext) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, EXT_histogram (defglextfun ("glGetMinmaxEXT" get-minmax-ext) :void (target enum) (reset boolean) (format enum) (type enum) (values (:pointer void))) ;;; GL version: 1.0, EXT_histogram (defglextfun ("glGetMinmaxParameterfvEXT" get-minmax-parameter-fv-ext) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, EXT_histogram (defglextfun ("glGetMinmaxParameterivEXT" get-minmax-parameter-iv-ext) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, EXT_histogram (defglextfun ("glHistogramEXT" histogram-ext) :void (target enum) (width sizei) (internalformat enum) (sink boolean)) ;;; GL version: 1.0, EXT_histogram (defglextfun ("glMinmaxEXT" minmax-ext) :void (target enum) (internalformat enum) (sink boolean)) ;;; GL version: 1.0, EXT_histogram (defglextfun ("glResetHistogramEXT" reset-histogram-ext) :void (target enum)) ;;; GL version: 1.0, EXT_histogram (defglextfun ("glResetMinmaxEXT" reset-minmax-ext) :void (target enum)) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glConvolutionFilter1DEXT" convolution-filter-1d-ext) :void (target enum) (internalformat enum) (width sizei) (format enum) (type enum) (image (:pointer void))) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glConvolutionFilter2DEXT" convolution-filter-2d-ext) :void (target enum) (internalformat enum) (width sizei) (height sizei) (format enum) (type enum) (image (:pointer void))) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glConvolutionParameterfEXT" convolution-parameter-f-ext) :void (target enum) (pname enum) (params float)) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glConvolutionParameterfvEXT" convolution-parameter-fv-ext) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glConvolutionParameteriEXT" convolution-parameter-i-ext) :void (target enum) (pname enum) (params int)) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glConvolutionParameterivEXT" convolution-parameter-iv-ext) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glCopyConvolutionFilter1DEXT" copy-convolution-filter-1d-ext) :void (target enum) (internalformat enum) (x int) (y int) (width sizei)) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glCopyConvolutionFilter2DEXT" copy-convolution-filter-2d-ext) :void (target enum) (internalformat enum) (x int) (y int) (width sizei) (height sizei)) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glGetConvolutionFilterEXT" get-convolution-filter-ext) :void (target enum) (format enum) (type enum) (image (:pointer void))) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glGetConvolutionParameterfvEXT" get-convolution-parameter-fv-ext) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glGetConvolutionParameterivEXT" get-convolution-parameter-iv-ext) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glGetSeparableFilterEXT" get-separable-filter-ext) :void (target enum) (format enum) (type enum) (row (:pointer void)) (column (:pointer void)) (span (:pointer void))) ;;; GL version: 1.0, EXT_convolution (defglextfun ("glSeparableFilter2DEXT" separable-filter-2d-ext) :void (target enum) (internalformat enum) (width sizei) (height sizei) (format enum) (type enum) (row (:pointer void)) (column (:pointer void))) ;;; GL version: 1.0, SGI_color_table (defglextfun ("glColorTableSGI" color-table-sgi) :void (target enum) (internalformat enum) (width sizei) (format enum) (type enum) (table (:pointer void))) ;;; GL version: 1.0, SGI_color_table (defglextfun ("glColorTableParameterfvSGI" color-table-parameter-fv-sgi) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGI_color_table (defglextfun ("glColorTableParameterivSGI" color-table-parameter-iv-sgi) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, SGI_color_table (defglextfun ("glCopyColorTableSGI" copy-color-table-sgi) :void (target enum) (internalformat enum) (x int) (y int) (width sizei)) ;;; GL version: 1.0, SGI_color_table (defglextfun ("glGetColorTableSGI" get-color-table-sgi) :void (target enum) (format enum) (type enum) (table (:pointer void))) ;;; GL version: 1.0, SGI_color_table (defglextfun ("glGetColorTableParameterfvSGI" get-color-table-parameter-fv-sgi) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGI_color_table (defglextfun ("glGetColorTableParameterivSGI" get-color-table-parameter-iv-sgi) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, SGIX_pixel_texture (defglextfun ("glPixelTexGenSGIX" pixel-tex-gen-sgix) :void (mode enum)) ;;; GL version: 1.0, SGIS_pixel_texture (defglextfun ("glPixelTexGenParameteriSGIS" pixel-tex-gen-parameter-i-sgis) :void (pname enum) (param int)) ;;; GL version: 1.0, SGIS_pixel_texture (defglextfun ("glPixelTexGenParameterivSGIS" pixel-tex-gen-parameter-iv-sgis) :void (pname enum) (params (:pointer int))) ;;; GL version: 1.0, SGIS_pixel_texture (defglextfun ("glPixelTexGenParameterfSGIS" pixel-tex-gen-parameter-f-sgis) :void (pname enum) (param float)) ;;; GL version: 1.0, SGIS_pixel_texture (defglextfun ("glPixelTexGenParameterfvSGIS" pixel-tex-gen-parameter-fv-sgis) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIS_pixel_texture (defglextfun ("glGetPixelTexGenParameterivSGIS" get-pixel-tex-gen-parameter-iv-sgis) :void (pname enum) (params (:pointer int))) ;;; GL version: 1.0, SGIS_pixel_texture (defglextfun ("glGetPixelTexGenParameterfvSGIS" get-pixel-tex-gen-parameter-fv-sgis) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIS_texture4D (defglextfun ("glTexImage4DSGIS" tex-image-4d-sgis) :void (target enum) (level int) (internalformat enum) (width sizei) (height sizei) (depth sizei) (size4d sizei) (border int) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.0, SGIS_texture4D (defglextfun ("glTexSubImage4DSGIS" tex-sub-image-4d-sgis) :void (target enum) (level int) (xoffset int) (yoffset int) (zoffset int) (woffset int) (width sizei) (height sizei) (depth sizei) (size4d sizei) (format enum) (type enum) (pixels (:pointer void))) ;;; GL version: 1.0, EXT_texture_object (defglextfun ("glAreTexturesResidentEXT" are-textures-resident-ext) boolean (n sizei) (textures (:pointer uint)) (residences (:pointer boolean))) ;;; GL version: 1.0, EXT_texture_object (defglextfun ("glBindTextureEXT" bind-texture-ext) :void (target enum) (texture uint)) ;;; GL version: 1.0, EXT_texture_object (defglextfun ("glDeleteTexturesEXT" delete-textures-ext) :void (n sizei) (textures (:pointer uint))) ;;; GL version: 1.0, EXT_texture_object (defglextfun ("glGenTexturesEXT" gen-textures-ext) :void (n sizei) (textures (:pointer uint))) ;;; GL version: 1.0, EXT_texture_object (defglextfun ("glIsTextureEXT" is-texture-ext) boolean (texture uint)) ;;; GL version: 1.0, EXT_texture_object (defglextfun ("glPrioritizeTexturesEXT" prioritize-textures-ext) :void (n sizei) (textures (:pointer uint)) (priorities (:pointer clampf))) ;;; GL version: 1.0, SGIS_detail_texture (defglextfun ("glDetailTexFuncSGIS" detail-tex-func-sgis) :void (target enum) (n sizei) (points (:pointer float))) ;;; GL version: 1.0, SGIS_detail_texture (defglextfun ("glGetDetailTexFuncSGIS" get-detail-tex-func-sgis) :void (target enum) (points (:pointer float))) ;;; GL version: 1.0, SGIS_sharpen_texture (defglextfun ("glSharpenTexFuncSGIS" sharpen-tex-func-sgis) :void (target enum) (n sizei) (points (:pointer float))) ;;; GL version: 1.0, SGIS_sharpen_texture (defglextfun ("glGetSharpenTexFuncSGIS" get-sharpen-tex-func-sgis) :void (target enum) (points (:pointer float))) ;;; GL version: 1.1, SGIS_multisample (defglextfun ("glSampleMaskSGIS" sample-mask-sgis) :void (value clampf) (invert boolean)) ;;; GL version: 1.0, SGIS_multisample (defglextfun ("glSamplePatternSGIS" sample-pattern-sgis) :void (pattern enum)) ;;; GL version: 1.0, EXT_vertex_array (defglextfun ("glArrayElementEXT" array-element-ext) :void (i int)) ;;; GL version: 1.0, EXT_vertex_array (defglextfun ("glColorPointerEXT" color-pointer-ext) :void (size int) (type enum) (stride sizei) (count sizei) (pointer (:pointer void))) ;;; GL version: 1.0, EXT_vertex_array (defglextfun ("glDrawArraysEXT" draw-arrays-ext) :void (mode enum) (first int) (count sizei)) ;;; GL version: 1.0, EXT_vertex_array (defglextfun ("glEdgeFlagPointerEXT" edge-flag-pointer-ext) :void (stride sizei) (count sizei) (pointer (:pointer boolean))) ;;; GL version: 1.0, EXT_vertex_array (defglextfun ("glGetPointervEXT" get-pointer-v-ext) :void (pname enum) (params (:pointer (:pointer void)))) ;;; GL version: 1.0, EXT_vertex_array (defglextfun ("glIndexPointerEXT" index-pointer-ext) :void (type enum) (stride sizei) (count sizei) (pointer (:pointer void))) ;;; GL version: 1.0, EXT_vertex_array (defglextfun ("glNormalPointerEXT" normal-pointer-ext) :void (type enum) (stride sizei) (count sizei) (pointer (:pointer void))) ;;; GL version: 1.0, EXT_vertex_array (defglextfun ("glTexCoordPointerEXT" tex-coord-pointer-ext) :void (size int) (type enum) (stride sizei) (count sizei) (pointer (:pointer void))) ;;; GL version: 1.0, EXT_vertex_array (defglextfun ("glVertexPointerEXT" vertex-pointer-ext) :void (size int) (type enum) (stride sizei) (count sizei) (pointer (:pointer void))) ;;; GL version: 1.0, EXT_blend_minmax (defglextfun ("glBlendEquationEXT" blend-equation-ext) :void (mode enum)) ;;; GL version: 1.0, SGIX_sprite (defglextfun ("glSpriteParameterfSGIX" sprite-parameter-f-sgix) :void (pname enum) (param float)) ;;; GL version: 1.0, SGIX_sprite (defglextfun ("glSpriteParameterfvSGIX" sprite-parameter-fv-sgix) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIX_sprite (defglextfun ("glSpriteParameteriSGIX" sprite-parameter-i-sgix) :void (pname enum) (param int)) ;;; GL version: 1.0, SGIX_sprite (defglextfun ("glSpriteParameterivSGIX" sprite-parameter-iv-sgix) :void (pname enum) (params (:pointer int))) ;;; GL version: 1.0, EXT_point_parameters (defglextfun ("glPointParameterfEXT" point-parameter-f-ext) :void (pname enum) (param float)) ;;; GL version: 1.0, EXT_point_parameters (defglextfun ("glPointParameterfvEXT" point-parameter-fv-ext) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIS_point_parameters (defglextfun ("glPointParameterfSGIS" point-parameter-f-sgis) :void (pname enum) (param float)) ;;; GL version: 1.0, SGIS_point_parameters (defglextfun ("glPointParameterfvSGIS" point-parameter-fv-sgis) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIX_instruments (defglextfun ("glGetInstrumentsSGIX" get-instruments-sgix) int) ;;; GL version: 1.0, SGIX_instruments (defglextfun ("glInstrumentsBufferSGIX" instruments-buffer-sgix) :void (size sizei) (buffer (:pointer int))) ;;; GL version: 1.0, SGIX_instruments (defglextfun ("glPollInstrumentsSGIX" poll-instruments-sgix) int (marker_p (:pointer int))) ;;; GL version: 1.0, SGIX_instruments (defglextfun ("glReadInstrumentsSGIX" read-instruments-sgix) :void (marker int)) ;;; GL version: 1.0, SGIX_instruments (defglextfun ("glStartInstrumentsSGIX" start-instruments-sgix) :void) ;;; GL version: 1.0, SGIX_instruments (defglextfun ("glStopInstrumentsSGIX" stop-instruments-sgix) :void (marker int)) ;;; GL version: 1.0, SGIX_framezoom (defglextfun ("glFrameZoomSGIX" frame-zoom-sgix) :void (factor int)) ;;; GL version: 1.0, SGIX_tag_sample_buffer (defglextfun ("glTagSampleBufferSGIX" tag-sample-buffer-sgix) :void) ;;; GL version: 1.0, SGIX_polynomial_ffd (defglextfun ("glDeformationMap3dSGIX" deformation-map-3d-sgix) :void (target enum) (u1 double) (u2 double) (ustride int) (uorder int) (v1 double) (v2 double) (vstride int) (vorder int) (w1 double) (w2 double) (wstride int) (worder int) (points (:pointer double))) ;;; GL version: 1.0, SGIX_polynomial_ffd (defglextfun ("glDeformationMap3fSGIX" deformation-map-3f-sgix) :void (target enum) (u1 float) (u2 float) (ustride int) (uorder int) (v1 float) (v2 float) (vstride int) (vorder int) (w1 float) (w2 float) (wstride int) (worder int) (points (:pointer float))) ;;; GL version: 1.0, SGIX_polynomial_ffd (defglextfun ("glDeformSGIX" deform-sgix) :void (mask bitfield)) ;;; GL version: 1.0, SGIX_polynomial_ffd (defglextfun ("glLoadIdentityDeformationMapSGIX" load-identity-deformation-map-sgix) :void (mask bitfield)) ;;; GL version: 1.0, SGIX_reference_plane (defglextfun ("glReferencePlaneSGIX" reference-plane-sgix) :void (equation (:pointer double))) ;;; GL version: 1.0, SGIX_flush_raster (defglextfun ("glFlushRasterSGIX" flush-raster-sgix) :void) ;;; GL version: 1.1, SGIS_fog_function (defglextfun ("glFogFuncSGIS" fog-func-sgis) :void (n sizei) (points (:pointer float))) ;;; GL version: 1.1, SGIS_fog_function (defglextfun ("glGetFogFuncSGIS" get-fog-func-sgis) :void (points (:pointer float))) ;;; GL version: 1.1, HP_image_transform (defglextfun ("glImageTransformParameteriHP" image-transform-parameter-i-hp) :void (target enum) (pname enum) (param int)) ;;; GL version: 1.1, HP_image_transform (defglextfun ("glImageTransformParameterfHP" image-transform-parameter-f-hp) :void (target enum) (pname enum) (param float)) ;;; GL version: 1.1, HP_image_transform (defglextfun ("glImageTransformParameterivHP" image-transform-parameter-iv-hp) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.1, HP_image_transform (defglextfun ("glImageTransformParameterfvHP" image-transform-parameter-fv-hp) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.1, HP_image_transform (defglextfun ("glGetImageTransformParameterivHP" get-image-transform-parameter-iv-hp) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.1, HP_image_transform (defglextfun ("glGetImageTransformParameterfvHP" get-image-transform-parameter-fv-hp) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, EXT_color_subtable (defglextfun ("glColorSubTableEXT" color-sub-table-ext) :void (target enum) (start sizei) (count sizei) (format enum) (type enum) (data (:pointer void))) ;;; GL version: 1.2, EXT_color_subtable (defglextfun ("glCopyColorSubTableEXT" copy-color-sub-table-ext) :void (target enum) (start sizei) (x int) (y int) (width sizei)) ;;; GL version: 1.1, PGI_misc_hints (defglextfun ("glHintPGI" hint-pgi) :void (target enum) (mode int)) ;;; GL version: 1.1, EXT_paletted_texture (defglextfun ("glColorTableEXT" color-table-ext) :void (target enum) (internalFormat enum) (width sizei) (format enum) (type enum) (table (:pointer void))) ;;; GL version: 1.1, EXT_paletted_texture (defglextfun ("glGetColorTableEXT" get-color-table-ext) :void (target enum) (format enum) (type enum) (data (:pointer void))) ;;; GL version: 1.1, EXT_paletted_texture (defglextfun ("glGetColorTableParameterivEXT" get-color-table-parameter-iv-ext) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.1, EXT_paletted_texture (defglextfun ("glGetColorTableParameterfvEXT" get-color-table-parameter-fv-ext) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIX_list_priority (defglextfun ("glGetListParameterfvSGIX" get-list-parameter-fv-sgix) :void (list uint) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIX_list_priority (defglextfun ("glGetListParameterivSGIX" get-list-parameter-iv-sgix) :void (list uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, SGIX_list_priority (defglextfun ("glListParameterfSGIX" list-parameter-f-sgix) :void (list uint) (pname enum) (param float)) ;;; GL version: 1.0, SGIX_list_priority (defglextfun ("glListParameterfvSGIX" list-parameter-fv-sgix) :void (list uint) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIX_list_priority (defglextfun ("glListParameteriSGIX" list-parameter-i-sgix) :void (list uint) (pname enum) (param int)) ;;; GL version: 1.0, SGIX_list_priority (defglextfun ("glListParameterivSGIX" list-parameter-iv-sgix) :void (list uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.1, EXT_index_material (defglextfun ("glIndexMaterialEXT" index-material-ext) :void (face enum) (mode enum)) ;;; GL version: 1.1, EXT_index_func (defglextfun ("glIndexFuncEXT" index-func-ext) :void (func enum) (ref clampf)) ;;; GL version: 1.1, EXT_compiled_vertex_array (defglextfun ("glLockArraysEXT" lock-arrays-ext) :void (first int) (count sizei)) ;;; GL version: 1.1, EXT_compiled_vertex_array (defglextfun ("glUnlockArraysEXT" unlock-arrays-ext) :void) ;;; GL version: 1.1, EXT_cull_vertex (defglextfun ("glCullParameterdvEXT" cull-parameter-dv-ext) :void (pname enum) (params (:pointer double))) ;;; GL version: 1.1, EXT_cull_vertex (defglextfun ("glCullParameterfvEXT" cull-parameter-fv-ext) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentColorMaterialSGIX" fragment-color-material-sgix) :void (face enum) (mode enum)) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentLightfSGIX" fragment-light-f-sgix) :void (light enum) (pname enum) (param float)) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentLightfvSGIX" fragment-light-fv-sgix) :void (light enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentLightiSGIX" fragment-light-i-sgix) :void (light enum) (pname enum) (param int)) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentLightivSGIX" fragment-light-iv-sgix) :void (light enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentLightModelfSGIX" fragment-light-model-f-sgix) :void (pname enum) (param float)) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentLightModelfvSGIX" fragment-light-model-fv-sgix) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentLightModeliSGIX" fragment-light-model-i-sgix) :void (pname enum) (param int)) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentLightModelivSGIX" fragment-light-model-iv-sgix) :void (pname enum) (params (:pointer int))) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentMaterialfSGIX" fragment-material-f-sgix) :void (face enum) (pname enum) (param float)) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentMaterialfvSGIX" fragment-material-fv-sgix) :void (face enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentMaterialiSGIX" fragment-material-i-sgix) :void (face enum) (pname enum) (param int)) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glFragmentMaterialivSGIX" fragment-material-iv-sgix) :void (face enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glGetFragmentLightfvSGIX" get-fragment-light-fv-sgix) :void (light enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glGetFragmentLightivSGIX" get-fragment-light-iv-sgix) :void (light enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glGetFragmentMaterialfvSGIX" get-fragment-material-fv-sgix) :void (face enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glGetFragmentMaterialivSGIX" get-fragment-material-iv-sgix) :void (face enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, SGIX_fragment_lighting (defglextfun ("glLightEnviSGIX" light-env-i-sgix) :void (pname enum) (param int)) ;;; GL version: 1.1, EXT_draw_range_elements (defglextfun ("glDrawRangeElementsEXT" draw-range-elements-ext) :void (mode enum) (start uint) (end uint) (count sizei) (type enum) (indices (:pointer void))) ;;; GL version: 1.1, EXT_light_texture (defglextfun ("glApplyTextureEXT" apply-texture-ext) :void (mode enum)) ;;; GL version: 1.1, EXT_light_texture (defglextfun ("glTextureLightEXT" texture-light-ext) :void (pname enum)) ;;; GL version: 1.1, EXT_light_texture (defglextfun ("glTextureMaterialEXT" texture-material-ext) :void (face enum) (mode enum)) ;;; GL version: 1.0, SGIX_async (defglextfun ("glAsyncMarkerSGIX" async-marker-sgix) :void (marker uint)) ;;; GL version: 1.0, SGIX_async (defglextfun ("glFinishAsyncSGIX" finish-async-sgix) int (markerp (:pointer uint))) ;;; GL version: 1.0, SGIX_async (defglextfun ("glPollAsyncSGIX" poll-async-sgix) int (markerp (:pointer uint))) ;;; GL version: 1.0, SGIX_async (defglextfun ("glGenAsyncMarkersSGIX" gen-async-markers-sgix) uint (range sizei)) ;;; GL version: 1.0, SGIX_async (defglextfun ("glDeleteAsyncMarkersSGIX" delete-async-markers-sgix) :void (marker uint) (range sizei)) ;;; GL version: 1.0, SGIX_async (defglextfun ("glIsAsyncMarkerSGIX" is-async-marker-sgix) boolean (marker uint)) ;;; GL version: 1.1, INTEL_parallel_arrays (defglextfun ("glVertexPointervINTEL" vertex-pointer-v-intel) :void (size int) (type enum) (pointer (:pointer (:pointer void)))) ;;; GL version: 1.1, INTEL_parallel_arrays (defglextfun ("glNormalPointervINTEL" normal-pointer-v-intel) :void (type enum) (pointer (:pointer (:pointer void)))) ;;; GL version: 1.1, INTEL_parallel_arrays (defglextfun ("glColorPointervINTEL" color-pointer-v-intel) :void (size int) (type enum) (pointer (:pointer (:pointer void)))) ;;; GL version: 1.1, INTEL_parallel_arrays (defglextfun ("glTexCoordPointervINTEL" tex-coord-pointer-v-intel) :void (size int) (type enum) (pointer (:pointer (:pointer void)))) ;;; GL version: 1.1, EXT_pixel_transform (defglextfun ("glPixelTransformParameteriEXT" pixel-transform-parameter-i-ext) :void (target enum) (pname enum) (param int)) ;;; GL version: 1.1, EXT_pixel_transform (defglextfun ("glPixelTransformParameterfEXT" pixel-transform-parameter-f-ext) :void (target enum) (pname enum) (param float)) ;;; GL version: 1.1, EXT_pixel_transform (defglextfun ("glPixelTransformParameterivEXT" pixel-transform-parameter-iv-ext) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.1, EXT_pixel_transform (defglextfun ("glPixelTransformParameterfvEXT" pixel-transform-parameter-fv-ext) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3bEXT" secondary-color-3b-ext) :void (red byte) (green byte) (blue byte)) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3bvEXT" secondary-color-3bv-ext) :void (v (:pointer byte))) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3dEXT" secondary-color-3d-ext) :void (red double) (green double) (blue double)) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3dvEXT" secondary-color-3dv-ext) :void (v (:pointer double))) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3fEXT" secondary-color-3f-ext) :void (red float) (green float) (blue float)) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3fvEXT" secondary-color-3fv-ext) :void (v (:pointer float))) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3iEXT" secondary-color-3i-ext) :void (red int) (green int) (blue int)) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3ivEXT" secondary-color-3iv-ext) :void (v (:pointer int))) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3sEXT" secondary-color-3s-ext) :void (red short) (green short) (blue short)) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3svEXT" secondary-color-3sv-ext) :void (v (:pointer short))) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3ubEXT" secondary-color-3ub-ext) :void (red ubyte) (green ubyte) (blue ubyte)) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3ubvEXT" secondary-color-3ubv-ext) :void (v (:pointer ubyte))) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3uiEXT" secondary-color-3ui-ext) :void (red uint) (green uint) (blue uint)) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3uivEXT" secondary-color-3uiv-ext) :void (v (:pointer uint))) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3usEXT" secondary-color-3us-ext) :void (red ushort) (green ushort) (blue ushort)) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColor3usvEXT" secondary-color-3usv-ext) :void (v (:pointer ushort))) ;;; GL version: 1.1, EXT_secondary_color (defglextfun ("glSecondaryColorPointerEXT" secondary-color-pointer-ext) :void (size int) (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, EXT_texture_perturb_normal (defglextfun ("glTextureNormalEXT" texture-normal-ext) :void (mode enum)) ;;; GL version: 1.1, EXT_multi_draw_arrays (defglextfun ("glMultiDrawArraysEXT" multi-draw-arrays-ext) :void (mode enum) (first (:pointer int)) (count (:pointer sizei)) (primcount sizei)) ;;; GL version: 1.1, EXT_multi_draw_arrays (defglextfun ("glMultiDrawElementsEXT" multi-draw-elements-ext) :void (mode enum) (count (:pointer sizei)) (type enum) (indices (:pointer (:pointer void))) (primcount sizei)) ;;; GL version: 1.1, EXT_fog_coord (defglextfun ("glFogCoordfEXT" fog-coord-f-ext) :void (coord float)) ;;; GL version: 1.1, EXT_fog_coord (defglextfun ("glFogCoordfvEXT" fog-coord-fv-ext) :void (coord (:pointer float))) ;;; GL version: 1.1, EXT_fog_coord (defglextfun ("glFogCoorddEXT" fog-coord-d-ext) :void (coord double)) ;;; GL version: 1.1, EXT_fog_coord (defglextfun ("glFogCoorddvEXT" fog-coord-dv-ext) :void (coord (:pointer double))) ;;; GL version: 1.1, EXT_fog_coord (defglextfun ("glFogCoordPointerEXT" fog-coord-pointer-ext) :void (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glTangent3bEXT" tangent-3b-ext) :void (tx byte) (ty byte) (tz byte)) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glTangent3bvEXT" tangent-3bv-ext) :void (v (:pointer byte))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glTangent3dEXT" tangent-3d-ext) :void (tx double) (ty double) (tz double)) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glTangent3dvEXT" tangent-3dv-ext) :void (v (:pointer double))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glTangent3fEXT" tangent-3f-ext) :void (tx float) (ty float) (tz float)) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glTangent3fvEXT" tangent-3fv-ext) :void (v (:pointer float))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glTangent3iEXT" tangent-3i-ext) :void (tx int) (ty int) (tz int)) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glTangent3ivEXT" tangent-3iv-ext) :void (v (:pointer int))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glTangent3sEXT" tangent-3s-ext) :void (tx short) (ty short) (tz short)) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glTangent3svEXT" tangent-3sv-ext) :void (v (:pointer short))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glBinormal3bEXT" binormal-3b-ext) :void (bx byte) (by byte) (bz byte)) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glBinormal3bvEXT" binormal-3bv-ext) :void (v (:pointer byte))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glBinormal3dEXT" binormal-3d-ext) :void (bx double) (by double) (bz double)) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glBinormal3dvEXT" binormal-3dv-ext) :void (v (:pointer double))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glBinormal3fEXT" binormal-3f-ext) :void (bx float) (by float) (bz float)) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glBinormal3fvEXT" binormal-3fv-ext) :void (v (:pointer float))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glBinormal3iEXT" binormal-3i-ext) :void (bx int) (by int) (bz int)) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glBinormal3ivEXT" binormal-3iv-ext) :void (v (:pointer int))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glBinormal3sEXT" binormal-3s-ext) :void (bx short) (by short) (bz short)) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glBinormal3svEXT" binormal-3sv-ext) :void (v (:pointer short))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glTangentPointerEXT" tangent-pointer-ext) :void (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, EXT_coordinate_frame (defglextfun ("glBinormalPointerEXT" binormal-pointer-ext) :void (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, SUNX_constant_data (defglextfun ("glFinishTextureSUNX" finish-texture-sunx) :void) ;;; GL version: 1.1, SUN_global_alpha (defglextfun ("glGlobalAlphaFactorbSUN" global-alpha-factor-b-sun) :void (factor byte)) ;;; GL version: 1.1, SUN_global_alpha (defglextfun ("glGlobalAlphaFactorsSUN" global-alpha-factor-s-sun) :void (factor short)) ;;; GL version: 1.1, SUN_global_alpha (defglextfun ("glGlobalAlphaFactoriSUN" global-alpha-factor-i-sun) :void (factor int)) ;;; GL version: 1.1, SUN_global_alpha (defglextfun ("glGlobalAlphaFactorfSUN" global-alpha-factor-f-sun) :void (factor float)) ;;; GL version: 1.1, SUN_global_alpha (defglextfun ("glGlobalAlphaFactordSUN" global-alpha-factor-d-sun) :void (factor double)) ;;; GL version: 1.1, SUN_global_alpha (defglextfun ("glGlobalAlphaFactorubSUN" global-alpha-factor-ub-sun) :void (factor ubyte)) ;;; GL version: 1.1, SUN_global_alpha (defglextfun ("glGlobalAlphaFactorusSUN" global-alpha-factor-us-sun) :void (factor ushort)) ;;; GL version: 1.1, SUN_global_alpha (defglextfun ("glGlobalAlphaFactoruiSUN" global-alpha-factor-ui-sun) :void (factor uint)) ;;; GL version: 1.1, SUN_triangle_list (defglextfun ("glReplacementCodeuiSUN" replacement-code-ui-sun) :void (code uint)) ;;; GL version: 1.1, SUN_triangle_list (defglextfun ("glReplacementCodeusSUN" replacement-code-us-sun) :void (code ushort)) ;;; GL version: 1.1, SUN_triangle_list (defglextfun ("glReplacementCodeubSUN" replacement-code-ub-sun) :void (code ubyte)) ;;; GL version: 1.1, SUN_triangle_list (defglextfun ("glReplacementCodeuivSUN" replacement-code-uiv-sun) :void (code (:pointer uint))) ;;; GL version: 1.1, SUN_triangle_list (defglextfun ("glReplacementCodeusvSUN" replacement-code-usv-sun) :void (code (:pointer ushort))) ;;; GL version: 1.1, SUN_triangle_list (defglextfun ("glReplacementCodeubvSUN" replacement-code-ubv-sun) :void (code (:pointer ubyte))) ;;; GL version: 1.1, SUN_triangle_list (defglextfun ("glReplacementCodePointerSUN" replacement-code-pointer-sun) :void (type enum) (stride sizei) (pointer (:pointer (:pointer void)))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glColor4ubVertex2fSUN" color-4ub-vertex-2f-sun) :void (r ubyte) (g ubyte) (b ubyte) (a ubyte) (x float) (y float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glColor4ubVertex2fvSUN" color-4ub-vertex-2fv-sun) :void (c (:pointer ubyte)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glColor4ubVertex3fSUN" color-4ub-vertex-3f-sun) :void (r ubyte) (g ubyte) (b ubyte) (a ubyte) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glColor4ubVertex3fvSUN" color-4ub-vertex-3fv-sun) :void (c (:pointer ubyte)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glColor3fVertex3fSUN" color-3f-vertex-3f-sun) :void (r float) (g float) (b float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glColor3fVertex3fvSUN" color-3f-vertex-3fv-sun) :void (c (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glNormal3fVertex3fSUN" normal-3f-vertex-3f-sun) :void (nx float) (ny float) (nz float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glNormal3fVertex3fvSUN" normal-3f-vertex-3fv-sun) :void (n (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glColor4fNormal3fVertex3fSUN" color-4f-normal-3f-vertex-3f-sun) :void (r float) (g float) (b float) (a float) (nx float) (ny float) (nz float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glColor4fNormal3fVertex3fvSUN" color-4f-normal-3f-vertex-3fv-sun) :void (c (:pointer float)) (n (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord2fVertex3fSUN" tex-coord-2f-vertex-3f-sun) :void (s float) (tee float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord2fVertex3fvSUN" tex-coord-2f-vertex-3fv-sun) :void (tc (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord4fVertex4fSUN" tex-coord-4f-vertex-4f-sun) :void (s float) (tee float) (p float) (q float) (x float) (y float) (z float) (w float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord4fVertex4fvSUN" tex-coord-4f-vertex-4fv-sun) :void (tc (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord2fColor4ubVertex3fSUN" tex-coord-2f-color-4ub-vertex-3f-sun) :void (s float) (tee float) (r ubyte) (g ubyte) (b ubyte) (a ubyte) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord2fColor4ubVertex3fvSUN" tex-coord-2f-color-4ub-vertex-3fv-sun) :void (tc (:pointer float)) (c (:pointer ubyte)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord2fColor3fVertex3fSUN" tex-coord-2f-color-3f-vertex-3f-sun) :void (s float) (tee float) (r float) (g float) (b float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord2fColor3fVertex3fvSUN" tex-coord-2f-color-3f-vertex-3fv-sun) :void (tc (:pointer float)) (c (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord2fNormal3fVertex3fSUN" tex-coord-2f-normal-3f-vertex-3f-sun) :void (s float) (tee float) (nx float) (ny float) (nz float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord2fNormal3fVertex3fvSUN" tex-coord-2f-normal-3f-vertex-3fv-sun) :void (tc (:pointer float)) (n (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord2fColor4fNormal3fVertex3fSUN" tex-coord-2f-color-4f-normal-3f-vertex-3f-sun) :void (s float) (tee float) (r float) (g float) (b float) (a float) (nx float) (ny float) (nz float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord2fColor4fNormal3fVertex3fvSUN" tex-coord-2f-color-4f-normal-3f-vertex-3fv-sun) :void (tc (:pointer float)) (c (:pointer float)) (n (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord4fColor4fNormal3fVertex4fSUN" tex-coord-4f-color-4f-normal-3f-vertex-4f-sun) :void (s float) (tee float) (p float) (q float) (r float) (g float) (b float) (a float) (nx float) (ny float) (nz float) (x float) (y float) (z float) (w float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glTexCoord4fColor4fNormal3fVertex4fvSUN" tex-coord-4f-color-4f-normal-3f-vertex-4fv-sun) :void (tc (:pointer float)) (c (:pointer float)) (n (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiVertex3fSUN" replacement-code-ui-vertex-3f-sun) :void (rc uint) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiVertex3fvSUN" replacement-code-ui-vertex-3fv-sun) :void (rc (:pointer uint)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiColor4ubVertex3fSUN" replacement-code-ui-color-4ub-vertex-3f-sun) :void (rc uint) (r ubyte) (g ubyte) (b ubyte) (a ubyte) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiColor4ubVertex3fvSUN" replacement-code-ui-color-4ub-vertex-3fv-sun) :void (rc (:pointer uint)) (c (:pointer ubyte)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiColor3fVertex3fSUN" replacement-code-ui-color-3f-vertex-3f-sun) :void (rc uint) (r float) (g float) (b float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiColor3fVertex3fvSUN" replacement-code-ui-color-3f-vertex-3fv-sun) :void (rc (:pointer uint)) (c (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiNormal3fVertex3fSUN" replacement-code-ui-normal-3f-vertex-3f-sun) :void (rc uint) (nx float) (ny float) (nz float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiNormal3fVertex3fvSUN" replacement-code-ui-normal-3f-vertex-3fv-sun) :void (rc (:pointer uint)) (n (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiColor4fNormal3fVertex3fSUN" replacement-code-ui-color-4f-normal-3f-vertex-3f-sun) :void (rc uint) (r float) (g float) (b float) (a float) (nx float) (ny float) (nz float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiColor4fNormal3fVertex3fvSUN" replacement-code-ui-color-4f-normal-3f-vertex-3fv-sun) :void (rc (:pointer uint)) (c (:pointer float)) (n (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiTexCoord2fVertex3fSUN" replacement-code-ui-tex-coord-2f-vertex-3f-sun) :void (rc uint) (s float) (tee float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiTexCoord2fVertex3fvSUN" replacement-code-ui-tex-coord-2f-vertex-3fv-sun) :void (rc (:pointer uint)) (tc (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN" replacement-code-ui-tex-coord-2f-normal-3f-vertex-3f-sun) :void (rc uint) (s float) (tee float) (nx float) (ny float) (nz float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN" replacement-code-ui-tex-coord-2f-normal-3f-vertex-3fv-sun) :void (rc (:pointer uint)) (tc (:pointer float)) (n (:pointer float)) (v (:pointer float))) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN" replacement-code-ui-tex-coord-2f-color-4f-normal-3f-vertex-3f-sun) :void (rc uint) (s float) (tee float) (r float) (g float) (b float) (a float) (nx float) (ny float) (nz float) (x float) (y float) (z float)) ;;; GL version: 1.1, SUN_vertex (defglextfun ("glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN" replacement-code-ui-tex-coord-2f-color-4f-normal-3f-vertex-3fv-sun) :void (rc (:pointer uint)) (tc (:pointer float)) (c (:pointer float)) (n (:pointer float)) (v (:pointer float))) ;;; GL version: 1.0, EXT_blend_func_separate (defglextfun ("glBlendFuncSeparateEXT" blend-func-separate-ext) :void (sfactorRGB enum) (dfactorRGB enum) (sfactorAlpha enum) (dfactorAlpha enum)) ;;; GL version: 1.0, INGR_blend_func_separate (defglextfun ("glBlendFuncSeparateINGR" blend-func-separate-ingr) :void (sfactorRGB enum) (dfactorRGB enum) (sfactorAlpha enum) (dfactorAlpha enum)) ;;; GL version: 1.1, EXT_vertex_weighting (defglextfun ("glVertexWeightfEXT" vertex-weight-f-ext) :void (weight float)) ;;; GL version: 1.1, EXT_vertex_weighting (defglextfun ("glVertexWeightfvEXT" vertex-weight-fv-ext) :void (weight (:pointer float))) ;;; GL version: 1.1, EXT_vertex_weighting (defglextfun ("glVertexWeightPointerEXT" vertex-weight-pointer-ext) :void (size sizei) (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.1, NV_vertex_array_range (defglextfun ("glFlushVertexArrayRangeNV" flush-vertex-array-range-nv) :void) ;;; GL version: 1.1, NV_vertex_array_range (defglextfun ("glVertexArrayRangeNV" vertex-array-range-nv) :void (length sizei) (pointer (:pointer void))) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glCombinerParameterfvNV" combiner-parameter-fv-nv) :void (pname enum) (params (:pointer float))) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glCombinerParameterfNV" combiner-parameter-f-nv) :void (pname enum) (param float)) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glCombinerParameterivNV" combiner-parameter-iv-nv) :void (pname enum) (params (:pointer int))) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glCombinerParameteriNV" combiner-parameter-i-nv) :void (pname enum) (param int)) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glCombinerInputNV" combiner-input-nv) :void (stage enum) (portion enum) (variable enum) (input enum) (mapping enum) (componentUsage enum)) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glCombinerOutputNV" combiner-output-nv) :void (stage enum) (portion enum) (abOutput enum) (cdOutput enum) (sumOutput enum) (scale enum) (bias enum) (abDotProduct boolean) (cdDotProduct boolean) (muxSum boolean)) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glFinalCombinerInputNV" final-combiner-input-nv) :void (variable enum) (input enum) (mapping enum) (componentUsage enum)) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glGetCombinerInputParameterfvNV" get-combiner-input-parameter-fv-nv) :void (stage enum) (portion enum) (variable enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glGetCombinerInputParameterivNV" get-combiner-input-parameter-iv-nv) :void (stage enum) (portion enum) (variable enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glGetCombinerOutputParameterfvNV" get-combiner-output-parameter-fv-nv) :void (stage enum) (portion enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glGetCombinerOutputParameterivNV" get-combiner-output-parameter-iv-nv) :void (stage enum) (portion enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glGetFinalCombinerInputParameterfvNV" get-final-combiner-input-parameter-fv-nv) :void (variable enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.1, NV_register_combiners (defglextfun ("glGetFinalCombinerInputParameterivNV" get-final-combiner-input-parameter-iv-nv) :void (variable enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, MESA_resize_buffers (defglextfun ("glResizeBuffersMESA" resize-buffers-mesa) :void) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos2dMESA" window-pos-2d-mesa) :void (x double) (y double)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos2dvMESA" window-pos-2dv-mesa) :void (v (:pointer double))) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos2fMESA" window-pos-2f-mesa) :void (x float) (y float)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos2fvMESA" window-pos-2fv-mesa) :void (v (:pointer float))) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos2iMESA" window-pos-2i-mesa) :void (x int) (y int)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos2ivMESA" window-pos-2iv-mesa) :void (v (:pointer int))) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos2sMESA" window-pos-2s-mesa) :void (x short) (y short)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos2svMESA" window-pos-2sv-mesa) :void (v (:pointer short))) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos3dMESA" window-pos-3d-mesa) :void (x double) (y double) (z double)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos3dvMESA" window-pos-3dv-mesa) :void (v (:pointer double))) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos3fMESA" window-pos-3f-mesa) :void (x float) (y float) (z float)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos3fvMESA" window-pos-3fv-mesa) :void (v (:pointer float))) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos3iMESA" window-pos-3i-mesa) :void (x int) (y int) (z int)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos3ivMESA" window-pos-3iv-mesa) :void (v (:pointer int))) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos3sMESA" window-pos-3s-mesa) :void (x short) (y short) (z short)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos3svMESA" window-pos-3sv-mesa) :void (v (:pointer short))) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos4dMESA" window-pos-4d-mesa) :void (x double) (y double) (z double) (w double)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos4dvMESA" window-pos-4dv-mesa) :void (v (:pointer double))) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos4fMESA" window-pos-4f-mesa) :void (x float) (y float) (z float) (w float)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos4fvMESA" window-pos-4fv-mesa) :void (v (:pointer float))) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos4iMESA" window-pos-4i-mesa) :void (x int) (y int) (z int) (w int)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos4ivMESA" window-pos-4iv-mesa) :void (v (:pointer int))) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos4sMESA" window-pos-4s-mesa) :void (x short) (y short) (z short) (w short)) ;;; GL version: 1.0, MESA_window_pos (defglextfun ("glWindowPos4svMESA" window-pos-4sv-mesa) :void (v (:pointer short))) ;;; GL version: 1.1, IBM_multimode_draw_arrays (defglextfun ("glMultiModeDrawArraysIBM" multi-mode-draw-arrays-ibm) :void (mode (:pointer enum)) (first (:pointer int)) (count (:pointer sizei)) (primcount sizei) (modestride int)) ;;; GL version: 1.1, IBM_multimode_draw_arrays (defglextfun ("glMultiModeDrawElementsIBM" multi-mode-draw-elements-ibm) :void (mode (:pointer enum)) (count (:pointer sizei)) (type enum) (indices (:pointer (:pointer void))) (primcount sizei) (modestride int)) ;;; GL version: 1.1, IBM_vertex_array_lists (defglextfun ("glColorPointerListIBM" color-pointer-list-ibm) :void (size int) (type enum) (stride int) (pointer (:pointer (:pointer void))) (ptrstride int)) ;;; GL version: 1.1, IBM_vertex_array_lists (defglextfun ("glSecondaryColorPointerListIBM" secondary-color-pointer-list-ibm) :void (size int) (type enum) (stride int) (pointer (:pointer (:pointer void))) (ptrstride int)) ;;; GL version: 1.1, IBM_vertex_array_lists (defglextfun ("glEdgeFlagPointerListIBM" edge-flag-pointer-list-ibm) :void (stride int) (pointer (:pointer (:pointer boolean))) (ptrstride int)) ;;; GL version: 1.1, IBM_vertex_array_lists (defglextfun ("glFogCoordPointerListIBM" fog-coord-pointer-list-ibm) :void (type enum) (stride int) (pointer (:pointer (:pointer void))) (ptrstride int)) ;;; GL version: 1.1, IBM_vertex_array_lists (defglextfun ("glIndexPointerListIBM" index-pointer-list-ibm) :void (type enum) (stride int) (pointer (:pointer (:pointer void))) (ptrstride int)) ;;; GL version: 1.1, IBM_vertex_array_lists (defglextfun ("glNormalPointerListIBM" normal-pointer-list-ibm) :void (type enum) (stride int) (pointer (:pointer (:pointer void))) (ptrstride int)) ;;; GL version: 1.1, IBM_vertex_array_lists (defglextfun ("glTexCoordPointerListIBM" tex-coord-pointer-list-ibm) :void (size int) (type enum) (stride int) (pointer (:pointer (:pointer void))) (ptrstride int)) ;;; GL version: 1.1, IBM_vertex_array_lists (defglextfun ("glVertexPointerListIBM" vertex-pointer-list-ibm) :void (size int) (type enum) (stride int) (pointer (:pointer (:pointer void))) (ptrstride int)) ;;; GL version: 1.2, 3DFX_tbuffer (defglextfun ("glTbufferMask3DFX" tbuffer-mask-3dfx) :void (mask uint)) ;;; GL version: 1.0, EXT_multisample (defglextfun ("glSampleMaskEXT" sample-mask-ext) :void (value clampf) (invert boolean)) ;;; GL version: 1.0, EXT_multisample (defglextfun ("glSamplePatternEXT" sample-pattern-ext) :void (pattern enum)) ;;; GL version: 1.1, SGIS_texture_color_mask (defglextfun ("glTextureColorMaskSGIS" texture-color-mask-sgis) :void (red boolean) (green boolean) (blue boolean) (alpha boolean)) ;;; GL version: 1.0, SGIX_igloo_interface (defglextfun ("glIglooInterfaceSGIX" igloo-interface-sgix) :void (pname enum) (params (:pointer void))) ;;; GL version: 1.2, NV_fence (defglextfun ("glDeleteFencesNV" delete-fences-nv) :void (n sizei) (fences (:pointer uint))) ;;; GL version: 1.2, NV_fence (defglextfun ("glGenFencesNV" gen-fences-nv) :void (n sizei) (fences (:pointer uint))) ;;; GL version: 1.2, NV_fence (defglextfun ("glIsFenceNV" is-fence-nv) boolean (fence uint)) ;;; GL version: 1.2, NV_fence (defglextfun ("glTestFenceNV" test-fence-nv) boolean (fence uint)) ;;; GL version: 1.2, NV_fence (defglextfun ("glGetFenceivNV" get-fence-iv-nv) :void (fence uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, NV_fence (defglextfun ("glFinishFenceNV" finish-fence-nv) :void (fence uint)) ;;; GL version: 1.2, NV_fence (defglextfun ("glSetFenceNV" set-fence-nv) :void (fence uint) (condition enum)) ;;; GL version: 1.1, NV_evaluators (defglextfun ("glMapControlPointsNV" map-control-points-nv) :void (target enum) (index uint) (type enum) (ustride sizei) (vstride sizei) (uorder int) (vorder int) (packed boolean) (points (:pointer void))) ;;; GL version: 1.1, NV_evaluators (defglextfun ("glMapParameterivNV" map-parameter-iv-nv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.1, NV_evaluators (defglextfun ("glMapParameterfvNV" map-parameter-fv-nv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.1, NV_evaluators (defglextfun ("glGetMapControlPointsNV" get-map-control-points-nv) :void (target enum) (index uint) (type enum) (ustride sizei) (vstride sizei) (packed boolean) (points (:pointer void))) ;;; GL version: 1.1, NV_evaluators (defglextfun ("glGetMapParameterivNV" get-map-parameter-iv-nv) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.1, NV_evaluators (defglextfun ("glGetMapParameterfvNV" get-map-parameter-fv-nv) :void (target enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.1, NV_evaluators (defglextfun ("glGetMapAttribParameterivNV" get-map-attrib-parameter-iv-nv) :void (target enum) (index uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.1, NV_evaluators (defglextfun ("glGetMapAttribParameterfvNV" get-map-attrib-parameter-fv-nv) :void (target enum) (index uint) (pname enum) (params (:pointer float))) ;;; GL version: 1.1, NV_evaluators (defglextfun ("glEvalMapsNV" eval-maps-nv) :void (target enum) (mode enum)) ;;; GL version: 1.1, NV_register_combiners2 (defglextfun ("glCombinerStageParameterfvNV" combiner-stage-parameter-fv-nv) :void (stage enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.1, NV_register_combiners2 (defglextfun ("glGetCombinerStageParameterfvNV" get-combiner-stage-parameter-fv-nv) :void (stage enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glAreProgramsResidentNV" are-programs-resident-nv) boolean (n sizei) (programs (:pointer uint)) (residences (:pointer boolean))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glBindProgramNV" bind-program-nv) :void (target enum) (id uint)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glDeleteProgramsNV" delete-programs-nv) :void (n sizei) (programs (:pointer uint))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glExecuteProgramNV" execute-program-nv) :void (target enum) (id uint) (params (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glGenProgramsNV" gen-programs-nv) :void (n sizei) (programs (:pointer uint))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glGetProgramParameterdvNV" get-program-parameter-dv-nv) :void (target enum) (index uint) (pname enum) (params (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glGetProgramParameterfvNV" get-program-parameter-fv-nv) :void (target enum) (index uint) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glGetProgramivNV" get-program-iv-nv) :void (id uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glGetProgramStringNV" get-program-string-nv) :void (id uint) (pname enum) (program (:pointer ubyte))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glGetTrackMatrixivNV" get-track-matrix-iv-nv) :void (target enum) (address uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glGetVertexAttribdvNV" get-vertex-attrib-dv-nv) :void (index uint) (pname enum) (params (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glGetVertexAttribfvNV" get-vertex-attrib-fv-nv) :void (index uint) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glGetVertexAttribivNV" get-vertex-attrib-iv-nv) :void (index uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glGetVertexAttribPointervNV" get-vertex-attrib-pointer-v-nv) :void (index uint) (pname enum) (pointer (:pointer (:pointer void)))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glIsProgramNV" is-program-nv) boolean (id uint)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glLoadProgramNV" load-program-nv) :void (target enum) (id uint) (len sizei) (program (:pointer ubyte))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glProgramParameter4dNV" program-parameter-4d-nv) :void (target enum) (index uint) (x double) (y double) (z double) (w double)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glProgramParameter4dvNV" program-parameter-4dv-nv) :void (target enum) (index uint) (v (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glProgramParameter4fNV" program-parameter-4f-nv) :void (target enum) (index uint) (x float) (y float) (z float) (w float)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glProgramParameter4fvNV" program-parameter-4fv-nv) :void (target enum) (index uint) (v (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glProgramParameters4dvNV" program-parameters-4dv-nv) :void (target enum) (index uint) (count uint) (v (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glProgramParameters4fvNV" program-parameters-4fv-nv) :void (target enum) (index uint) (count uint) (v (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glRequestResidentProgramsNV" request-resident-programs-nv) :void (n sizei) (programs (:pointer uint))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glTrackMatrixNV" track-matrix-nv) :void (target enum) (address uint) (matrix enum) (transform enum)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribPointerNV" vertex-attrib-pointer-nv) :void (index uint) (fsize int) (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib1dNV" vertex-attrib-1d-nv) :void (index uint) (x double)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib1dvNV" vertex-attrib-1dv-nv) :void (index uint) (v (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib1fNV" vertex-attrib-1f-nv) :void (index uint) (x float)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib1fvNV" vertex-attrib-1fv-nv) :void (index uint) (v (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib1sNV" vertex-attrib-1s-nv) :void (index uint) (x short)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib1svNV" vertex-attrib-1sv-nv) :void (index uint) (v (:pointer short))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib2dNV" vertex-attrib-2d-nv) :void (index uint) (x double) (y double)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib2dvNV" vertex-attrib-2dv-nv) :void (index uint) (v (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib2fNV" vertex-attrib-2f-nv) :void (index uint) (x float) (y float)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib2fvNV" vertex-attrib-2fv-nv) :void (index uint) (v (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib2sNV" vertex-attrib-2s-nv) :void (index uint) (x short) (y short)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib2svNV" vertex-attrib-2sv-nv) :void (index uint) (v (:pointer short))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib3dNV" vertex-attrib-3d-nv) :void (index uint) (x double) (y double) (z double)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib3dvNV" vertex-attrib-3dv-nv) :void (index uint) (v (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib3fNV" vertex-attrib-3f-nv) :void (index uint) (x float) (y float) (z float)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib3fvNV" vertex-attrib-3fv-nv) :void (index uint) (v (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib3sNV" vertex-attrib-3s-nv) :void (index uint) (x short) (y short) (z short)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib3svNV" vertex-attrib-3sv-nv) :void (index uint) (v (:pointer short))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib4dNV" vertex-attrib-4d-nv) :void (index uint) (x double) (y double) (z double) (w double)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib4dvNV" vertex-attrib-4dv-nv) :void (index uint) (v (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib4fNV" vertex-attrib-4f-nv) :void (index uint) (x float) (y float) (z float) (w float)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib4fvNV" vertex-attrib-4fv-nv) :void (index uint) (v (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib4sNV" vertex-attrib-4s-nv) :void (index uint) (x short) (y short) (z short) (w short)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib4svNV" vertex-attrib-4sv-nv) :void (index uint) (v (:pointer short))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib4ubNV" vertex-attrib-4ub-nv) :void (index uint) (x ubyte) (y ubyte) (z ubyte) (w ubyte)) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttrib4ubvNV" vertex-attrib-4ubv-nv) :void (index uint) (v (:pointer ubyte))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs1dvNV" vertex-attribs-1dv-nv) :void (index uint) (count sizei) (v (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs1fvNV" vertex-attribs-1fv-nv) :void (index uint) (count sizei) (v (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs1svNV" vertex-attribs-1sv-nv) :void (index uint) (count sizei) (v (:pointer short))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs2dvNV" vertex-attribs-2dv-nv) :void (index uint) (count sizei) (v (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs2fvNV" vertex-attribs-2fv-nv) :void (index uint) (count sizei) (v (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs2svNV" vertex-attribs-2sv-nv) :void (index uint) (count sizei) (v (:pointer short))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs3dvNV" vertex-attribs-3dv-nv) :void (index uint) (count sizei) (v (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs3fvNV" vertex-attribs-3fv-nv) :void (index uint) (count sizei) (v (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs3svNV" vertex-attribs-3sv-nv) :void (index uint) (count sizei) (v (:pointer short))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs4dvNV" vertex-attribs-4dv-nv) :void (index uint) (count sizei) (v (:pointer double))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs4fvNV" vertex-attribs-4fv-nv) :void (index uint) (count sizei) (v (:pointer float))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs4svNV" vertex-attribs-4sv-nv) :void (index uint) (count sizei) (v (:pointer short))) ;;; GL version: 1.2, NV_vertex_program (defglextfun ("glVertexAttribs4ubvNV" vertex-attribs-4ubv-nv) :void (index uint) (count sizei) (v (:pointer ubyte))) ;;; GL version: 1.2, ATI_envmap_bumpmap (defglextfun ("glTexBumpParameterivATI" tex-bump-parameter-iv-ati) :void (pname enum) (param (:pointer int))) ;;; GL version: 1.2, ATI_envmap_bumpmap (defglextfun ("glTexBumpParameterfvATI" tex-bump-parameter-fv-ati) :void (pname enum) (param (:pointer float))) ;;; GL version: 1.2, ATI_envmap_bumpmap (defglextfun ("glGetTexBumpParameterivATI" get-tex-bump-parameter-iv-ati) :void (pname enum) (param (:pointer int))) ;;; GL version: 1.2, ATI_envmap_bumpmap (defglextfun ("glGetTexBumpParameterfvATI" get-tex-bump-parameter-fv-ati) :void (pname enum) (param (:pointer float))) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glGenFragmentShadersATI" gen-fragment-shaders-ati) uint (range uint)) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glBindFragmentShaderATI" bind-fragment-shader-ati) :void (id uint)) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glDeleteFragmentShaderATI" delete-fragment-shader-ati) :void (id uint)) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glBeginFragmentShaderATI" begin-fragment-shader-ati) :void) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glEndFragmentShaderATI" end-fragment-shader-ati) :void) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glPassTexCoordATI" pass-tex-coord-ati) :void (dst uint) (coord uint) (swizzle enum)) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glSampleMapATI" sample-map-ati) :void (dst uint) (interp uint) (swizzle enum)) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glColorFragmentOp1ATI" color-fragment-op-1-ati) :void (op enum) (dst uint) (dstMask uint) (dstMod uint) (arg1 uint) (arg1Rep uint) (arg1Mod uint)) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glColorFragmentOp2ATI" color-fragment-op-2-ati) :void (op enum) (dst uint) (dstMask uint) (dstMod uint) (arg1 uint) (arg1Rep uint) (arg1Mod uint) (arg2 uint) (arg2Rep uint) (arg2Mod uint)) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glColorFragmentOp3ATI" color-fragment-op-3-ati) :void (op enum) (dst uint) (dstMask uint) (dstMod uint) (arg1 uint) (arg1Rep uint) (arg1Mod uint) (arg2 uint) (arg2Rep uint) (arg2Mod uint) (arg3 uint) (arg3Rep uint) (arg3Mod uint)) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glAlphaFragmentOp1ATI" alpha-fragment-op-1-ati) :void (op enum) (dst uint) (dstMod uint) (arg1 uint) (arg1Rep uint) (arg1Mod uint)) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glAlphaFragmentOp2ATI" alpha-fragment-op-2-ati) :void (op enum) (dst uint) (dstMod uint) (arg1 uint) (arg1Rep uint) (arg1Mod uint) (arg2 uint) (arg2Rep uint) (arg2Mod uint)) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glAlphaFragmentOp3ATI" alpha-fragment-op-3-ati) :void (op enum) (dst uint) (dstMod uint) (arg1 uint) (arg1Rep uint) (arg1Mod uint) (arg2 uint) (arg2Rep uint) (arg2Mod uint) (arg3 uint) (arg3Rep uint) (arg3Mod uint)) ;;; GL version: 1.2, ATI_fragment_shader (defglextfun ("glSetFragmentShaderConstantATI" set-fragment-shader-constant-ati) :void (dst uint) (value (:pointer float))) ;;; GL version: 1.2, ATI_pn_triangles (defglextfun ("glPNTrianglesiATI" pntriangles-i-ati) :void (pname enum) (param int)) ;;; GL version: 1.2, ATI_pn_triangles (defglextfun ("glPNTrianglesfATI" pntriangles-f-ati) :void (pname enum) (param float)) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glNewObjectBufferATI" new-object-buffer-ati) uint (size sizei) (pointer (:pointer void)) (usage enum)) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glIsObjectBufferATI" is-object-buffer-ati) boolean (buffer uint)) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glUpdateObjectBufferATI" update-object-buffer-ati) :void (buffer uint) (offset uint) (size sizei) (pointer (:pointer void)) (preserve enum)) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glGetObjectBufferfvATI" get-object-buffer-fv-ati) :void (buffer uint) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glGetObjectBufferivATI" get-object-buffer-iv-ati) :void (buffer uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glFreeObjectBufferATI" free-object-buffer-ati) :void (buffer uint)) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glArrayObjectATI" array-object-ati) :void (array enum) (size int) (type enum) (stride sizei) (buffer uint) (offset uint)) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glGetArrayObjectfvATI" get-array-object-fv-ati) :void (array enum) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glGetArrayObjectivATI" get-array-object-iv-ati) :void (array enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glVariantArrayObjectATI" variant-array-object-ati) :void (id uint) (type enum) (stride sizei) (buffer uint) (offset uint)) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glGetVariantArrayObjectfvATI" get-variant-array-object-fv-ati) :void (id uint) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, ATI_vertex_array_object (defglextfun ("glGetVariantArrayObjectivATI" get-variant-array-object-iv-ati) :void (id uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glBeginVertexShaderEXT" begin-vertex-shader-ext) :void) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glEndVertexShaderEXT" end-vertex-shader-ext) :void) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glBindVertexShaderEXT" bind-vertex-shader-ext) :void (id uint)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGenVertexShadersEXT" gen-vertex-shaders-ext) uint (range uint)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glDeleteVertexShaderEXT" delete-vertex-shader-ext) :void (id uint)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glShaderOp1EXT" shader-op-1-ext) :void (op enum) (res uint) (arg1 uint)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glShaderOp2EXT" shader-op-2-ext) :void (op enum) (res uint) (arg1 uint) (arg2 uint)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glShaderOp3EXT" shader-op-3-ext) :void (op enum) (res uint) (arg1 uint) (arg2 uint) (arg3 uint)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glSwizzleEXT" swizzle-ext) :void (res uint) (in uint) (outX enum) (outY enum) (outZ enum) (outW enum)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glWriteMaskEXT" write-mask-ext) :void (res uint) (in uint) (outX enum) (outY enum) (outZ enum) (outW enum)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glInsertComponentEXT" insert-component-ext) :void (res uint) (src uint) (num uint)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glExtractComponentEXT" extract-component-ext) :void (res uint) (src uint) (num uint)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGenSymbolsEXT" gen-symbols-ext) uint (datatype enum) (storagetype enum) (range enum) (components uint)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glSetInvariantEXT" set-invariant-ext) :void (id uint) (type enum) (addr (:pointer void))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glSetLocalConstantEXT" set-local-constant-ext) :void (id uint) (type enum) (addr (:pointer void))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glVariantbvEXT" variant-bv-ext) :void (id uint) (addr (:pointer byte))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glVariantsvEXT" variant-sv-ext) :void (id uint) (addr (:pointer short))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glVariantivEXT" variant-iv-ext) :void (id uint) (addr (:pointer int))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glVariantfvEXT" variant-fv-ext) :void (id uint) (addr (:pointer float))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glVariantdvEXT" variant-dv-ext) :void (id uint) (addr (:pointer double))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glVariantubvEXT" variant-ubv-ext) :void (id uint) (addr (:pointer ubyte))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glVariantusvEXT" variant-usv-ext) :void (id uint) (addr (:pointer ushort))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glVariantuivEXT" variant-uiv-ext) :void (id uint) (addr (:pointer uint))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glVariantPointerEXT" variant-pointer-ext) :void (id uint) (type enum) (stride uint) (addr (:pointer void))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glEnableVariantClientStateEXT" enable-variant-client-state-ext) :void (id uint)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glDisableVariantClientStateEXT" disable-variant-client-state-ext) :void (id uint)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glBindLightParameterEXT" bind-light-parameter-ext) uint (light enum) (value enum)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glBindMaterialParameterEXT" bind-material-parameter-ext) uint (face enum) (value enum)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glBindTexGenParameterEXT" bind-tex-gen-parameter-ext) uint (unit enum) (coord enum) (value enum)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glBindTextureUnitParameterEXT" bind-texture-unit-parameter-ext) uint (unit enum) (value enum)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glBindParameterEXT" bind-parameter-ext) uint (value enum)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glIsVariantEnabledEXT" is-variant-enabled-ext) boolean (id uint) (cap enum)) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGetVariantBooleanvEXT" get-variant-boolean-v-ext) :void (id uint) (value enum) (data (:pointer boolean))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGetVariantIntegervEXT" get-variant-integer-v-ext) :void (id uint) (value enum) (data (:pointer int))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGetVariantFloatvEXT" get-variant-float-v-ext) :void (id uint) (value enum) (data (:pointer float))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGetVariantPointervEXT" get-variant-pointer-v-ext) :void (id uint) (value enum) (data (:pointer (:pointer void)))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGetInvariantBooleanvEXT" get-invariant-boolean-v-ext) :void (id uint) (value enum) (data (:pointer boolean))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGetInvariantIntegervEXT" get-invariant-integer-v-ext) :void (id uint) (value enum) (data (:pointer int))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGetInvariantFloatvEXT" get-invariant-float-v-ext) :void (id uint) (value enum) (data (:pointer float))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGetLocalConstantBooleanvEXT" get-local-constant-boolean-v-ext) :void (id uint) (value enum) (data (:pointer boolean))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGetLocalConstantIntegervEXT" get-local-constant-integer-v-ext) :void (id uint) (value enum) (data (:pointer int))) ;;; GL version: 1.2, EXT_vertex_shader (defglextfun ("glGetLocalConstantFloatvEXT" get-local-constant-float-v-ext) :void (id uint) (value enum) (data (:pointer float))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream1sATI" vertex-stream-1s-ati) :void (stream enum) (x short)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream1svATI" vertex-stream-1sv-ati) :void (stream enum) (coords (:pointer short))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream1iATI" vertex-stream-1i-ati) :void (stream enum) (x int)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream1ivATI" vertex-stream-1iv-ati) :void (stream enum) (coords (:pointer int))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream1fATI" vertex-stream-1f-ati) :void (stream enum) (x float)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream1fvATI" vertex-stream-1fv-ati) :void (stream enum) (coords (:pointer float))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream1dATI" vertex-stream-1d-ati) :void (stream enum) (x double)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream1dvATI" vertex-stream-1dv-ati) :void (stream enum) (coords (:pointer double))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream2sATI" vertex-stream-2s-ati) :void (stream enum) (x short) (y short)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream2svATI" vertex-stream-2sv-ati) :void (stream enum) (coords (:pointer short))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream2iATI" vertex-stream-2i-ati) :void (stream enum) (x int) (y int)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream2ivATI" vertex-stream-2iv-ati) :void (stream enum) (coords (:pointer int))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream2fATI" vertex-stream-2f-ati) :void (stream enum) (x float) (y float)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream2fvATI" vertex-stream-2fv-ati) :void (stream enum) (coords (:pointer float))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream2dATI" vertex-stream-2d-ati) :void (stream enum) (x double) (y double)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream2dvATI" vertex-stream-2dv-ati) :void (stream enum) (coords (:pointer double))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream3sATI" vertex-stream-3s-ati) :void (stream enum) (x short) (y short) (z short)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream3svATI" vertex-stream-3sv-ati) :void (stream enum) (coords (:pointer short))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream3iATI" vertex-stream-3i-ati) :void (stream enum) (x int) (y int) (z int)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream3ivATI" vertex-stream-3iv-ati) :void (stream enum) (coords (:pointer int))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream3fATI" vertex-stream-3f-ati) :void (stream enum) (x float) (y float) (z float)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream3fvATI" vertex-stream-3fv-ati) :void (stream enum) (coords (:pointer float))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream3dATI" vertex-stream-3d-ati) :void (stream enum) (x double) (y double) (z double)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream3dvATI" vertex-stream-3dv-ati) :void (stream enum) (coords (:pointer double))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream4sATI" vertex-stream-4s-ati) :void (stream enum) (x short) (y short) (z short) (w short)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream4svATI" vertex-stream-4sv-ati) :void (stream enum) (coords (:pointer short))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream4iATI" vertex-stream-4i-ati) :void (stream enum) (x int) (y int) (z int) (w int)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream4ivATI" vertex-stream-4iv-ati) :void (stream enum) (coords (:pointer int))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream4fATI" vertex-stream-4f-ati) :void (stream enum) (x float) (y float) (z float) (w float)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream4fvATI" vertex-stream-4fv-ati) :void (stream enum) (coords (:pointer float))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream4dATI" vertex-stream-4d-ati) :void (stream enum) (x double) (y double) (z double) (w double)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexStream4dvATI" vertex-stream-4dv-ati) :void (stream enum) (coords (:pointer double))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glNormalStream3bATI" normal-stream-3b-ati) :void (stream enum) (nx byte) (ny byte) (nz byte)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glNormalStream3bvATI" normal-stream-3bv-ati) :void (stream enum) (coords (:pointer byte))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glNormalStream3sATI" normal-stream-3s-ati) :void (stream enum) (nx short) (ny short) (nz short)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glNormalStream3svATI" normal-stream-3sv-ati) :void (stream enum) (coords (:pointer short))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glNormalStream3iATI" normal-stream-3i-ati) :void (stream enum) (nx int) (ny int) (nz int)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glNormalStream3ivATI" normal-stream-3iv-ati) :void (stream enum) (coords (:pointer int))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glNormalStream3fATI" normal-stream-3f-ati) :void (stream enum) (nx float) (ny float) (nz float)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glNormalStream3fvATI" normal-stream-3fv-ati) :void (stream enum) (coords (:pointer float))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glNormalStream3dATI" normal-stream-3d-ati) :void (stream enum) (nx double) (ny double) (nz double)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glNormalStream3dvATI" normal-stream-3dv-ati) :void (stream enum) (coords (:pointer double))) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glClientActiveVertexStreamATI" client-active-vertex-stream-ati) :void (stream enum)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexBlendEnviATI" vertex-blend-env-i-ati) :void (pname enum) (param int)) ;;; GL version: 1.2, ATI_vertex_streams (defglextfun ("glVertexBlendEnvfATI" vertex-blend-env-f-ati) :void (pname enum) (param float)) ;;; GL version: 1.2, ATI_element_array (defglextfun ("glElementPointerATI" element-pointer-ati) :void (type enum) (pointer (:pointer void))) ;;; GL version: 1.2, ATI_element_array (defglextfun ("glDrawElementArrayATI" draw-element-array-ati) :void (mode enum) (count sizei)) ;;; GL version: 1.2, ATI_element_array (defglextfun ("glDrawRangeElementArrayATI" draw-range-element-array-ati) :void (mode enum) (start uint) (end uint) (count sizei)) ;;; GL version: 1.1, SUN_mesh_array (defglextfun ("glDrawMeshArraysSUN" draw-mesh-arrays-sun) :void (mode enum) (first int) (count sizei) (width sizei)) ;;; GL version: 1.2, NV_occlusion_query (defglextfun ("glGenOcclusionQueriesNV" gen-occlusion-queries-nv) :void (n sizei) (ids (:pointer uint))) ;;; GL version: 1.2, NV_occlusion_query (defglextfun ("glDeleteOcclusionQueriesNV" delete-occlusion-queries-nv) :void (n sizei) (ids (:pointer uint))) ;;; GL version: 1.2, NV_occlusion_query (defglextfun ("glIsOcclusionQueryNV" is-occlusion-query-nv) boolean (id uint)) ;;; GL version: 1.2, NV_occlusion_query (defglextfun ("glBeginOcclusionQueryNV" begin-occlusion-query-nv) :void (id uint)) ;;; GL version: 1.2, NV_occlusion_query (defglextfun ("glEndOcclusionQueryNV" end-occlusion-query-nv) :void) ;;; GL version: 1.2, NV_occlusion_query (defglextfun ("glGetOcclusionQueryivNV" get-occlusion-query-iv-nv) :void (id uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, NV_occlusion_query (defglextfun ("glGetOcclusionQueryuivNV" get-occlusion-query-uiv-nv) :void (id uint) (pname enum) (params (:pointer uint))) ;;; GL version: 1.2, NV_point_sprite (defglextfun ("glPointParameteriNV" point-parameter-i-nv) :void (pname enum) (param int)) ;;; GL version: 1.2, NV_point_sprite (defglextfun ("glPointParameterivNV" point-parameter-iv-nv) :void (pname enum) (params (:pointer int))) ;;; GL version: 1.3, EXT_stencil_two_side (defglextfun ("glActiveStencilFaceEXT" active-stencil-face-ext) :void (face enum)) ;;; GL version: 1.2, APPLE_element_array (defglextfun ("glElementPointerAPPLE" element-pointer-apple) :void (type enum) (pointer (:pointer void))) ;;; GL version: 1.2, APPLE_element_array (defglextfun ("glDrawElementArrayAPPLE" draw-element-array-apple) :void (mode enum) (first int) (count sizei)) ;;; GL version: 1.2, APPLE_element_array (defglextfun ("glDrawRangeElementArrayAPPLE" draw-range-element-array-apple) :void (mode enum) (start uint) (end uint) (first int) (count sizei)) ;;; GL version: 1.2, APPLE_element_array (defglextfun ("glMultiDrawElementArrayAPPLE" multi-draw-element-array-apple) :void (mode enum) (first (:pointer int)) (count (:pointer sizei)) (primcount sizei)) ;;; GL version: 1.2, APPLE_element_array (defglextfun ("glMultiDrawRangeElementArrayAPPLE" multi-draw-range-element-array-apple) :void (mode enum) (start uint) (end uint) (first (:pointer int)) (count (:pointer sizei)) (primcount sizei)) ;;; GL version: 1.2, APPLE_fence (defglextfun ("glGenFencesAPPLE" gen-fences-apple) :void (n sizei) (fences (:pointer uint))) ;;; GL version: 1.2, APPLE_fence (defglextfun ("glDeleteFencesAPPLE" delete-fences-apple) :void (n sizei) (fences (:pointer uint))) ;;; GL version: 1.2, APPLE_fence (defglextfun ("glSetFenceAPPLE" set-fence-apple) :void (fence uint)) ;;; GL version: 1.2, APPLE_fence (defglextfun ("glIsFenceAPPLE" is-fence-apple) boolean (fence uint)) ;;; GL version: 1.2, APPLE_fence (defglextfun ("glTestFenceAPPLE" test-fence-apple) boolean (fence uint)) ;;; GL version: 1.2, APPLE_fence (defglextfun ("glFinishFenceAPPLE" finish-fence-apple) :void (fence uint)) ;;; GL version: 1.2, APPLE_fence (defglextfun ("glTestObjectAPPLE" test-object-apple) boolean (object enum) (name uint)) ;;; GL version: 1.2, APPLE_fence (defglextfun ("glFinishObjectAPPLE" finish-object-apple) :void (object enum) (name int)) ;;; GL version: 1.2, APPLE_vertex_array_object (defglextfun ("glBindVertexArrayAPPLE" bind-vertex-array-apple) :void (array uint)) ;;; GL version: 1.2, APPLE_vertex_array_object (defglextfun ("glDeleteVertexArraysAPPLE" delete-vertex-arrays-apple) :void (n sizei) (arrays (:pointer uint))) ;;; GL version: 1.2, APPLE_vertex_array_object (defglextfun ("glGenVertexArraysAPPLE" gen-vertex-arrays-apple) :void (n sizei) (arrays (:pointer uint))) ;;; GL version: 1.2, APPLE_vertex_array_object (defglextfun ("glIsVertexArrayAPPLE" is-vertex-array-apple) boolean (array uint)) ;;; GL version: 1.2, APPLE_vertex_array_range (defglextfun ("glVertexArrayRangeAPPLE" vertex-array-range-apple) :void (length sizei) (pointer (:pointer void))) ;;; GL version: 1.2, APPLE_vertex_array_range (defglextfun ("glFlushVertexArrayRangeAPPLE" flush-vertex-array-range-apple) :void (length sizei) (pointer (:pointer void))) ;;; GL version: 1.2, APPLE_vertex_array_range (defglextfun ("glVertexArrayParameteriAPPLE" vertex-array-parameter-i-apple) :void (pname enum) (param int)) ;;; GL version: 1.2, ATI_draw_buffers (defglextfun ("glDrawBuffersATI" draw-buffers-ati) :void (n sizei) (bufs (:pointer enum))) ;;; GL version: 1.2, NV_fragment_program (defglextfun ("glProgramNamedParameter4fNV" program-named-parameter-4f-nv) :void (id uint) (len sizei) (name (:pointer ubyte)) (x float) (y float) (z float) (w float)) ;;; GL version: 1.2, NV_fragment_program (defglextfun ("glProgramNamedParameter4dNV" program-named-parameter-4d-nv) :void (id uint) (len sizei) (name (:pointer ubyte)) (x double) (y double) (z double) (w double)) ;;; GL version: 1.2, NV_fragment_program (defglextfun ("glProgramNamedParameter4fvNV" program-named-parameter-4fv-nv) :void (id uint) (len sizei) (name (:pointer ubyte)) (v (:pointer float))) ;;; GL version: 1.2, NV_fragment_program (defglextfun ("glProgramNamedParameter4dvNV" program-named-parameter-4dv-nv) :void (id uint) (len sizei) (name (:pointer ubyte)) (v (:pointer double))) ;;; GL version: 1.2, NV_fragment_program (defglextfun ("glGetProgramNamedParameterfvNV" get-program-named-parameter-fv-nv) :void (id uint) (len sizei) (name (:pointer ubyte)) (params (:pointer float))) ;;; GL version: 1.2, NV_fragment_program (defglextfun ("glGetProgramNamedParameterdvNV" get-program-named-parameter-dv-nv) :void (id uint) (len sizei) (name (:pointer ubyte)) (params (:pointer double))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertex2hNV" vertex-2h-nv) :void (x half-nv) (y half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertex2hvNV" vertex-2hv-nv) :void (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertex3hNV" vertex-3h-nv) :void (x half-nv) (y half-nv) (z half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertex3hvNV" vertex-3hv-nv) :void (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertex4hNV" vertex-4h-nv) :void (x half-nv) (y half-nv) (z half-nv) (w half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertex4hvNV" vertex-4hv-nv) :void (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glNormal3hNV" normal-3h-nv) :void (nx half-nv) (ny half-nv) (nz half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glNormal3hvNV" normal-3hv-nv) :void (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glColor3hNV" color-3h-nv) :void (red half-nv) (green half-nv) (blue half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glColor3hvNV" color-3hv-nv) :void (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glColor4hNV" color-4h-nv) :void (red half-nv) (green half-nv) (blue half-nv) (alpha half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glColor4hvNV" color-4hv-nv) :void (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glTexCoord1hNV" tex-coord-1h-nv) :void (s half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glTexCoord1hvNV" tex-coord-1hv-nv) :void (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glTexCoord2hNV" tex-coord-2h-nv) :void (s half-nv) (tee half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glTexCoord2hvNV" tex-coord-2hv-nv) :void (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glTexCoord3hNV" tex-coord-3h-nv) :void (s half-nv) (tee half-nv) (r half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glTexCoord3hvNV" tex-coord-3hv-nv) :void (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glTexCoord4hNV" tex-coord-4h-nv) :void (s half-nv) (tee half-nv) (r half-nv) (q half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glTexCoord4hvNV" tex-coord-4hv-nv) :void (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glMultiTexCoord1hNV" multi-tex-coord-1h-nv) :void (target enum) (s half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glMultiTexCoord1hvNV" multi-tex-coord-1hv-nv) :void (target enum) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glMultiTexCoord2hNV" multi-tex-coord-2h-nv) :void (target enum) (s half-nv) (tee half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glMultiTexCoord2hvNV" multi-tex-coord-2hv-nv) :void (target enum) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glMultiTexCoord3hNV" multi-tex-coord-3h-nv) :void (target enum) (s half-nv) (tee half-nv) (r half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glMultiTexCoord3hvNV" multi-tex-coord-3hv-nv) :void (target enum) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glMultiTexCoord4hNV" multi-tex-coord-4h-nv) :void (target enum) (s half-nv) (tee half-nv) (r half-nv) (q half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glMultiTexCoord4hvNV" multi-tex-coord-4hv-nv) :void (target enum) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glFogCoordhNV" fog-coord-h-nv) :void (fog half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glFogCoordhvNV" fog-coord-hv-nv) :void (fog (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glSecondaryColor3hNV" secondary-color-3h-nv) :void (red half-nv) (green half-nv) (blue half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glSecondaryColor3hvNV" secondary-color-3hv-nv) :void (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexWeighthNV" vertex-weight-h-nv) :void (weight half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexWeighthvNV" vertex-weight-hv-nv) :void (weight (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttrib1hNV" vertex-attrib-1h-nv) :void (index uint) (x half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttrib1hvNV" vertex-attrib-1hv-nv) :void (index uint) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttrib2hNV" vertex-attrib-2h-nv) :void (index uint) (x half-nv) (y half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttrib2hvNV" vertex-attrib-2hv-nv) :void (index uint) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttrib3hNV" vertex-attrib-3h-nv) :void (index uint) (x half-nv) (y half-nv) (z half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttrib3hvNV" vertex-attrib-3hv-nv) :void (index uint) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttrib4hNV" vertex-attrib-4h-nv) :void (index uint) (x half-nv) (y half-nv) (z half-nv) (w half-nv)) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttrib4hvNV" vertex-attrib-4hv-nv) :void (index uint) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttribs1hvNV" vertex-attribs-1hv-nv) :void (index uint) (n sizei) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttribs2hvNV" vertex-attribs-2hv-nv) :void (index uint) (n sizei) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttribs3hvNV" vertex-attribs-3hv-nv) :void (index uint) (n sizei) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_half_float (defglextfun ("glVertexAttribs4hvNV" vertex-attribs-4hv-nv) :void (index uint) (n sizei) (v (:pointer half-nv))) ;;; GL version: 1.2, NV_pixel_data_range (defglextfun ("glPixelDataRangeNV" pixel-data-range-nv) :void (target enum) (length sizei) (pointer (:pointer void))) ;;; GL version: 1.2, NV_pixel_data_range (defglextfun ("glFlushPixelDataRangeNV" flush-pixel-data-range-nv) :void (target enum)) ;;; GL version: 1.2, NV_primitive_restart (defglextfun ("glPrimitiveRestartNV" primitive-restart-nv) :void) ;;; GL version: 1.2, NV_primitive_restart (defglextfun ("glPrimitiveRestartIndexNV" primitive-restart-index-nv) :void (index uint)) ;;; GL version: 1.2, ATI_map_object_buffer (defglextfun ("glMapObjectBufferATI" map-object-buffer-ati) (:pointer void) (buffer uint)) ;;; GL version: 1.2, ATI_map_object_buffer (defglextfun ("glUnmapObjectBufferATI" unmap-object-buffer-ati) :void (buffer uint)) ;;; GL version: 1.2, ATI_separate_stencil (defglextfun ("glStencilOpSeparateATI" stencil-op-separate-ati) :void (face enum) (sfail enum) (dpfail enum) (dppass enum)) ;;; GL version: 1.2, ATI_separate_stencil (defglextfun ("glStencilFuncSeparateATI" stencil-func-separate-ati) :void (frontfunc enum) (backfunc enum) (ref int) (mask uint)) ;;; GL version: 1.2, ATI_vertex_attrib_array_object (defglextfun ("glVertexAttribArrayObjectATI" vertex-attrib-array-object-ati) :void (index uint) (size int) (type enum) (normalized boolean) (stride sizei) (buffer uint) (offset uint)) ;;; GL version: 1.2, ATI_vertex_attrib_array_object (defglextfun ("glGetVertexAttribArrayObjectfvATI" get-vertex-attrib-array-object-fv-ati) :void (index uint) (pname enum) (params (:pointer float))) ;;; GL version: 1.2, ATI_vertex_attrib_array_object (defglextfun ("glGetVertexAttribArrayObjectivATI" get-vertex-attrib-array-object-iv-ati) :void (index uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, EXT_depth_bounds_test (defglextfun ("glDepthBoundsEXT" depth-bounds-ext) :void (zmin clampd) (zmax clampd)) ;;; GL version: 1.2, EXT_blend_equation_separate (defglextfun ("glBlendEquationSeparateEXT" blend-equation-separate-ext) :void (modeRGB enum) (modeAlpha enum)) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glIsRenderbufferEXT" is-renderbuffer-ext) boolean (renderbuffer uint)) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glBindRenderbufferEXT" bind-renderbuffer-ext) :void (target enum) (renderbuffer uint)) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glDeleteRenderbuffersEXT" delete-renderbuffers-ext) :void (n sizei) (renderbuffers (:pointer uint))) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glGenRenderbuffersEXT" gen-renderbuffers-ext) :void (n sizei) (renderbuffers (:pointer uint))) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glRenderbufferStorageEXT" renderbuffer-storage-ext) :void (target enum) (internalformat enum) (width sizei) (height sizei)) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glGetRenderbufferParameterivEXT" get-renderbuffer-parameter-iv-ext) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glIsFramebufferEXT" is-framebuffer-ext) boolean (framebuffer uint)) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glBindFramebufferEXT" bind-framebuffer-ext) :void (target enum) (framebuffer uint)) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glDeleteFramebuffersEXT" delete-framebuffers-ext) :void (n sizei) (framebuffers (:pointer uint))) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glGenFramebuffersEXT" gen-framebuffers-ext) :void (n sizei) (framebuffers (:pointer uint))) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glCheckFramebufferStatusEXT" check-framebuffer-status-ext) enum (target enum)) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glFramebufferTexture1DEXT" framebuffer-texture-1d-ext) :void (target enum) (attachment enum) (textarget enum) (texture uint) (level int)) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glFramebufferTexture2DEXT" framebuffer-texture-2d-ext) :void (target enum) (attachment enum) (textarget enum) (texture uint) (level int)) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glFramebufferTexture3DEXT" framebuffer-texture-3d-ext) :void (target enum) (attachment enum) (textarget enum) (texture uint) (level int) (zoffset int)) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glFramebufferRenderbufferEXT" framebuffer-renderbuffer-ext) :void (target enum) (attachment enum) (renderbuffertarget enum) (renderbuffer uint)) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glGetFramebufferAttachmentParameterivEXT" get-framebuffer-attachment-parameter-iv-ext) :void (target enum) (attachment enum) (pname enum) (params (:pointer int))) ;;; GL version: 1.2, EXT_framebuffer_object (defglextfun ("glGenerateMipmapEXT" generate-mipmap-ext) :void (target enum)) ;;; GL version: 1.0, GREMEDY_string_marker (defglextfun ("glStringMarkerGREMEDY" string-marker-gremedy) :void (len sizei) (string (:pointer void))) ;;; GL version: 1.5, EXT_stencil_clear_tag (defglextfun ("glStencilClearTagEXT" stencil-clear-tag-ext) :void (stencilTagBits sizei) (stencilClearTag uint)) ;;; GL version: 1.5, EXT_framebuffer_blit (defglextfun ("glBlitFramebufferEXT" blit-framebuffer-ext) :void (srcX0 int) (srcY0 int) (srcX1 int) (srcY1 int) (dstX0 int) (dstY0 int) (dstX1 int) (dstY1 int) (mask bitfield) (filter enum)) ;;; GL version: 1.5, EXT_framebuffer_multisample (defglextfun ("glRenderbufferStorageMultisampleEXT" renderbuffer-storage-multisample-ext) :void (target enum) (samples sizei) (internalformat enum) (width sizei) (height sizei)) ;;; GL version: 1.5, EXT_timer_query (defglextfun ("glGetQueryObjecti64vEXT" get-query-object-i64v-ext) :void (id uint) (pname enum) (params (:pointer int64-ext))) ;;; GL version: 1.5, EXT_timer_query (defglextfun ("glGetQueryObjectui64vEXT" get-query-object-ui64v-ext) :void (id uint) (pname enum) (params (:pointer uint64-ext))) ;;; GL version: 1.2, EXT_gpu_program_parameters (defglextfun ("glProgramEnvParameters4fvEXT" program-env-parameters-4fv-ext) :void (target enum) (index uint) (count sizei) (params (:pointer float))) ;;; GL version: 1.2, EXT_gpu_program_parameters (defglextfun ("glProgramLocalParameters4fvEXT" program-local-parameters-4fv-ext) :void (target enum) (index uint) (count sizei) (params (:pointer float))) ;;; GL version: 1.5, APPLE_flush_buffer_range (defglextfun ("glBufferParameteriAPPLE" buffer-parameter-i-apple) :void (target enum) (pname enum) (param int)) ;;; GL version: 1.5, APPLE_flush_buffer_range (defglextfun ("glFlushMappedBufferRangeAPPLE" flush-mapped-buffer-range-apple) :void (target enum) (offset intptr) (size sizeiptr)) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramLocalParameterI4iNV" program-local-parameter-i4i-nv) :void (target enum) (index uint) (x int) (y int) (z int) (w int)) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramLocalParameterI4ivNV" program-local-parameter-i4iv-nv) :void (target enum) (index uint) (params (:pointer int))) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramLocalParametersI4ivNV" program-local-parameters-i4iv-nv) :void (target enum) (index uint) (count sizei) (params (:pointer int))) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramLocalParameterI4uiNV" program-local-parameter-i4ui-nv) :void (target enum) (index uint) (x uint) (y uint) (z uint) (w uint)) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramLocalParameterI4uivNV" program-local-parameter-i4uiv-nv) :void (target enum) (index uint) (params (:pointer uint))) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramLocalParametersI4uivNV" program-local-parameters-i4uiv-nv) :void (target enum) (index uint) (count sizei) (params (:pointer uint))) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramEnvParameterI4iNV" program-env-parameter-i4i-nv) :void (target enum) (index uint) (x int) (y int) (z int) (w int)) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramEnvParameterI4ivNV" program-env-parameter-i4iv-nv) :void (target enum) (index uint) (params (:pointer int))) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramEnvParametersI4ivNV" program-env-parameters-i4iv-nv) :void (target enum) (index uint) (count sizei) (params (:pointer int))) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramEnvParameterI4uiNV" program-env-parameter-i4ui-nv) :void (target enum) (index uint) (x uint) (y uint) (z uint) (w uint)) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramEnvParameterI4uivNV" program-env-parameter-i4uiv-nv) :void (target enum) (index uint) (params (:pointer uint))) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glProgramEnvParametersI4uivNV" program-env-parameters-i4uiv-nv) :void (target enum) (index uint) (count sizei) (params (:pointer uint))) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glGetProgramLocalParameterIivNV" get-program-local-parameter-iiv-nv) :void (target enum) (index uint) (params (:pointer int))) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glGetProgramLocalParameterIuivNV" get-program-local-parameter-iuiv-nv) :void (target enum) (index uint) (params (:pointer uint))) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glGetProgramEnvParameterIivNV" get-program-env-parameter-iiv-nv) :void (target enum) (index uint) (params (:pointer int))) ;;; GL version: 1.3, NV_gpu_program4 (defglextfun ("glGetProgramEnvParameterIuivNV" get-program-env-parameter-iuiv-nv) :void (target enum) (index uint) (params (:pointer uint))) ;;; GL version: 2.0, NV_geometry_program4 (defglextfun ("glProgramVertexLimitNV" program-vertex-limit-nv) :void (target enum) (limit int)) ;;; GL version: 2.0, NV_geometry_program4 (defglextfun ("glFramebufferTextureEXT" framebuffer-texture-ext) :void (target enum) (attachment enum) (texture uint) (level int)) ;;; GL version: 2.0, NV_geometry_program4 (defglextfun ("glFramebufferTextureLayerEXT" framebuffer-texture-layer-ext) :void (target enum) (attachment enum) (texture uint) (level int) (layer int)) ;;; GL version: 2.0, NV_geometry_program4 (defglextfun ("glFramebufferTextureFaceEXT" framebuffer-texture-face-ext) :void (target enum) (attachment enum) (texture uint) (level int) (face enum)) ;;; GL version: 2.0, EXT_geometry_shader4 (defglextfun ("glProgramParameteriEXT" program-parameter-i-ext) :void (program uint) (pname enum) (value int)) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI1iEXT" vertex-attrib-i1i-ext) :void (index uint) (x int)) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI2iEXT" vertex-attrib-i2i-ext) :void (index uint) (x int) (y int)) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI3iEXT" vertex-attrib-i3i-ext) :void (index uint) (x int) (y int) (z int)) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI4iEXT" vertex-attrib-i4i-ext) :void (index uint) (x int) (y int) (z int) (w int)) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI1uiEXT" vertex-attrib-i1ui-ext) :void (index uint) (x uint)) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI2uiEXT" vertex-attrib-i2ui-ext) :void (index uint) (x uint) (y uint)) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI3uiEXT" vertex-attrib-i3ui-ext) :void (index uint) (x uint) (y uint) (z uint)) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI4uiEXT" vertex-attrib-i4ui-ext) :void (index uint) (x uint) (y uint) (z uint) (w uint)) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI1ivEXT" vertex-attrib-i1iv-ext) :void (index uint) (v (:pointer int))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI2ivEXT" vertex-attrib-i2iv-ext) :void (index uint) (v (:pointer int))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI3ivEXT" vertex-attrib-i3iv-ext) :void (index uint) (v (:pointer int))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI4ivEXT" vertex-attrib-i4iv-ext) :void (index uint) (v (:pointer int))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI1uivEXT" vertex-attrib-i1uiv-ext) :void (index uint) (v (:pointer uint))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI2uivEXT" vertex-attrib-i2uiv-ext) :void (index uint) (v (:pointer uint))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI3uivEXT" vertex-attrib-i3uiv-ext) :void (index uint) (v (:pointer uint))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI4uivEXT" vertex-attrib-i4uiv-ext) :void (index uint) (v (:pointer uint))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI4bvEXT" vertex-attrib-i4bv-ext) :void (index uint) (v (:pointer byte))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI4svEXT" vertex-attrib-i4sv-ext) :void (index uint) (v (:pointer short))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI4ubvEXT" vertex-attrib-i4ubv-ext) :void (index uint) (v (:pointer ubyte))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribI4usvEXT" vertex-attrib-i4usv-ext) :void (index uint) (v (:pointer ushort))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glVertexAttribIPointerEXT" vertex-attrib-ipointer-ext) :void (index uint) (size int) (type enum) (stride sizei) (pointer (:pointer void))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glGetVertexAttribIivEXT" get-vertex-attrib-iiv-ext) :void (index uint) (pname enum) (params (:pointer int))) ;;; GL version: 1.0, NV_vertex_program4 (defglextfun ("glGetVertexAttribIuivEXT" get-vertex-attrib-iuiv-ext) :void (index uint) (pname enum) (params (:pointer uint))) ;;; GL version: 2.0, EXT_gpu_shader4 (defglextfun ("glGetUniformuivEXT" get-uniform-uiv-ext) :void (program uint) (location int) (params (:pointer uint))) ;;; GL version: 2.0, EXT_gpu_shader4 (defglextfun ("glBindFragDataLocationEXT" bind-frag-data-location-ext) :void (program uint) (color uint) (name (:pointer char))) ;;; GL version: 2.0, EXT_gpu_shader4 (defglextfun ("glGetFragDataLocationEXT" get-frag-data-location-ext) int (program uint) (name (:pointer char))) ;;; GL version: 2.0, EXT_gpu_shader4 (defglextfun ("glUniform1uiEXT" uniform-1ui-ext) :void (location int) (v0 uint)) ;;; GL version: 2.0, EXT_gpu_shader4 (defglextfun ("glUniform2uiEXT" uniform-2ui-ext) :void (location int) (v0 uint) (v1 uint)) ;;; GL version: 2.0, EXT_gpu_shader4 (defglextfun ("glUniform3uiEXT" uniform-3ui-ext) :void (location int) (v0 uint) (v1 uint) (v2 uint)) ;;; GL version: 2.0, EXT_gpu_shader4 (defglextfun ("glUniform4uiEXT" uniform-4ui-ext) :void (location int) (v0 uint) (v1 uint) (v2 uint) (v3 uint)) ;;; GL version: 2.0, EXT_gpu_shader4 (defglextfun ("glUniform1uivEXT" uniform-1uiv-ext) :void (location int) (count sizei) (value (:pointer uint))) ;;; GL version: 2.0, EXT_gpu_shader4 (defglextfun ("glUniform2uivEXT" uniform-2uiv-ext) :void (location int) (count sizei) (value (:pointer uint))) ;;; GL version: 2.0, EXT_gpu_shader4 (defglextfun ("glUniform3uivEXT" uniform-3uiv-ext) :void (location int) (count sizei) (value (:pointer uint))) ;;; GL version: 2.0, EXT_gpu_shader4 (defglextfun ("glUniform4uivEXT" uniform-4uiv-ext) :void (location int) (count sizei) (value (:pointer uint))) ;;; GL version: 2.0, EXT_draw_instanced (defglextfun ("glDrawArraysInstancedEXT" draw-arrays-instanced-ext) :void (mode enum) (start int) (count sizei) (primcount sizei)) ;;; GL version: 2.0, EXT_draw_instanced (defglextfun ("glDrawElementsInstancedEXT" draw-elements-instanced-ext) :void (mode enum) (count sizei) (type enum) (indices (:pointer void)) (primcount sizei)) ;;; GL version: 2.0, EXT_texture_buffer_object (defglextfun ("glTexBufferEXT" tex-buffer-ext) :void (target enum) (internalformat enum) (buffer uint)) ;;; GL version: 2.0, NV_depth_buffer_float (defglextfun ("glDepthRangedNV" depth-range-d-nv) :void (zNear double) (zFar double)) ;;; GL version: 2.0, NV_depth_buffer_float (defglextfun ("glClearDepthdNV" clear-depth-d-nv) :void (depth double)) ;;; GL version: 2.0, NV_depth_buffer_float (defglextfun ("glDepthBoundsdNV" depth-bounds-d-nv) :void (zmin double) (zmax double)) ;;; GL version: 1.5, NV_framebuffer_multisample_coverage (defglextfun ("glRenderbufferStorageMultisampleCoverageNV" renderbuffer-storage-multisample-coverage-nv) :void (target enum) (coverageSamples sizei) (colorSamples sizei) (internalformat enum) (width sizei) (height sizei)) ;;; GL version: 1.2, NV_parameter_buffer_object (defglextfun ("glProgramBufferParametersfvNV" program-buffer-parameters-fv-nv) :void (target enum) (buffer uint) (index uint) (count sizei) (params (:pointer float))) ;;; GL version: 1.2, NV_parameter_buffer_object (defglextfun ("glProgramBufferParametersIivNV" program-buffer-parameters-iiv-nv) :void (target enum) (buffer uint) (index uint) (count sizei) (params (:pointer int))) ;;; GL version: 1.2, NV_parameter_buffer_object (defglextfun ("glProgramBufferParametersIuivNV" program-buffer-parameters-iuiv-nv) :void (target enum) (buffer uint) (index uint) (count sizei) (params (:pointer uint))) ;;; GL version: 2.0, EXT_draw_buffers2 (defglextfun ("glColorMaskIndexedEXT" color-mask-indexed-ext) :void (index uint) (r boolean) (g boolean) (b boolean) (a boolean)) ;;; GL version: 2.0, EXT_draw_buffers2 (defglextfun ("glGetBooleanIndexedvEXT" get-boolean-indexed-v-ext) :void (target enum) (index uint) (data (:pointer boolean))) ;;; GL version: 2.0, EXT_draw_buffers2 (defglextfun ("glGetIntegerIndexedvEXT" get-integer-indexed-v-ext) :void (target enum) (index uint) (data (:pointer int))) ;;; GL version: 2.0, EXT_draw_buffers2 (defglextfun ("glEnableIndexedEXT" enable-indexed-ext) :void (target enum) (index uint)) ;;; GL version: 2.0, EXT_draw_buffers2 (defglextfun ("glDisableIndexedEXT" disable-indexed-ext) :void (target enum) (index uint)) ;;; GL version: 2.0, EXT_draw_buffers2 (defglextfun ("glIsEnabledIndexedEXT" is-enabled-indexed-ext) boolean (target enum) (index uint)) ;;; GL version: 1.5, NV_transform_feedback (defglextfun ("glBeginTransformFeedbackNV" begin-transform-feedback-nv) :void (primitiveMode enum)) ;;; GL version: 1.5, NV_transform_feedback (defglextfun ("glEndTransformFeedbackNV" end-transform-feedback-nv) :void) ;;; GL version: 1.5, NV_transform_feedback (defglextfun ("glTransformFeedbackAttribsNV" transform-feedback-attribs-nv) :void (count uint) (attribs (:pointer int)) (bufferMode enum)) ;;; GL version: 1.5, NV_transform_feedback (defglextfun ("glBindBufferRangeNV" bind-buffer-range-nv) :void (target enum) (index uint) (buffer uint) (offset intptr) (size sizeiptr)) ;;; GL version: 1.5, NV_transform_feedback (defglextfun ("glBindBufferOffsetNV" bind-buffer-offset-nv) :void (target enum) (index uint) (buffer uint) (offset intptr)) ;;; GL version: 1.5, NV_transform_feedback (defglextfun ("glBindBufferBaseNV" bind-buffer-base-nv) :void (target enum) (index uint) (buffer uint)) ;;; GL version: 1.5, NV_transform_feedback (defglextfun ("glTransformFeedbackVaryingsNV" transform-feedback-varyings-nv) :void (program uint) (count sizei) (locations (:pointer int)) (bufferMode enum)) ;;; GL version: 1.5, NV_transform_feedback (defglextfun ("glActiveVaryingNV" active-varying-nv) :void (program uint) (name (:pointer char))) ;;; GL version: 1.5, NV_transform_feedback (defglextfun ("glGetVaryingLocationNV" get-varying-location-nv) int (program uint) (name (:pointer char))) ;;; GL version: 1.5, NV_transform_feedback (defglextfun ("glGetActiveVaryingNV" get-active-varying-nv) :void (program uint) (index uint) (bufSize sizei) (length (:pointer sizei)) (size (:pointer sizei)) (type (:pointer enum)) (name (:pointer char))) ;;; GL version: 1.5, NV_transform_feedback (defglextfun ("glGetTransformFeedbackVaryingNV" get-transform-feedback-varying-nv) :void (program uint) (index uint) (location (:pointer int))) ;;; GL version: 2.0, EXT_bindable_uniform (defglextfun ("glUniformBufferEXT" uniform-buffer-ext) :void (program uint) (location int) (buffer uint)) ;;; GL version: 2.0, EXT_bindable_uniform (defglextfun ("glGetUniformBufferSizeEXT" get-uniform-buffer-size-ext) int (program uint) (location int)) ;;; GL version: 2.0, EXT_bindable_uniform (defglextfun ("glGetUniformOffsetEXT" get-uniform-offset-ext) intptr (program uint) (location int)) ;;; GL version: 2.0, EXT_texture_integer (defglextfun ("glTexParameterIivEXT" tex-parameter-iiv-ext) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 2.0, EXT_texture_integer (defglextfun ("glTexParameterIuivEXT" tex-parameter-iuiv-ext) :void (target enum) (pname enum) (params (:pointer uint))) ;;; GL version: 2.0, EXT_texture_integer (defglextfun ("glGetTexParameterIivEXT" get-tex-parameter-iiv-ext) :void (target enum) (pname enum) (params (:pointer int))) ;;; GL version: 2.0, EXT_texture_integer (defglextfun ("glGetTexParameterIuivEXT" get-tex-parameter-iuiv-ext) :void (target enum) (pname enum) (params (:pointer uint))) ;;; GL version: 2.0, EXT_texture_integer (defglextfun ("glClearColorIiEXT" clear-color-ii-ext) :void (red int) (green int) (blue int) (alpha int)) ;;; GL version: 2.0, EXT_texture_integer (defglextfun ("glClearColorIuiEXT" clear-color-iui-ext) :void (red uint) (green uint) (blue uint) (alpha uint)) ;;; GL version: 1.0, GREMEDY_frame_terminator (defglextfun ("glFrameTerminatorGREMEDY" frame-terminator-gremedy) :void)
229,303
Common Lisp
.lisp
7,436
28.461807
146
0.713589
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
0fbb41ebcfe4afcb302fc85109f5dcae20f574f458f39325ec821b107e291cf6
21,602
[ -1 ]
21,603
constants.lisp
rheaplex_minara/lib/cl-opengl/gl/constants.lisp
;;; this file is automatically generated, do not edit (in-package #:cl-opengl-bindings) (defcenum (enum :unsigned-int) (:1pass-ext #x80A1) (:1pass-sgis #x80A1) (:2-bytes #x1407) (:2d #x600) (:2pass-0-ext #x80A2) (:2pass-0-sgis #x80A2) (:2pass-1-ext #x80A3) (:2pass-1-sgis #x80A3) (:2x-bit-ati #x1) (:3-bytes #x1408) (:3d #x601) (:3d-color #x602) (:3d-color-texture #x603) (:4-bytes #x1409) (:422-average-ext #x80CE) (:422-ext #x80CC) (:422-rev-average-ext #x80CF) (:422-rev-ext #x80CD) (:4d-color-texture #x604) (:4pass-0-ext #x80A4) (:4pass-0-sgis #x80A4) (:4pass-1-ext #x80A5) (:4pass-1-sgis #x80A5) (:4pass-2-ext #x80A6) (:4pass-2-sgis #x80A6) (:4pass-3-ext #x80A7) (:4pass-3-sgis #x80A7) (:4x-bit-ati #x2) (:8x-bit-ati #x4) (:abgr-ext #x8000) (:accum #x100) (:accum-alpha #xD5B) (:accum-alpha-bits #xD5B) (:accum-blue #xD5A) (:accum-blue-bits #xD5A) (:accum-buffer #x200) (:accum-buffer-bit #x200) (:accum-clear-value #xB80) (:accum-green #xD59) (:accum-green-bits #xD59) (:accum-red #xD58) (:accum-red-bits #xD58) (:active-attribute-max-length #x8B8A) (:active-attributes #x8B89) (:active-stencil-face-ext #x8911) (:active-texture #x84E0) (:active-texture-arb #x84E0) (:active-uniform-max-length #x8B87) (:active-uniforms #x8B86) (:active-varying-max-length-nv #x8C82) (:active-varyings-nv #x8C81) (:active-vertex-units-arb #x86A5) (:add #x104) (:add-ati #x8963) (:add-signed #x8574) (:add-signed-arb #x8574) (:add-signed-ext #x8574) (:aliased-line-width-range #x846E) (:aliased-point-size-range #x846D) (:all-attrib #xFFFFFFFF) (:all-attrib-bits #xFFFFFFFF) (:all-completed-nv #x84F2) (:allow-draw-frg-hint-pgi #x1A210) (:allow-draw-mem-hint-pgi #x1A211) (:allow-draw-obj-hint-pgi #x1A20E) (:allow-draw-win-hint-pgi #x1A20F) (:alpha #x1906) (:alpha-bias #xD1D) (:alpha-bits #xD55) (:alpha-float16-ati #x881C) (:alpha-float32-ati #x8816) (:alpha-integer-ext #x8D97) (:alpha-max-clamp-ingr #x8567) (:alpha-max-sgix #x8321) (:alpha-min-clamp-ingr #x8563) (:alpha-min-sgix #x8320) (:alpha-scale #xD1C) (:alpha-test #xBC0) (:alpha-test-func #xBC1) (:alpha-test-ref #xBC2) (:alpha12 #x803D) (:alpha12-ext #x803D) (:alpha16 #x803E) (:alpha16-ext #x803E) (:alpha16f-arb #x881C) (:alpha16i-ext #x8D8A) (:alpha16ui-ext #x8D78) (:alpha32f-arb #x8816) (:alpha32i-ext #x8D84) (:alpha32ui-ext #x8D72) (:alpha4 #x803B) (:alpha4-ext #x803B) (:alpha8 #x803C) (:alpha8-ext #x803C) (:alpha8i-ext #x8D90) (:alpha8ui-ext #x8D7E) (:always #x207) (:always-fast-hint-pgi #x1A20C) (:always-soft-hint-pgi #x1A20D) (:ambient #x1200) (:ambient-and-diffuse #x1602) (:and #x1501) (:and-inverted #x1504) (:and-reverse #x1502) (:array-buffer #x8892) (:array-buffer-arb #x8892) (:array-buffer-binding #x8894) (:array-buffer-binding-arb #x8894) (:array-element-lock-count-ext #x81A9) (:array-element-lock-first-ext #x81A8) (:array-object-buffer-ati #x8766) (:array-object-offset-ati #x8767) (:async-draw-pixels-sgix #x835D) (:async-histogram-sgix #x832C) (:async-marker-sgix #x8329) (:async-read-pixels-sgix #x835E) (:async-tex-image-sgix #x835C) (:attached-shaders #x8B85) (:attenuation-ext #x834D) (:attrib-array-pointer-nv #x8645) (:attrib-array-size-nv #x8623) (:attrib-array-stride-nv #x8624) (:attrib-array-type-nv #x8625) (:attrib-stack-depth #xBB0) (:auto-normal #xD80) (:aux-buffers #xC00) (:aux0 #x409) (:aux1 #x40A) (:aux2 #x40B) (:aux3 #x40C) (:average-ext #x8335) (:average-hp #x8160) (:back #x405) (:back-left #x402) (:back-normals-hint-pgi #x1A223) (:back-primary-color-nv #x8C77) (:back-right #x403) (:back-secondary-color-nv #x8C78) (:bgr #x80E0) (:bgr-ext #x80E0) (:bgr-integer-ext #x8D9A) (:bgra #x80E1) (:bgra-ext #x80E1) (:bgra-integer-ext #x8D9B) (:bias-bit-ati #x8) (:bias-by-negative-one-half-nv #x8541) (:binormal-array-ext #x843A) (:binormal-array-pointer-ext #x8443) (:binormal-array-stride-ext #x8441) (:binormal-array-type-ext #x8440) (:bitmap #x1A00) (:bitmap-token #x704) (:blend #xBE2) (:blend-color #x8005) (:blend-color-ext #x8005) (:blend-dst #xBE0) (:blend-dst-alpha #x80CA) (:blend-dst-alpha-ext #x80CA) (:blend-dst-rgb #x80C8) (:blend-dst-rgb-ext #x80C8) (:blend-equation #x8009) (:blend-equation-alpha #x883D) (:blend-equation-alpha-ext #x883D) (:blend-equation-ext #x8009) (:blend-src #xBE1) (:blend-src-alpha #x80CB) (:blend-src-alpha-ext #x80CB) (:blend-src-rgb #x80C9) (:blend-src-rgb-ext #x80C9) (:blue #x1905) (:blue-bias #xD1B) (:blue-bit-ati #x4) (:blue-bits #xD54) (:blue-integer-ext #x8D96) (:blue-max-clamp-ingr #x8566) (:blue-min-clamp-ingr #x8562) (:blue-scale #xD1A) (:bool #x8B56) (:bool-arb #x8B56) (:bool-vec2 #x8B57) (:bool-vec2-arb #x8B57) (:bool-vec3 #x8B58) (:bool-vec3-arb #x8B58) (:bool-vec4 #x8B59) (:bool-vec4-arb #x8B59) (:buffer-access #x88BB) (:buffer-access-arb #x88BB) (:buffer-flushing-unmap-apple #x8A13) (:buffer-map-pointer #x88BD) (:buffer-map-pointer-arb #x88BD) (:buffer-mapped #x88BC) (:buffer-mapped-arb #x88BC) (:buffer-serialized-modify-apple #x8A12) (:buffer-size #x8764) (:buffer-size-arb #x8764) (:buffer-usage #x8765) (:buffer-usage-arb #x8765) (:bump-envmap-ati #x877B) (:bump-num-tex-units-ati #x8777) (:bump-rot-matrix-ati #x8775) (:bump-rot-matrix-size-ati #x8776) (:bump-target-ati #x877C) (:bump-tex-units-ati #x8778) (:byte #x1400) (:c3f-v3f #x2A24) (:c4f-n3f-v3f #x2A26) (:c4ub-v2f #x2A22) (:c4ub-v3f #x2A23) (:calligraphic-fragment-sgix #x8183) (:ccw #x901) (:clamp #x2900) (:clamp-fragment-color-arb #x891B) (:clamp-read-color-arb #x891C) (:clamp-to-border #x812D) (:clamp-to-border-arb #x812D) (:clamp-to-border-sgis #x812D) (:clamp-to-edge #x812F) (:clamp-to-edge-sgis #x812F) (:clamp-vertex-color-arb #x891A) (:clear #x1500) (:client-active-texture #x84E1) (:client-active-texture-arb #x84E1) (:client-all-attrib #xFFFFFFFF) (:client-all-attrib-bits #xFFFFFFFF) (:client-attrib-stack-depth #xBB1) (:client-pixel-store #x1) (:client-pixel-store-bit #x1) (:client-vertex-array #x2) (:client-vertex-array-bit #x2) (:clip-distance-nv #x8C7A) (:clip-far-hint-pgi #x1A221) (:clip-near-hint-pgi #x1A220) (:clip-plane0 #x3000) (:clip-plane1 #x3001) (:clip-plane2 #x3002) (:clip-plane3 #x3003) (:clip-plane4 #x3004) (:clip-plane5 #x3005) (:clip-volume-clipping-hint-ext #x80F0) (:cmyk-ext #x800C) (:cmyka-ext #x800D) (:cnd-ati #x896A) (:cnd0-ati #x896B) (:coeff #xA00) (:color #x1800) (:color-alpha-pairing-ati #x8975) (:color-array #x8076) (:color-array-buffer-binding #x8898) (:color-array-buffer-binding-arb #x8898) (:color-array-count-ext #x8084) (:color-array-ext #x8076) (:color-array-list-ibm #x192A0) (:color-array-list-stride-ibm #x192AA) (:color-array-parallel-pointers-intel #x83F7) (:color-array-pointer #x8090) (:color-array-pointer-ext #x8090) (:color-array-size #x8081) (:color-array-size-ext #x8081) (:color-array-stride #x8083) (:color-array-stride-ext #x8083) (:color-array-type #x8082) (:color-array-type-ext #x8082) (:color-attachment0-ext #x8CE0) (:color-attachment1-ext #x8CE1) (:color-attachment10-ext #x8CEA) (:color-attachment11-ext #x8CEB) (:color-attachment12-ext #x8CEC) (:color-attachment13-ext #x8CED) (:color-attachment14-ext #x8CEE) (:color-attachment15-ext #x8CEF) (:color-attachment2-ext #x8CE2) (:color-attachment3-ext #x8CE3) (:color-attachment4-ext #x8CE4) (:color-attachment5-ext #x8CE5) (:color-attachment6-ext #x8CE6) (:color-attachment7-ext #x8CE7) (:color-attachment8-ext #x8CE8) (:color-attachment9-ext #x8CE9) (:color-buffer #x4000) (:color-buffer-bit #x4000) (:color-clear-unclamped-value-ati #x8835) (:color-clear-value #xC22) (:color-index #x1900) (:color-index1-ext #x80E2) (:color-index12-ext #x80E6) (:color-index16-ext #x80E7) (:color-index2-ext #x80E3) (:color-index4-ext #x80E4) (:color-index8-ext #x80E5) (:color-indexes #x1603) (:color-logic-op #xBF2) (:color-material #xB57) (:color-material-face #xB55) (:color-material-parameter #xB56) (:color-matrix #x80B1) (:color-matrix-sgi #x80B1) (:color-matrix-stack-depth #x80B2) (:color-matrix-stack-depth-sgi #x80B2) (:color-sum #x8458) (:color-sum-arb #x8458) (:color-sum-clamp-nv #x854F) (:color-sum-ext #x8458) (:color-table #x80D0) (:color-table-alpha-size #x80DD) (:color-table-alpha-size-sgi #x80DD) (:color-table-bias #x80D7) (:color-table-bias-sgi #x80D7) (:color-table-blue-size #x80DC) (:color-table-blue-size-sgi #x80DC) (:color-table-format #x80D8) (:color-table-format-sgi #x80D8) (:color-table-green-size #x80DB) (:color-table-green-size-sgi #x80DB) (:color-table-intensity-size #x80DF) (:color-table-intensity-size-sgi #x80DF) (:color-table-luminance-size #x80DE) (:color-table-luminance-size-sgi #x80DE) (:color-table-red-size #x80DA) (:color-table-red-size-sgi #x80DA) (:color-table-scale #x80D6) (:color-table-scale-sgi #x80D6) (:color-table-sgi #x80D0) (:color-table-width #x80D9) (:color-table-width-sgi #x80D9) (:color-writemask #xC23) (:color3-bit-pgi #x10000) (:color4-bit-pgi #x20000) (:combine #x8570) (:combine-alpha #x8572) (:combine-alpha-arb #x8572) (:combine-alpha-ext #x8572) (:combine-arb #x8570) (:combine-ext #x8570) (:combine-rgb #x8571) (:combine-rgb-arb #x8571) (:combine-rgb-ext #x8571) (:combine4-nv #x8503) (:combiner-ab-dot-product-nv #x8545) (:combiner-ab-output-nv #x854A) (:combiner-bias-nv #x8549) (:combiner-cd-dot-product-nv #x8546) (:combiner-cd-output-nv #x854B) (:combiner-component-usage-nv #x8544) (:combiner-input-nv #x8542) (:combiner-mapping-nv #x8543) (:combiner-mux-sum-nv #x8547) (:combiner-scale-nv #x8548) (:combiner-sum-output-nv #x854C) (:combiner0-nv #x8550) (:combiner1-nv #x8551) (:combiner2-nv #x8552) (:combiner3-nv #x8553) (:combiner4-nv #x8554) (:combiner5-nv #x8555) (:combiner6-nv #x8556) (:combiner7-nv #x8557) (:comp-bit-ati #x2) (:compare-r-to-texture #x884E) (:compare-ref-depth-to-texture-ext #x884E) (:compile #x1300) (:compile-and-execute #x1301) (:compile-status #x8B81) (:compressed-alpha #x84E9) (:compressed-alpha-arb #x84E9) (:compressed-intensity #x84EC) (:compressed-intensity-arb #x84EC) (:compressed-luminance #x84EA) (:compressed-luminance-alpha #x84EB) (:compressed-luminance-alpha-arb #x84EB) (:compressed-luminance-alpha-latc2-ext #x8C72) (:compressed-luminance-arb #x84EA) (:compressed-luminance-latc1-ext #x8C70) (:compressed-red-green-rgtc2-ext #x8DBD) (:compressed-red-rgtc1-ext #x8DBB) (:compressed-rgb #x84ED) (:compressed-rgb-arb #x84ED) (:compressed-rgb-fxt1-3dfx #x86B0) (:compressed-rgb-s3tc-dxt1-ext #x83F0) (:compressed-rgba #x84EE) (:compressed-rgba-arb #x84EE) (:compressed-rgba-fxt1-3dfx #x86B1) (:compressed-rgba-s3tc-dxt1-ext #x83F1) (:compressed-rgba-s3tc-dxt3-ext #x83F2) (:compressed-rgba-s3tc-dxt5-ext #x83F3) (:compressed-signed-luminance-alpha-latc2-ext #x8C73) (:compressed-signed-luminance-latc1-ext #x8C71) (:compressed-signed-red-green-rgtc2-ext #x8DBE) (:compressed-signed-red-rgtc1-ext #x8DBC) (:compressed-sluminance #x8C4A) (:compressed-sluminance-alpha #x8C4B) (:compressed-sluminance-alpha-ext #x8C4B) (:compressed-sluminance-ext #x8C4A) (:compressed-srgb #x8C48) (:compressed-srgb-alpha #x8C49) (:compressed-srgb-alpha-ext #x8C49) (:compressed-srgb-alpha-s3tc-dxt1-ext #x8C4D) (:compressed-srgb-alpha-s3tc-dxt3-ext #x8C4E) (:compressed-srgb-alpha-s3tc-dxt5-ext #x8C4F) (:compressed-srgb-ext #x8C48) (:compressed-srgb-s3tc-dxt1-ext #x8C4C) (:compressed-texture-formats #x86A3) (:compressed-texture-formats-arb #x86A3) (:con-0-ati #x8941) (:con-1-ati #x8942) (:con-10-ati #x894B) (:con-11-ati #x894C) (:con-12-ati #x894D) (:con-13-ati #x894E) (:con-14-ati #x894F) (:con-15-ati #x8950) (:con-16-ati #x8951) (:con-17-ati #x8952) (:con-18-ati #x8953) (:con-19-ati #x8954) (:con-2-ati #x8943) (:con-20-ati #x8955) (:con-21-ati #x8956) (:con-22-ati #x8957) (:con-23-ati #x8958) (:con-24-ati #x8959) (:con-25-ati #x895A) (:con-26-ati #x895B) (:con-27-ati #x895C) (:con-28-ati #x895D) (:con-29-ati #x895E) (:con-3-ati #x8944) (:con-30-ati #x895F) (:con-31-ati #x8960) (:con-4-ati #x8945) (:con-5-ati #x8946) (:con-6-ati #x8947) (:con-7-ati #x8948) (:con-8-ati #x8949) (:con-9-ati #x894A) (:conserve-memory-hint-pgi #x1A1FD) (:const-eye-nv #x86E5) (:constant #x8576) (:constant-alpha #x8003) (:constant-alpha-ext #x8003) (:constant-arb #x8576) (:constant-attenuation #x1207) (:constant-border #x8151) (:constant-border-hp #x8151) (:constant-color #x8001) (:constant-color-ext #x8001) (:constant-color0-nv #x852A) (:constant-color1-nv #x852B) (:constant-ext #x8576) (:convolution-1d #x8010) (:convolution-1d-ext #x8010) (:convolution-2d #x8011) (:convolution-2d-ext #x8011) (:convolution-border-color #x8154) (:convolution-border-color-hp #x8154) (:convolution-border-mode #x8013) (:convolution-border-mode-ext #x8013) (:convolution-filter-bias #x8015) (:convolution-filter-bias-ext #x8015) (:convolution-filter-scale #x8014) (:convolution-filter-scale-ext #x8014) (:convolution-format #x8017) (:convolution-format-ext #x8017) (:convolution-height #x8019) (:convolution-height-ext #x8019) (:convolution-hint-sgix #x8316) (:convolution-width #x8018) (:convolution-width-ext #x8018) (:coord-replace #x8862) (:coord-replace-arb #x8862) (:coord-replace-nv #x8862) (:copy #x1503) (:copy-inverted #x150C) (:copy-pixel-token #x706) (:cubic-ext #x8334) (:cubic-hp #x815F) (:cull-face #xB44) (:cull-face-mode #xB45) (:cull-fragment-nv #x86E7) (:cull-modes-nv #x86E0) (:cull-vertex-ext #x81AA) (:cull-vertex-eye-position-ext #x81AB) (:cull-vertex-ibm #x1928A) (:cull-vertex-object-position-ext #x81AC) (:current #x1) (:current-attrib-nv #x8626) (:current-binormal-ext #x843C) (:current-bit #x1) (:current-color #xB00) (:current-fog-coordinate #x8453) (:current-fog-coordinate-ext #x8453) (:current-index #xB01) (:current-matrix-arb #x8641) (:current-matrix-index-arb #x8845) (:current-matrix-nv #x8641) (:current-matrix-stack-depth-arb #x8640) (:current-matrix-stack-depth-nv #x8640) (:current-normal #xB02) (:current-occlusion-query-id-nv #x8865) (:current-palette-matrix-arb #x8843) (:current-program #x8B8D) (:current-query #x8865) (:current-query-arb #x8865) (:current-raster-color #xB04) (:current-raster-distance #xB09) (:current-raster-index #xB05) (:current-raster-normal-sgix #x8406) (:current-raster-position #xB07) (:current-raster-position-valid #xB08) (:current-raster-secondary-color #x845F) (:current-raster-texture-coords #xB06) (:current-secondary-color #x8459) (:current-secondary-color-ext #x8459) (:current-tangent-ext #x843B) (:current-texture-coords #xB03) (:current-vertex-attrib #x8626) (:current-vertex-attrib-arb #x8626) (:current-vertex-ext #x87E2) (:current-vertex-weight-ext #x850B) (:current-weight-arb #x86A8) (:cw #x900) (:decal #x2101) (:decr #x1E03) (:decr-wrap #x8508) (:decr-wrap-ext #x8508) (:deformations-mask-sgix #x8196) (:delete-status #x8B80) (:dependent-ar-texture-2d-nv #x86E9) (:dependent-gb-texture-2d-nv #x86EA) (:dependent-hilo-texture-2d-nv #x8858) (:dependent-rgb-texture-3d-nv #x8859) (:dependent-rgb-texture-cube-map-nv #x885A) (:depth #x1801) (:depth-attachment-ext #x8D00) (:depth-bias #xD1F) (:depth-bits #xD56) (:depth-bounds-ext #x8891) (:depth-bounds-test-ext #x8890) (:depth-buffer #x100) (:depth-buffer-bit #x100) (:depth-buffer-float-mode-nv #x8DAF) (:depth-clamp-nv #x864F) (:depth-clear-value #xB73) (:depth-component #x1902) (:depth-component16 #x81A5) (:depth-component16-arb #x81A5) (:depth-component16-sgix #x81A5) (:depth-component24 #x81A6) (:depth-component24-arb #x81A6) (:depth-component24-sgix #x81A6) (:depth-component32 #x81A7) (:depth-component32-arb #x81A7) (:depth-component32-sgix #x81A7) (:depth-component32f-nv #x8DAB) (:depth-func #xB74) (:depth-pass-instrument-counters-sgix #x8311) (:depth-pass-instrument-max-sgix #x8312) (:depth-pass-instrument-sgix #x8310) (:depth-range #xB70) (:depth-scale #xD1E) (:depth-stencil-ext #x84F9) (:depth-stencil-nv #x84F9) (:depth-stencil-to-bgra-nv #x886F) (:depth-stencil-to-rgba-nv #x886E) (:depth-test #xB71) (:depth-texture-mode #x884B) (:depth-texture-mode-arb #x884B) (:depth-writemask #xB72) (:depth24-stencil8-ext #x88F0) (:depth32f-stencil8-nv #x8DAC) (:detail-texture-2d-binding-sgis #x8096) (:detail-texture-2d-sgis #x8095) (:detail-texture-func-points-sgis #x809C) (:detail-texture-level-sgis #x809A) (:detail-texture-mode-sgis #x809B) (:diffuse #x1201) (:discard-ati #x8763) (:discard-nv #x8530) (:distance-attenuation-ext #x8129) (:distance-attenuation-sgis #x8129) (:dither #xBD0) (:domain #xA02) (:dont-care #x1100) (:dot-product-affine-depth-replace-nv #x885D) (:dot-product-const-eye-reflect-cube-map-nv #x86F3) (:dot-product-depth-replace-nv #x86ED) (:dot-product-diffuse-cube-map-nv #x86F1) (:dot-product-nv #x86EC) (:dot-product-pass-through-nv #x885B) (:dot-product-reflect-cube-map-nv #x86F2) (:dot-product-texture-1d-nv #x885C) (:dot-product-texture-2d-nv #x86EE) (:dot-product-texture-3d-nv #x86EF) (:dot-product-texture-cube-map-nv #x86F0) (:dot-product-texture-rectangle-nv #x864E) (:dot2-add-ati #x896C) (:dot3-ati #x8966) (:dot3-rgb #x86AE) (:dot3-rgb-arb #x86AE) (:dot3-rgb-ext #x8740) (:dot3-rgba #x86AF) (:dot3-rgba-arb #x86AF) (:dot3-rgba-ext #x8741) (:dot4-ati #x8967) (:double #x140A) (:double-ext #x140A) (:doublebuffer #xC32) (:draw-buffer #xC01) (:draw-buffer0 #x8825) (:draw-buffer0-arb #x8825) (:draw-buffer0-ati #x8825) (:draw-buffer1 #x8826) (:draw-buffer1-arb #x8826) (:draw-buffer1-ati #x8826) (:draw-buffer10 #x882F) (:draw-buffer10-arb #x882F) (:draw-buffer10-ati #x882F) (:draw-buffer11 #x8830) (:draw-buffer11-arb #x8830) (:draw-buffer11-ati #x8830) (:draw-buffer12 #x8831) (:draw-buffer12-arb #x8831) (:draw-buffer12-ati #x8831) (:draw-buffer13 #x8832) (:draw-buffer13-arb #x8832) (:draw-buffer13-ati #x8832) (:draw-buffer14 #x8833) (:draw-buffer14-arb #x8833) (:draw-buffer14-ati #x8833) (:draw-buffer15 #x8834) (:draw-buffer15-arb #x8834) (:draw-buffer15-ati #x8834) (:draw-buffer2 #x8827) (:draw-buffer2-arb #x8827) (:draw-buffer2-ati #x8827) (:draw-buffer3 #x8828) (:draw-buffer3-arb #x8828) (:draw-buffer3-ati #x8828) (:draw-buffer4 #x8829) (:draw-buffer4-arb #x8829) (:draw-buffer4-ati #x8829) (:draw-buffer5 #x882A) (:draw-buffer5-arb #x882A) (:draw-buffer5-ati #x882A) (:draw-buffer6 #x882B) (:draw-buffer6-arb #x882B) (:draw-buffer6-ati #x882B) (:draw-buffer7 #x882C) (:draw-buffer7-arb #x882C) (:draw-buffer7-ati #x882C) (:draw-buffer8 #x882D) (:draw-buffer8-arb #x882D) (:draw-buffer8-ati #x882D) (:draw-buffer9 #x882E) (:draw-buffer9-arb #x882E) (:draw-buffer9-ati #x882E) (:draw-framebuffer-ext #x8CA9) (:draw-pixel-token #x705) (:draw-pixels-apple #x8A0A) (:ds-bias-nv #x8716) (:ds-scale-nv #x8710) (:dsdt-mag-intensity-nv #x86DC) (:dsdt-mag-nv #x86F6) (:dsdt-mag-vib-nv #x86F7) (:dsdt-nv #x86F5) (:dsdt8-mag8-intensity8-nv #x870B) (:dsdt8-mag8-nv #x870A) (:dsdt8-nv #x8709) (:dst-alpha #x304) (:dst-color #x306) (:dt-bias-nv #x8717) (:dt-scale-nv #x8711) (:du8dv8-ati #x877A) (:dual-alpha12-sgis #x8112) (:dual-alpha16-sgis #x8113) (:dual-alpha4-sgis #x8110) (:dual-alpha8-sgis #x8111) (:dual-intensity12-sgis #x811A) (:dual-intensity16-sgis #x811B) (:dual-intensity4-sgis #x8118) (:dual-intensity8-sgis #x8119) (:dual-luminance-alpha4-sgis #x811C) (:dual-luminance-alpha8-sgis #x811D) (:dual-luminance12-sgis #x8116) (:dual-luminance16-sgis #x8117) (:dual-luminance4-sgis #x8114) (:dual-luminance8-sgis #x8115) (:dual-texture-select-sgis #x8124) (:dudv-ati #x8779) (:dynamic-ati #x8761) (:dynamic-copy #x88EA) (:dynamic-copy-arb #x88EA) (:dynamic-draw #x88E8) (:dynamic-draw-arb #x88E8) (:dynamic-read #x88E9) (:dynamic-read-arb #x88E9) (:e-times-f-nv #x8531) (:edge-flag #xB43) (:edge-flag-array #x8079) (:edge-flag-array-buffer-binding #x889B) (:edge-flag-array-buffer-binding-arb #x889B) (:edge-flag-array-count-ext #x808D) (:edge-flag-array-ext #x8079) (:edge-flag-array-list-ibm #x192A3) (:edge-flag-array-list-stride-ibm #x192AD) (:edge-flag-array-pointer #x8093) (:edge-flag-array-pointer-ext #x8093) (:edge-flag-array-stride #x808C) (:edge-flag-array-stride-ext #x808C) (:edgeflag-bit-pgi #x40000) (:eighth-bit-ati #x20) (:element-array-apple #x8768) (:element-array-ati #x8768) (:element-array-buffer #x8893) (:element-array-buffer-arb #x8893) (:element-array-buffer-binding #x8895) (:element-array-buffer-binding-arb #x8895) (:element-array-pointer-apple #x876A) (:element-array-pointer-ati #x876A) (:element-array-type-apple #x8769) (:element-array-type-ati #x8769) (:emboss-constant-nv #x855E) (:emboss-light-nv #x855D) (:emboss-map-nv #x855F) (:emission #x1600) (:enable #x2000) (:enable-bit #x2000) (:equal #x202) (:equiv #x1509) (:eval #x10000) (:eval-2d-nv #x86C0) (:eval-bit #x10000) (:eval-fractional-tessellation-nv #x86C5) (:eval-triangular-2d-nv #x86C1) (:eval-vertex-attrib0-nv #x86C6) (:eval-vertex-attrib1-nv #x86C7) (:eval-vertex-attrib10-nv #x86D0) (:eval-vertex-attrib11-nv #x86D1) (:eval-vertex-attrib12-nv #x86D2) (:eval-vertex-attrib13-nv #x86D3) (:eval-vertex-attrib14-nv #x86D4) (:eval-vertex-attrib15-nv #x86D5) (:eval-vertex-attrib2-nv #x86C8) (:eval-vertex-attrib3-nv #x86C9) (:eval-vertex-attrib4-nv #x86CA) (:eval-vertex-attrib5-nv #x86CB) (:eval-vertex-attrib6-nv #x86CC) (:eval-vertex-attrib7-nv #x86CD) (:eval-vertex-attrib8-nv #x86CE) (:eval-vertex-attrib9-nv #x86CF) (:exp #x800) (:exp2 #x801) (:expand-negate-nv #x8539) (:expand-normal-nv #x8538) (:extensions #x1F03) (:eye-distance-to-line-sgis #x81F2) (:eye-distance-to-point-sgis #x81F0) (:eye-line-sgis #x81F6) (:eye-linear #x2400) (:eye-plane #x2502) (:eye-plane-absolute-nv #x855C) (:eye-point-sgis #x81F4) (:eye-radial-nv #x855B) (:false #x0) (:fastest #x1101) (:feedback #x1C01) (:feedback-buffer-pointer #xDF0) (:feedback-buffer-size #xDF1) (:feedback-buffer-type #xDF2) (:fence-apple #x8A0B) (:fence-condition-nv #x84F4) (:fence-status-nv #x84F3) (:fill #x1B02) (:filter4-sgis #x8146) (:fixed-only-arb #x891D) (:flat #x1D00) (:float #x1406) (:float-32-unsigned-int-24-8-rev-nv #x8DAD) (:float-clear-color-value-nv #x888D) (:float-mat2 #x8B5A) (:float-mat2-arb #x8B5A) (:float-mat2x3 #x8B65) (:float-mat2x4 #x8B66) (:float-mat3 #x8B5B) (:float-mat3-arb #x8B5B) (:float-mat3x2 #x8B67) (:float-mat3x4 #x8B68) (:float-mat4 #x8B5C) (:float-mat4-arb #x8B5C) (:float-mat4x2 #x8B69) (:float-mat4x3 #x8B6A) (:float-r-nv #x8880) (:float-r16-nv #x8884) (:float-r32-nv #x8885) (:float-rg-nv #x8881) (:float-rg16-nv #x8886) (:float-rg32-nv #x8887) (:float-rgb-nv #x8882) (:float-rgb16-nv #x8888) (:float-rgb32-nv #x8889) (:float-rgba-mode-nv #x888E) (:float-rgba-nv #x8883) (:float-rgba16-nv #x888A) (:float-rgba32-nv #x888B) (:float-vec2 #x8B50) (:float-vec2-arb #x8B50) (:float-vec3 #x8B51) (:float-vec3-arb #x8B51) (:float-vec4 #x8B52) (:float-vec4-arb #x8B52) (:fog #xB60) (:fog-bit #x80) (:fog-color #xB66) (:fog-coordinate #x8451) (:fog-coordinate-array #x8457) (:fog-coordinate-array-buffer-binding #x889D) (:fog-coordinate-array-buffer-binding-arb #x889D) (:fog-coordinate-array-ext #x8457) (:fog-coordinate-array-list-ibm #x192A4) (:fog-coordinate-array-list-stride-ibm #x192AE) (:fog-coordinate-array-pointer #x8456) (:fog-coordinate-array-pointer-ext #x8456) (:fog-coordinate-array-stride #x8455) (:fog-coordinate-array-stride-ext #x8455) (:fog-coordinate-array-type #x8454) (:fog-coordinate-array-type-ext #x8454) (:fog-coordinate-ext #x8451) (:fog-coordinate-source #x8450) (:fog-coordinate-source-ext #x8450) (:fog-density #xB62) (:fog-distance-mode-nv #x855A) (:fog-end #xB64) (:fog-factor-to-alpha-sgix #x836F) (:fog-func-points-sgis #x812B) (:fog-func-sgis #x812A) (:fog-hint #xC54) (:fog-index #xB61) (:fog-mode #xB65) (:fog-offset-sgix #x8198) (:fog-offset-value-sgix #x8199) (:fog-scale-sgix #x81FC) (:fog-scale-value-sgix #x81FD) (:fog-specular-texture-win #x80EC) (:fog-start #xB63) (:force-blue-to-one-nv #x8860) (:format-subsample-24-24-oml #x8982) (:format-subsample-244-244-oml #x8983) (:fragment-color-ext #x834C) (:fragment-color-material-face-sgix #x8402) (:fragment-color-material-parameter-sgix #x8403) (:fragment-color-material-sgix #x8401) (:fragment-depth #x8452) (:fragment-depth-ext #x8452) (:fragment-light-model-ambient-sgix #x840A) (:fragment-light-model-local-viewer-sgix #x8408) (:fragment-light-model-normal-interpolation-sgix #x840B) (:fragment-light-model-two-side-sgix #x8409) (:fragment-light0-sgix #x840C) (:fragment-light1-sgix #x840D) (:fragment-light2-sgix #x840E) (:fragment-light3-sgix #x840F) (:fragment-light4-sgix #x8410) (:fragment-light5-sgix #x8411) (:fragment-light6-sgix #x8412) (:fragment-light7-sgix #x8413) (:fragment-lighting-sgix #x8400) (:fragment-material-ext #x8349) (:fragment-normal-ext #x834A) (:fragment-program-arb #x8804) (:fragment-program-binding-nv #x8873) (:fragment-program-nv #x8870) (:fragment-program-parameter-buffer-nv #x8DA4) (:fragment-shader #x8B30) (:fragment-shader-arb #x8B30) (:fragment-shader-ati #x8920) (:fragment-shader-derivative-hint #x8B8B) (:fragment-shader-derivative-hint-arb #x8B8B) (:framebuffer-attachment-layered-ext #x8DA7) (:framebuffer-attachment-object-name-ext #x8CD1) (:framebuffer-attachment-object-type-ext #x8CD0) (:framebuffer-attachment-texture-3d-zoffset-ext #x8CD4) (:framebuffer-attachment-texture-cube-map-face-ext #x8CD3) (:framebuffer-attachment-texture-layer-ext #x8CD4) (:framebuffer-attachment-texture-level-ext #x8CD2) (:framebuffer-binding-ext #x8CA6) (:framebuffer-complete-ext #x8CD5) (:framebuffer-ext #x8D40) (:framebuffer-incomplete-attachment-ext #x8CD6) (:framebuffer-incomplete-dimensions-ext #x8CD9) (:framebuffer-incomplete-draw-buffer-ext #x8CDB) (:framebuffer-incomplete-formats-ext #x8CDA) (:framebuffer-incomplete-layer-count-ext #x8DA9) (:framebuffer-incomplete-layer-targets-ext #x8DA8) (:framebuffer-incomplete-missing-attachment-ext #x8CD7) (:framebuffer-incomplete-multisample-ext #x8D56) (:framebuffer-incomplete-read-buffer-ext #x8CDC) (:framebuffer-srgb-capable-ext #x8DBA) (:framebuffer-srgb-ext #x8DB9) (:framebuffer-unsupported-ext #x8CDD) (:framezoom-factor-sgix #x818C) (:framezoom-sgix #x818B) (:front #x404) (:front-and-back #x408) (:front-face #xB46) (:front-left #x400) (:front-right #x401) (:full-range-ext #x87E1) (:full-stipple-hint-pgi #x1A219) (:func-add #x8006) (:func-add-ext #x8006) (:func-reverse-subtract #x800B) (:func-reverse-subtract-ext #x800B) (:func-subtract #x800A) (:func-subtract-ext #x800A) (:generate-mipmap #x8191) (:generate-mipmap-hint #x8192) (:generate-mipmap-hint-sgis #x8192) (:generate-mipmap-sgis #x8191) (:generic-attrib-nv #x8C7D) (:geometry-deformation-bit-sgix #x2) (:geometry-deformation-sgix #x8194) (:geometry-input-type-ext #x8DDB) (:geometry-output-type-ext #x8DDC) (:geometry-program-nv #x8C26) (:geometry-program-parameter-buffer-nv #x8DA3) (:geometry-shader-ext #x8DD9) (:geometry-vertices-out-ext #x8DDA) (:gequal #x206) (:global-alpha-factor-sun #x81DA) (:global-alpha-sun #x81D9) (:greater #x204) (:green #x1904) (:green-bias #xD19) (:green-bit-ati #x2) (:green-bits #xD53) (:green-integer-ext #x8D95) (:green-max-clamp-ingr #x8565) (:green-min-clamp-ingr #x8561) (:green-scale #xD18) (:half-bias-negate-nv #x853B) (:half-bias-normal-nv #x853A) (:half-bit-ati #x8) (:half-float-arb #x140B) (:half-float-nv #x140B) (:hi-bias-nv #x8714) (:hi-scale-nv #x870E) (:hilo-nv #x86F4) (:hilo16-nv #x86F8) (:hilo8-nv #x885E) (:hint #x8000) (:hint-bit #x8000) (:histogram #x8024) (:histogram-alpha-size #x802B) (:histogram-alpha-size-ext #x802B) (:histogram-blue-size #x802A) (:histogram-blue-size-ext #x802A) (:histogram-ext #x8024) (:histogram-format #x8027) (:histogram-format-ext #x8027) (:histogram-green-size #x8029) (:histogram-green-size-ext #x8029) (:histogram-luminance-size #x802C) (:histogram-luminance-size-ext #x802C) (:histogram-red-size #x8028) (:histogram-red-size-ext #x8028) (:histogram-sink #x802D) (:histogram-sink-ext #x802D) (:histogram-width #x8026) (:histogram-width-ext #x8026) (:identity-nv #x862A) (:ignore-border-hp #x8150) (:image-cubic-weight-hp #x815E) (:image-mag-filter-hp #x815C) (:image-min-filter-hp #x815D) (:image-rotate-angle-hp #x8159) (:image-rotate-origin-x-hp #x815A) (:image-rotate-origin-y-hp #x815B) (:image-scale-x-hp #x8155) (:image-scale-y-hp #x8156) (:image-transform-2d-hp #x8161) (:image-translate-x-hp #x8157) (:image-translate-y-hp #x8158) (:implementation-color-read-format-oes #x8B9B) (:implementation-color-read-type-oes #x8B9A) (:incr #x1E02) (:incr-wrap #x8507) (:incr-wrap-ext #x8507) (:index #xD51) (:index-array #x8077) (:index-array-buffer-binding #x8899) (:index-array-buffer-binding-arb #x8899) (:index-array-count-ext #x8087) (:index-array-ext #x8077) (:index-array-list-ibm #x192A1) (:index-array-list-stride-ibm #x192AB) (:index-array-pointer #x8091) (:index-array-pointer-ext #x8091) (:index-array-stride #x8086) (:index-array-stride-ext #x8086) (:index-array-type #x8085) (:index-array-type-ext #x8085) (:index-bit-pgi #x80000) (:index-bits #xD51) (:index-clear-value #xC20) (:index-logic-op #xBF1) (:index-material-ext #x81B8) (:index-material-face-ext #x81BA) (:index-material-parameter-ext #x81B9) (:index-mode #xC30) (:index-offset #xD13) (:index-shift #xD12) (:index-test-ext #x81B5) (:index-test-func-ext #x81B6) (:index-test-ref-ext #x81B7) (:index-writemask #xC21) (:info-log-length #x8B84) (:instrument-buffer-pointer-sgix #x8180) (:instrument-measurements-sgix #x8181) (:int #x1404) (:int-sampler-1d-array-ext #x8DCE) (:int-sampler-1d-ext #x8DC9) (:int-sampler-2d-array-ext #x8DCF) (:int-sampler-2d-ext #x8DCA) (:int-sampler-2d-rect-ext #x8DCD) (:int-sampler-3d-ext #x8DCB) (:int-sampler-buffer-ext #x8DD0) (:int-sampler-cube-ext #x8DCC) (:int-vec2 #x8B53) (:int-vec2-arb #x8B53) (:int-vec3 #x8B54) (:int-vec3-arb #x8B54) (:int-vec4 #x8B55) (:int-vec4-arb #x8B55) (:intensity #x8049) (:intensity-ext #x8049) (:intensity-float16-ati #x881D) (:intensity-float32-ati #x8817) (:intensity12 #x804C) (:intensity12-ext #x804C) (:intensity16 #x804D) (:intensity16-ext #x804D) (:intensity16f-arb #x881D) (:intensity16i-ext #x8D8B) (:intensity16ui-ext #x8D79) (:intensity32f-arb #x8817) (:intensity32i-ext #x8D85) (:intensity32ui-ext #x8D73) (:intensity4 #x804A) (:intensity4-ext #x804A) (:intensity8 #x804B) (:intensity8-ext #x804B) (:intensity8i-ext #x8D91) (:intensity8ui-ext #x8D7F) (:interlace-oml #x8980) (:interlace-read-ingr #x8568) (:interlace-read-oml #x8981) (:interlace-sgix #x8094) (:interleaved-attribs-nv #x8C8C) (:interpolate #x8575) (:interpolate-arb #x8575) (:interpolate-ext #x8575) (:invalid-enum #x500) (:invalid-framebuffer-operation-ext #x506) (:invalid-operation #x502) (:invalid-value #x501) (:invariant-datatype-ext #x87EB) (:invariant-ext #x87C2) (:invariant-value-ext #x87EA) (:inverse-nv #x862B) (:inverse-transpose-nv #x862D) (:invert #x150A) (:inverted-screen-w-rend #x8491) (:ir-instrument1-sgix #x817F) (:iui-n3f-v2f-ext #x81AF) (:iui-n3f-v3f-ext #x81B0) (:iui-v2f-ext #x81AD) (:iui-v3f-ext #x81AE) (:keep #x1E00) (:left #x406) (:lequal #x203) (:lerp-ati #x8969) (:less #x201) (:light-env-mode-sgix #x8407) (:light-model-ambient #xB53) (:light-model-color-control #x81F8) (:light-model-color-control-ext #x81F8) (:light-model-local-viewer #xB51) (:light-model-specular-vector-apple #x85B0) (:light-model-two-side #xB52) (:light0 #x4000) (:light1 #x4001) (:light2 #x4002) (:light3 #x4003) (:light4 #x4004) (:light5 #x4005) (:light6 #x4006) (:light7 #x4007) (:lighting #xB50) (:lighting-bit #x40) (:line #x1B01) (:line-bit #x4) (:line-loop #x2) (:line-reset-token #x707) (:line-smooth #xB20) (:line-smooth-hint #xC52) (:line-stipple #xB24) (:line-stipple-pattern #xB25) (:line-stipple-repeat #xB26) (:line-strip #x3) (:line-strip-adjacency-ext #xB) (:line-token #x702) (:line-width #xB21) (:line-width-granularity #xB23) (:line-width-range #xB22) (:linear #x2601) (:linear-attenuation #x1208) (:linear-clipmap-linear-sgix #x8170) (:linear-clipmap-nearest-sgix #x844F) (:linear-detail-alpha-sgis #x8098) (:linear-detail-color-sgis #x8099) (:linear-detail-sgis #x8097) (:linear-mipmap-linear #x2703) (:linear-mipmap-nearest #x2701) (:linear-sharpen-alpha-sgis #x80AE) (:linear-sharpen-color-sgis #x80AF) (:linear-sharpen-sgis #x80AD) (:lines #x1) (:lines-adjacency-ext #xA) (:link-status #x8B82) (:list #x20000) (:list-base #xB32) (:list-bit #x20000) (:list-index #xB33) (:list-mode #xB30) (:list-priority-sgix #x8182) (:lo-bias-nv #x8715) (:lo-scale-nv #x870F) (:load #x101) (:local-constant-datatype-ext #x87ED) (:local-constant-ext #x87C3) (:local-constant-value-ext #x87EC) (:local-ext #x87C4) (:logic-op #xBF1) (:logic-op-mode #xBF0) (:lower-left #x8CA1) (:luminance #x1909) (:luminance-alpha #x190A) (:luminance-alpha-float16-ati #x881F) (:luminance-alpha-float32-ati #x8819) (:luminance-alpha-integer-ext #x8D9D) (:luminance-alpha16f-arb #x881F) (:luminance-alpha16i-ext #x8D8D) (:luminance-alpha16ui-ext #x8D7B) (:luminance-alpha32f-arb #x8819) (:luminance-alpha32i-ext #x8D87) (:luminance-alpha32ui-ext #x8D75) (:luminance-alpha8i-ext #x8D93) (:luminance-alpha8ui-ext #x8D81) (:luminance-float16-ati #x881E) (:luminance-float32-ati #x8818) (:luminance-integer-ext #x8D9C) (:luminance12 #x8041) (:luminance12-alpha12 #x8047) (:luminance12-alpha12-ext #x8047) (:luminance12-alpha4 #x8046) (:luminance12-alpha4-ext #x8046) (:luminance12-ext #x8041) (:luminance16 #x8042) (:luminance16-alpha16 #x8048) (:luminance16-alpha16-ext #x8048) (:luminance16-ext #x8042) (:luminance16f-arb #x881E) (:luminance16i-ext #x8D8C) (:luminance16ui-ext #x8D7A) (:luminance32f-arb #x8818) (:luminance32i-ext #x8D86) (:luminance32ui-ext #x8D74) (:luminance4 #x803F) (:luminance4-alpha4 #x8043) (:luminance4-alpha4-ext #x8043) (:luminance4-ext #x803F) (:luminance6-alpha2 #x8044) (:luminance6-alpha2-ext #x8044) (:luminance8 #x8040) (:luminance8-alpha8 #x8045) (:luminance8-alpha8-ext #x8045) (:luminance8-ext #x8040) (:luminance8i-ext #x8D92) (:luminance8ui-ext #x8D80) (:mad-ati #x8968) (:magnitude-bias-nv #x8718) (:magnitude-scale-nv #x8712) (:map-attrib-u-order-nv #x86C3) (:map-attrib-v-order-nv #x86C4) (:map-color #xD10) (:map-stencil #xD11) (:map-tessellation-nv #x86C2) (:map1-binormal-ext #x8446) (:map1-color-4 #xD90) (:map1-grid-domain #xDD0) (:map1-grid-segments #xDD1) (:map1-index #xD91) (:map1-normal #xD92) (:map1-tangent-ext #x8444) (:map1-texture-coord-1 #xD93) (:map1-texture-coord-2 #xD94) (:map1-texture-coord-3 #xD95) (:map1-texture-coord-4 #xD96) (:map1-vertex-3 #xD97) (:map1-vertex-4 #xD98) (:map1-vertex-attrib0-4-nv #x8660) (:map1-vertex-attrib1-4-nv #x8661) (:map1-vertex-attrib10-4-nv #x866A) (:map1-vertex-attrib11-4-nv #x866B) (:map1-vertex-attrib12-4-nv #x866C) (:map1-vertex-attrib13-4-nv #x866D) (:map1-vertex-attrib14-4-nv #x866E) (:map1-vertex-attrib15-4-nv #x866F) (:map1-vertex-attrib2-4-nv #x8662) (:map1-vertex-attrib3-4-nv #x8663) (:map1-vertex-attrib4-4-nv #x8664) (:map1-vertex-attrib5-4-nv #x8665) (:map1-vertex-attrib6-4-nv #x8666) (:map1-vertex-attrib7-4-nv #x8667) (:map1-vertex-attrib8-4-nv #x8668) (:map1-vertex-attrib9-4-nv #x8669) (:map2-binormal-ext #x8447) (:map2-color-4 #xDB0) (:map2-grid-domain #xDD2) (:map2-grid-segments #xDD3) (:map2-index #xDB1) (:map2-normal #xDB2) (:map2-tangent-ext #x8445) (:map2-texture-coord-1 #xDB3) (:map2-texture-coord-2 #xDB4) (:map2-texture-coord-3 #xDB5) (:map2-texture-coord-4 #xDB6) (:map2-vertex-3 #xDB7) (:map2-vertex-4 #xDB8) (:map2-vertex-attrib0-4-nv #x8670) (:map2-vertex-attrib1-4-nv #x8671) (:map2-vertex-attrib10-4-nv #x867A) (:map2-vertex-attrib11-4-nv #x867B) (:map2-vertex-attrib12-4-nv #x867C) (:map2-vertex-attrib13-4-nv #x867D) (:map2-vertex-attrib14-4-nv #x867E) (:map2-vertex-attrib15-4-nv #x867F) (:map2-vertex-attrib2-4-nv #x8672) (:map2-vertex-attrib3-4-nv #x8673) (:map2-vertex-attrib4-4-nv #x8674) (:map2-vertex-attrib5-4-nv #x8675) (:map2-vertex-attrib6-4-nv #x8676) (:map2-vertex-attrib7-4-nv #x8677) (:map2-vertex-attrib8-4-nv #x8678) (:map2-vertex-attrib9-4-nv #x8679) (:mat-ambient-and-diffuse-bit-pgi #x200000) (:mat-ambient-bit-pgi #x100000) (:mat-color-indexes-bit-pgi #x1000000) (:mat-diffuse-bit-pgi #x400000) (:mat-emission-bit-pgi #x800000) (:mat-shininess-bit-pgi #x2000000) (:mat-specular-bit-pgi #x4000000) (:material-side-hint-pgi #x1A22C) (:matrix-ext #x87C0) (:matrix-index-array-arb #x8844) (:matrix-index-array-pointer-arb #x8849) (:matrix-index-array-size-arb #x8846) (:matrix-index-array-stride-arb #x8848) (:matrix-index-array-type-arb #x8847) (:matrix-mode #xBA0) (:matrix-palette-arb #x8840) (:matrix0-arb #x88C0) (:matrix0-nv #x8630) (:matrix1-arb #x88C1) (:matrix1-nv #x8631) (:matrix10-arb #x88CA) (:matrix11-arb #x88CB) (:matrix12-arb #x88CC) (:matrix13-arb #x88CD) (:matrix14-arb #x88CE) (:matrix15-arb #x88CF) (:matrix16-arb #x88D0) (:matrix17-arb #x88D1) (:matrix18-arb #x88D2) (:matrix19-arb #x88D3) (:matrix2-arb #x88C2) (:matrix2-nv #x8632) (:matrix20-arb #x88D4) (:matrix21-arb #x88D5) (:matrix22-arb #x88D6) (:matrix23-arb #x88D7) (:matrix24-arb #x88D8) (:matrix25-arb #x88D9) (:matrix26-arb #x88DA) (:matrix27-arb #x88DB) (:matrix28-arb #x88DC) (:matrix29-arb #x88DD) (:matrix3-arb #x88C3) (:matrix3-nv #x8633) (:matrix30-arb #x88DE) (:matrix31-arb #x88DF) (:matrix4-arb #x88C4) (:matrix4-nv #x8634) (:matrix5-arb #x88C5) (:matrix5-nv #x8635) (:matrix6-arb #x88C6) (:matrix6-nv #x8636) (:matrix7-arb #x88C7) (:matrix7-nv #x8637) (:matrix8-arb #x88C8) (:matrix9-arb #x88C9) (:max #x8008) (:max-3d-texture-size #x8073) (:max-3d-texture-size-ext #x8073) (:max-4d-texture-size-sgis #x8138) (:max-active-lights-sgix #x8405) (:max-array-texture-layers-ext #x88FF) (:max-async-draw-pixels-sgix #x8360) (:max-async-histogram-sgix #x832D) (:max-async-read-pixels-sgix #x8361) (:max-async-tex-image-sgix #x835F) (:max-attrib-stack-depth #xD35) (:max-bindable-uniform-size-ext #x8DED) (:max-client-attrib-stack-depth #xD3B) (:max-clip-planes #xD32) (:max-clipmap-depth-sgix #x8177) (:max-clipmap-virtual-depth-sgix #x8178) (:max-color-attachments-ext #x8CDF) (:max-color-matrix-stack-depth #x80B3) (:max-color-matrix-stack-depth-sgi #x80B3) (:max-combined-texture-image-units #x8B4D) (:max-combined-texture-image-units-arb #x8B4D) (:max-convolution-height #x801B) (:max-convolution-height-ext #x801B) (:max-convolution-width #x801A) (:max-convolution-width-ext #x801A) (:max-cube-map-texture-size #x851C) (:max-cube-map-texture-size-arb #x851C) (:max-cube-map-texture-size-ext #x851C) (:max-deformation-order-sgix #x8197) (:max-draw-buffers #x8824) (:max-draw-buffers-arb #x8824) (:max-draw-buffers-ati #x8824) (:max-elements-indices #x80E9) (:max-elements-indices-ext #x80E9) (:max-elements-vertices #x80E8) (:max-elements-vertices-ext #x80E8) (:max-eval-order #xD30) (:max-ext #x8008) (:max-fog-func-points-sgis #x812C) (:max-fragment-bindable-uniforms-ext #x8DE3) (:max-fragment-lights-sgix #x8404) (:max-fragment-program-local-parameters-nv #x8868) (:max-fragment-uniform-components #x8B49) (:max-fragment-uniform-components-arb #x8B49) (:max-framezoom-factor-sgix #x818D) (:max-general-combiners-nv #x854D) (:max-geometry-bindable-uniforms-ext #x8DE4) (:max-geometry-output-vertices-ext #x8DE0) (:max-geometry-texture-image-units-ext #x8C29) (:max-geometry-total-output-components-ext #x8DE1) (:max-geometry-uniform-components-ext #x8DDF) (:max-geometry-varying-components-ext #x8DDD) (:max-lights #xD31) (:max-list-nesting #xB31) (:max-map-tessellation-nv #x86D6) (:max-matrix-palette-stack-depth-arb #x8841) (:max-modelview-stack-depth #xD36) (:max-multisample-coverage-modes-nv #x8E11) (:max-name-stack-depth #xD37) (:max-optimized-vertex-shader-instructions-ext #x87CA) (:max-optimized-vertex-shader-invariants-ext #x87CD) (:max-optimized-vertex-shader-local-constants-ext #x87CC) (:max-optimized-vertex-shader-locals-ext #x87CE) (:max-optimized-vertex-shader-variants-ext #x87CB) (:max-palette-matrices-arb #x8842) (:max-pixel-map-table #xD34) (:max-pixel-transform-2d-stack-depth-ext #x8337) (:max-pn-triangles-tesselation-level-ati #x87F1) (:max-program-address-registers-arb #x88B1) (:max-program-alu-instructions-arb #x880B) (:max-program-attrib-components-nv #x8908) (:max-program-attribs-arb #x88AD) (:max-program-call-depth-nv #x88F5) (:max-program-env-parameters-arb #x88B5) (:max-program-exec-instructions-nv #x88F4) (:max-program-generic-attribs-nv #x8DA5) (:max-program-generic-results-nv #x8DA6) (:max-program-if-depth-nv #x88F6) (:max-program-instructions-arb #x88A1) (:max-program-local-parameters-arb #x88B4) (:max-program-loop-count-nv #x88F8) (:max-program-loop-depth-nv #x88F7) (:max-program-matrices-arb #x862F) (:max-program-matrix-stack-depth-arb #x862E) (:max-program-native-address-registers-arb #x88B3) (:max-program-native-alu-instructions-arb #x880E) (:max-program-native-attribs-arb #x88AF) (:max-program-native-instructions-arb #x88A3) (:max-program-native-parameters-arb #x88AB) (:max-program-native-temporaries-arb #x88A7) (:max-program-native-tex-indirections-arb #x8810) (:max-program-native-tex-instructions-arb #x880F) (:max-program-output-vertices-nv #x8C27) (:max-program-parameter-buffer-bindings-nv #x8DA0) (:max-program-parameter-buffer-size-nv #x8DA1) (:max-program-parameters-arb #x88A9) (:max-program-result-components-nv #x8909) (:max-program-temporaries-arb #x88A5) (:max-program-tex-indirections-arb #x880D) (:max-program-tex-instructions-arb #x880C) (:max-program-texel-offset-nv #x8905) (:max-program-total-output-components-nv #x8C28) (:max-projection-stack-depth #xD38) (:max-rational-eval-order-nv #x86D7) (:max-rectangle-texture-size-arb #x84F8) (:max-rectangle-texture-size-nv #x84F8) (:max-renderbuffer-size-ext #x84E8) (:max-samples-ext #x8D57) (:max-shininess-nv #x8504) (:max-spot-exponent-nv #x8505) (:max-texture-buffer-size-ext #x8C2B) (:max-texture-coords #x8871) (:max-texture-coords-arb #x8871) (:max-texture-coords-nv #x8871) (:max-texture-image-units #x8872) (:max-texture-image-units-arb #x8872) (:max-texture-image-units-nv #x8872) (:max-texture-lod-bias #x84FD) (:max-texture-lod-bias-ext #x84FD) (:max-texture-max-anisotropy-ext #x84FF) (:max-texture-size #xD33) (:max-texture-stack-depth #xD39) (:max-texture-units #x84E2) (:max-texture-units-arb #x84E2) (:max-track-matrices-nv #x862F) (:max-track-matrix-stack-depth-nv #x862E) (:max-transform-feedback-interleaved-attribs-nv #x8C8A) (:max-transform-feedback-separate-attribs-nv #x8C8B) (:max-transform-feedback-separate-components-nv #x8C80) (:max-varying-components-ext #x8B4B) (:max-varying-floats #x8B4B) (:max-varying-floats-arb #x8B4B) (:max-vertex-array-range-element-nv #x8520) (:max-vertex-attribs #x8869) (:max-vertex-attribs-arb #x8869) (:max-vertex-bindable-uniforms-ext #x8DE2) (:max-vertex-hint-pgi #x1A22D) (:max-vertex-shader-instructions-ext #x87C5) (:max-vertex-shader-invariants-ext #x87C7) (:max-vertex-shader-local-constants-ext #x87C8) (:max-vertex-shader-locals-ext #x87C9) (:max-vertex-shader-variants-ext #x87C6) (:max-vertex-streams-ati #x876B) (:max-vertex-texture-image-units #x8B4C) (:max-vertex-texture-image-units-arb #x8B4C) (:max-vertex-uniform-components #x8B4A) (:max-vertex-uniform-components-arb #x8B4A) (:max-vertex-units-arb #x86A4) (:max-vertex-varying-components-ext #x8DDE) (:max-viewport-dims #xD3A) (:min #x8007) (:min-ext #x8007) (:min-program-texel-offset-nv #x8904) (:minmax #x802E) (:minmax-ext #x802E) (:minmax-format #x802F) (:minmax-format-ext #x802F) (:minmax-sink #x8030) (:minmax-sink-ext #x8030) (:mirror-clamp-ati #x8742) (:mirror-clamp-ext #x8742) (:mirror-clamp-to-border-ext #x8912) (:mirror-clamp-to-edge-ati #x8743) (:mirror-clamp-to-edge-ext #x8743) (:mirrored-repeat #x8370) (:mirrored-repeat-arb #x8370) (:mirrored-repeat-ibm #x8370) (:modelview #x1700) (:modelview-matrix #xBA6) (:modelview-projection-nv #x8629) (:modelview-stack-depth #xBA3) (:modelview0-arb #x1700) (:modelview1-arb #x850A) (:modelview1-ext #x850A) (:modelview1-matrix-ext #x8506) (:modelview1-stack-depth-ext #x8502) (:modelview10-arb #x872A) (:modelview11-arb #x872B) (:modelview12-arb #x872C) (:modelview13-arb #x872D) (:modelview14-arb #x872E) (:modelview15-arb #x872F) (:modelview16-arb #x8730) (:modelview17-arb #x8731) (:modelview18-arb #x8732) (:modelview19-arb #x8733) (:modelview2-arb #x8722) (:modelview20-arb #x8734) (:modelview21-arb #x8735) (:modelview22-arb #x8736) (:modelview23-arb #x8737) (:modelview24-arb #x8738) (:modelview25-arb #x8739) (:modelview26-arb #x873A) (:modelview27-arb #x873B) (:modelview28-arb #x873C) (:modelview29-arb #x873D) (:modelview3-arb #x8723) (:modelview30-arb #x873E) (:modelview31-arb #x873F) (:modelview4-arb #x8724) (:modelview5-arb #x8725) (:modelview6-arb #x8726) (:modelview7-arb #x8727) (:modelview8-arb #x8728) (:modelview9-arb #x8729) (:modulate #x2100) (:modulate-add-ati #x8744) (:modulate-signed-add-ati #x8745) (:modulate-subtract-ati #x8746) (:mov-ati #x8961) (:mul-ati #x8964) (:mult #x103) (:multisample #x20000000) (:multisample-3dfx #x86B2) (:multisample-arb #x809D) (:multisample-bit #x20000000) (:multisample-bit-3dfx #x20000000) (:multisample-bit-arb #x20000000) (:multisample-bit-ext #x20000000) (:multisample-coverage-modes-nv #x8E12) (:multisample-ext #x809D) (:multisample-filter-hint-nv #x8534) (:multisample-sgis #x809D) (:mvp-matrix-ext #x87E3) (:n3f-v3f #x2A25) (:name-stack-depth #xD70) (:nand #x150E) (:native-graphics-begin-hint-pgi #x1A203) (:native-graphics-end-hint-pgi #x1A204) (:native-graphics-handle-pgi #x1A202) (:nearest #x2600) (:nearest-clipmap-linear-sgix #x844E) (:nearest-clipmap-nearest-sgix #x844D) (:nearest-mipmap-linear #x2702) (:nearest-mipmap-nearest #x2700) (:negate-bit-ati #x4) (:negative-one-ext #x87DF) (:negative-w-ext #x87DC) (:negative-x-ext #x87D9) (:negative-y-ext #x87DA) (:negative-z-ext #x87DB) (:never #x200) (:nicest #x1102) (:no-error #x0) (:none #x0) (:noop #x1505) (:nor #x1508) (:normal-array #x8075) (:normal-array-buffer-binding #x8897) (:normal-array-buffer-binding-arb #x8897) (:normal-array-count-ext #x8080) (:normal-array-ext #x8075) (:normal-array-list-ibm #x1929F) (:normal-array-list-stride-ibm #x192A9) (:normal-array-parallel-pointers-intel #x83F6) (:normal-array-pointer #x808F) (:normal-array-pointer-ext #x808F) (:normal-array-stride #x807F) (:normal-array-stride-ext #x807F) (:normal-array-type #x807E) (:normal-array-type-ext #x807E) (:normal-bit-pgi #x8000000) (:normal-map #x8511) (:normal-map-arb #x8511) (:normal-map-ext #x8511) (:normal-map-nv #x8511) (:normalize #xBA1) (:normalized-range-ext #x87E0) (:notequal #x205) (:num-compressed-texture-formats #x86A2) (:num-compressed-texture-formats-arb #x86A2) (:num-fragment-constants-ati #x896F) (:num-fragment-registers-ati #x896E) (:num-general-combiners-nv #x854E) (:num-input-interpolator-components-ati #x8973) (:num-instructions-per-pass-ati #x8971) (:num-instructions-total-ati #x8972) (:num-loopback-components-ati #x8974) (:num-passes-ati #x8970) (:object-active-attribute-max-length-arb #x8B8A) (:object-active-attributes-arb #x8B89) (:object-active-uniform-max-length-arb #x8B87) (:object-active-uniforms-arb #x8B86) (:object-attached-objects-arb #x8B85) (:object-buffer-size-ati #x8764) (:object-buffer-usage-ati #x8765) (:object-compile-status-arb #x8B81) (:object-delete-status-arb #x8B80) (:object-distance-to-line-sgis #x81F3) (:object-distance-to-point-sgis #x81F1) (:object-info-log-length-arb #x8B84) (:object-line-sgis #x81F7) (:object-linear #x2401) (:object-link-status-arb #x8B82) (:object-plane #x2501) (:object-point-sgis #x81F5) (:object-shader-source-length-arb #x8B88) (:object-subtype-arb #x8B4F) (:object-type-arb #x8B4E) (:object-validate-status-arb #x8B83) (:occlusion-test-hp #x8165) (:occlusion-test-result-hp #x8166) (:offset-hilo-projective-texture-2d-nv #x8856) (:offset-hilo-projective-texture-rectangle-nv #x8857) (:offset-hilo-texture-2d-nv #x8854) (:offset-hilo-texture-rectangle-nv #x8855) (:offset-projective-texture-2d-nv #x8850) (:offset-projective-texture-2d-scale-nv #x8851) (:offset-projective-texture-rectangle-nv #x8852) (:offset-projective-texture-rectangle-scale-nv #x8853) (:offset-texture-2d-nv #x86E8) (:offset-texture-bias-nv #x86E3) (:offset-texture-matrix-nv #x86E1) (:offset-texture-rectangle-nv #x864C) (:offset-texture-rectangle-scale-nv #x864D) (:offset-texture-scale-nv #x86E2) (:one #x1) (:one-ext #x87DE) (:one-minus-constant-alpha #x8004) (:one-minus-constant-alpha-ext #x8004) (:one-minus-constant-color #x8002) (:one-minus-constant-color-ext #x8002) (:one-minus-dst-alpha #x305) (:one-minus-dst-color #x307) (:one-minus-src-alpha #x303) (:one-minus-src-color #x301) (:op-add-ext #x8787) (:op-clamp-ext #x878E) (:op-cross-product-ext #x8797) (:op-dot3-ext #x8784) (:op-dot4-ext #x8785) (:op-exp-base-2-ext #x8791) (:op-floor-ext #x878F) (:op-frac-ext #x8789) (:op-index-ext #x8782) (:op-log-base-2-ext #x8792) (:op-madd-ext #x8788) (:op-max-ext #x878A) (:op-min-ext #x878B) (:op-mov-ext #x8799) (:op-mul-ext #x8786) (:op-multiply-matrix-ext #x8798) (:op-negate-ext #x8783) (:op-power-ext #x8793) (:op-recip-ext #x8794) (:op-recip-sqrt-ext #x8795) (:op-round-ext #x8790) (:op-set-ge-ext #x878C) (:op-set-lt-ext #x878D) (:op-sub-ext #x8796) (:operand0-alpha #x8598) (:operand0-alpha-arb #x8598) (:operand0-alpha-ext #x8598) (:operand0-rgb #x8590) (:operand0-rgb-arb #x8590) (:operand0-rgb-ext #x8590) (:operand1-alpha #x8599) (:operand1-alpha-arb #x8599) (:operand1-alpha-ext #x8599) (:operand1-rgb #x8591) (:operand1-rgb-arb #x8591) (:operand1-rgb-ext #x8591) (:operand2-alpha #x859A) (:operand2-alpha-arb #x859A) (:operand2-alpha-ext #x859A) (:operand2-rgb #x8592) (:operand2-rgb-arb #x8592) (:operand2-rgb-ext #x8592) (:operand3-alpha-nv #x859B) (:operand3-rgb-nv #x8593) (:or #x1507) (:or-inverted #x150D) (:or-reverse #x150B) (:order #xA01) (:out-of-memory #x505) (:output-color0-ext #x879B) (:output-color1-ext #x879C) (:output-fog-ext #x87BD) (:output-texture-coord0-ext #x879D) (:output-texture-coord1-ext #x879E) (:output-texture-coord10-ext #x87A7) (:output-texture-coord11-ext #x87A8) (:output-texture-coord12-ext #x87A9) (:output-texture-coord13-ext #x87AA) (:output-texture-coord14-ext #x87AB) (:output-texture-coord15-ext #x87AC) (:output-texture-coord16-ext #x87AD) (:output-texture-coord17-ext #x87AE) (:output-texture-coord18-ext #x87AF) (:output-texture-coord19-ext #x87B0) (:output-texture-coord2-ext #x879F) (:output-texture-coord20-ext #x87B1) (:output-texture-coord21-ext #x87B2) (:output-texture-coord22-ext #x87B3) (:output-texture-coord23-ext #x87B4) (:output-texture-coord24-ext #x87B5) (:output-texture-coord25-ext #x87B6) (:output-texture-coord26-ext #x87B7) (:output-texture-coord27-ext #x87B8) (:output-texture-coord28-ext #x87B9) (:output-texture-coord29-ext #x87BA) (:output-texture-coord3-ext #x87A0) (:output-texture-coord30-ext #x87BB) (:output-texture-coord31-ext #x87BC) (:output-texture-coord4-ext #x87A1) (:output-texture-coord5-ext #x87A2) (:output-texture-coord6-ext #x87A3) (:output-texture-coord7-ext #x87A4) (:output-texture-coord8-ext #x87A5) (:output-texture-coord9-ext #x87A6) (:output-vertex-ext #x879A) (:pack-alignment #xD05) (:pack-cmyk-hint-ext #x800E) (:pack-image-depth-sgis #x8131) (:pack-image-height #x806C) (:pack-image-height-ext #x806C) (:pack-invert-mesa #x8758) (:pack-lsb-first #xD01) (:pack-resample-oml #x8984) (:pack-resample-sgix #x842C) (:pack-row-length #xD02) (:pack-skip-images #x806B) (:pack-skip-images-ext #x806B) (:pack-skip-pixels #xD04) (:pack-skip-rows #xD03) (:pack-skip-volumes-sgis #x8130) (:pack-subsample-rate-sgix #x85A0) (:pack-swap-bytes #xD00) (:parallel-arrays-intel #x83F4) (:pass-through-nv #x86E6) (:pass-through-token #x700) (:per-stage-constants-nv #x8535) (:perspective-correction-hint #xC50) (:perturb-ext #x85AE) (:phong-hint-win #x80EB) (:phong-win #x80EA) (:pixel-count-available-nv #x8867) (:pixel-count-nv #x8866) (:pixel-counter-bits-nv #x8864) (:pixel-cubic-weight-ext #x8333) (:pixel-fragment-alpha-source-sgis #x8355) (:pixel-fragment-rgb-source-sgis #x8354) (:pixel-group-color-sgis #x8356) (:pixel-mag-filter-ext #x8331) (:pixel-map-a-to-a #xC79) (:pixel-map-a-to-a-size #xCB9) (:pixel-map-b-to-b #xC78) (:pixel-map-b-to-b-size #xCB8) (:pixel-map-g-to-g #xC77) (:pixel-map-g-to-g-size #xCB7) (:pixel-map-i-to-a #xC75) (:pixel-map-i-to-a-size #xCB5) (:pixel-map-i-to-b #xC74) (:pixel-map-i-to-b-size #xCB4) (:pixel-map-i-to-g #xC73) (:pixel-map-i-to-g-size #xCB3) (:pixel-map-i-to-i #xC70) (:pixel-map-i-to-i-size #xCB0) (:pixel-map-i-to-r #xC72) (:pixel-map-i-to-r-size #xCB2) (:pixel-map-r-to-r #xC76) (:pixel-map-r-to-r-size #xCB6) (:pixel-map-s-to-s #xC71) (:pixel-map-s-to-s-size #xCB1) (:pixel-min-filter-ext #x8332) (:pixel-mode #x20) (:pixel-mode-bit #x20) (:pixel-pack-buffer #x88EB) (:pixel-pack-buffer-arb #x88EB) (:pixel-pack-buffer-binding #x88ED) (:pixel-pack-buffer-binding-arb #x88ED) (:pixel-pack-buffer-binding-ext #x88ED) (:pixel-pack-buffer-ext #x88EB) (:pixel-subsample-2424-sgix #x85A3) (:pixel-subsample-4242-sgix #x85A4) (:pixel-subsample-4444-sgix #x85A2) (:pixel-tex-gen-alpha-ls-sgix #x8189) (:pixel-tex-gen-alpha-ms-sgix #x818A) (:pixel-tex-gen-alpha-no-replace-sgix #x8188) (:pixel-tex-gen-alpha-replace-sgix #x8187) (:pixel-tex-gen-mode-sgix #x832B) (:pixel-tex-gen-q-ceiling-sgix #x8184) (:pixel-tex-gen-q-floor-sgix #x8186) (:pixel-tex-gen-q-round-sgix #x8185) (:pixel-tex-gen-sgix #x8139) (:pixel-texture-sgis #x8353) (:pixel-tile-best-alignment-sgix #x813E) (:pixel-tile-cache-increment-sgix #x813F) (:pixel-tile-cache-size-sgix #x8145) (:pixel-tile-grid-depth-sgix #x8144) (:pixel-tile-grid-height-sgix #x8143) (:pixel-tile-grid-width-sgix #x8142) (:pixel-tile-height-sgix #x8141) (:pixel-tile-width-sgix #x8140) (:pixel-transform-2d-ext #x8330) (:pixel-transform-2d-matrix-ext #x8338) (:pixel-transform-2d-stack-depth-ext #x8336) (:pixel-unpack-buffer #x88EC) (:pixel-unpack-buffer-arb #x88EC) (:pixel-unpack-buffer-binding #x88EF) (:pixel-unpack-buffer-binding-arb #x88EF) (:pixel-unpack-buffer-binding-ext #x88EF) (:pixel-unpack-buffer-ext #x88EC) (:pn-triangles-ati #x87F0) (:pn-triangles-normal-mode-ati #x87F3) (:pn-triangles-normal-mode-linear-ati #x87F7) (:pn-triangles-normal-mode-quadratic-ati #x87F8) (:pn-triangles-point-mode-ati #x87F2) (:pn-triangles-point-mode-cubic-ati #x87F6) (:pn-triangles-point-mode-linear-ati #x87F5) (:pn-triangles-tesselation-level-ati #x87F4) (:point #x1B00) (:point-bit #x2) (:point-distance-attenuation #x8129) (:point-distance-attenuation-arb #x8129) (:point-fade-threshold-size #x8128) (:point-fade-threshold-size-arb #x8128) (:point-fade-threshold-size-ext #x8128) (:point-fade-threshold-size-sgis #x8128) (:point-size #xB11) (:point-size-granularity #xB13) (:point-size-max #x8127) (:point-size-max-arb #x8127) (:point-size-max-ext #x8127) (:point-size-max-sgis #x8127) (:point-size-min #x8126) (:point-size-min-arb #x8126) (:point-size-min-ext #x8126) (:point-size-min-sgis #x8126) (:point-size-range #xB12) (:point-smooth #xB10) (:point-smooth-hint #xC51) (:point-sprite #x8861) (:point-sprite-arb #x8861) (:point-sprite-coord-origin #x8CA0) (:point-sprite-nv #x8861) (:point-sprite-r-mode-nv #x8863) (:point-token #x701) (:points #x0) (:polygon #x9) (:polygon-bit #x8) (:polygon-mode #xB40) (:polygon-offset-bias-ext #x8039) (:polygon-offset-ext #x8037) (:polygon-offset-factor #x8038) (:polygon-offset-factor-ext #x8038) (:polygon-offset-fill #x8037) (:polygon-offset-line #x2A02) (:polygon-offset-point #x2A01) (:polygon-offset-units #x2A00) (:polygon-smooth #xB41) (:polygon-smooth-hint #xC53) (:polygon-stipple #xB42) (:polygon-stipple-bit #x10) (:polygon-token #x703) (:position #x1203) (:post-color-matrix-alpha-bias #x80BB) (:post-color-matrix-alpha-bias-sgi #x80BB) (:post-color-matrix-alpha-scale #x80B7) (:post-color-matrix-alpha-scale-sgi #x80B7) (:post-color-matrix-blue-bias #x80BA) (:post-color-matrix-blue-bias-sgi #x80BA) (:post-color-matrix-blue-scale #x80B6) (:post-color-matrix-blue-scale-sgi #x80B6) (:post-color-matrix-color-table #x80D2) (:post-color-matrix-color-table-sgi #x80D2) (:post-color-matrix-green-bias #x80B9) (:post-color-matrix-green-bias-sgi #x80B9) (:post-color-matrix-green-scale #x80B5) (:post-color-matrix-green-scale-sgi #x80B5) (:post-color-matrix-red-bias #x80B8) (:post-color-matrix-red-bias-sgi #x80B8) (:post-color-matrix-red-scale #x80B4) (:post-color-matrix-red-scale-sgi #x80B4) (:post-convolution-alpha-bias #x8023) (:post-convolution-alpha-bias-ext #x8023) (:post-convolution-alpha-scale #x801F) (:post-convolution-alpha-scale-ext #x801F) (:post-convolution-blue-bias #x8022) (:post-convolution-blue-bias-ext #x8022) (:post-convolution-blue-scale #x801E) (:post-convolution-blue-scale-ext #x801E) (:post-convolution-color-table #x80D1) (:post-convolution-color-table-sgi #x80D1) (:post-convolution-green-bias #x8021) (:post-convolution-green-bias-ext #x8021) (:post-convolution-green-scale #x801D) (:post-convolution-green-scale-ext #x801D) (:post-convolution-red-bias #x8020) (:post-convolution-red-bias-ext #x8020) (:post-convolution-red-scale #x801C) (:post-convolution-red-scale-ext #x801C) (:post-image-transform-color-table-hp #x8162) (:post-texture-filter-bias-range-sgix #x817B) (:post-texture-filter-bias-sgix #x8179) (:post-texture-filter-scale-range-sgix #x817C) (:post-texture-filter-scale-sgix #x817A) (:prefer-doublebuffer-hint-pgi #x1A1F8) (:preserve-ati #x8762) (:previous #x8578) (:previous-arb #x8578) (:previous-ext #x8578) (:previous-texture-input-nv #x86E4) (:primary-color #x8577) (:primary-color-arb #x8577) (:primary-color-ext #x8577) (:primary-color-nv #x852C) (:primitive-id-nv #x8C7C) (:primitive-restart-index-nv #x8559) (:primitive-restart-nv #x8558) (:primitives-generated-nv #x8C87) (:program-address-registers-arb #x88B0) (:program-alu-instructions-arb #x8805) (:program-attrib-components-nv #x8906) (:program-attribs-arb #x88AC) (:program-binding-arb #x8677) (:program-error-position-arb #x864B) (:program-error-position-nv #x864B) (:program-error-string-arb #x8874) (:program-error-string-nv #x8874) (:program-format-arb #x8876) (:program-format-ascii-arb #x8875) (:program-instructions-arb #x88A0) (:program-length-arb #x8627) (:program-length-nv #x8627) (:program-native-address-registers-arb #x88B2) (:program-native-alu-instructions-arb #x8808) (:program-native-attribs-arb #x88AE) (:program-native-instructions-arb #x88A2) (:program-native-parameters-arb #x88AA) (:program-native-temporaries-arb #x88A6) (:program-native-tex-indirections-arb #x880A) (:program-native-tex-instructions-arb #x8809) (:program-object-arb #x8B40) (:program-parameter-nv #x8644) (:program-parameters-arb #x88A8) (:program-point-size-ext #x8642) (:program-resident-nv #x8647) (:program-result-components-nv #x8907) (:program-string-arb #x8628) (:program-string-nv #x8628) (:program-target-nv #x8646) (:program-temporaries-arb #x88A4) (:program-tex-indirections-arb #x8807) (:program-tex-instructions-arb #x8806) (:program-under-native-limits-arb #x88B6) (:projection #x1701) (:projection-matrix #xBA7) (:projection-stack-depth #xBA4) (:proxy-color-table #x80D3) (:proxy-color-table-sgi #x80D3) (:proxy-histogram #x8025) (:proxy-histogram-ext #x8025) (:proxy-post-color-matrix-color-table #x80D5) (:proxy-post-color-matrix-color-table-sgi #x80D5) (:proxy-post-convolution-color-table #x80D4) (:proxy-post-convolution-color-table-sgi #x80D4) (:proxy-post-image-transform-color-table-hp #x8163) (:proxy-texture-1d #x8063) (:proxy-texture-1d-array-ext #x8C19) (:proxy-texture-1d-ext #x8063) (:proxy-texture-1d-stack-mesax #x875B) (:proxy-texture-2d #x8064) (:proxy-texture-2d-array-ext #x8C1B) (:proxy-texture-2d-ext #x8064) (:proxy-texture-2d-stack-mesax #x875C) (:proxy-texture-3d #x8070) (:proxy-texture-3d-ext #x8070) (:proxy-texture-4d-sgis #x8135) (:proxy-texture-color-table-sgi #x80BD) (:proxy-texture-cube-map #x851B) (:proxy-texture-cube-map-arb #x851B) (:proxy-texture-cube-map-ext #x851B) (:proxy-texture-rectangle-arb #x84F7) (:proxy-texture-rectangle-nv #x84F7) (:q #x2003) (:quad-alpha4-sgis #x811E) (:quad-alpha8-sgis #x811F) (:quad-intensity4-sgis #x8122) (:quad-intensity8-sgis #x8123) (:quad-luminance4-sgis #x8120) (:quad-luminance8-sgis #x8121) (:quad-mesh-sun #x8614) (:quad-strip #x8) (:quad-texture-select-sgis #x8125) (:quadratic-attenuation #x1209) (:quads #x7) (:quarter-bit-ati #x10) (:query-counter #x8864) (:query-counter-bits #x8864) (:query-counter-bits-arb #x8864) (:query-result #x8866) (:query-result-arb #x8866) (:query-result-available #x8867) (:query-result-available-arb #x8867) (:r #x2002) (:r11f-g11f-b10f-ext #x8C3A) (:r1ui-c3f-v3f-sun #x85C6) (:r1ui-c4f-n3f-v3f-sun #x85C8) (:r1ui-c4ub-v3f-sun #x85C5) (:r1ui-n3f-v3f-sun #x85C7) (:r1ui-t2f-c4f-n3f-v3f-sun #x85CB) (:r1ui-t2f-n3f-v3f-sun #x85CA) (:r1ui-t2f-v3f-sun #x85C9) (:r1ui-v3f-sun #x85C4) (:r3-g3-b2 #x2A10) (:raster-position-unclipped-ibm #x19262) (:rasterizer-discard-nv #x8C89) (:read-buffer #xC02) (:read-framebuffer-binding-ext #x8CAA) (:read-framebuffer-ext #x8CA8) (:read-only #x88B8) (:read-only-arb #x88B8) (:read-pixel-data-range-length-nv #x887B) (:read-pixel-data-range-nv #x8879) (:read-pixel-data-range-pointer-nv #x887D) (:read-write #x88BA) (:read-write-arb #x88BA) (:reclaim-memory-hint-pgi #x1A1FE) (:red #x1903) (:red-bias #xD15) (:red-bit-ati #x1) (:red-bits #xD52) (:red-integer-ext #x8D94) (:red-max-clamp-ingr #x8564) (:red-min-clamp-ingr #x8560) (:red-scale #xD14) (:reduce #x8016) (:reduce-ext #x8016) (:reference-plane-equation-sgix #x817E) (:reference-plane-sgix #x817D) (:reflection-map #x8512) (:reflection-map-arb #x8512) (:reflection-map-ext #x8512) (:reflection-map-nv #x8512) (:reg-0-ati #x8921) (:reg-1-ati #x8922) (:reg-10-ati #x892B) (:reg-11-ati #x892C) (:reg-12-ati #x892D) (:reg-13-ati #x892E) (:reg-14-ati #x892F) (:reg-15-ati #x8930) (:reg-16-ati #x8931) (:reg-17-ati #x8932) (:reg-18-ati #x8933) (:reg-19-ati #x8934) (:reg-2-ati #x8923) (:reg-20-ati #x8935) (:reg-21-ati #x8936) (:reg-22-ati #x8937) (:reg-23-ati #x8938) (:reg-24-ati #x8939) (:reg-25-ati #x893A) (:reg-26-ati #x893B) (:reg-27-ati #x893C) (:reg-28-ati #x893D) (:reg-29-ati #x893E) (:reg-3-ati #x8924) (:reg-30-ati #x893F) (:reg-31-ati #x8940) (:reg-4-ati #x8925) (:reg-5-ati #x8926) (:reg-6-ati #x8927) (:reg-7-ati #x8928) (:reg-8-ati #x8929) (:reg-9-ati #x892A) (:register-combiners-nv #x8522) (:render #x1C00) (:render-mode #xC40) (:renderbuffer-alpha-size-ext #x8D53) (:renderbuffer-binding-ext #x8CA7) (:renderbuffer-blue-size-ext #x8D52) (:renderbuffer-color-samples-nv #x8E10) (:renderbuffer-coverage-samples-nv #x8CAB) (:renderbuffer-depth-size-ext #x8D54) (:renderbuffer-ext #x8D41) (:renderbuffer-green-size-ext #x8D51) (:renderbuffer-height-ext #x8D43) (:renderbuffer-internal-format-ext #x8D44) (:renderbuffer-red-size-ext #x8D50) (:renderbuffer-samples-ext #x8CAB) (:renderbuffer-stencil-size-ext #x8D55) (:renderbuffer-width-ext #x8D42) (:renderer #x1F01) (:repeat #x2901) (:replace #x1E01) (:replace-ext #x8062) (:replace-middle-sun #x2) (:replace-oldest-sun #x3) (:replacement-code-array-pointer-sun #x85C3) (:replacement-code-array-stride-sun #x85C2) (:replacement-code-array-sun #x85C0) (:replacement-code-array-type-sun #x85C1) (:replacement-code-sun #x81D8) (:replicate-border #x8153) (:replicate-border-hp #x8153) (:resample-average-oml #x8988) (:resample-decimate-oml #x8989) (:resample-decimate-sgix #x8430) (:resample-replicate-oml #x8986) (:resample-replicate-sgix #x842E) (:resample-zero-fill-oml #x8987) (:resample-zero-fill-sgix #x842F) (:rescale-normal #x803A) (:rescale-normal-ext #x803A) (:restart-sun #x1) (:return #x102) (:rgb #x1907) (:rgb-float16-ati #x881B) (:rgb-float32-ati #x8815) (:rgb-integer-ext #x8D98) (:rgb-s3tc #x83A0) (:rgb-scale #x8573) (:rgb-scale-arb #x8573) (:rgb-scale-ext #x8573) (:rgb10 #x8052) (:rgb10-a2 #x8059) (:rgb10-a2-ext #x8059) (:rgb10-ext #x8052) (:rgb12 #x8053) (:rgb12-ext #x8053) (:rgb16 #x8054) (:rgb16-ext #x8054) (:rgb16f-arb #x881B) (:rgb16i-ext #x8D89) (:rgb16ui-ext #x8D77) (:rgb2-ext #x804E) (:rgb32f-arb #x8815) (:rgb32i-ext #x8D83) (:rgb32ui-ext #x8D71) (:rgb4 #x804F) (:rgb4-ext #x804F) (:rgb4-s3tc #x83A1) (:rgb5 #x8050) (:rgb5-a1 #x8057) (:rgb5-a1-ext #x8057) (:rgb5-ext #x8050) (:rgb8 #x8051) (:rgb8-ext #x8051) (:rgb8i-ext #x8D8F) (:rgb8ui-ext #x8D7D) (:rgb9-e5-ext #x8C3D) (:rgba #x1908) (:rgba-float-mode-arb #x8820) (:rgba-float16-ati #x881A) (:rgba-float32-ati #x8814) (:rgba-integer-ext #x8D99) (:rgba-integer-mode-ext #x8D9E) (:rgba-mode #xC31) (:rgba-s3tc #x83A2) (:rgba-signed-components-ext #x8C3C) (:rgba-unsigned-dot-product-mapping-nv #x86D9) (:rgba12 #x805A) (:rgba12-ext #x805A) (:rgba16 #x805B) (:rgba16-ext #x805B) (:rgba16f-arb #x881A) (:rgba16i-ext #x8D88) (:rgba16ui-ext #x8D76) (:rgba2 #x8055) (:rgba2-ext #x8055) (:rgba32f-arb #x8814) (:rgba32i-ext #x8D82) (:rgba32ui-ext #x8D70) (:rgba4 #x8056) (:rgba4-ext #x8056) (:rgba4-s3tc #x83A3) (:rgba8 #x8058) (:rgba8-ext #x8058) (:rgba8i-ext #x8D8E) (:rgba8ui-ext #x8D7C) (:right #x407) (:s #x2000) (:sample-alpha-to-coverage #x809E) (:sample-alpha-to-coverage-arb #x809E) (:sample-alpha-to-mask-ext #x809E) (:sample-alpha-to-mask-sgis #x809E) (:sample-alpha-to-one #x809F) (:sample-alpha-to-one-arb #x809F) (:sample-alpha-to-one-ext #x809F) (:sample-alpha-to-one-sgis #x809F) (:sample-buffers #x80A8) (:sample-buffers-3dfx #x86B3) (:sample-buffers-arb #x80A8) (:sample-buffers-ext #x80A8) (:sample-buffers-sgis #x80A8) (:sample-coverage #x80A0) (:sample-coverage-arb #x80A0) (:sample-coverage-invert #x80AB) (:sample-coverage-invert-arb #x80AB) (:sample-coverage-value #x80AA) (:sample-coverage-value-arb #x80AA) (:sample-mask-ext #x80A0) (:sample-mask-invert-ext #x80AB) (:sample-mask-invert-sgis #x80AB) (:sample-mask-sgis #x80A0) (:sample-mask-value-ext #x80AA) (:sample-mask-value-sgis #x80AA) (:sample-pattern-ext #x80AC) (:sample-pattern-sgis #x80AC) (:sampler-1d #x8B5D) (:sampler-1d-arb #x8B5D) (:sampler-1d-array-ext #x8DC0) (:sampler-1d-array-shadow-ext #x8DC3) (:sampler-1d-shadow #x8B61) (:sampler-1d-shadow-arb #x8B61) (:sampler-2d #x8B5E) (:sampler-2d-arb #x8B5E) (:sampler-2d-array-ext #x8DC1) (:sampler-2d-array-shadow-ext #x8DC4) (:sampler-2d-rect-arb #x8B63) (:sampler-2d-rect-shadow-arb #x8B64) (:sampler-2d-shadow #x8B62) (:sampler-2d-shadow-arb #x8B62) (:sampler-3d #x8B5F) (:sampler-3d-arb #x8B5F) (:sampler-buffer-ext #x8DC2) (:sampler-cube #x8B60) (:sampler-cube-arb #x8B60) (:sampler-cube-shadow-ext #x8DC5) (:samples #x80A9) (:samples-3dfx #x86B4) (:samples-arb #x80A9) (:samples-ext #x80A9) (:samples-passed #x8914) (:samples-passed-arb #x8914) (:samples-sgis #x80A9) (:saturate-bit-ati #x40) (:scalar-ext #x87BE) (:scale-by-four-nv #x853F) (:scale-by-one-half-nv #x8540) (:scale-by-two-nv #x853E) (:scalebias-hint-sgix #x8322) (:scissor #x80000) (:scissor-bit #x80000) (:scissor-box #xC10) (:scissor-test #xC11) (:screen-coordinates-rend #x8490) (:secondary-color-array #x845E) (:secondary-color-array-buffer-binding #x889C) (:secondary-color-array-buffer-binding-arb #x889C) (:secondary-color-array-ext #x845E) (:secondary-color-array-list-ibm #x192A5) (:secondary-color-array-list-stride-ibm #x192AF) (:secondary-color-array-pointer #x845D) (:secondary-color-array-pointer-ext #x845D) (:secondary-color-array-size #x845A) (:secondary-color-array-size-ext #x845A) (:secondary-color-array-stride #x845C) (:secondary-color-array-stride-ext #x845C) (:secondary-color-array-type #x845B) (:secondary-color-array-type-ext #x845B) (:secondary-color-nv #x852D) (:secondary-interpolator-ati #x896D) (:select #x1C02) (:selection-buffer-pointer #xDF3) (:selection-buffer-size #xDF4) (:separable-2d #x8012) (:separable-2d-ext #x8012) (:separate-attribs-nv #x8C8D) (:separate-specular-color #x81FA) (:separate-specular-color-ext #x81FA) (:set #x150F) (:shade-model #xB54) (:shader-consistent-nv #x86DD) (:shader-object-arb #x8B48) (:shader-operation-nv #x86DF) (:shader-source-length #x8B88) (:shader-type #x8B4F) (:shading-language-version #x8B8C) (:shading-language-version-arb #x8B8C) (:shadow-ambient-sgix #x80BF) (:shadow-attenuation-ext #x834E) (:shared-texture-palette-ext #x81FB) (:sharpen-texture-func-points-sgis #x80B0) (:shininess #x1601) (:short #x1402) (:signed-alpha-nv #x8705) (:signed-alpha8-nv #x8706) (:signed-hilo-nv #x86F9) (:signed-hilo16-nv #x86FA) (:signed-hilo8-nv #x885F) (:signed-identity-nv #x853C) (:signed-intensity-nv #x8707) (:signed-intensity8-nv #x8708) (:signed-luminance-alpha-nv #x8703) (:signed-luminance-nv #x8701) (:signed-luminance8-alpha8-nv #x8704) (:signed-luminance8-nv #x8702) (:signed-negate-nv #x853D) (:signed-rgb-nv #x86FE) (:signed-rgb-unsigned-alpha-nv #x870C) (:signed-rgb8-nv #x86FF) (:signed-rgb8-unsigned-alpha8-nv #x870D) (:signed-rgba-nv #x86FB) (:signed-rgba8-nv #x86FC) (:single-color #x81F9) (:single-color-ext #x81F9) (:slice-accum-sun #x85CC) (:sluminance #x8C46) (:sluminance-alpha #x8C44) (:sluminance-alpha-ext #x8C44) (:sluminance-ext #x8C46) (:sluminance8 #x8C47) (:sluminance8-alpha8 #x8C45) (:sluminance8-alpha8-ext #x8C45) (:sluminance8-ext #x8C47) (:smooth #x1D01) (:smooth-line-width-granularity #xB23) (:smooth-line-width-range #xB22) (:smooth-point-size-granularity #xB13) (:smooth-point-size-range #xB12) (:source0-alpha #x8588) (:source0-alpha-arb #x8588) (:source0-alpha-ext #x8588) (:source0-rgb #x8580) (:source0-rgb-arb #x8580) (:source0-rgb-ext #x8580) (:source1-alpha #x8589) (:source1-alpha-arb #x8589) (:source1-alpha-ext #x8589) (:source1-rgb #x8581) (:source1-rgb-arb #x8581) (:source1-rgb-ext #x8581) (:source2-alpha #x858A) (:source2-alpha-arb #x858A) (:source2-alpha-ext #x858A) (:source2-rgb #x8582) (:source2-rgb-arb #x8582) (:source2-rgb-ext #x8582) (:source3-alpha-nv #x858B) (:source3-rgb-nv #x8583) (:spare0-nv #x852E) (:spare0-plus-secondary-color-nv #x8532) (:spare1-nv #x852F) (:specular #x1202) (:sphere-map #x2402) (:spot-cutoff #x1206) (:spot-direction #x1204) (:spot-exponent #x1205) (:sprite-axial-sgix #x814C) (:sprite-axis-sgix #x814A) (:sprite-eye-aligned-sgix #x814E) (:sprite-mode-sgix #x8149) (:sprite-object-aligned-sgix #x814D) (:sprite-sgix #x8148) (:sprite-translation-sgix #x814B) (:src-alpha #x302) (:src-alpha-saturate #x308) (:src-color #x300) (:srgb #x8C40) (:srgb-alpha #x8C42) (:srgb-alpha-ext #x8C42) (:srgb-ext #x8C40) (:srgb8 #x8C41) (:srgb8-alpha8 #x8C43) (:srgb8-alpha8-ext #x8C43) (:srgb8-ext #x8C41) (:stack-overflow #x503) (:stack-underflow #x504) (:static-ati #x8760) (:static-copy #x88E6) (:static-copy-arb #x88E6) (:static-draw #x88E4) (:static-draw-arb #x88E4) (:static-read #x88E5) (:static-read-arb #x88E5) (:stencil #x1802) (:stencil-attachment-ext #x8D20) (:stencil-back-fail #x8801) (:stencil-back-fail-ati #x8801) (:stencil-back-func #x8800) (:stencil-back-func-ati #x8800) (:stencil-back-pass-depth-fail #x8802) (:stencil-back-pass-depth-fail-ati #x8802) (:stencil-back-pass-depth-pass #x8803) (:stencil-back-pass-depth-pass-ati #x8803) (:stencil-back-ref #x8CA3) (:stencil-back-value-mask #x8CA4) (:stencil-back-writemask #x8CA5) (:stencil-bits #xD57) (:stencil-buffer #x400) (:stencil-buffer-bit #x400) (:stencil-clear-tag-value-ext #x88F3) (:stencil-clear-value #xB91) (:stencil-fail #xB94) (:stencil-func #xB92) (:stencil-index #x1901) (:stencil-index1-ext #x8D46) (:stencil-index16-ext #x8D49) (:stencil-index4-ext #x8D47) (:stencil-index8-ext #x8D48) (:stencil-pass-depth-fail #xB95) (:stencil-pass-depth-pass #xB96) (:stencil-ref #xB97) (:stencil-tag-bits-ext #x88F2) (:stencil-test #xB90) (:stencil-test-two-side-ext #x8910) (:stencil-value-mask #xB93) (:stencil-writemask #xB98) (:stereo #xC33) (:storage-cached-apple #x85BE) (:storage-shared-apple #x85BF) (:stream-copy #x88E2) (:stream-copy-arb #x88E2) (:stream-draw #x88E0) (:stream-draw-arb #x88E0) (:stream-read #x88E1) (:stream-read-arb #x88E1) (:strict-depthfunc-hint-pgi #x1A216) (:strict-lighting-hint-pgi #x1A217) (:strict-scissor-hint-pgi #x1A218) (:sub-ati #x8965) (:subpixel #xD50) (:subpixel-bits #xD50) (:subtract #x84E7) (:subtract-arb #x84E7) (:swizzle-stq-ati #x8977) (:swizzle-stq-dq-ati #x8979) (:swizzle-str-ati #x8976) (:swizzle-str-dr-ati #x8978) (:swizzle-strq-ati #x897A) (:swizzle-strq-dq-ati #x897B) (:t #x2001) (:t2f-c3f-v3f #x2A2A) (:t2f-c4f-n3f-v3f #x2A2C) (:t2f-c4ub-v3f #x2A29) (:t2f-iui-n3f-v2f-ext #x81B3) (:t2f-iui-n3f-v3f-ext #x81B4) (:t2f-iui-v2f-ext #x81B1) (:t2f-iui-v3f-ext #x81B2) (:t2f-n3f-v3f #x2A2B) (:t2f-v3f #x2A27) (:t4f-c4f-n3f-v4f #x2A2D) (:t4f-v4f #x2A28) (:table-too-large #x8031) (:table-too-large-ext #x8031) (:tangent-array-ext #x8439) (:tangent-array-pointer-ext #x8442) (:tangent-array-stride-ext #x843F) (:tangent-array-type-ext #x843E) (:texcoord1-bit-pgi #x10000000) (:texcoord2-bit-pgi #x20000000) (:texcoord3-bit-pgi #x40000000) (:texcoord4-bit-pgi #x80000000) (:text-fragment-shader-ati #x8200) (:texture #x1702) (:texture-1d #xDE0) (:texture-1d-array-ext #x8C18) (:texture-1d-binding-ext #x8068) (:texture-1d-stack-binding-mesax #x875D) (:texture-1d-stack-mesax #x8759) (:texture-2d #xDE1) (:texture-2d-array-ext #x8C1A) (:texture-2d-binding-ext #x8069) (:texture-2d-stack-binding-mesax #x875E) (:texture-2d-stack-mesax #x875A) (:texture-3d #x806F) (:texture-3d-binding-ext #x806A) (:texture-3d-ext #x806F) (:texture-4d-binding-sgis #x814F) (:texture-4d-sgis #x8134) (:texture-4dsize-sgis #x8136) (:texture-alpha-size #x805F) (:texture-alpha-size-ext #x805F) (:texture-alpha-type-arb #x8C13) (:texture-application-mode-ext #x834F) (:texture-base-level #x813C) (:texture-base-level-sgis #x813C) (:texture-binding-1d #x8068) (:texture-binding-1d-array-ext #x8C1C) (:texture-binding-2d #x8069) (:texture-binding-2d-array-ext #x8C1D) (:texture-binding-3d #x806A) (:texture-binding-buffer-ext #x8C2C) (:texture-binding-cube-map #x8514) (:texture-binding-cube-map-arb #x8514) (:texture-binding-cube-map-ext #x8514) (:texture-binding-rectangle-arb #x84F6) (:texture-binding-rectangle-nv #x84F6) (:texture-bit #x40000) (:texture-blue-size #x805E) (:texture-blue-size-ext #x805E) (:texture-blue-type-arb #x8C12) (:texture-border #x1005) (:texture-border-color #x1004) (:texture-border-values-nv #x871A) (:texture-buffer-data-store-binding-ext #x8C2D) (:texture-buffer-ext #x8C2A) (:texture-buffer-format-ext #x8C2E) (:texture-clipmap-center-sgix #x8171) (:texture-clipmap-depth-sgix #x8176) (:texture-clipmap-frame-sgix #x8172) (:texture-clipmap-lod-offset-sgix #x8175) (:texture-clipmap-offset-sgix #x8173) (:texture-clipmap-virtual-depth-sgix #x8174) (:texture-color-table-sgi #x80BC) (:texture-color-writemask-sgis #x81EF) (:texture-compare-fail-value-arb #x80BF) (:texture-compare-func #x884D) (:texture-compare-mode #x884C) (:texture-compare-operator-sgix #x819B) (:texture-compare-sgix #x819A) (:texture-components #x1003) (:texture-compressed #x86A1) (:texture-compressed-arb #x86A1) (:texture-compressed-image-size #x86A0) (:texture-compressed-image-size-arb #x86A0) (:texture-compression-hint #x84EF) (:texture-compression-hint-arb #x84EF) (:texture-constant-data-sunx #x81D6) (:texture-coord-array #x8078) (:texture-coord-array-buffer-binding #x889A) (:texture-coord-array-buffer-binding-arb #x889A) (:texture-coord-array-count-ext #x808B) (:texture-coord-array-ext #x8078) (:texture-coord-array-list-ibm #x192A2) (:texture-coord-array-list-stride-ibm #x192AC) (:texture-coord-array-parallel-pointers-intel #x83F8) (:texture-coord-array-pointer #x8092) (:texture-coord-array-pointer-ext #x8092) (:texture-coord-array-size #x8088) (:texture-coord-array-size-ext #x8088) (:texture-coord-array-stride #x808A) (:texture-coord-array-stride-ext #x808A) (:texture-coord-array-type #x8089) (:texture-coord-array-type-ext #x8089) (:texture-coord-nv #x8C79) (:texture-cube-map #x8513) (:texture-cube-map-arb #x8513) (:texture-cube-map-ext #x8513) (:texture-cube-map-negative-x #x8516) (:texture-cube-map-negative-x-arb #x8516) (:texture-cube-map-negative-x-ext #x8516) (:texture-cube-map-negative-y #x8518) (:texture-cube-map-negative-y-arb #x8518) (:texture-cube-map-negative-y-ext #x8518) (:texture-cube-map-negative-z #x851A) (:texture-cube-map-negative-z-arb #x851A) (:texture-cube-map-negative-z-ext #x851A) (:texture-cube-map-positive-x #x8515) (:texture-cube-map-positive-x-arb #x8515) (:texture-cube-map-positive-x-ext #x8515) (:texture-cube-map-positive-y #x8517) (:texture-cube-map-positive-y-arb #x8517) (:texture-cube-map-positive-y-ext #x8517) (:texture-cube-map-positive-z #x8519) (:texture-cube-map-positive-z-arb #x8519) (:texture-cube-map-positive-z-ext #x8519) (:texture-deformation-bit-sgix #x1) (:texture-deformation-sgix #x8195) (:texture-depth #x8071) (:texture-depth-ext #x8071) (:texture-depth-size #x884A) (:texture-depth-size-arb #x884A) (:texture-depth-type-arb #x8C16) (:texture-ds-size-nv #x871D) (:texture-dt-size-nv #x871E) (:texture-env #x2300) (:texture-env-bias-sgix #x80BE) (:texture-env-color #x2201) (:texture-env-mode #x2200) (:texture-filter-control #x8500) (:texture-filter-control-ext #x8500) (:texture-filter4-size-sgis #x8147) (:texture-float-components-nv #x888C) (:texture-gen-mode #x2500) (:texture-gen-q #xC63) (:texture-gen-r #xC62) (:texture-gen-s #xC60) (:texture-gen-t #xC61) (:texture-gequal-r-sgix #x819D) (:texture-green-size #x805D) (:texture-green-size-ext #x805D) (:texture-green-type-arb #x8C11) (:texture-height #x1001) (:texture-hi-size-nv #x871B) (:texture-index-size-ext #x80ED) (:texture-intensity-size #x8061) (:texture-intensity-size-ext #x8061) (:texture-intensity-type-arb #x8C15) (:texture-internal-format #x1003) (:texture-lequal-r-sgix #x819C) (:texture-light-ext #x8350) (:texture-lighting-mode-hp #x8167) (:texture-lo-size-nv #x871C) (:texture-lod-bias #x8501) (:texture-lod-bias-ext #x8501) (:texture-lod-bias-r-sgix #x8190) (:texture-lod-bias-s-sgix #x818E) (:texture-lod-bias-t-sgix #x818F) (:texture-luminance-size #x8060) (:texture-luminance-size-ext #x8060) (:texture-luminance-type-arb #x8C14) (:texture-mag-filter #x2800) (:texture-mag-size-nv #x871F) (:texture-material-face-ext #x8351) (:texture-material-parameter-ext #x8352) (:texture-matrix #xBA8) (:texture-max-anisotropy-ext #x84FE) (:texture-max-clamp-r-sgix #x836B) (:texture-max-clamp-s-sgix #x8369) (:texture-max-clamp-t-sgix #x836A) (:texture-max-level #x813D) (:texture-max-level-sgis #x813D) (:texture-max-lod #x813B) (:texture-max-lod-sgis #x813B) (:texture-min-filter #x2801) (:texture-min-lod #x813A) (:texture-min-lod-sgis #x813A) (:texture-multi-buffer-hint-sgix #x812E) (:texture-normal-ext #x85AF) (:texture-post-specular-hp #x8168) (:texture-pre-specular-hp #x8169) (:texture-priority #x8066) (:texture-priority-ext #x8066) (:texture-rectangle-arb #x84F5) (:texture-rectangle-nv #x84F5) (:texture-red-size #x805C) (:texture-red-size-ext #x805C) (:texture-red-type-arb #x8C10) (:texture-resident #x8067) (:texture-resident-ext #x8067) (:texture-shader-nv #x86DE) (:texture-shared-size-ext #x8C3F) (:texture-stack-depth #xBA5) (:texture-stencil-size-ext #x88F1) (:texture-too-large-ext #x8065) (:texture-unsigned-remap-mode-nv #x888F) (:texture-width #x1000) (:texture-wrap-q-sgis #x8137) (:texture-wrap-r #x8072) (:texture-wrap-r-ext #x8072) (:texture-wrap-s #x2802) (:texture-wrap-t #x2803) (:texture0 #x84C0) (:texture0-arb #x84C0) (:texture1 #x84C1) (:texture1-arb #x84C1) (:texture10 #x84CA) (:texture10-arb #x84CA) (:texture11 #x84CB) (:texture11-arb #x84CB) (:texture12 #x84CC) (:texture12-arb #x84CC) (:texture13 #x84CD) (:texture13-arb #x84CD) (:texture14 #x84CE) (:texture14-arb #x84CE) (:texture15 #x84CF) (:texture15-arb #x84CF) (:texture16 #x84D0) (:texture16-arb #x84D0) (:texture17 #x84D1) (:texture17-arb #x84D1) (:texture18 #x84D2) (:texture18-arb #x84D2) (:texture19 #x84D3) (:texture19-arb #x84D3) (:texture2 #x84C2) (:texture2-arb #x84C2) (:texture20 #x84D4) (:texture20-arb #x84D4) (:texture21 #x84D5) (:texture21-arb #x84D5) (:texture22 #x84D6) (:texture22-arb #x84D6) (:texture23 #x84D7) (:texture23-arb #x84D7) (:texture24 #x84D8) (:texture24-arb #x84D8) (:texture25 #x84D9) (:texture25-arb #x84D9) (:texture26 #x84DA) (:texture26-arb #x84DA) (:texture27 #x84DB) (:texture27-arb #x84DB) (:texture28 #x84DC) (:texture28-arb #x84DC) (:texture29 #x84DD) (:texture29-arb #x84DD) (:texture3 #x84C3) (:texture3-arb #x84C3) (:texture30 #x84DE) (:texture30-arb #x84DE) (:texture31 #x84DF) (:texture31-arb #x84DF) (:texture4 #x84C4) (:texture4-arb #x84C4) (:texture5 #x84C5) (:texture5-arb #x84C5) (:texture6 #x84C6) (:texture6-arb #x84C6) (:texture7 #x84C7) (:texture7-arb #x84C7) (:texture8 #x84C8) (:texture8-arb #x84C8) (:texture9 #x84C9) (:texture9-arb #x84C9) (:time-elapsed-ext #x88BF) (:track-matrix-nv #x8648) (:track-matrix-transform-nv #x8649) (:transform #x1000) (:transform-bit #x1000) (:transform-feedback-attribs-nv #x8C7E) (:transform-feedback-buffer-binding-nv #x8C8F) (:transform-feedback-buffer-mode-nv #x8C7F) (:transform-feedback-buffer-nv #x8C8E) (:transform-feedback-buffer-size-nv #x8C85) (:transform-feedback-buffer-start-nv #x8C84) (:transform-feedback-primitives-written-nv #x8C88) (:transform-feedback-record-nv #x8C86) (:transform-feedback-varyings-nv #x8C83) (:transform-hint-apple #x85B1) (:transpose-color-matrix #x84E6) (:transpose-color-matrix-arb #x84E6) (:transpose-current-matrix-arb #x88B7) (:transpose-modelview-matrix #x84E3) (:transpose-modelview-matrix-arb #x84E3) (:transpose-nv #x862C) (:transpose-projection-matrix #x84E4) (:transpose-projection-matrix-arb #x84E4) (:transpose-texture-matrix #x84E5) (:transpose-texture-matrix-arb #x84E5) (:triangle-fan #x6) (:triangle-list-sun #x81D7) (:triangle-mesh-sun #x8615) (:triangle-strip #x5) (:triangle-strip-adjacency-ext #xD) (:triangles #x4) (:triangles-adjacency-ext #xC) (:true #x1) (:type-rgba-float-ati #x8820) (:uniform-buffer-binding-ext #x8DEF) (:uniform-buffer-ext #x8DEE) (:unpack-alignment #xCF5) (:unpack-client-storage-apple #x85B2) (:unpack-cmyk-hint-ext #x800F) (:unpack-constant-data-sunx #x81D5) (:unpack-image-depth-sgis #x8133) (:unpack-image-height #x806E) (:unpack-image-height-ext #x806E) (:unpack-lsb-first #xCF1) (:unpack-resample-oml #x8985) (:unpack-resample-sgix #x842D) (:unpack-row-length #xCF2) (:unpack-skip-images #x806D) (:unpack-skip-images-ext #x806D) (:unpack-skip-pixels #xCF4) (:unpack-skip-rows #xCF3) (:unpack-skip-volumes-sgis #x8132) (:unpack-subsample-rate-sgix #x85A1) (:unpack-swap-bytes #xCF0) (:unsigned-byte #x1401) (:unsigned-byte-2-3-3-rev #x8362) (:unsigned-byte-2-3-3-rev-ext #x8362) (:unsigned-byte-3-3-2 #x8032) (:unsigned-byte-3-3-2-ext #x8032) (:unsigned-identity-nv #x8536) (:unsigned-int #x1405) (:unsigned-int-10-10-10-2 #x8036) (:unsigned-int-10-10-10-2-ext #x8036) (:unsigned-int-10f-11f-11f-rev-ext #x8C3B) (:unsigned-int-2-10-10-10-rev #x8368) (:unsigned-int-2-10-10-10-rev-ext #x8368) (:unsigned-int-24-8-ext #x84FA) (:unsigned-int-24-8-nv #x84FA) (:unsigned-int-5-9-9-9-rev-ext #x8C3E) (:unsigned-int-8-8-8-8 #x8035) (:unsigned-int-8-8-8-8-ext #x8035) (:unsigned-int-8-8-8-8-rev #x8367) (:unsigned-int-8-8-8-8-rev-ext #x8367) (:unsigned-int-8-8-s8-s8-rev-nv #x86DB) (:unsigned-int-s8-s8-8-8-nv #x86DA) (:unsigned-int-sampler-1d-array-ext #x8DD6) (:unsigned-int-sampler-1d-ext #x8DD1) (:unsigned-int-sampler-2d-array-ext #x8DD7) (:unsigned-int-sampler-2d-ext #x8DD2) (:unsigned-int-sampler-2d-rect-ext #x8DD5) (:unsigned-int-sampler-3d-ext #x8DD3) (:unsigned-int-sampler-buffer-ext #x8DD8) (:unsigned-int-sampler-cube-ext #x8DD4) (:unsigned-int-vec2-ext #x8DC6) (:unsigned-int-vec3-ext #x8DC7) (:unsigned-int-vec4-ext #x8DC8) (:unsigned-invert-nv #x8537) (:unsigned-normalized-arb #x8C17) (:unsigned-short #x1403) (:unsigned-short-1-5-5-5-rev #x8366) (:unsigned-short-1-5-5-5-rev-ext #x8366) (:unsigned-short-4-4-4-4 #x8033) (:unsigned-short-4-4-4-4-ext #x8033) (:unsigned-short-4-4-4-4-rev #x8365) (:unsigned-short-4-4-4-4-rev-ext #x8365) (:unsigned-short-5-5-5-1 #x8034) (:unsigned-short-5-5-5-1-ext #x8034) (:unsigned-short-5-6-5 #x8363) (:unsigned-short-5-6-5-ext #x8363) (:unsigned-short-5-6-5-rev #x8364) (:unsigned-short-5-6-5-rev-ext #x8364) (:unsigned-short-8-8-apple #x85BA) (:unsigned-short-8-8-mesa #x85BA) (:unsigned-short-8-8-rev-apple #x85BB) (:unsigned-short-8-8-rev-mesa #x85BB) (:upper-left #x8CA2) (:v2f #x2A20) (:v3f #x2A21) (:validate-status #x8B83) (:variable-a-nv #x8523) (:variable-b-nv #x8524) (:variable-c-nv #x8525) (:variable-d-nv #x8526) (:variable-e-nv #x8527) (:variable-f-nv #x8528) (:variable-g-nv #x8529) (:variant-array-ext #x87E8) (:variant-array-pointer-ext #x87E9) (:variant-array-stride-ext #x87E6) (:variant-array-type-ext #x87E7) (:variant-datatype-ext #x87E5) (:variant-ext #x87C1) (:variant-value-ext #x87E4) (:vector-ext #x87BF) (:vendor #x1F00) (:version #x1F02) (:vertex-array #x8074) (:vertex-array-binding-apple #x85B5) (:vertex-array-buffer-binding #x8896) (:vertex-array-buffer-binding-arb #x8896) (:vertex-array-count-ext #x807D) (:vertex-array-ext #x8074) (:vertex-array-list-ibm #x1929E) (:vertex-array-list-stride-ibm #x192A8) (:vertex-array-parallel-pointers-intel #x83F5) (:vertex-array-pointer #x808E) (:vertex-array-pointer-ext #x808E) (:vertex-array-range-apple #x851D) (:vertex-array-range-length-apple #x851E) (:vertex-array-range-length-nv #x851E) (:vertex-array-range-nv #x851D) (:vertex-array-range-pointer-apple #x8521) (:vertex-array-range-pointer-nv #x8521) (:vertex-array-range-valid-nv #x851F) (:vertex-array-range-without-flush-nv #x8533) (:vertex-array-size #x807A) (:vertex-array-size-ext #x807A) (:vertex-array-storage-hint-apple #x851F) (:vertex-array-stride #x807C) (:vertex-array-stride-ext #x807C) (:vertex-array-type #x807B) (:vertex-array-type-ext #x807B) (:vertex-attrib-array-buffer-binding #x889F) (:vertex-attrib-array-buffer-binding-arb #x889F) (:vertex-attrib-array-enabled #x8622) (:vertex-attrib-array-enabled-arb #x8622) (:vertex-attrib-array-integer-nv #x88FD) (:vertex-attrib-array-normalized #x886A) (:vertex-attrib-array-normalized-arb #x886A) (:vertex-attrib-array-pointer #x8645) (:vertex-attrib-array-pointer-arb #x8645) (:vertex-attrib-array-size #x8623) (:vertex-attrib-array-size-arb #x8623) (:vertex-attrib-array-stride #x8624) (:vertex-attrib-array-stride-arb #x8624) (:vertex-attrib-array-type #x8625) (:vertex-attrib-array-type-arb #x8625) (:vertex-attrib-array0-nv #x8650) (:vertex-attrib-array1-nv #x8651) (:vertex-attrib-array10-nv #x865A) (:vertex-attrib-array11-nv #x865B) (:vertex-attrib-array12-nv #x865C) (:vertex-attrib-array13-nv #x865D) (:vertex-attrib-array14-nv #x865E) (:vertex-attrib-array15-nv #x865F) (:vertex-attrib-array2-nv #x8652) (:vertex-attrib-array3-nv #x8653) (:vertex-attrib-array4-nv #x8654) (:vertex-attrib-array5-nv #x8655) (:vertex-attrib-array6-nv #x8656) (:vertex-attrib-array7-nv #x8657) (:vertex-attrib-array8-nv #x8658) (:vertex-attrib-array9-nv #x8659) (:vertex-blend-arb #x86A7) (:vertex-consistent-hint-pgi #x1A22B) (:vertex-data-hint-pgi #x1A22A) (:vertex-id-nv #x8C7B) (:vertex-preclip-hint-sgix #x83EF) (:vertex-preclip-sgix #x83EE) (:vertex-program-arb #x8620) (:vertex-program-binding-nv #x864A) (:vertex-program-nv #x8620) (:vertex-program-parameter-buffer-nv #x8DA2) (:vertex-program-point-size #x8642) (:vertex-program-point-size-arb #x8642) (:vertex-program-point-size-nv #x8642) (:vertex-program-two-side #x8643) (:vertex-program-two-side-arb #x8643) (:vertex-program-two-side-nv #x8643) (:vertex-shader #x8B31) (:vertex-shader-arb #x8B31) (:vertex-shader-binding-ext #x8781) (:vertex-shader-ext #x8780) (:vertex-shader-instructions-ext #x87CF) (:vertex-shader-invariants-ext #x87D1) (:vertex-shader-local-constants-ext #x87D2) (:vertex-shader-locals-ext #x87D3) (:vertex-shader-optimized-ext #x87D4) (:vertex-shader-variants-ext #x87D0) (:vertex-source-ati #x8774) (:vertex-state-program-nv #x8621) (:vertex-stream0-ati #x876C) (:vertex-stream1-ati #x876D) (:vertex-stream2-ati #x876E) (:vertex-stream3-ati #x876F) (:vertex-stream4-ati #x8770) (:vertex-stream5-ati #x8771) (:vertex-stream6-ati #x8772) (:vertex-stream7-ati #x8773) (:vertex-weight-array-ext #x850C) (:vertex-weight-array-pointer-ext #x8510) (:vertex-weight-array-size-ext #x850D) (:vertex-weight-array-stride-ext #x850F) (:vertex-weight-array-type-ext #x850E) (:vertex-weighting-ext #x8509) (:vertex23-bit-pgi #x4) (:vertex4-bit-pgi #x8) (:vibrance-bias-nv #x8719) (:vibrance-scale-nv #x8713) (:viewport #xBA2) (:viewport-bit #x800) (:w-ext #x87D8) (:weight-array-arb #x86AD) (:weight-array-buffer-binding #x889E) (:weight-array-buffer-binding-arb #x889E) (:weight-array-pointer-arb #x86AC) (:weight-array-size-arb #x86AB) (:weight-array-stride-arb #x86AA) (:weight-array-type-arb #x86A9) (:weight-sum-unity-arb #x86A6) (:wide-line-hint-pgi #x1A222) (:wrap-border-sun #x81D4) (:write-only #x88B9) (:write-only-arb #x88B9) (:write-pixel-data-range-length-nv #x887A) (:write-pixel-data-range-nv #x8878) (:write-pixel-data-range-pointer-nv #x887C) (:x-ext #x87D5) (:xor #x1506) (:y-ext #x87D6) (:ycbcr-422-apple #x85B9) (:ycbcr-mesa #x8757) (:ycrcb-422-sgix #x81BB) (:ycrcb-444-sgix #x81BC) (:ycrcb-sgix #x8318) (:ycrcba-sgix #x8319) (:z-ext #x87D7) (:zero #x0) (:zero-ext #x87DD) (:zoom-x #xD16) (:zoom-y #xD17))
94,343
Common Lisp
.lisp
2,975
28.713613
60
0.696827
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ede1964444902169c14d3a5b15257f95c7ba066748d9343b268902b021419e29
21,603
[ -1 ]
21,604
rasterization.lisp
rheaplex_minara/lib/cl-opengl/gl/rasterization.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; Copyright (c) 2004, Oliver Markovic <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions are met: ;;; ;;; o Redistributions of source code must retain the above copyright notice, ;;; this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may be ;;; used to endorse or promote products derived from this software without ;;; specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ;;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ;;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;;; POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-opengl) ;;; ;;; Chapter 3 - Rasterization ;;; ;;; ;;; 3.3 Points ;;; (import-export %gl:point-size) (defun point-parameter (pname value) (ecase pname ((:point-size-min :point-size-max :point-fade-threshold-size) (%gl:point-parameter-f pname value)) (:point-sprite-coord-origin (%gl:point-parameter-i pname (foreign-enum-value '%gl:enum value))) (:point-distance-attenuation (with-foreign-object (p '%gl:float 3) (dotimes (i 3) (setf (mem-aref p '%gl:float i) (elt value i))) (%gl:point-parameter-fv pname p))))) ;;; ;;; 3.4 Line Segments ;;; (import-export %gl:line-width %gl:line-stipple) ;;; ;;; 3.5 Polygons ;;; ;;; 3.5.1 Basic Polygon Rasterization (import-export %gl:cull-face) ;;; 3.5.2 Stippling (defun polygon-stipple (pattern) (with-opengl-sequence (p '%gl:ubyte pattern) (%gl:polygon-stipple p))) ;;; 3.5.4 Options Controlling Polygon Rasterization (import-export %gl:polygon-mode %gl:polygon-offset) ;;; ;;; 3.6 Pixel Rectangles ;;; ;;; 3.6.1 Pixel Storage Modes (defun pixel-store (pname value) (ecase pname ((:unpack-swap-bytes :unpack-lsb-first :pack-swap-bytes :pack-lsb-first) (%gl:pixel-store-i pname (if value 1 0))) ((:unpack-row-length :unpack-skip-rows :unpack-skip-pixels :unpack-alignment :unpack-image-height :unpack-skip-images :pack-row-length :pack-skip-rows :pack-skip-pixels :pack-alignment :pack-image-height :pack-skip-images) (%gl:pixel-store-i pname value)))) ;;; 3.6.3 Pixel Transfer Modes (defun pixel-transfer (pname value) (case pname ((:map-color :map-stencil) (%gl:pixel-transfer-i pname (if value 1 0))) ((:index-shift :index-offset) (%gl:pixel-transfer-i pname value)) (t (%gl:pixel-transfer-f pname value)))) (defun pixel-map (map values) (let ((n (length values))) (with-foreign-object (p '%gl:float n) (dotimes (i n) (setf (mem-aref p '%gl:float i) (elt values i))) (%gl:pixel-map-fv map n p)))) ;;; 3.6.4 Rasterization of Pixel Rectangles (defun draw-pixels (width height format type data) (with-pixel-array (array type data) (%gl:draw-pixels width height format type array))) ;;; ;;; 3.8 Texturing ;;; ;;; 3.8.1 Texture image specification (defun internal-format->int (format) (if (keywordp format) (foreign-enum-value '%gl:enum format) (if (and (numberp format) (< 0 format 5)) format (error "Internal format must be either a keyword or an integer ~ in the range [1,4].")))) (defun tex-image-3d (target level internal-format width height depth border format type data) (let ((internal-size (internal-format->int internal-format))) (if (pointerp data) (%gl:tex-image-3d target level internal-size width height depth border format type data) (with-pixel-array (array type data) (%gl:tex-image-3d target level internal-size width height depth border format type array))))) (defun tex-image-2d (target level internal-format width height border format type data) (let ((internal-size (internal-format->int internal-format))) (if (pointerp data) (%gl:tex-image-2d target level internal-size width height border format type data) (with-pixel-array (array type data) (%gl:tex-image-2d target level internal-size width height border format type array))))) (defun tex-image-1d (target level internal-format width border format type data) (let ((internal-size (internal-format->int internal-format))) (if (pointerp data) (%gl:tex-image-1d target level internal-size width border format type data) (with-pixel-array (array type data) (%gl:tex-image-1d target level internal-size width border format type array))))) ;;; 3.8.2 Alternate Texture Image Specification Commands (defun copy-tex-image-2d (target level internal-format x y width height border) (%gl:copy-tex-image-2d target level (internal-format->int internal-format) x y width height border)) (defun copy-tex-image-1d (target level internal-format x y width border) (%gl:copy-tex-image-1d target level (internal-format->int internal-format) x y width border)) (defun tex-sub-image-1d (target level xoffset width format type data) (if (pointerp data) (%gl:tex-sub-image-1d target level xoffset width format type data) (with-pixel-array (array type data) (%gl:tex-sub-image-1d target level xoffset width format type array)))) (defun tex-sub-image-2d (target level xoffset yoffset width height format type data) (if (pointerp data) (%gl:tex-sub-image-2d target level xoffset yoffset width height format type data) (with-pixel-array (array type data) (%gl:tex-sub-image-2d target level xoffset yoffset width height format type array)))) (defun tex-sub-image-3d (target level xoffset yoffset zoffset width height depth format type data) (if (pointerp data) (%gl:tex-sub-image-3d target level xoffset yoffset zoffset width height depth format type data) (with-pixel-array (array type data) (%gl:tex-sub-image-3d target level xoffset yoffset zoffset width height depth format type array)))) (import-export %gl:copy-tex-sub-image-1d %gl:copy-tex-sub-image-2d %gl:copy-tex-sub-image-3d) ;;; 3.8.3 Compressed Texture Images (defun compressed-tex-image-1d (target level internal-format width border data &optional (image-size (length data))) (if (pointerp data) (%gl:compressed-tex-image-1d target level internal-format width border image-size data) (with-pixel-array (array :unsigned-byte data) (%gl:compressed-tex-image-1d target level internal-format width border image-size array)))) (defun compressed-tex-image-2d (target level internal-format width height border data &optional (image-size (length data))) (if (pointerp data) (%gl:compressed-tex-image-2d target level internal-format width height border image-size data) (with-pixel-array (array :unsigned-byte data) (%gl:compressed-tex-image-2d target level internal-format width height border image-size array)))) (defun compressed-tex-image-3d (target level internal-format width height depth border data &optional (image-size (length data))) (if (pointerp data) (%gl:compressed-tex-image-3d target level internal-format width height depth border image-size data) (with-pixel-array (array :unsigned-byte data) (%gl:compressed-tex-image-3d target level internal-format width height depth border image-size array)))) (defun compressed-tex-sub-image-1d (target level xoffset width format data &optional (image-size (length data))) (if (pointerp data) (%gl:compressed-tex-sub-image-1d target level xoffset width format image-size data) (with-pixel-array (array :unsigned-byte data) (%gl:compressed-tex-sub-image-1d target level xoffset width format image-size array)))) (defun compressed-tex-sub-image-2d (target level xoffset yoffset width height format data &optional (image-size (length data))) (if (pointerp data) (%gl:compressed-tex-sub-image-2d target level xoffset yoffset width height format image-size data) (with-pixel-array (array :unsigned-byte data) (%gl:compressed-tex-sub-image-2d target level xoffset yoffset width height format image-size array)))) (defun compressed-tex-sub-image-3d (target level xoffset yoffset zoffset width height depth format data &optional (image-size (length data))) (if (pointerp data) (%gl:compressed-tex-sub-image-3d target level xoffset yoffset zoffset width height depth format image-size data) (with-pixel-array (array :unsigned-byte data) (%gl:compressed-tex-sub-image-3d target level xoffset yoffset zoffset width height depth format image-size array)))) ;;; 3.8.4 Texture parameters (defun tex-parameter (target pname param) (ecase pname ((:texture-wrap-s :texture-wrap-t :texture-wrap-r) (%gl:tex-parameter-i target pname (foreign-enum-value '%gl:enum param))) (:texture-min-filter (%gl:tex-parameter-i target pname (foreign-enum-value '%gl:enum param))) (:texture-mag-filter (%gl:tex-parameter-i target pname (foreign-enum-value '%gl:enum param))) (:texture-border-color (with-foreign-object (array '%gl:float 4) (dotimes (i 4) (setf (mem-aref array '%gl:float i) (elt param i))) (%gl:tex-parameter-fv target pname array))) ((:texture-priority :texture-min-lod :texture-max-lod) (%gl:tex-parameter-f target pname param)) ((:texture-base-level :texture-lod-bias) (%gl:tex-parameter-i target pname (truncate param))) (:depth-texture-mode (%gl:tex-parameter-i target pname (foreign-enum-value '%gl:enum param))) (:texture-compare-mode (%gl:tex-parameter-i target pname (foreign-enum-value '%gl:enum param))) (:texture-compare-func (%gl:tex-parameter-i target pname (foreign-enum-value '%gl:enum param))) (:generate-mipmap (%gl:tex-parameter-i target pname (if param 1 0))) (:texture-max-anisotropy-ext (%gl:tex-parameter-f target pname param)))) ;;; 3.8.12 Texture Objects (import-export %gl:bind-texture) (defun delete-textures (textures) (with-opengl-sequence (array '%gl:uint textures) (%gl:delete-textures (length textures) array))) (defun gen-textures (count) (with-foreign-object (texture-array '%gl:uint count) (%gl:gen-textures count texture-array) (loop for i below count collecting (mem-aref texture-array '%gl:uint i)))) ;;; The following two functions look awkward to use, so we'll provide the two ;;; lispier functions TEXTURE-RESIDENT-P and PRIORITIZE-TEXTURE, which can be ;;; used in mapping functions or like (every #'texture-resident-p texture-list). ;;; TODO: check whether the new gl:boolean semantics didn't break ;;; these functions. (defun are-textures-resident (textures) (let ((count (length textures))) (with-opengl-sequence (texture-array '%gl:uint textures) (with-foreign-object (residence-array '%gl:boolean count) (if (%gl:are-textures-resident count texture-array residence-array) (loop for i below count collecting (mem-aref residence-array '%gl:boolean i)) t))))) (defun prioritize-textures (textures priorities) (let ((texture-count (length textures)) (priority-count (length priorities))) (when (/= texture-count priority-count) (error "There needs to be an equal number of textures and priorities.")) (with-opengl-sequence (texture-array '%gl:uint textures) (with-opengl-sequence (priority-array '%gl:clampf priorities) (%gl:prioritize-textures texture-count texture-array priority-array))))) (defun texture-resident-p (texture) (with-foreign-objects ((texture-pointer '%gl:uint) (residence-pointer '%gl:boolean)) (setf (mem-ref texture-pointer '%gl:uint) texture) (%gl:are-textures-resident 1 texture-pointer residence-pointer))) (defun prioritize-texture (texture priority) (with-foreign-objects ((texture-pointer '%gl:uint) (priority-pointer '%gl:clampf)) (setf (mem-ref texture-pointer '%gl:uint) texture (mem-ref priority-pointer '%gl:clampf) priority) (%gl:prioritize-textures 1 texture-pointer priority-pointer))) ;;; 3.8.13 Texture Environments and Texture Functions ;;; Ye gods, have mercy! (defun tex-env (target pname value) (let (pname-value) (ecase target (:texture-filter-control (setf pname-value (foreign-enum-value '%gl:enum pname)) (ecase pname (:texture-lod-bias (%gl:tex-env-f target pname-value value)))) (:texture-env (setf pname-value (foreign-enum-value '%gl:enum pname)) (ecase pname (:texture-env-mode (%gl:tex-env-i target pname-value (foreign-enum-value '%gl:enum value))) (:texture-env-color (with-foreign-object (p '%gl:float 4) (dotimes (i 4) (setf (mem-aref p '%gl:float i) (elt value i))) (%gl:tex-env-fv target pname-value p))) (:combine-rgb (%gl:tex-env-i target pname-value (foreign-enum-value '%gl:enum value))) (:combine-alpha (%gl:tex-env-i target pname-value (foreign-enum-value '%gl:enum value))))) (:point-sprite (setf pname-value (foreign-enum-value '%gl:enum pname)) (ecase pname (:coord-replace (%gl:tex-env-i target pname-value (if value 1 0)))))))) ;;; ;;; 3.10 Fog ;;; (defun fog (pname param) (ecase pname (:fog-color (with-foreign-object (c '%gl:float 4) (dotimes (i 4) (setf (mem-aref c '%gl:float i) (elt param i))) (%gl:fog-fv pname c))) (:fog-mode (%gl:fog-i pname (foreign-enum-value '%gl:enum param))) (:fog-coord-src (%gl:fog-i pname (foreign-enum-value '%gl:enum param))) ((:fog-density :fog-start :fog-end) (%gl:fog-f pname param))))
15,841
Common Lisp
.lisp
329
40.021277
91
0.650117
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
aab3cc2b37a0c85f1540097cbd7d3b99b48f2854cf7c8a895ee24e18b1268972
21,604
[ -1 ]
21,605
glu.lisp
rheaplex_minara/lib/cl-opengl/glu/glu.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; glu.lisp --- Bindings to GLU routines. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glu) ;;;; Types (defcenum (string-name %gl:enum) (:version 100800) :extensions) ;;; Some GLU functions return an integer error code indicating success ;;; or failure. When the error code is zero, we can use glGetError to ;;; obtain the actual error that occurred. This type adds a ;;; translation to signal GLU-ERROR conditions for these errors. (defctype glu-result %gl:int) (define-foreign-type glu-result () () (:actual-type %gl:int) (:simple-parser glu-result)) ;;; Check GLU result codes and signal errors on zero values. (defmethod translate-from-foreign (value (type glu-result)) (when (zerop value) (gl:check-error)) value) ;;;; 2. Initialization (defcfun ("gluGetString" get-string) :string (name-keyword string-name)) #-windows (defcfun ("gluCheckExtension" check-extension) %gl:boolean (extension-name :string) (extension-string :string)) ;;;; 3. Mipmapping ;;; TODO: make this struct or an object ;;;; 3.1 Image Scaling (defcfun ("gluScaleImage" %gluScaleImage) :int (format %gl:enum) (width-in %gl:sizei) (height-in %gl:sizei) (type-in %gl:enum) (data-in :pointer) (width-out %gl:sizei) (height-out %gl:sizei) (type-out %gl:enum) (data-out :pointer)) ;;(defun scale-image (format width-in height-in type-in data-in ;; or just a glu:image object, instead of all these ;; arguments. ;; width-out height-out type-out) ;; allocate data-out ;; call gluScaleImage(), check for errors ;;) ;;;; 3.2 Automatic Mipmapping ;;; TODO: gluBuild{1,3}DMipmaps; gluBuild{1,2,3}DMipmapLevels (defcfun ("gluBuild2DMipmaps" %GluBuild2DMipmaps) :void (target %gl:enum) (internalformat %gl:int) (width %gl:sizei) (height %gl:sizei) (format %gl:enum) (type %gl:enum) (data :pointer)) (defun build-2d-mipmaps (target internal-format width height format type data) (let ((internal-size (gl::internal-format->int internal-format))) (if (pointerp data) (%gluBuild2dMipmaps target internal-size width height format type data) (gl::with-pixel-array (array type data) (%gluBuild2dMipmaps target internal-size width height format type array))))) ;;;; 4. Matrix Manipulation ;;;; 4.1 Matrix Setup (defcfun ("gluOrtho2D" ortho-2d) :void (left %gl:double) (right %gl:double) (bottom %gl:double) (top %gl:double)) (defcfun ("gluPerspective" perspective) :void (fov-y %gl:double) (aspect %gl:double) (zNear %gl:double) (zFar %gl:double)) (defcfun ("gluLookAt" look-at) :void (eye-x %gl:double) (eye-y %gl:double) (eye-z %gl:double) (center-x %gl:double) (center-y %gl:double) (center-z %gl:double) (up-x %gl:double) (up-y %gl:double) (up-z %gl:double)) (defcfun ("gluPickMatrix" %gluPickMatrix) :void (x %gl:double) (y %gl:double) (delta-x %gl:double) (delta-y %gl:double) (viewport :pointer)) (defun pick-matrix (x y delta-x delta-y viewport) (assert (= (length viewport) 4)) (gl::with-opengl-sequence (array '%gl:int viewport) (%gluPickMatrix x y delta-x delta-y array))) ;;;; 4.2 Coordinate Projection (defcfun ("gluProject" %gluProject) glu-result (obj-x %gl:double) (obj-y %gl:double) (obj-z %gl:double) (modelview (:pointer %gl:double)) (projection (:pointer %gl:double)) (viewport (:pointer %gl:int)) (win-x (:pointer %gl:double)) (win-y (:pointer %gl:double)) (win-z (:pointer %gl:double))) (defcfun ("gluUnProject" %gluUnProject) glu-result (win-x %gl:double) (win-y %gl:double) (win-z %gl:double) (modelview (:pointer %gl:double)) (projection (:pointer %gl:double)) (viewport (:pointer %gl:int)) (obj-x (:pointer %gl:double)) (obj-y (:pointer %gl:double)) (obj-z (:pointer %gl:double))) #-cffi-features:windows (defcfun ("gluUnProject4" %gluUnProject4) glu-result (win-x %gl:double) (win-y %gl:double) (win-z %gl:double) (clip-w %gl:double) (modelview (:pointer %gl:double)) (projection (:pointer %gl:double)) (viewport (:pointer %gl:int)) (near %gl:double) (far %gl:double) (obj-x (:pointer %gl:double)) (obj-y (:pointer %gl:double)) (obj-z (:pointer %gl:double)) (obj-w (:pointer %gl:double))) ;;; Bind each symbol in NAMES to a foreign double float allocated with ;;; dynamic-extent, returing the final value of each of them as ;;; multiple values. The return value of BODY is ignored. (defmacro with-double-floats/values (names &body body) `(with-foreign-objects (,@(mapcar (lambda (name) `(,name '%gl:double)) names)) ,@body (values ,@(mapcar (lambda (name) `(mem-ref ,name '%gl:double)) names)))) ;;; Rebind MODEL, PROJ, and VIEWPORT to foreign arrays of the ;;; appropriate type to contain the modelview matrix, projection ;;; matrix, and viewport for calls to GLU projection functions. (defmacro with-projection-arrays ((model proj viewport) &body body) (gl::once-only (model proj viewport) `(progn (assert (= (length ,model) 16)) (assert (= (length ,proj) 16)) (assert (= (length ,viewport) 4)) (gl::with-opengl-arrays ((,model '%gl:double ,model) (,proj '%gl:double ,proj) (,viewport '%gl:int ,viewport)) ,@body)))) ;;; Map object coordinates to window coordinates. The MODELVIEW ;;; matrix, PROJECTION matrix, and VIEWPORT dimensions will be queried ;;; from the OpenGL state if not supplied. Returns the window X, Y, ;;; and Z as multiple values. (defun project (obj-x obj-y obj-z &key (modelview (gl:get-double :modelview-matrix)) (projection (gl:get-double :projection-matrix)) (viewport (gl:get-integer :viewport))) (with-projection-arrays (modelview projection viewport) (with-double-floats/values (x y z) (%gluProject obj-x obj-y obj-z modelview projection viewport x y z)))) ;;; Map window coordinates to object coordinates. The MODELVIEW ;;; matrix, PROJECTION matrix, and VIEWPORT dimensions will be queried ;;; from the OpenGL state if not supplied. Returns the object X, Y, ;;; and Z as multiple values. (defun un-project (win-x win-y win-z &key (modelview (gl:get-double :modelview-matrix)) (projection (gl:get-double :projection-matrix)) (viewport (gl:get-integer :viewport))) (with-projection-arrays (modelview projection viewport) (with-double-floats/values (x y z) (%gluUnProject win-x win-y win-z modelview projection viewport x y z)))) ;;; Map window and clip coordinates to object coordinates. The ;;; MODELVIEW matrix, PROJECTION matrix, and VIEWPORT dimensions will ;;; be queried from the OpenGL state if not supplied. Returns the ;;; object X, Y, Z, and W as multiple values. (defun un-project4 (win-x win-y win-z clip-w &key (near 0.0d0) (far 1.0d0) (modelview (gl:get-double :modelview-matrix)) (projection (gl:get-double :projection-matrix)) (viewport (gl:get-integer :viewport))) (with-projection-arrays (modelview projection viewport) (with-double-floats/values (x y z w) (%gluUnProject4 win-x win-y win-z clip-w modelview projection viewport near far x y z w)))) ;;;; 5. Polygon Tessellation ;;; TODO: make an object for these too.. ;;;; 5.1 The Tessellation Object (defctype tesselator :pointer) (defcfun ("gluNewTess" new-tess) tesselator) (defcfun ("gluDeleteTess" delete-tess) :void (tess-obj tesselator)) ;;;; 5.2 Polygon Definition (defcfun ("gluTessBeginPolygon" tess-begin-polygon) :void (tess tesselator) (polygon-data :pointer)) (defcfun ("gluTessBeginContour" tess-begin-contour) :void (tess tesselator)) (defcfun ("gluTessVertex" tess-vertex) :void (tess tesselator) (coords :pointer) ; GLdouble coords[3] (vertex-data :pointer)) (defcfun ("gluTessEndContour" tess-end-contour) :void (tess tesselator)) (defcfun ("gluTessEndPolygon" tess-end-polygon) :void (tess tesselator)) ;;;; 5.3 Callbacks ;;; TODO ;;(defcfun ("gluTessCallback" tess-callback) :void ;; ) ;;;; 5.4 Control Over Tessellation ;;(defcfun ("gluTessProperty" tess-property) :void ;; ) ;;;; 5.7 Backwards Compatibility ;;; We don't bother defining gluBeginPolygon(), gluNextContour() and ;;; gluEndPolygon(). ;;;; 6. Quadrics ;;;; 6.1 The Quadrics Object ;;; TODO: make a clos class for these too (defctype quadric-obj :pointer) (defcfun ("gluNewQuadric" new-quadric) quadric-obj) (defcfun ("gluDeleteQuadric" delete-quadric) :void (quadric-object quadric-obj)) ;;;; 6.2 Callbacks ;;; TODO ;;(defcfun ("gluQuadricCallback" quadric-callback) :void ;; (quadric-object quadric-obj) ;; ...) ;;;; 6.3 Rendering Styles (defcfun ("gluQuadricTexture" quadric-texture) :void (quadric-object quadric-obj) (texture-coords %gl:boolean)) (defcenum glu-orientation (:outside #x186B4) (:inside #x186B5)) (defcfun ("gluQuadricOrientation" quadric-orientation) :void (quadric-object quadric-obj) (orientation glu-orientation)) (defcenum glu-normals (:smooth #x186A0) (:flat #x186A1) (:none #x186A2)) (defcfun ("gluQuadricNormals" quadric-normals) :void (quadric-object quadric-obj) (normals glu-normals)) ;; gluQuadricDrawStyle ;;;; 6.4 Quadrics Primitives (defcfun ("gluSphere" sphere) :void (quadric-object quadric-obj) (radius %gl:double) (slices %gl:int) (stacks %gl:int)) (defcfun ("gluCylinder" cylinder) :void (quadric-object quadric-obj) (base-radius %gl:double) (top-radius %gl:double) (height %gl:double) (slices %gl:int) (stacks %gl:int)) (defcfun ("gluDisk" disk) :void (quadric-object quadric-obj) (inner-radius %gl:double) (outer-radius %gl:double) (slices %gl:int) (loops %gl:int)) (defcfun ("gluPartialDisk" partial-disk) :void (quadric-object quadric-obj) (inner-radius %gl:double) (outer-radius %gl:double) (slices %gl:int) (loops %gl:int) (start-angle %gl:double) (sweep-angle %gl:double)) ;;;; 7. NURBS ;;;; 7.1 The NURBS Object (defctype nurbs-obj :pointer) (defcfun ("gluNewNurbsRenderer" new-nurbs-renderer) nurbs-obj) (defcfun ("gluDeleteNurbsRenderer" delete-nurbs-renderer) :void (nurbs-object nurbs-obj)) ;;;; 7.2 Callbacks ;;; TODO ;;(defcfun ("gluNurbsCallback" nurbs-callback) :void ;; ) ;;;; 7.3 NURBS Curves (defcfun ("gluBeginCurve" begin-curve) :void (nurbs-object nurbs-obj)) ;; (defcfun ("gluNurbsCurve" nurbs-curve) :void ;; (nurbs-object nurbs-obj) ;; (n-knots %gl:int) ;; ...) ;;; 7.4 NURBS Surfaces (defcfun ("gluBeginSurface" begin-surface) :void (nurbs-object nurbs-obj)) ;;(defcfun ("gluNurbsSurface" nurbs-surface) :void ;; ...) (defcfun ("gluEndSurface" end-surface) :void (nurbs-object nurbs-obj)) ;;;; 7.5 Trimming (defcfun ("gluBeginTrim" begin-trim) :void (nurbs-object nurbs-obj)) ;;(defcfun ("gluPwlCurve" pwl-curve) :void ;; ...) ;;(defcfun ("gluNurbsCurve" nurbs-curve) :void ;; ...) (defcfun ("gluEndTrim" end-trim) :void (nurbs-object nurbs-obj)) ;;;; 7.6 NURBS Properties ;;(defcfun ("gluNurbsProperty" nurbs-property) :void ;; ...) ;;(defcfun ("gluLoadSamplingMatrices" load-sampling-matrices) :void ;; ...) ;;(defcfun ("gluGetNurbsProperty" get-nurbs-property) :void ;; (nurbs-object nurbs-obj) ;; ...) ;;;; 8. Errors ;; maybe this could be a subclass of opengl-error? (define-condition glu-error (simple-error) ((error-message :initarg :message)) (:report (lambda (c s) (write-string (slot-value c 'error-message) s)))) (defcenum (error-codes %gl:enum) (:invalid-enum 100900) :invalid-value :out-of-memory :incompatible-gl-version :invalid-operation ;; plus NURBS, Quadrics and Tesselation errors? ;; probably not necessary ) (defcfun ("gluErrorString" error-string) :string (error-code %gl:enum))
13,689
Common Lisp
.lisp
366
33.797814
79
0.692174
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
81bd9814e6d696b6f6ff3ea414e729ce38f794e57729d7f0e852a423d6e85f82
21,605
[ 378979 ]
21,606
package.lisp
rheaplex_minara/lib/cl-opengl/glu/package.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; package.lisp --- Package definition for cl-glu. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-user) (defpackage #:cl-glu (:nicknames #:glu) (:use #:cl #:cffi) (:export ;;# Functions #:quadric-texture #:quadric-orientation #:quadric-normals #:new-quadric #:quadric-normals #:sphere #:build-2d-mipmaps #:get-string #:check-extension #:scale-image #:ortho-2d #:perspective #:look-at #:pick-matrix #:project #:un-project #:un-project4))
2,146
Common Lisp
.lisp
54
37.592593
75
0.73445
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
c524aedba263b7a393606b568ef23728ce795480163c0c6e047caf500a54a817
21,606
[ 456580 ]
21,607
library.lisp
rheaplex_minara/lib/cl-opengl/glu/library.lisp
;;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; library.lisp --- GLU foreign library definition. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glu) ;;; On darwin GLU is part of the OpenGL framework and thus ;;; is loaded already by cl-opengl, on which cl-glu depends. (define-foreign-library glu (:windows "glu32.dll") ; XXX? ((:and :unix (:not :darwin)) (:or "libGLU.so.1" "libGLU.so")) ((:not :darwin) (:default "libGLU"))) (use-foreign-library glu)
2,065
Common Lisp
.lisp
39
51.717949
75
0.745428
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
7a6794741fdce0bbd330d0096cce075afaf638fbe72e141c82b7f4d37e08a6c4
21,607
[ -1 ]
21,608
package.lisp
rheaplex_minara/lib/cl-opengl/glut/package.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; package.lisp --- cl-glut package definition. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-user) (defpackage #:cl-glut (:nicknames #:glut) (:use #:cl #:cffi) (:shadow #:get) (:export ;; Enums and Bitfields #:cursor #:device-get-param #:display-mode #:entry-state #:color-component #:game-mode-param #:get-param #:layer-get-param #:layer-type #:menu-state #:modifiers #:video-resize-param #:mouse-button #:mouse-button-state #:key-repeat-mode #:rendering-context #:rendering-context-options #:joystick-buttons #:special-keys #:visibility-state #:options ; freeglut ext #:window-close-behaviour ; freeglut ext #:window-status ;; initialization api #:init #:init-display-mode #:init-display-string #:init-window-size #:init-window-position ;; event loop api #:main-loop #:main-loop-event #:leave-main-loop ;; window api #:create-window #:create-sub-window #:destroy-window #:set-window #:get-window #:set-window-title #:set-icon-title #:reshape-window #:position-window #:show-window #:hide-window #:iconify-window #:push-window #:pop-window #:full-screen #:post-window-redisplay #:post-redisplay #:swap-buffers #:warp-pointer #:set-cursor ;; overlay management api #:establish-overlay #:remove-overlay #:use-layer #:post-overlay-redisplay #:post-window-overlay-redisplay #:show-overlay #:hide-overlay ;; menu management api #:create-menu #:destroy-menu #:get-menu #:set-menu #:add-menu-entry #:add-sub-menu #:change-to-menu-entry #:change-to-sub-menu #:remove-menu-item #:attach-menu #:detach-menu ;; window callback api #:timer-func #:idle-func #:keyboard-func #:special-func #:reshape-func #:visibility-func #:display-func #:mouse-func #:motion-func #:passive-motion-func #:entry-func #:menu-state-func #:spaceball-motion-func #:spaceball-rotate-func #:spaceball-button-func #:button-box-func #:dials-func #:tablet-motion-func #:tablet-button-func #:dials-func #:menu-status-func #:overlay-display-func #:window-status-func #:keyboard-up-func #:special-up-func #:joystick-func #:mouse-wheel-func ; freeglut ext #:close-func ; freeglut ext #:wm-close-func ; freeglut ext #:menu-destroy-func ; freeglut ext ;; state api #:set-option ; freeglut ext #:set-display-mode #:set-action-on-window-close #:set-rendering-context #:set-direct-rendering #:get #:getp #:get-window-cursor #:get-init-display-mode #:device-get #:device-getp #:layer-get #:layer-getp #:get-layer-in-use #:get-modifers #:get-modifier-values #:extension-supported-p #:get-proc-address ;; font rendering api #:+stroke-roman+ #:+stroke-mono-roman+ #:+bitmap-9-by-15+ #:+bitmap-8-by-13+ #:+bitmap-times-roman-10+ #:+bitmap-times-roman-24+ #:+bitmap-helvetica-10+ #:+bitmap-helvetica-12+ #:+bitmap-helvetica-18+ #:bitmap-character #:bitmap-width #:stroke-character #:stroke-width #:bitmap-length ; freeglut ext? #:stroke-length ; freeglut ext? #:bitmap-height ; freeglut ext #:stroke-height ; freeglut ext #:bitmap-string ; freeglut ext #:stroke-string ; freeglut ext ;; geometry api #:wire-cube #:solid-cube #:wire-sphere #:solid-sphere #:wire-cone #:solid-cone #:wire-torus #:solid-torus #:wire-dodecahedron #:solid-dodecahedron #:wire-octahedron #:solid-octahedron #:wire-tetrahedron #:solid-tetrahedron #:wire-icosahedron #:solid-icosahedron #:wire-teapot #:solid-teapot #:wire-rhombic-dodecahedron ; freeglut ext #:solid-rhombic-dodecahedron ; freeglut ext #:wire-sierpinski-sponge ; freeglut ext #:solid-sierpinski-sponge ; freeglut ext #:wire-cylinder ; freeglut ext #:solid-cylinder ; freeglut ext ;; game mode api #:game-mode-string #:enter-game-mode #:leave-game-mode #:game-mode-get #:game-mode-getp ;; video resize api (unimplemented by freeglut) #:video-resize-get #:setup-video-resizing #:stop-video-resizing #:video-resize #:video-pan ;; misc #:set-color #:get-color #:copy-colormap #:ignore-key-repeat #:set-key-repeat #:force-joystick-func #:report-errors ))
6,432
Common Lisp
.lisp
228
24.600877
75
0.652989
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
0fe2dab15434fdc0a74889fade88a3ff6cd2372bebebeee24b3126c1a4654c24
21,608
[ 148155 ]
21,609
overlay.lisp
rheaplex_minara/lib/cl-opengl/glut/overlay.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; overlay.lisp --- GLUT Overlay Management API. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glut) (defcfun ("glutEstablishOverlay" establish-overlay) :void) (defcfun ("glutRemoveOverlay" remove-overlay) :void) (defcenum (layer-type %gl:enum) :normal :overlay) (defcfun ("glutUseLayer" use-layer) :void (layer layer-type)) (defcfun ("glutPostOverlayRedisplay" post-overlay-redisplay) :void) (defcfun ("glutPostWindowOverlayRedisplay" post-window-overlay-redisplay) :void (window-id :int)) (defcfun ("glutShowOverlay" show-overlay) :void) (defcfun ("glutHideOverlay" hide-overlay) :void)
2,251
Common Lisp
.lisp
44
49.840909
79
0.761472
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e40ae3ed75bf5264848c5496c320cc64c6c28596a90f84a960935c3a3c9e09b4
21,609
[ -1 ]
21,610
callbacks.lisp
rheaplex_minara/lib/cl-opengl/glut/callbacks.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; callbacks.lisp --- GLUT Callback Registration API. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glut) ;;; Low-level functions (exported nevertheless) (defcfun ("glutTimerFunc" timer-func) :void (millis :unsigned-int) (callback-pointer :pointer) ; void (*func)(int value) (value :int)) (defcfun ("glutIdleFunc" idle-func) :void ;; void (*func)(void) (callback-pointer :pointer)) (defcfun ("glutKeyboardFunc" keyboard-func) :void ;; void (*func)(unsigned char int, int x, int y) (callback-pointer :pointer)) (defcfun ("glutSpecialFunc" special-func) :void ;; void (*func)(int key, int x, int y) (callback-pointer :pointer)) (defcfun ("glutReshapeFunc" reshape-func) :void ;; void (*func)(int width, int height) (callback-pointer :pointer)) (defcfun ("glutVisibilityFunc" visibility-func) :void ;; void (*func)(int state) (callback-pointer :pointer)) (defcfun ("glutDisplayFunc" display-func) :void ;; void (*func)(void) (callback-pointer :pointer)) (defcfun ("glutMouseFunc" mouse-func) :void ;; void (*func)(int button, int state, int x, int y) (callback-pointer :pointer)) (defcfun ("glutMotionFunc" motion-func) :void ;; void (*func)(int x, int y) (callback-pointer :pointer)) (defcfun ("glutPassiveMotionFunc" passive-motion-func) :void ;; void (*func)(int x, int y) (callback-pointer :pointer)) (defcfun ("glutEntryFunc" entry-func) :void ;; void (*func)(int state) (callback-pointer :pointer)) (defcfun ("glutMenuStateFunc" menu-state-func) :void ;; void (*func)(int state) (callback-pointer :pointer)) (defcfun ("glutSpaceballMotionFunc" spaceball-motion-func) :void ;; void (*func)(int x, int y, int z) (callback-pointer :pointer)) (defcfun ("glutSpaceballRotateFunc" spaceball-rotate-func) :void ;; void (*func)(int x, int y, int z) (callback-pointer :pointer)) (defcfun ("glutSpaceballButtonFunc" spaceball-button-func) :void ;; void (*func)(int button, int state) (callback-pointer :pointer)) (defcfun ("glutButtonBoxFunc" button-box-func) :void ;; void (*func)(int button, int state) (callback-pointer :pointer)) (defcfun ("glutDialsFunc" dials-func) :void ;; void (*func)(int dial, int value) (callback-pointer :pointer)) (defcfun ("glutTabletMotionFunc" tablet-motion-func) :void ;; void (*func)(int x, int y) (callback-pointer :pointer)) (defcfun ("glutTabletButtonFunc" tablet-button-func) :void ;; void (*func)(int button, int state, int x, int y) (callback-pointer :pointer)) (defcfun ("glutMenuStatusFunc" menu-status-func) :void ;; void (*func)(int status, int x, int y) (callback-pointer :pointer)) (defcfun ("glutOverlayDisplayFunc" overlay-display-func) :void ;; void (*func)(void) (callback-pointer :pointer)) (defcfun ("glutWindowStatusFunc" window-status-func) :void ;; void (*func)(int state) (callback-pointer :pointer)) (defcfun ("glutKeyboardUpFunc" keyboard-up-func) :void ;; void (*func)(unsigned char key, int x, int y) (callback-pointer :pointer)) (defcfun ("glutSpecialUpFunc" special-up-func) :void ;; void (*func)(int key, int x, int y) (callback-pointer :pointer)) (defcfun ("glutJoystickFunc" joystick-func) :void ;; void (*func)(unsigned int buttonMask, int x, int y, int z) (callback-pointer :pointer) (poll-interval :int)) ;; freeglut ext (defcfun ("glutMouseWheelFunc" mouse-wheel-func) :void ;; void (*func)(int button, int pressed, int x, int y) (callback-pointer :pointer)) ;; freeglut ext (defcfun ("glutCloseFunc" close-func) :void ;; void (*func)(void) (callback-pointer :pointer)) ;; freeglut ext (defcfun ("glutWMCloseFunc" wm-close-func) :void ;; void (*func)(void) (callback-pointer :pointer)) ;; freeglut ext (defcfun ("glutMenuDestroyFunc" menu-destroy-func) :void ;; void (*func)(void) (callback-pointer :pointer)) ;;;; Types used for callbacks. (defcenum entry-state :left :entered) (defbitfield (joystick-buttons :unsigned-int) (:joystick-button-a 1) (:joystick-button-b 2) (:joystick-button-c 4) (:joystick-button-d 8)) (defcenum menu-state :menu-not-in-use :menu-in-use) (defbitfield modifiers (:active-shift 1) (:active-ctrl 2) (:active-alt 4)) (defcenum mouse-button :left-button :middle-button :right-button :wheel-up :wheel-down :button4 :button5 :button6 :button7) (defcenum mouse-button-state (:wheel-down -1) :down :up) (defcenum special-keys ;; Function keys. (:key-f1 1) :key-f2 :key-f3 :key-f4 :key-f5 :key-f6 :key-f7 :key-f8 :key-f9 :key-f10 :key-f11 :key-f12 ;; Directional keys. (:key-left 100) :key-up :key-right :key-down :key-page-up :key-page-down :key-home :key-end :key-insert) (defcenum visibility-state :not-visible :visible) (defcenum window-status :hidden :fully-retained :partially-retained :fully-covered)
6,507
Common Lisp
.lisp
188
32.196809
75
0.723045
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
54bf845cced8c61000f4dbc0fc9ffc635a63d2341f1d535f8481906bed01f423
21,610
[ -1 ]
21,611
menu.lisp
rheaplex_minara/lib/cl-opengl/glut/menu.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; menu.lisp --- GLUT Menu Management API. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glut) ;;; TODO: high-level interface (defcfun ("glutCreateMenu" create-menu) :int (callback :pointer)) ; void (*callback)(int menu) (defcfun ("glutDestroyMenu" destroy-menu) :void (menu-id :int)) (defcfun ("glutGetMenu" get-menu) :int) (defcfun ("glutSetMenu" set-menu) :void (menu-id :int)) (defcfun ("glutAddMenuEntry" add-menu-entry) :void (label :string) (value :int)) (defcfun ("glutAddSubMenu" add-sub-menu) :void (label :string) (sub-menu-id :int)) (defcfun ("glutChangeToMenuEntry" change-to-menu-entry) :void (item :int) (label :string) (value :int)) (defcfun ("glutChangeToSubMenu" change-to-sub-menu) :void (item :int) (label :string) (value :int)) (defcfun ("glutRemoveMenuItem" remove-menu-item) :void (item :int)) (defcfun ("glutAttachMenu" attach-menu) :void (button :int)) (defcfun ("glutDetachMenu" detach-menu) :void (button :int))
2,630
Common Lisp
.lisp
60
42.116667
75
0.740914
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
25d9bb870c04419d6fc98d834cf13d739d453d1704ccb8937fd2424e0801d6ee
21,611
[ -1 ]
21,612
library.lisp
rheaplex_minara/lib/cl-opengl/glut/library.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; library.lisp --- GLUT foreign library definition. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package :cl-glut) (define-foreign-library glut (:darwin (:or "libglut.dylib" "libglut.3.dylib")) (:windows "freeglut.dll") (:unix (:or "libglut.so" "libglut.so.3"))) (use-foreign-library glut)
1,936
Common Lisp
.lisp
37
51.108108
75
0.751186
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
cc5fa005f0b4187bf5c3bf03b30dd3a196492031c4d5daf94b8c54a141f35e11
21,612
[ 126994 ]
21,613
main.lisp
rheaplex_minara/lib/cl-opengl/glut/main.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; main.lisp --- GLUT Event Processing API. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glut) (defcfun ("glutMainLoop" %glutMainLoop) :void) (defun main-loop () (without-fp-traps (%glutMainLoop)) (init)) (defcfun ("glutMainLoopEvent" main-loop-event) :void) (defcfun ("glutLeaveMainLoop" leave-main-loop) :void)
1,974
Common Lisp
.lisp
39
49.307692
75
0.753496
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
9a69d07558a786859cbac740279b0f8d7481b9a256c4655d460e99ee005db8fd
21,613
[ -1 ]
21,614
fonts.lisp
rheaplex_minara/lib/cl-opengl/glut/fonts.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; fonts.lisp --- GLUT Font Rendering API. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glut) ;;; Erm, should we want CLISP cross-platform fasl portability I think ;;; those conditionals should be changed to calls to FEATURE-P. ;;; Ugh, freeglut's font macros seem to expand into a pointer to ;;; to a couple of global variables that point somewhere else. ;;; Unless it's windows, in which case it's a sort of enum-as-pointer ;;; thing. "So here it goes:" (defparameter +stroke-roman+ #+windows (make-pointer 0) #-windows (foreign-symbol-pointer "glutStrokeRoman")) (defparameter +stroke-mono-roman+ #+windows (make-pointer 1) #-windows (foreign-symbol-pointer "glutStrokeMonoRoman")) (defparameter +bitmap-9-by-15+ #+windows (make-pointer 2) #-windows (foreign-symbol-pointer "glutBitmap9By15")) (defparameter +bitmap-8-by-13+ #+windows (make-pointer 3) #-windows (foreign-symbol-pointer "glutBitmap8By13")) (defparameter +bitmap-times-roman-10+ #+windows (make-pointer 4) #-windows (foreign-symbol-pointer "glutBitmapTimesRoman10")) (defparameter +bitmap-times-roman-24+ #+windows (make-pointer 5) #-windows (foreign-symbol-pointer "glutBitmapTimesRoman24")) (defparameter +bitmap-helvetica-10+ #+windows (make-pointer 6) #-windows (foreign-symbol-pointer "glutBitmapHelvetica10")) (defparameter +bitmap-helvetica-12+ #+windows (make-pointer 7) #-windows (foreign-symbol-pointer "glutBitmapHelvetica12")) (defparameter +bitmap-helvetica-18+ #+windows (make-pointer 8) #-windows (foreign-symbol-pointer "glutBitmapHelvetica18")) ;;; Functions ;;; Do we want CHAR-CODE conversion here? (defcfun ("glutBitmapCharacter" bitmap-character) :void (font :pointer) (character :int)) (defcfun ("glutBitmapWidth" bitmap-width) :int (font :pointer) (character :int)) (defcfun ("glutStrokeCharacter" stroke-character) :void (font :pointer) (character :int)) (defcfun ("glutStrokeWidth" stroke-width) :int (font :pointer) (character :int)) ;; freeglut ext? (defcfun ("glutBitmapLength" bitmap-length) :int (font :pointer) (string :string)) ;; freeglut ext? (defcfun ("glutStrokeLength" stroke-length) :int (font :pointer) (string :string)) ;; freeglut ext (defcfun ("glutBitmapHeight" bitmap-height) :int (font :pointer)) ;; freeglut ext (defcfun ("glutStrokeHeight" stroke-height) %gl:float (font :pointer)) ;; freeglut ext (defcfun ("glutBitmapString" bitmap-string) :void (font :pointer) (string :string)) ;; freeglut ext (defcfun ("glutStrokeString" stroke-string) :void (font :pointer) (string :string))
4,241
Common Lisp
.lisp
101
40.049505
75
0.751761
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
025168fbfe5cb9adb470122ebd20266574b2150f374cd7caa2d223f51430c31e
21,614
[ -1 ]
21,615
window.lisp
rheaplex_minara/lib/cl-opengl/glut/window.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; window.lisp --- GLUT window management API. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glut) ;;; TODO: make sure if it's safe to free the window title ;;; right after calling glutCreateWindow(). (defcfun ("glutCreateWindow" create-window) :int (title :string)) (defcfun ("glutCreateSubWindow" create-sub-window) :int (window-id :int) (x :int) (y :int) (width :int) (height :int)) (defcfun ("glutDestroyWindow" destroy-window) :void (window-id :int)) (defcfun ("glutSetWindow" set-window) :void (window-id :int)) (defcfun ("glutGetWindow" get-window) :int) ;;; Do we need to be paranoid here too? See create-window. (defcfun ("glutSetWindowTitle" set-window-title) :void (string :string)) (defcfun ("glutSetIconTitle" set-icon-title) :void (string :string)) (defcfun ("glutReshapeWindow" reshape-window) :void (width :int) (height :int)) (defcfun ("glutPositionWindow" position-window) :void (x :int) (y :int)) (defcfun ("glutShowWindow" show-window) :void) (defcfun ("glutHideWindow" hide-window) :void) (defcfun ("glutIconifyWindow" iconify-window) :void) (defcfun ("glutPushWindow" push-window) :void) (defcfun ("glutPopWindow" pop-window) :void) (defcfun ("glutFullScreen" full-screen) :void) (defcfun ("glutPostWindowRedisplay" post-window-redisplay) :void (window-id :int)) (defcfun ("glutPostRedisplay" post-redisplay) :void) (defcfun ("glutSwapBuffers" swap-buffers) :void) ;; freeglut ext? (defcfun ("glutWarpPointer" warp-pointer) :void (x :int) (y :int)) (defcenum cursor :cursor-right-arrow :cursor-left-arrow :cursor-info :cursor-destroy :cursor-help :cursor-cycle :cursor-spray :cursor-wait :cursor-text :cursor-crosshair :cursor-up-down :cursor-left-right :cursor-top-side :cursor-bottom-side :cursor-left-side :cursor-right-side :cursor-top-left-corner :cursor-top-right-corner :cursor-bottom-right-corner :cursor-bottom-left-corner (:cursor-inherit #x0064) :cursor-none :cursor-full-crosshair) (defcfun ("glutSetCursor" set-cursor) :void (cursor cursor))
3,722
Common Lisp
.lisp
98
35.989796
75
0.746467
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
44a306c8f34a45ae6231fa30a49d4c95239ed8bf8caf0d7b5c94420d76de054a
21,615
[ -1 ]
21,616
state.lisp
rheaplex_minara/lib/cl-opengl/glut/state.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; state.lisp --- GLUT Window state setting and retrieval API. ;;; ;;; Copyright (c) 2006, Alexey Dvoychenkov ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glut) ;;; Unimplemented freeglut extensions: ;;; ;;; FGAPI void* FGAPIENTRY glutGetWindowData( void ); ;;; FGAPI void FGAPIENTRY glutSetWindowData(void* data); ;;; FGAPI void* FGAPIENTRY glutGetMenuData( void ); ;;; FGAPI void FGAPIENTRY glutSetMenuData(void* data); ;;; Setting Options ;; freeglut ext (defcenum (options %gl:enum) (:init-window-x #x01F4) :init-window-y :init-window-width :init-window-height :init-display-mode :action-on-window-close (:rendering-context #x01FD) :direct-rendering (:window-cursor #x007A)) ;;; freeglut ext (defcfun ("glutSetOption" set-option) :void (option options) (value :int)) ;;; Also provide some utility functions around glutSetOption(). ;; freeglut ext (defcenum rendering-context :create-new-context :use-current-context) ;; freeglut ext (defcenum rendering-context-options :force-indirect-context :allow-direct-context :try-direct-context :force-direct-context) ;; freeglut ext (defcenum window-close-behaviour :action-exit :action-glutmainloop-returns :action-continue-execution) (defbitfield (display-mode :unsigned-int) (:rgb 0) (:rgba 0) (:index 1) (:single 0) (:double 2) (:accum 4) (:alpha 8) (:depth 16) (:stencil 32) (:multisample 128) (:stereo 256) (:luminance 512) (:aux1 #x1000) ; freeglut ext (:aux2 #x2000) ; freeglut ext (:aux3 #x4000) ; freeglut ext (:aux4 #x8000)) ; freeglut ext (defun set-display-mode (&rest options) (set-option :init-display-mode (foreign-bitfield-value 'display-mode options))) (defun set-action-on-window-close (action) (set-option :action-on-window-close (foreign-enum-value 'window-close-behaviour action))) (defun set-rendering-context (option) (set-option :rendering-context (foreign-enum-value 'rendering-context option))) (defun set-direct-rendering (option) (set-option :direct-rendering (foreign-enum-value 'rendering-context-options option))) ;;; Getting Options (defcenum (get-param %gl:enum) (:window-x #x0064) :window-y :window-width :window-height :window-buffer-size :window-stencil-size :window-depth-size :window-red-size :window-green-size :window-blue-size :window-alpha-size :window-accum-red-size :window-accum-green-size :window-accum-blue-size :window-accum-alpha-size :window-doublebuffer :window-rgba :window-parent :window-num-children :window-colormap-size :window-num-samples :window-stereo :window-cursor (:screen-width #x00C8) :screen-height :screen-width-mm :screen-height-mm (:menu-num-items #x012C) (:display-mode-possible #x0190) (:init-window-x #x01F4) :init-window-y :init-window-width :init-window-height :init-display-mode (:elapsed-time #x02BC) (:window-format-id #x007B) :init-state (:action-on-window-close #x01F9) ; freeglut ext :window-border-width ; freeglut ext :window-header-height ; freeglut ext :version ; freeglut ext :rendering-context ; freeglut ext :direct-rendering) (defcfun ("glutGet" get) :int (query get-param)) ;;; Utility functions around glutGet(). (defun getp (query) (if (= (get query) 0) nil t)) (defun get-window-cursor () (foreign-enum-keyword 'cursor (get :window-cursor))) (defun get-init-display-mode () (foreign-bitfield-symbols 'display-mode (get :init-display-mode))) ;;; Other Getters (defcenum (device-get-param %gl:enum) (:has-keyboard #x0258) :has-mouse :has-spaceball :has-dial-and-button-box :has-tablet :num-mouse-buttons :num-spaceball-buttons :num-button-box-buttons :num-dials :num-tablet-buttons :device-ignore-key-repeat :device-key-repeat :has-joystick :owns-joystick :joystick-buttons :joystick-axes :joystick-poll-rate) (defcfun ("glutDeviceGet" device-get) :int (query device-get-param)) (defun device-getp (query) (if (= (device-get query) 0) nil t)) (defcenum (layer-get-param %gl:enum) (:overlay-possible #x0320) :layer-in-use :has-overlay :transparent-index :normal-damaged :overlay-damaged) (defcfun ("glutLayerGet" layer-get) :int (query layer-get-param)) (defun layer-getp (query) (if (= (layer-get query) 0) nil t)) (defun get-layer-in-use () (foreign-enum-keyword 'layer-type (layer-get :layer-in-use))) (defcfun ("glutGetModifiers" %glutGetModifiers) :int) (declaim (inline get-modifiers)) (defun get-modifiers () (foreign-bitfield-symbols 'modifiers (%glutGetModifiers))) ;;; No idea if this is more efficient space-wise... (declaim (inline get-modifier-values)) (defun get-modifier-values () (let ((mask (%glutGetModifiers))) (values (= 1 (logand mask 1)) ; shift (= 2 (logand mask 2)) ; ctrl (= 4 (logand mask 4))))) ; alt (defcfun ("glutExtensionSupported" extension-supported-p) :boolean (extension-name :string)) ;;; freeglut ext (defcfun ("glutGetProcAddress" get-proc-address) :pointer (proc-name :string))
6,954
Common Lisp
.lisp
211
30.104265
75
0.705812
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
57738f0cc05201c20c513ff7ebe413fca13d085eff173dc0ffb55f7c6cef4ca6
21,616
[ 486526 ]
21,617
interface.lisp
rheaplex_minara/lib/cl-opengl/glut/interface.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; interface.lisp --- CLOS interface to the GLUT API. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glut) ;;; This an experimental interface to GLUT. The main goal of this interface ;;; is to provide an easy, flexible way to explore OpenGL. GLUT is not very ;;; helpful in achieving this goal (even though Freeglut is much better than ;;; the original GLUT in this aspect). ;;; ;;; At the moment, not all of GLUT's capabilities are accessible when ;;; using this high-level interface *exclusively*. Patches and ;;; suggestions are most welcome! (eval-when (:compile-toplevel :load-toplevel :execute) ;; FIXME: find good alternative names instead of shadowing these CL symbols (shadow '(cl:special cl:close))) (export '(;; events / GFs idle keyboard special reshape visibility display mouse motion passive-motion entry menu-state spaceball-motion spaceball-rotate spaceball-button button-box dials tablet-motion tablet-button menu-status overlay-display window-status keyboard-up special-up joystick mouse-wheel close wm-close menu-destroy enable-event disable-event display-window tick ;; classes base-window window sub-window ;; accessors title name id events parent pos-x pos-y width height mode game-mode ;; other functions and macros display-window find-window with-window destroy-current-window schedule-timer enable-tick disable-tick ;; specials *run-main-loop-after-display*)) (defvar *id->window* (make-array 0 :adjustable t) "Mapping of GLUT window IDs to instances of the BASE-WINDOW class.") (defvar *windows-with-idle-event* '()) ;;;; Timers (defparameter *timer-functions* nil) (defcallback timer-cb :void ((id :int)) (let ((function (cdr (assoc id *timer-functions*)))) (when function (funcall function)))) (defvar *timer-id-counter* 0) (defun schedule-timer (millis function) (setf *timer-id-counter* (logand (1+ *timer-id-counter*) #xFFFFFFFF)) (push (cons *timer-id-counter* function) *timer-functions*) (timer-func millis (callback timer-cb) *timer-id-counter*)) ;;;; Events ;;; One callback is defined for each GLUT event. Enabling an event for ;;; a given window means registering the respective shared callback ;;; for its window id (using the *-func GLUT functions). ;;; ;;; There is one generic function for each event which is called by ;;; the shared callback to dispatch to the correct method based on the ;;; window (and possibly the other arguments). ;;; ;;; Ugh, some of these event are not implemented by Freeglut, which ;;; is what we care about... Better remove them? ;;; ;;; TODO: The JOYSTICK event has parameters, meaning a way to accept ;;; parameters eg: (:joystick n m) when enabling an event is ;;; necessary. Unlikely to be implemented anytime soon; I ;;; haven't seen a joystick in years. (defparameter *events* '()) (defstruct event name gf cb func arg-count) (defun find-event-or-lose (event-name) (or (find event-name *events* :key #'event-name) (error "No such event: ~A" event-name))) (defgeneric enable-event (window event-name)) (defgeneric disable-event (window event-name)) (defmacro when-current-window-exists (&body body) "Evals BODY when GLUT's current window exists in *ID->WINDOW*. Lexically binds CURRENT-WINDOW to the respective object." (let ((id (gensym))) `(let ((,id (get-window))) (when (> (length *id->window*) ,id) (let ((current-window (aref *id->window* ,id))) (unless (null current-window) ;;(format t "glut callback: ~A -> ~A~%" ,id current-window) ,@body)))))) (define-foreign-type ascii-to-char () () (:actual-type :unsigned-char) (:simple-parser ascii-to-char)) ;;; Without this EVAL-WHEN, the type expansion wouldn't be visible to ;;; the DEFCALLBACKs generated by DEFINE-GLUT-EVENTS. (eval-when (:compile-toplevel :load-toplevel :execute) (defmethod expand-from-foreign (value (type ascii-to-char)) `(code-char ,value))) ;;; The first element in ARGS is a dummy name for the first argument ;;; in the event's generic function, the window. (defmacro define-glut-event (name args &body callback-body) (let ((arg-names (mapcar #'car (cdr args))) (event-cb (gl::symbolicate "%" name)) (event-func (gl::symbolicate name '#:-func)) (event-name (intern (symbol-name name) '#:keyword))) `(progn (defgeneric ,name (,(car args) ,@arg-names)) (defcallback ,event-cb :void ,(cdr args) ,@callback-body) ;; When we put #'foo-func instead of 'foo-func in the ;; FUNC slot weird stuff happens. No idea why. (push (make-event :name ,event-name :gf #',name :cb ',event-cb :func ',event-func :arg-count ,(length arg-names)) *events*)))) (defmacro define-glut-events (&body event-specs) `(progn (setq *events* '()) ,@(loop for (name args) in event-specs collect `(define-glut-event ,name ,args (when-current-window-exists (,name current-window ,@(mapcar #'car (cdr args)))))))) (define-glut-events ;; (idle (window)) (keyboard (window (key ascii-to-char) (x :int) (y :int))) (special (window (special-key special-keys) (x :int) (y :int))) (reshape (window (width :int) (height :int))) (visibility (window (state visibility-state))) (display (window)) (mouse (window (button mouse-button) (state mouse-button-state) (x :int) (y :int))) (motion (window (x :int) (y :int))) (passive-motion (window (x :int) (y :int))) (entry (window (state entry-state))) (menu-state (window (state menu-state))) (spaceball-motion (window (x :int) (y :int) (z :int))) (spaceball-rotate (window (x :int) (y :int) (z :int))) (spaceball-button (window (button :int) (state :int))) (button-box (window (button :int) (state :int))) (dials (window (dial :int) (value :int))) (tablet-motion (window (x :int) (y :int))) (tablet-button (window (button :int) (state :int) (x :int) (y :int))) (menu-status (window (status menu-state) (x :int) (y :int))) (overlay-display (window)) (window-status (window (state window-status))) (keyboard-up (window (key ascii-to-char) (x :int) (y :int))) (special-up (window (special-key special-keys) (x :int) (y :int))) ;; (joystick (window (buttons joystick-buttons) (x :int) (y :int) ;; (z :int))) (mouse-wheel (window (button mouse-button) (pressed mouse-button-state) (x :int) (y :int))) (close (window)) ;; (wm-close (window)) ; synonym for CLOSE (menu-destroy (window))) ;;; These two functions should not be called directly and are called ;;; by ENABLE-EVENT and DISABLE-EVENT. See below. (defun register-callback (event) (funcall (event-func event) (get-callback (event-cb event)))) (defun unregister-callback (event) (funcall (event-func event) (null-pointer))) ;;;; Windows ;;; The WINDOW (top-level windows) and SUB-WINDOW (those pseudo-windows ;;; that live inside top-level windows and have their own GL context) ;;; classes inherit BASE-WINDOW. ;;; ;;; See DISPLAY-WINDOW's documentation. (defparameter +default-title+ (concatenate 'string (lisp-implementation-type) " " (lisp-implementation-version))) (defvar *run-main-loop-after-display* t "This special variable controls whether the DISPLAY-WINDOW method specialized on GLUT:WINDOW will call GLUT:MAIN-LOOP.") (defclass base-window () ((name :reader name :initarg :name :initform (gensym "GLUT-WINDOW")) (id :reader id) (pos-x :accessor pos-x :initarg :pos-x) (pos-y :accessor pos-y :initarg :pos-y) (height :accessor height :initarg :height) (width :accessor width :initarg :width) (title :accessor title :initarg :title) (tick-interval :accessor tick-interval :initarg :tick-interval) ;; When this slot unbound, DISPLAY-WINDOW calls ;; FIND-APPLICABLE-EVENTS to populate it. (events :accessor events :initarg :events)) (:default-initargs :pos-x -1 :pos-y -1 :height 300 :width 300 :title +default-title+ :tick-interval nil)) (defmethod initialize-instance :before ((win base-window) &key name &allow-other-keys) (declare (ignore win name)) (glut:init)) (defgeneric display-window (window) (:documentation "Creates the underlying GLUT window structures and displays WINDOW. The creation takes place in :AROUND methods so the user can define :before methods on DISPLAY-WINDOW and do OpenGL stuff with it, for example.")) (defun find-window (name) (loop for window across *id->window* when (and (not (null window)) (eq (name window) name)) do (return window))) (defmacro with-window (window &body body) (let ((current-id (gensym))) `(let ((,current-id (get-window))) (unwind-protect (progn (set-window (id ,window)) ,@body) (set-window ,current-id))))) ;;; We do some extra stuff to provide an IDLE event per-window since ;;; GLUT's IDLE event is global. (define-glut-event idle (window) (loop for win in *windows-with-idle-event* do (with-window win (idle win)))) (defun find-applicable-events (window) (loop for event in *events* when (compute-applicable-methods (event-gf event) (cons window (loop repeat (event-arg-count event) collect t))) collect event)) (defun enable-tick (window millis) (setf (tick-interval window) millis) (timer-func millis (callback tick-timer-cb) (id window))) (defun disable-tick (window) (setf (tick-interval window) nil)) (defmethod display-window :around ((win base-window)) (unless (slot-boundp win 'events) (setf (events win) (find-applicable-events win))) (with-window win (glut:position-window (pos-x win) (pos-y win)) (glut:reshape-window (width win) (height win)) (glut:set-window-title (title win)) (dolist (event (events win)) (register-callback event))) (when (member :idle (events win) :key #'event-name) (push win *windows-with-idle-event*)) ;; save window in the *id->window* array (when (<= (length *id->window*) (id win)) (setq *id->window* (adjust-array *id->window* (1+ (id win)) :initial-element nil))) (setf (aref *id->window* (id win)) win) ;; setup tick timer (when (tick-interval win) (enable-tick win (tick-interval win))) (call-next-method)) (defmethod display-window ((win base-window)) (values)) (defmethod enable-event ((window base-window) event-name) (let ((event (find-event-or-lose event-name))) (with-window window (register-callback event)) (pushnew event (events window)) (when (eq event-name :idle) (push window *windows-with-idle-event*)))) (defmethod disable-event ((window base-window) event-name) (if (eq event-name :display) (warn "GLUT would be upset if we set the DISPLAY callback to NULL. ~ So we won't do that.") (let ((event (find-event-or-lose event-name))) ;; We don't actually disable the CLOSE event since we need it ;; for bookkeeping. See the CLOSE methods below. (unless (or (eq event-name :idle) (eq event-name :close)) (with-window window (unregister-callback event))) (setf (events window) (delete event (events window))) (when (eq event-name :idle) (setq *windows-with-idle-event* (delete window *windows-with-idle-event*)))))) (defun destroy-current-window () (when-current-window-exists (if (game-mode current-window) (leave-game-mode) (destroy-window (id current-window))))) (defmethod close :around ((w base-window)) (when (member :close (events w) :key #'event-name) (call-next-method)) (setf (aref *id->window* (id w)) nil) (setq *windows-with-idle-event* (delete w *windows-with-idle-event*)) (when (null *windows-with-idle-event*) (unregister-callback (find-event-or-lose :idle)))) (defmethod close ((w base-window)) (values)) (defgeneric tick (window)) (defcallback tick-timer-cb :void ((id :int)) (when (> (length *id->window*) id) (let ((window (aref *id->window* id))) (unless (null window) (tick window) (when (tick-interval window) (timer-func (tick-interval window) (callback tick-timer-cb) id)))))) ;;;; Top-level Windows (defclass window (base-window) ((sub-windows :accessor sub-windows :initform nil) ;; Can sub-windows have a different display mode? (mode :initarg :mode :initform nil) (game-mode :initarg :game-mode :accessor game-mode :initform nil))) (defmethod (setf title) :before (string (win window)) (when (slot-boundp win 'id) (with-window win (set-window-title string)))) (defun setup-game-mode (win) (let ((width (get :screen-width)) (height (get :screen-height))) (setf (pos-x win) 0 (pos-y win) 0 (width win) width (height win) height) (game-mode-string (format nil "~Dx~D" width height)))) (defmethod display-window :around ((win window)) (when (game-mode win) (setup-game-mode win)) (init-window-position (pos-x win) (pos-y win)) (init-window-size (width win) (height win)) (without-fp-traps (apply #'init-display-mode (slot-value win 'mode)) (setf (slot-value win 'id) (if (game-mode win) (enter-game-mode) (create-window (title win)))) (call-next-method) (when *run-main-loop-after-display* (glut:main-loop)))) ;;;; Sub-windows (defclass sub-window (base-window) ((parent :reader parent :initform (error "Must specify a PARENT window.")))) (defmethod initialize-instance :after ((win sub-window) &key parent &allow-other-keys) (let ((parent-window (typecase parent (window parent) (symbol (find-window parent))))) (check-type parent-window window) (setf (slot-value win 'parent) parent-window) (push win (sub-windows parent-window)))) (defmethod display-window :around ((win sub-window)) (setf (slot-value win 'id) (create-sub-window (id (parent win)) 0 0 0 0)) (call-next-method)) ;;;; For posterity ;;; "This is quite ugly: OS X is very picky about which thread gets to handle ;;; events and only allows the main thread to do so. We need to run any event ;;; loops in the initial thread on multithreaded Lisps, or in this case, ;;; OpenMCL." ;; #-openmcl ;; (defun run-event-loop () ;; (glut:main-loop)) ;; #+openmcl ;; (defun run-event-loop () ;; (flet ((start () ;; (ccl:%set-toplevel nil) ;; (glut:main-loop))) ;; (ccl:process-interrupt ccl::*initial-process* ;; (lambda () ;; (ccl:%set-toplevel #'start) ;; (ccl:toplevel)))))
16,874
Common Lisp
.lisp
371
40.706199
78
0.660564
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
4cf0705f3f37b2583ea3c47252a28608fc3cca85a4729a4ee9a52abcc6a5d7d6
21,617
[ -1 ]
21,618
geometry.lisp
rheaplex_minara/lib/cl-opengl/glut/geometry.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; geometry.lisp --- GLUT Geometric Object Rendering API. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glut) ;;; Functions. (defcfun ("glutWireCube" wire-cube) :void (size %gl:double)) (defcfun ("glutSolidCube" solid-cube) :void (size %gl:double)) (defcfun ("glutWireSphere" wire-sphere) :void (radius %gl:double) (slices %gl:int) (stacks %gl:int)) (defcfun ("glutSolidSphere" solid-sphere) :void (radius %gl:double) (slices %gl:int) (stacks %gl:int)) (defcfun ("glutWireCone" wire-cone) :void (base %gl:double) (height %gl:double) (slices %gl:int) (stacks %gl:int)) (defcfun ("glutSolidCone" solid-cone) :void (base %gl:double) (height %gl:double) (slices %gl:int) (stacks %gl:int)) (defcfun ("glutWireTorus" wire-torus) :void (inner-radius %gl:double) (outer-radius %gl:double) (slices %gl:int) (rings %gl:int)) (defcfun ("glutSolidTorus" solid-torus) :void (inner-radius %gl:double) (outer-radius %gl:double) (slices %gl:int) (rings %gl:int)) (defcfun ("glutWireDodecahedron" wire-dodecahedron) :void) (defcfun ("glutWireOctahedron" wire-octahedron) :void) (defcfun ("glutWireTetrahedron" wire-tetrahedron) :void) (defcfun ("glutWireIcosahedron" wire-icosahedron) :void) (defcfun ("glutSolidDodecahedron" solid-dodecahedron) :void) (defcfun ("glutSolidOctahedron" solid-octahedron) :void) (defcfun ("glutSolidTetrahedron" solid-tetrahedron) :void) (defcfun ("glutSolidIcosahedron" solid-icosahedron) :void) (defcfun ("glutWireTeapot" wire-teapot) :void (size %gl:double)) (defcfun ("glutSolidTeapot" solid-teapot) :void (size %gl:double)) ;;; The following are freeglut extensions: (defcfun ("glutWireRhombicDodecahedron" wire-rhombic-dodecahedron) :void) (defcfun ("glutSolidRhombicDodecahedron" solid-rhombic-dodecahedron) :void) (defcfun ("glutWireSierpinskiSponge" %glutWireSierpinskiSponge) :void (num-levels :int) (offset-seq :pointer) ; GLdouble offset[3] (scale %gl:double)) (defun wire-sierpinski-sponge (num-levels offset-seq scale) (gl::with-opengl-sequence (offset '%gl:double offset-seq) (%glutWireSierpinskiSponge num-levels offset scale))) (defcfun ("glutSolidSierpinskiSponge" %glutSolidSierpinskiSponge) :void (num-levels :int) (offset-seq :pointer) ; GLdouble offset[3] (scale %gl:double)) (defun solid-sierpinski-sponge (num-levels offset-seq scale) (gl::with-opengl-sequence (offset '%gl:double offset-seq) (%glutSolidSierpinskiSponge num-levels offset scale))) (defcfun ("glutWireCylinder" wire-cylinder) :void (radius %gl:double) (height %gl:double) (slices %gl:int) (stacks %gl:int)) (defcfun ("glutSolidCylinder" solid-cylinder) :void (radius %gl:double) (height %gl:double) (slices %gl:int) (stacks %gl:int))
4,399
Common Lisp
.lisp
104
40.211538
75
0.748713
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
2bdf56777a518afbc39484ee3702128bf43f0fd5ce7e8b885f9731fba5e32542
21,618
[ 449266 ]
21,619
misc.lisp
rheaplex_minara/lib/cl-opengl/glut/misc.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; misc.lisp --- Misc functions from the GLUT API. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glut) ;;; Color API (defcfun ("glutSetColor" set-color) :void (ndx :int) (red %gl:float) (green %gl:float) (blue %gl:float)) (defcenum color-component :red :green :blue) (defcfun ("glutGetColor" get-color) %gl:float (color :int) (component color-component)) (defcfun ("glutCopyColormap" copy-colormap) :void (window-id :int)) ;;; Misc keyboard and joystick functions. (defcfun ("glutIgnoreKeyRepeat" ignore-key-repeat) :void (ignore :int)) (defcenum key-repeat-mode :key-repeat-off :key-repeat-on :key-repeat-default) (defcfun ("glutSetKeyRepeat" set-key-repeat) :void (repeat-mode key-repeat-mode)) (defcfun ("glutForceJoystickFunc" force-joystick-func) :void) (defcfun ("glutReportErrors" report-errors) :void) ;;; Game Mode API (defcfun ("glutGameModeString" game-mode-string) :void (string :string)) (defcfun ("glutEnterGameMode" enter-game-mode) :int) (defcfun ("glutLeaveGameMode" leave-game-mode) :void) (defcenum (game-mode-param %gl:enum) :game-mode-active :game-mode-possible :game-mode-width :game-mode-height :game-mode-pixel-depth :game-mode-refresh-rate :game-mode-display-changed) (defcfun ("glutGameModeGet" game-mode-get) :int (query game-mode-param)) (defcfun ("glutGameModeGet" game-mode-getp) :boolean (query game-mode-param)) ;;; Video API ;;; freeglut doesn't implement any of these (defcenum (video-resize-param %gl:enum) (:video-resize-possible #x0384) :video-resize-in-use :video-resize-x-delta :video-resize-y-delta :video-resize-width-delta :video-resize-height-delta :video-resize-x :video-resize-y :video-resize-width :video-resize-height) (defcfun ("glutVideoResizeGet" video-resize-get) :int (query video-resize-param)) (defcfun ("glutVideoResizeGet" video-resize-getp) :boolean (query video-resize-param)) (defcfun ("glutSetupVideoResizing" setup-video-resizing) :void) (defcfun ("glutStopVideoResizing" stop-video-resizing) :void) (defcfun ("glutVideoResize" video-resize) :void (x :int) (y :int) (width :int) (height :int)) (defcfun ("glutVideoPan" video-pan) :void (x :int) (y :int) (width :int) (height :int))
3,910
Common Lisp
.lisp
104
35.5
75
0.745637
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
9317ec93fe1d8d1d30184c13875f3e46b8737da69e41ee0ec621efa253a251c4
21,619
[ -1 ]
21,620
init.lisp
rheaplex_minara/lib/cl-opengl/glut/init.lisp
;;; -*- Mode: Lisp; indent-tabs-mode: nil -*- ;;; ;;; init.lisp --- GLUT Initialization API. ;;; ;;; Copyright (c) 2006, Luis Oliveira <[email protected]> ;;; All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; o Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; o Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; o Neither the name of the author nor the names of the contributors may ;;; be used to endorse or promote products derived from this software ;;; without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:cl-glut) (defcfun ("glutInit" %glutInit) :void (argcp :pointer) ; int* (argv :pointer)) ; char** (defmacro without-fp-traps (&body body) #+(and sbcl (or x86 x86-64)) `(sb-int:with-float-traps-masked (:invalid :divide-by-zero) ,@body) #-(and sbcl (or x86 x86-64)) `(progn ,@body)) (defun init (&optional (program-name (lisp-implementation-type))) (without-fp-traps ;; freeglut will exit() if we try to call initGlut() when ;; things are already initialized. (unless (getp :init-state) (with-foreign-objects ((argcp :int) (argv :pointer)) (setf (mem-ref argcp :int) 1) (with-foreign-string (str program-name) (setf (mem-ref argv :pointer) str) (%glutInit argcp argv))) ;; By default, we choose the saner option to return from the event ;; loop on window close instead of exit()ing. (set-action-on-window-close :action-continue-execution) ;; this probably doesn't play well with other toolkits (setq %gl:*gl-get-proc-address* 'get-proc-address))) (values)) ;; We call init at load-time in order to ensure a usable glut as often ;; as possible. Also, we call init when the main event loop returns in ;; main.lisp and some other places. We do this to avoid having ;; freeglut call exit() when performing some operation that needs ;; previous initialization. (init) ;;; The display-mode bitfield is defined in state.lisp (defcfun ("glutInitDisplayMode" %glutInitDisplayMode) :void (mode display-mode)) ;;; freeglut_ext.h says: "Only one GLUT_AUXn bit may be used at a time." (defun init-display-mode (&rest options) (declare (dynamic-extent options)) (%glutInitDisplayMode options)) ;;; useless? (defcfun ("glutInitDisplayString" init-display-string) :void (display-mode :string)) (defcfun ("glutInitWindowPosition" init-window-position) :void (x :int) (y :int)) (defcfun ("glutInitWindowSize" init-window-size) :void (width :int) (height :int))
3,707
Common Lisp
.lisp
79
44.265823
75
0.726368
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
385e5cb3d039e4b2ffcfeb0d5639f9ef4e73c445d988875b211e76f082c88a7f
21,620
[ -1 ]
21,621
asdf.lisp
rheaplex_minara/lib/cffi/grovel/asdf.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; asdf.lisp --- ASDF components for cffi-grovel. ;;; ;;; Copyright (C) 2005-2006, Dan Knap <[email protected]> ;;; Copyright (C) 2005-2006, Matthew Backes <[email protected]> ;;; Copyright (C) 2007, Stelian Ionescu <[email protected]> ;;; Copyright (C) 2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-grovel) (defun ensure-pathname (thing) (if (typep thing 'logical-pathname) (translate-logical-pathname thing) (pathname thing))) (defclass cc-flags-mixin () ((cc-flags :initform nil :accessor cc-flags-of :initarg :cc-flags))) (defmethod asdf:perform :around ((op asdf:compile-op) (file cc-flags-mixin)) (let ((*cc-flags* (append (ensure-list (cc-flags-of file)) *cc-flags*))) (call-next-method))) ;;;# ASDF component: GROVEL-FILE (defclass grovel-file (asdf:cl-source-file cc-flags-mixin) () (:documentation "This ASDF component defines COMPILE-OP and LOAD-SOURCE-OP operations that take care of calling PROCESS-GROVEL-FILE in order to generate a Lisp file that is subsequently compiled and/or loaded.")) (defmethod asdf:perform ((op asdf:compile-op) (c grovel-file)) (let ((output-file (ensure-pathname (car (asdf:output-files op c))))) (compile-file (process-grovel-file (asdf:component-pathname c) output-file) :output-file output-file))) (defmethod asdf:perform ((op asdf:load-source-op) (c grovel-file)) (load (process-grovel-file (asdf:component-pathname c) (ensure-pathname (car (asdf:output-files op c)))))) ;;;# ASDF component: WRAPPER-FILE (defclass wrapper-file (asdf:cl-source-file cc-flags-mixin) () (:documentation "This ASDF component defines COMPILE-OP and LOAD-SOURCE-OP operations that take care of calling PROCESS-WRAPPER-FILE in order to generate a foreign library and matching CFFI bindings that are subsequently compiled and/or loaded.")) (defmethod asdf:perform ((op asdf:compile-op) (c wrapper-file)) (let ((output-file (ensure-pathname (car (asdf:output-files op c))))) (compile-file (process-wrapper-file (asdf:component-pathname c) output-file) :output-file output-file))) (defmethod asdf:perform ((op asdf:load-source-op) (c wrapper-file)) (load (process-wrapper-file (asdf:component-pathname c) (ensure-pathname (car (asdf:output-files op c))))))
3,530
Common Lisp
.lisp
72
45.75
80
0.722867
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ccd1d1a2b4b99c901e103974ede755fc8ca956d1268068cfb384f520267544bd
21,621
[ 208388 ]
21,629
cffi-scl.lisp
rheaplex_minara/lib/cffi/src/cffi-scl.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; cffi-scl.lisp --- CFFI-SYS implementation for the Scieneer Common Lisp. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; Copyright (C) 2006-2007, Scieneer Pty Ltd. ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;;# Administrivia (defpackage #:cffi-sys (:use #:common-lisp #:alien #:c-call) (:import-from #:alexandria #:once-only #:with-unique-names) (:export #:canonicalize-symbol-name-case #:foreign-pointer #:pointerp #:pointer-eq #:null-pointer #:null-pointer-p #:inc-pointer #:make-pointer #:pointer-address #:%foreign-alloc #:foreign-free #:with-foreign-pointer #:%foreign-funcall #:%foreign-funcall-pointer #:%foreign-type-alignment #:%foreign-type-size #:%load-foreign-library #:%close-foreign-library #:native-namestring #:%mem-ref #:%mem-set #:make-shareable-byte-vector #:with-pointer-to-vector-data #:%foreign-symbol-pointer #:%defcallback #:%callback)) (in-package #:cffi-sys) ;;;# Mis-features (pushnew 'flat-namespace *features*) ;;;# Symbol Case (defun canonicalize-symbol-name-case (name) (declare (string name)) (if (eq ext:*case-mode* :upper) (string-upcase name) (string-downcase name))) ;;;# Basic Pointer Operations (deftype foreign-pointer () 'sys:system-area-pointer) (declaim (inline pointerp)) (defun pointerp (ptr) "Return true if 'ptr is a foreign pointer." (sys:system-area-pointer-p ptr)) (declaim (inline pointer-eq)) (defun pointer-eq (ptr1 ptr2) "Return true if 'ptr1 and 'ptr2 point to the same address." (sys:sap= ptr1 ptr2)) (declaim (inline null-pointer)) (defun null-pointer () "Construct and return a null pointer." (sys:int-sap 0)) (declaim (inline null-pointer-p)) (defun null-pointer-p (ptr) "Return true if 'ptr is a null pointer." (zerop (sys:sap-int ptr))) (declaim (inline inc-pointer)) (defun inc-pointer (ptr offset) "Return a pointer pointing 'offset bytes past 'ptr." (sys:sap+ ptr offset)) (declaim (inline make-pointer)) (defun make-pointer (address) "Return a pointer pointing to 'address." (sys:int-sap address)) (declaim (inline pointer-address)) (defun pointer-address (ptr) "Return the address pointed to by 'ptr." (sys:sap-int ptr)) (defmacro with-foreign-pointer ((var size &optional size-var) &body body) "Bind 'var to 'size bytes of foreign memory during 'body. The pointer in 'var is invalid beyond the dynamic extent of 'body, and may be stack-allocated if supported by the implementation. If 'size-var is supplied, it will be bound to 'size during 'body." (unless size-var (setf size-var (gensym (symbol-name '#:size)))) ;; If the size is constant we can stack-allocate. (cond ((constantp size) (let ((alien-var (gensym (symbol-name '#:alien)))) `(with-alien ((,alien-var (array (unsigned 8) ,(eval size)))) (let ((,size-var ,size) (,var (alien-sap ,alien-var))) (declare (ignorable ,size-var)) ,@body)))) (t `(let ((,size-var ,size)) (alien:with-bytes (,var ,size-var) ,@body))))) ;;;# Allocation ;;; ;;; Functions and macros for allocating foreign memory on the stack and on the ;;; heap. The main CFFI package defines macros that wrap 'foreign-alloc and ;;; 'foreign-free in 'unwind-protect for the common usage when the memory has ;;; dynamic extent. (defun %foreign-alloc (size) "Allocate 'size bytes on the heap and return a pointer." (declare (type (unsigned-byte #-64bit 32 #+64bit 64) size)) (alien-funcall (extern-alien "malloc" (function system-area-pointer unsigned)) size)) (defun foreign-free (ptr) "Free a 'ptr allocated by 'foreign-alloc." (declare (type system-area-pointer ptr)) (alien-funcall (extern-alien "free" (function (values) system-area-pointer)) ptr)) ;;;# Shareable Vectors (defun make-shareable-byte-vector (size) "Create a Lisp vector of 'size bytes that can passed to 'with-pointer-to-vector-data." (make-array size :element-type '(unsigned-byte 8))) (defmacro with-pointer-to-vector-data ((ptr-var vector) &body body) "Bind 'ptr-var to a foreign pointer to the data in 'vector." (let ((vector-var (gensym (symbol-name '#:vector)))) `(let ((,vector-var ,vector)) (ext:with-pinned-object (,vector-var) (let ((,ptr-var (sys:vector-sap ,vector-var))) ,@body))))) ;;;# Dereferencing ;;; Define the %MEM-REF and %MEM-SET functions, as well as compiler ;;; macros that optimize the case where the type keyword is constant ;;; at compile-time. (defmacro define-mem-accessors (&body pairs) `(progn (defun %mem-ref (ptr type &optional (offset 0)) (ecase type ,@(loop for (keyword fn) in pairs collect `(,keyword (,fn ptr offset))))) (defun %mem-set (value ptr type &optional (offset 0)) (ecase type ,@(loop for (keyword fn) in pairs collect `(,keyword (setf (,fn ptr offset) value))))) (define-compiler-macro %mem-ref (&whole form ptr type &optional (offset 0)) (if (constantp type) (ecase (eval type) ,@(loop for (keyword fn) in pairs collect `(,keyword `(,',fn ,ptr ,offset)))) form)) (define-compiler-macro %mem-set (&whole form value ptr type &optional (offset 0)) (if (constantp type) (once-only (value) (ecase (eval type) ,@(loop for (keyword fn) in pairs collect `(,keyword `(setf (,',fn ,ptr ,offset) ,value))))) form)))) (define-mem-accessors (:char sys:signed-sap-ref-8) (:unsigned-char sys:sap-ref-8) (:short sys:signed-sap-ref-16) (:unsigned-short sys:sap-ref-16) (:int sys:signed-sap-ref-32) (:unsigned-int sys:sap-ref-32) (:long #-64bit sys:signed-sap-ref-32 #+64bit sys:signed-sap-ref-64) (:unsigned-long #-64bit sys:sap-ref-32 #+64bit sys:sap-ref-64) (:long-long sys:signed-sap-ref-64) (:unsigned-long-long sys:sap-ref-64) (:float sys:sap-ref-single) (:double sys:sap-ref-double) #+long-float (:long-double sys:sap-ref-long) (:pointer sys:sap-ref-sap)) ;;;# Calling Foreign Functions (defun convert-foreign-type (type-keyword) "Convert a CFFI type keyword to an ALIEN type." (ecase type-keyword (:char 'char) (:unsigned-char 'unsigned-char) (:short 'short) (:unsigned-short 'unsigned-short) (:int 'int) (:unsigned-int 'unsigned-int) (:long 'long) (:unsigned-long 'unsigned-long) (:long-long '(signed 64)) (:unsigned-long-long '(unsigned 64)) (:float 'single-float) (:double 'double-float) #+long-float (:long-double 'long-float) (:pointer 'system-area-pointer) (:void 'void))) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (values (truncate (alien-internals:alien-type-bits (alien-internals:parse-alien-type (convert-foreign-type type-keyword))) 8))) (defun %foreign-type-alignment (type-keyword) "Return the alignment in bytes of a foreign type." (values (truncate (alien-internals:alien-type-alignment (alien-internals:parse-alien-type (convert-foreign-type type-keyword))) 8))) (defun foreign-funcall-type-and-args (args) "Return an 'alien function type for 'args." (let ((return-type nil)) (loop for (type arg) on args by #'cddr if arg collect (convert-foreign-type type) into types and collect arg into fargs else do (setf return-type (convert-foreign-type type)) finally (return (values types fargs return-type))))) (defmacro %%foreign-funcall (name types fargs rettype) "Internal guts of '%foreign-funcall." `(alien-funcall (extern-alien ,name (function ,rettype ,@types)) ,@fargs)) (defmacro %foreign-funcall (name args &key library calling-convention) "Perform a foreign function call, document it more later." (declare (ignore library calling-convention)) (multiple-value-bind (types fargs rettype) (foreign-funcall-type-and-args args) `(%%foreign-funcall ,name ,types ,fargs ,rettype))) (defmacro %foreign-funcall-pointer (ptr args &key calling-convention) "Funcall a pointer to a foreign function." (declare (ignore calling-convention)) (multiple-value-bind (types fargs rettype) (foreign-funcall-type-and-args args) (with-unique-names (function) `(with-alien ((,function (* (function ,rettype ,@types)) ,ptr)) (alien-funcall ,function ,@fargs))))) ;;; Callbacks (defmacro %defcallback (name rettype arg-names arg-types body &key calling-convention) `(alien:defcallback ,name (,(convert-foreign-type rettype) ,@(mapcar (lambda (sym type) (list sym (convert-foreign-type type))) arg-names arg-types)) ,body)) (declaim (inline %callback)) (defun %callback (name) (alien:callback-sap name)) ;;;# Loading and Closing Foreign Libraries (defun %load-foreign-library (name path) "Load the foreign library 'name." (declare (ignore name)) (ext:load-dynamic-object path)) (defun %close-foreign-library (name) "Closes the foreign library 'name." (ext:close-dynamic-object name)) (defun native-namestring (pathname) (ext:unix-namestring pathname nil)) ;;;# Foreign Globals (defun %foreign-symbol-pointer (name library) "Returns a pointer to a foreign symbol 'name." (declare (ignore library)) (let ((sap (sys:foreign-symbol-address name))) (if (zerop (sys:sap-int sap)) nil sap)))
11,107
Common Lisp
.lisp
278
34.643885
78
0.655943
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e4951464de135e3a5040bc930ddc54bac3f112cfc64a7a685a9bbbf0b2a3921b
21,629
[ 267638 ]
21,630
package.lisp
rheaplex_minara/lib/cffi/src/package.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; package.lisp --- Package definition for CFFI. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cl-user) (defpackage #:cffi (:use #:common-lisp #:cffi-sys #:babel-encodings) (:import-from #:alexandria #:ensure-list #:featurep #:format-symbol #:if-let #:make-gensym-list #:once-only #:parse-body #:symbolicate #:when-let #:with-unique-names) (:export ;; Types. #:foreign-pointer ;; Primitive pointer operations. #:foreign-free #:foreign-alloc #:mem-aref #:mem-ref #:pointerp #:pointer-eq #:null-pointer #:null-pointer-p #:inc-pointer #:incf-pointer #:with-foreign-pointer #:make-pointer #:pointer-address ;; Shareable vectors. #:make-shareable-byte-vector #:with-pointer-to-vector-data ;; Foreign string operations. #:*default-foreign-encoding* #:foreign-string-alloc #:foreign-string-free #:foreign-string-to-lisp #:lisp-string-to-foreign #:with-foreign-string #:with-foreign-strings #:with-foreign-pointer-as-string ;; Foreign function operations. #:defcfun #:foreign-funcall #:foreign-funcall-pointer ;; Foreign library operations. #:*foreign-library-directories* #:*darwin-framework-directories* #:define-foreign-library #:load-foreign-library #:load-foreign-library-error #:use-foreign-library #:close-foreign-library ;; Callbacks. #:callback #:get-callback #:defcallback ;; Foreign type operations. #:defcstruct #:defcunion #:defctype #:defcenum #:defbitfield #:define-foreign-type #:define-parse-method #:define-c-struct-wrapper #:foreign-enum-keyword #:foreign-enum-keyword-list #:foreign-enum-value #:foreign-bitfield-symbol-list #:foreign-bitfield-symbols #:foreign-bitfield-value #:foreign-slot-pointer #:foreign-slot-value #:foreign-slot-offset #:foreign-slot-names #:foreign-type-alignment #:foreign-type-size #:with-foreign-object #:with-foreign-objects #:with-foreign-slots #:convert-to-foreign #:convert-from-foreign #:free-converted-object ;; Extensible foreign type operations. #:translate-to-foreign #:translate-from-foreign #:free-translated-object #:expand-to-foreign-dyn #:expand-to-foreign #:expand-from-foreign ;; Foreign globals. #:defcvar #:get-var-pointer #:foreign-symbol-pointer ))
3,619
Common Lisp
.lisp
117
27.247863
73
0.706961
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
2bd95b105443ea7a3ded45f571ed9e535fe458255fc14fff51bffe833ef220e3
21,630
[ -1 ]
21,631
foreign-vars.lisp
rheaplex_minara/lib/cffi/src/foreign-vars.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; foreign-vars.lisp --- High-level interface to foreign globals. ;;; ;;; Copyright (C) 2005-2008, Luis Oliveira <loliveira(@)common-lisp.net> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi) ;;;# Accessing Foreign Globals ;;; Called by FOREIGN-OPTIONS in functions.lisp. (defun parse-defcvar-options (options) (destructuring-bind (&key (library :default) read-only) options (list :library library :read-only read-only))) (defun get-var-pointer (symbol) "Return a pointer to the foreign global variable relative to SYMBOL." (foreign-symbol-pointer (get symbol 'foreign-var-name) :library (get symbol 'foreign-var-library))) ;;; Note: this will lookup not only variables but also functions. (defun foreign-symbol-pointer (name &key (library :default)) (%foreign-symbol-pointer name (if (eq library :default) :default (foreign-library-handle (get-foreign-library library))))) (defun fs-pointer-or-lose (foreign-name library) "Like foreign-symbol-ptr but throws an error instead of returning nil when foreign-name is not found." (or (foreign-symbol-pointer foreign-name :library library) (error "Trying to access undefined foreign variable ~S." foreign-name))) (defmacro defcvar (name-and-options type &optional documentation) "Define a foreign global variable." (declare (ignore documentation)) (multiple-value-bind (lisp-name foreign-name options) (parse-name-and-options name-and-options t) (let ((fn (symbolicate '#:%var-accessor- lisp-name)) (read-only (getf options :read-only)) (library (getf options :library))) ;; We can't really setf an aggregate type. (when (aggregatep (parse-type type)) (setq read-only t)) `(progn ;; Save foreign-name and library for posterior access by ;; GET-VAR-POINTER. (setf (get ',lisp-name 'foreign-var-name) ,foreign-name) (setf (get ',lisp-name 'foreign-var-library) ',library) ;; Getter (defun ,fn () (mem-ref (fs-pointer-or-lose ,foreign-name ',library) ',type)) ;; Setter (defun (setf ,fn) (value) ,(if read-only '(declare (ignore value)) (values)) ,(if read-only `(error ,(format nil "Trying to modify read-only foreign var: ~A." lisp-name)) `(setf (mem-ref (fs-pointer-or-lose ,foreign-name ',library) ',type) value))) ;; While most Lisps already expand DEFINE-SYMBOL-MACRO to an ;; EVAL-WHEN form like this, that is not required by the ;; standard so we do it ourselves. (eval-when (:compile-toplevel :load-toplevel :execute) (define-symbol-macro ,lisp-name (,fn)))))))
4,005
Common Lisp
.lisp
82
42.207317
78
0.664964
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
715b9ab83c58ee4e1d80e7492ba66fdc9f135d09c11d09c13bb13ef5f159f85b
21,631
[ -1 ]
21,632
types.lisp
rheaplex_minara/lib/cffi/src/types.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; types.lisp --- User-defined CFFI types. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; Copyright (C) 2005-2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi) ;;;# Built-In Types (define-built-in-foreign-type :char) (define-built-in-foreign-type :unsigned-char) (define-built-in-foreign-type :short) (define-built-in-foreign-type :unsigned-short) (define-built-in-foreign-type :int) (define-built-in-foreign-type :unsigned-int) (define-built-in-foreign-type :long) (define-built-in-foreign-type :unsigned-long) (define-built-in-foreign-type :float) (define-built-in-foreign-type :double) (define-built-in-foreign-type :void) #-cffi-sys::no-long-long (progn (define-built-in-foreign-type :long-long) (define-built-in-foreign-type :unsigned-long-long)) ;;; Define emulated LONG-LONG types. Needs checking whether we're ;;; using the right sizes on various platforms. ;;; ;;; A possibly better, certainly faster though more intrusive, ;;; alternative is available here: ;;; <http://article.gmane.org/gmane.lisp.cffi.devel/1091> #+cffi-sys::no-long-long (eval-when (:compile-toplevel :load-toplevel :execute) (defclass emulated-llong-type (foreign-type) ()) (defmethod foreign-type-size ((tp emulated-llong-type)) 8) (defmethod foreign-type-alignment ((tp emulated-llong-type)) ;; better than assuming that the alignment is 8 (foreign-type-alignment :long)) (defmethod aggregatep ((tp emulated-llong-type)) nil) (define-foreign-type emulated-llong (emulated-llong-type) () (:simple-parser :long-long)) (define-foreign-type emulated-ullong (emulated-llong-type) () (:simple-parser :unsigned-long-long)) (defmethod canonicalize ((tp emulated-llong)) :long-long) (defmethod unparse-type ((tp emulated-llong)) :long-long) (defmethod canonicalize ((tp emulated-ullong)) :unsigned-long-long) (defmethod unparse-type ((tp emulated-ullong)) :unsigned-long-long) (defun %emulated-mem-ref-64 (ptr type offset) (let ((value #+big-endian (+ (ash (mem-ref ptr :unsigned-long offset) 32) (mem-ref ptr :unsigned-long (+ offset 4))) #+little-endian (+ (mem-ref ptr :unsigned-long offset) (ash (mem-ref ptr :unsigned-long (+ offset 4)) 32)))) (if (and (eq type :long-long) (logbitp 63 value)) (lognot (logxor value #xFFFFFFFFFFFFFFFF)) value))) (defun %emulated-mem-set-64 (value ptr type offset) (when (and (eq type :long-long) (minusp value)) (setq value (lognot (logxor value #xFFFFFFFFFFFFFFFF)))) (%mem-set (ldb (byte 32 0) value) ptr :unsigned-long #+big-endian (+ offset 4) #+little-endian offset) (%mem-set (ldb (byte 32 32) value) ptr :unsigned-long #+big-endian offset #+little-endian (+ offset 4)) value)) ;;; When some lisp other than SCL supports :long-double we should ;;; use #-cffi-sys::no-long-double here instead. #+(and scl long-float) (define-built-in-foreign-type :long-double) ;;;# Foreign Pointers (define-modify-macro incf-pointer (&optional (offset 1)) inc-pointer) (defun mem-ref (ptr type &optional (offset 0)) "Return the value of TYPE at OFFSET bytes from PTR. If TYPE is aggregate, we don't return its 'value' but a pointer to it, which is PTR itself." (let ((ptype (parse-type type))) (if (aggregatep ptype) (inc-pointer ptr offset) (let ((ctype (canonicalize ptype))) #+cffi-sys::no-long-long (when (or (eq ctype :long-long) (eq ctype :unsigned-long-long)) (return-from mem-ref (translate-from-foreign (%emulated-mem-ref-64 ptr ctype offset) ptype))) ;; normal branch (translate-from-foreign (%mem-ref ptr ctype offset) ptype))))) (define-compiler-macro mem-ref (&whole form ptr type &optional (offset 0)) "Compiler macro to open-code MEM-REF when TYPE is constant." (if (constantp type) (let* ((parsed-type (parse-type (eval type))) (ctype (canonicalize parsed-type))) ;; Bail out when using emulated long long types. #+cffi-sys::no-long-long (when (member ctype '(:long-long :unsigned-long-long)) (return-from mem-ref form)) (if (aggregatep parsed-type) `(inc-pointer ,ptr ,offset) (expand-from-foreign `(%mem-ref ,ptr ,ctype ,offset) parsed-type))) form)) (defun mem-set (value ptr type &optional (offset 0)) "Set the value of TYPE at OFFSET bytes from PTR to VALUE." (let* ((ptype (parse-type type)) (ctype (canonicalize ptype))) #+cffi-sys::no-long-long (when (or (eq ctype :long-long) (eq ctype :unsigned-long-long)) (return-from mem-set (%emulated-mem-set-64 (translate-to-foreign value ptype) ptr ctype offset))) (%mem-set (translate-to-foreign value ptype) ptr ctype offset))) (define-setf-expander mem-ref (ptr type &optional (offset 0) &environment env) "SETF expander for MEM-REF that doesn't rebind TYPE. This is necessary for the compiler macro on MEM-SET to be able to open-code (SETF MEM-REF) forms." (multiple-value-bind (dummies vals newval setter getter) (get-setf-expansion ptr env) (declare (ignore setter newval)) ;; if either TYPE or OFFSET are constant, we avoid rebinding them ;; so that the compiler macros on MEM-SET and %MEM-SET work. (with-unique-names (store type-tmp offset-tmp) (values (append (unless (constantp type) (list type-tmp)) (unless (constantp offset) (list offset-tmp)) dummies) (append (unless (constantp type) (list type)) (unless (constantp offset) (list offset)) vals) (list store) `(progn (mem-set ,store ,getter ,@(if (constantp type) (list type) (list type-tmp)) ,@(if (constantp offset) (list offset) (list offset-tmp))) ,store) `(mem-ref ,getter ,@(if (constantp type) (list type) (list type-tmp)) ,@(if (constantp offset) (list offset) (list offset-tmp))))))) (define-compiler-macro mem-set (&whole form value ptr type &optional (offset 0)) "Compiler macro to open-code (SETF MEM-REF) when type is constant." (if (constantp type) (let* ((parsed-type (parse-type (eval type))) (ctype (canonicalize parsed-type))) ;; Bail out when using emulated long long types. #+cffi-sys::no-long-long (when (member ctype '(:long-long :unsigned-long-long)) (return-from mem-set form)) `(%mem-set ,(expand-to-foreign value parsed-type) ,ptr ,ctype ,offset)) form)) ;;;# Dereferencing Foreign Arrays ;;; Maybe this should be named MEM-SVREF? [2007-02-28 LO] (defun mem-aref (ptr type &optional (index 0)) "Like MEM-REF except for accessing 1d arrays." (mem-ref ptr type (* index (foreign-type-size type)))) (define-compiler-macro mem-aref (&whole form ptr type &optional (index 0)) "Compiler macro to open-code MEM-AREF when TYPE (and eventually INDEX)." (if (constantp type) (if (constantp index) `(mem-ref ,ptr ,type ,(* (eval index) (foreign-type-size (eval type)))) `(mem-ref ,ptr ,type (* ,index ,(foreign-type-size (eval type))))) form)) (define-setf-expander mem-aref (ptr type &optional (index 0) &environment env) "SETF expander for MEM-AREF." (multiple-value-bind (dummies vals newval setter getter) (get-setf-expansion ptr env) (declare (ignore setter newval)) ;; we avoid rebinding type and index, if possible (and if type is not ;; constant, we don't bother about the index), so that the compiler macros ;; on MEM-SET or %MEM-SET can work. (with-unique-names (store type-tmp index-tmp) (values (append (unless (constantp type) (list type-tmp)) (unless (and (constantp type) (constantp index)) (list index-tmp)) dummies) (append (unless (constantp type) (list type)) (unless (and (constantp type) (constantp index)) (list index)) vals) (list store) ;; Here we'll try to calculate the offset from the type and index, ;; or if not possible at least get the type size early. `(progn ,(if (constantp type) (if (constantp index) `(mem-set ,store ,getter ,type ,(* (eval index) (foreign-type-size (eval type)))) `(mem-set ,store ,getter ,type (* ,index-tmp ,(foreign-type-size (eval type))))) `(mem-set ,store ,getter ,type-tmp (* ,index-tmp (foreign-type-size ,type-tmp)))) ,store) `(mem-aref ,getter ,@(if (constantp type) (list type) (list type-tmp)) ,@(if (and (constantp type) (constantp index)) (list index) (list index-tmp))))))) (define-foreign-type foreign-array-type () ((dimensions :reader dimensions :initarg :dimensions) (element-type :reader element-type :initarg :element-type)) (:actual-type :pointer)) (defmethod print-object ((type foreign-array-type) stream) "Print a FOREIGN-ARRAY-TYPE instance to STREAM unreadably." (print-unreadable-object (type stream :type t :identity nil) (format stream "~S ~S" (element-type type) (dimensions type)))) (define-parse-method :array (element-type &rest dimensions) (make-instance 'foreign-array-type :element-type element-type :dimensions dimensions)) (defun array-element-size (array-type) (foreign-type-size (element-type array-type))) (defun indexes-to-row-major-index (dimensions &rest subscripts) (apply #'+ (maplist (lambda (x y) (* (car x) (apply #'* (cdr y)))) subscripts dimensions))) (defun row-major-index-to-indexes (index dimensions) (loop with idx = index with rank = (length dimensions) with indexes = (make-list rank) for dim-index from (- rank 1) downto 0 do (setf (values idx (nth dim-index indexes)) (floor idx (nth dim-index dimensions))) finally (return indexes))) (defun lisp-array-to-foreign (array pointer array-type) "Copy elements from a Lisp array to POINTER." (let* ((type (follow-typedefs (parse-type array-type))) (el-type (element-type type)) (dimensions (dimensions type))) (loop with foreign-type-size = (array-element-size type) with size = (reduce #'* dimensions) for i from 0 below size for offset = (* i foreign-type-size) for element = (apply #'aref array (row-major-index-to-indexes i dimensions)) do (setf (mem-ref pointer el-type offset) element)))) (defun foreign-array-to-lisp (pointer array-type) "Copy elements from ptr into a Lisp array. If POINTER is a null pointer, returns NIL." (unless (null-pointer-p pointer) (let* ((type (follow-typedefs (parse-type array-type))) (el-type (element-type type)) (dimensions (dimensions type)) (array (make-array dimensions))) (loop with foreign-type-size = (array-element-size type) with size = (reduce #'* dimensions) for i from 0 below size for offset = (* i foreign-type-size) for element = (mem-ref pointer el-type offset) do (setf (apply #'aref array (row-major-index-to-indexes i dimensions)) element)) array))) (defun foreign-array-alloc (array array-type) "Allocate a foreign array containing the elements of lisp array. The foreign array must be freed with foreign-array-free." (check-type array array) (let* ((type (follow-typedefs (parse-type array-type))) (ptr (foreign-alloc (element-type type) :count (reduce #'* (dimensions type))))) (lisp-array-to-foreign array ptr array-type) ptr)) (defun foreign-array-free (ptr) "Free a foreign array allocated by foreign-array-alloc." (foreign-free ptr)) (defmacro with-foreign-array ((var lisp-array array-type) &body body) "Bind var to a foreign array containing lisp-array elements in body." (with-unique-names (type) `(let ((,type (follow-typedefs (parse-type ,array-type)))) (with-foreign-pointer (,var (* (reduce #'* (dimensions ,type)) (array-element-size ,type))) (lisp-array-to-foreign ,lisp-array ,var ,array-type) ,@body)))) (defun foreign-aref (ptr array-type &rest indexes) (let* ((type (follow-typedefs (parse-type array-type))) (offset (* (array-element-size type) (apply #'indexes-to-row-major-index (dimensions type) indexes)))) (mem-ref ptr (element-type type) offset))) (defun (setf foreign-aref) (value ptr array-type &rest indexes) (let* ((type (follow-typedefs (parse-type array-type))) (offset (* (array-element-size type) (apply #'indexes-to-row-major-index (dimensions type) indexes)))) (setf (mem-ref ptr (element-type type) offset) value))) ;;; This type has defined type translators to allocate and free the ;;; array. It will also invoke type translators for each of the ;;; array's element. **But it doesn't free them yet** (define-foreign-type auto-array-type (foreign-array-type) ()) (define-parse-method :auto-array (element-type &rest dimensions) (assert (>= (length dimensions) 1)) (make-instance 'auto-array-type :element-type element-type :dimensions dimensions)) (defmethod translate-to-foreign (array (type auto-array-type)) (foreign-array-alloc array (unparse-type type))) (defmethod translate-from-foreign (pointer (type auto-array-type)) (foreign-array-to-lisp pointer (unparse-type type))) (defmethod free-translated-object (pointer (type auto-array-type) param) (declare (ignore param)) (foreign-array-free pointer)) ;;;# Foreign Structures ;;;## Foreign Structure Slots (defgeneric foreign-struct-slot-pointer (ptr slot) (:documentation "Get the address of SLOT relative to PTR.")) (defgeneric foreign-struct-slot-pointer-form (ptr slot) (:documentation "Return a form to get the address of SLOT in PTR.")) (defgeneric foreign-struct-slot-value (ptr slot) (:documentation "Return the value of SLOT in structure PTR.")) (defgeneric (setf foreign-struct-slot-value) (value ptr slot) (:documentation "Set the value of a SLOT in structure PTR.")) (defgeneric foreign-struct-slot-value-form (ptr slot) (:documentation "Return a form to get the value of SLOT in struct PTR.")) (defgeneric foreign-struct-slot-set-form (value ptr slot) (:documentation "Return a form to set the value of SLOT in struct PTR.")) (defclass foreign-struct-slot () ((name :initarg :name :reader slot-name) (offset :initarg :offset :accessor slot-offset) (type :initarg :type :accessor slot-type)) (:documentation "Base class for simple and aggregate slots.")) (defmethod foreign-struct-slot-pointer (ptr (slot foreign-struct-slot)) "Return the address of SLOT relative to PTR." (inc-pointer ptr (slot-offset slot))) (defmethod foreign-struct-slot-pointer-form (ptr (slot foreign-struct-slot)) "Return a form to get the address of SLOT relative to PTR." (let ((offset (slot-offset slot))) (if (zerop offset) ptr `(inc-pointer ,ptr ,offset)))) (defun foreign-slot-names (type) "Returns a list of TYPE's slot names in no particular order." (loop for value being the hash-values in (slots (follow-typedefs (parse-type type))) collect (slot-name value))) ;;;### Simple Slots (defclass simple-struct-slot (foreign-struct-slot) () (:documentation "Non-aggregate structure slots.")) (defmethod foreign-struct-slot-value (ptr (slot simple-struct-slot)) "Return the value of a simple SLOT from a struct at PTR." (mem-ref ptr (slot-type slot) (slot-offset slot))) (defmethod foreign-struct-slot-value-form (ptr (slot simple-struct-slot)) "Return a form to get the value of a slot from PTR." `(mem-ref ,ptr ',(slot-type slot) ,(slot-offset slot))) (defmethod (setf foreign-struct-slot-value) (value ptr (slot simple-struct-slot)) "Set the value of a simple SLOT to VALUE in PTR." (setf (mem-ref ptr (slot-type slot) (slot-offset slot)) value)) (defmethod foreign-struct-slot-set-form (value ptr (slot simple-struct-slot)) "Return a form to set the value of a simple structure slot." `(setf (mem-ref ,ptr ',(slot-type slot) ,(slot-offset slot)) ,value)) ;;;### Aggregate Slots (defclass aggregate-struct-slot (foreign-struct-slot) ((count :initarg :count :accessor slot-count)) (:documentation "Aggregate structure slots.")) ;;; A case could be made for just returning an error here instead of ;;; this rather DWIM-ish behavior to return the address. It would ;;; complicate being able to chain together slot names when accessing ;;; slot values in nested structures though. (defmethod foreign-struct-slot-value (ptr (slot aggregate-struct-slot)) "Return a pointer to SLOT relative to PTR." (foreign-struct-slot-pointer ptr slot)) (defmethod foreign-struct-slot-value-form (ptr (slot aggregate-struct-slot)) "Return a form to get the value of SLOT relative to PTR." (foreign-struct-slot-pointer-form ptr slot)) ;;; This is definitely an error though. Eventually, we could define a ;;; new type of type translator that can convert certain aggregate ;;; types, notably C strings or arrays of integers. For now, just error. (defmethod (setf foreign-struct-slot-value) (value ptr (slot aggregate-struct-slot)) "Signal an error; setting aggregate slot values is forbidden." (declare (ignore value ptr)) (error "Cannot set value of aggregate slot ~A." slot)) (defmethod foreign-struct-slot-set-form (value ptr (slot aggregate-struct-slot)) "Signal an error; setting aggregate slot values is forbidden." (declare (ignore value ptr)) (error "Cannot set value of aggregate slot ~A." slot)) ;;;## Defining Foreign Structures (defun make-struct-slot (name offset type count) "Make the appropriate type of structure slot." ;; If TYPE is an aggregate type or COUNT is >1, create an ;; AGGREGATE-STRUCT-SLOT, otherwise a SIMPLE-STRUCT-SLOT. (if (or (> count 1) (aggregatep (parse-type type))) (make-instance 'aggregate-struct-slot :offset offset :type type :name name :count count) (make-instance 'simple-struct-slot :offset offset :type type :name name))) ;;; Regarding structure alignment, the following ABIs were checked: ;;; - System-V ABI: x86, x86-64, ppc, arm, mips and itanium. (more?) ;;; - Mac OS X ABI Function Call Guide: ppc32, ppc64 and x86. ;;; ;;; Rules used here: ;;; ;;; 1. "An entire structure or union object is aligned on the same ;;; boundary as its most strictly aligned member." ;;; ;;; 2. "Each member is assigned to the lowest available offset with ;;; the appropriate alignment. This may require internal ;;; padding, depending on the previous member." ;;; ;;; 3. "A structure's size is increased, if necessary, to make it a ;;; multiple of the alignment. This may require tail padding, ;;; depending on the last member." ;;; ;;; Special cases from darwin/ppc32's ABI: ;;; http://developer.apple.com/documentation/DeveloperTools/Conceptual/LowLevelABI/index.html ;;; ;;; 4. "The embedding alignment of the first element in a data ;;; structure is equal to the element's natural alignment." ;;; ;;; 5. "For subsequent elements that have a natural alignment ;;; greater than 4 bytes, the embedding alignment is 4, unless ;;; the element is a vector." (note: this applies for ;;; structures too) ;; FIXME: get a better name for this. --luis (defun get-alignment (type alignment-type firstp) "Return alignment for TYPE according to ALIGNMENT-TYPE." (declare (ignorable firstp)) (ecase alignment-type (:normal #-(and darwin ppc) (foreign-type-alignment type) #+(and darwin ppc) (if firstp (foreign-type-alignment type) (min 4 (foreign-type-alignment type)))))) (defun adjust-for-alignment (type offset alignment-type firstp) "Return OFFSET aligned properly for TYPE according to ALIGNMENT-TYPE." (let* ((align (get-alignment type alignment-type firstp)) (rem (mod offset align))) (if (zerop rem) offset (+ offset (- align rem))))) (defun notice-foreign-struct-definition (name-and-options slots) "Parse and install a foreign structure definition." (destructuring-bind (name &key size (class 'foreign-struct-type)) (ensure-list name-and-options) (let ((struct (make-instance class :name name)) (current-offset 0) (max-align 1) (firstp t)) ;; determine offsets (dolist (slotdef slots) (destructuring-bind (slotname type &key (count 1) offset) slotdef (when (eq (canonicalize-foreign-type type) :void) (error "void type not allowed in structure definition: ~S" slotdef)) (setq current-offset (or offset (adjust-for-alignment type current-offset :normal firstp))) (let* ((slot (make-struct-slot slotname current-offset type count)) (align (get-alignment (slot-type slot) :normal firstp))) (setf (gethash slotname (slots struct)) slot) (when (> align max-align) (setq max-align align))) (incf current-offset (* count (foreign-type-size type)))) (setq firstp nil)) ;; calculate padding and alignment (setf (alignment struct) max-align) ; See point 1 above. (let ((tail-padding (- max-align (rem current-offset max-align)))) (unless (= tail-padding max-align) ; See point 3 above. (incf current-offset tail-padding))) (setf (size struct) (or size current-offset)) (notice-foreign-type name struct)))) (defmacro defcstruct (name-and-options &body fields) "Define the layout of a foreign structure." (discard-docstring fields) `(eval-when (:compile-toplevel :load-toplevel :execute) ;; n-f-s-d could do with this with mop:ensure-class. ,(when-let (class (getf (cdr (ensure-list name-and-options)) :class)) `(defclass ,class (foreign-struct-type) ())) (notice-foreign-struct-definition ',name-and-options ',fields))) ;;;## Accessing Foreign Structure Slots (defun get-slot-info (type slot-name) "Return the slot info for SLOT-NAME or raise an error." (let* ((struct (follow-typedefs (parse-type type))) (info (gethash slot-name (slots struct)))) (unless info (error "Undefined slot ~A in foreign type ~A." slot-name type)) info)) (defun foreign-slot-pointer (ptr type slot-name) "Return the address of SLOT-NAME in the structure at PTR." (foreign-struct-slot-pointer ptr (get-slot-info type slot-name))) (defun foreign-slot-offset (type slot-name) "Return the offset of SLOT in a struct TYPE." (slot-offset (get-slot-info type slot-name))) (defun foreign-slot-value (ptr type slot-name) "Return the value of SLOT-NAME in the foreign structure at PTR." (foreign-struct-slot-value ptr (get-slot-info type slot-name))) (define-compiler-macro foreign-slot-value (&whole form ptr type slot-name) "Optimizer for FOREIGN-SLOT-VALUE when TYPE is constant." (if (and (constantp type) (constantp slot-name)) (foreign-struct-slot-value-form ptr (get-slot-info (eval type) (eval slot-name))) form)) (define-setf-expander foreign-slot-value (ptr type slot-name &environment env) "SETF expander for FOREIGN-SLOT-VALUE." (multiple-value-bind (dummies vals newval setter getter) (get-setf-expansion ptr env) (declare (ignore setter newval)) (if (and (constantp type) (constantp slot-name)) ;; if TYPE and SLOT-NAME are constant we avoid rebinding them ;; so that the compiler macro on FOREIGN-SLOT-SET works. (with-unique-names (store) (values dummies vals (list store) `(progn (foreign-slot-set ,store ,getter ,type ,slot-name) ,store) `(foreign-slot-value ,getter ,type ,slot-name))) ;; if not... (with-unique-names (store slot-name-tmp type-tmp) (values (list* type-tmp slot-name-tmp dummies) (list* type slot-name vals) (list store) `(progn (foreign-slot-set ,store ,getter ,type-tmp ,slot-name-tmp) ,store) `(foreign-slot-value ,getter ,type-tmp ,slot-name-tmp)))))) (defun foreign-slot-set (value ptr type slot-name) "Set the value of SLOT-NAME in a foreign structure." (setf (foreign-struct-slot-value ptr (get-slot-info type slot-name)) value)) (define-compiler-macro foreign-slot-set (&whole form value ptr type slot-name) "Optimizer when TYPE and SLOT-NAME are constant." (if (and (constantp type) (constantp slot-name)) (foreign-struct-slot-set-form value ptr (get-slot-info (eval type) (eval slot-name))) form)) (defmacro with-foreign-slots ((vars ptr type) &body body) "Create local symbol macros for each var in VARS to reference foreign slots in PTR of TYPE. Similar to WITH-SLOTS." (let ((ptr-var (gensym "PTR"))) `(let ((,ptr-var ,ptr)) (symbol-macrolet ,(loop for var in vars collect `(,var (foreign-slot-value ,ptr-var ',type ',var))) ,@body)))) ;;; We could add an option to define a struct instead of a class, in ;;; the unlikely event someone needs something like that. (defmacro define-c-struct-wrapper (class-and-type supers &optional slots) "Define a new class with CLOS slots matching those of a foreign struct type. An INITIALIZE-INSTANCE method is defined which takes a :POINTER initarg that is used to store the slots of a foreign object. This pointer is only used for initialization and it is not retained. CLASS-AND-TYPE is either a list of the form (class-name struct-type) or a single symbol naming both. The class will inherit SUPERS. If a list of SLOTS is specified, only those slots will be defined and stored." (destructuring-bind (class-name &optional (struct-type class-name)) (ensure-list class-and-type) (let ((slots (or slots (foreign-slot-names struct-type)))) `(progn (defclass ,class-name ,supers ,(loop for slot in slots collect `(,slot :reader ,(format-symbol t "~A-~A" class-name slot)))) ;; This could be done in a parent class by using ;; FOREIGN-SLOT-NAMES when instantiating but then the compiler ;; macros wouldn't kick in. (defmethod initialize-instance :after ((inst ,class-name) &key pointer) (with-foreign-slots (,slots pointer ,struct-type) ,@(loop for slot in slots collect `(setf (slot-value inst ',slot) ,slot)))) ',class-name)))) ;;;# Foreign Unions ;;; ;;; A union is a FOREIGN-STRUCT-TYPE in which all slots have an offset ;;; of zero. ;;; See also the notes regarding ABI requirements in ;;; NOTICE-FOREIGN-STRUCT-DEFINITION (defun notice-foreign-union-definition (name-and-options slots) "Parse and install a foreign union definition." (destructuring-bind (name &key size) (ensure-list name-and-options) (let ((struct (make-instance 'foreign-struct-type :name name)) (max-size 0) (max-align 0)) (dolist (slotdef slots) (destructuring-bind (slotname type &key (count 1)) slotdef (when (eq (canonicalize-foreign-type type) :void) (error "void type not allowed in union definition: ~S" slotdef)) (let* ((slot (make-struct-slot slotname 0 type count)) (size (* count (foreign-type-size type))) (align (foreign-type-alignment (slot-type slot)))) (setf (gethash slotname (slots struct)) slot) (when (> size max-size) (setf max-size size)) (when (> align max-align) (setf max-align align))))) (setf (size struct) (or size max-size)) (setf (alignment struct) max-align) (notice-foreign-type name struct)))) (defmacro defcunion (name &body fields) "Define the layout of a foreign union." (discard-docstring fields) `(eval-when (:compile-toplevel :load-toplevel :execute) (notice-foreign-union-definition ',name ',fields))) ;;;# Operations on Types (defmethod foreign-type-alignment (type) "Return the alignment in bytes of a foreign type." (foreign-type-alignment (parse-type type))) (defun foreign-alloc (type &key (initial-element nil initial-element-p) (initial-contents nil initial-contents-p) (count 1 count-p) null-terminated-p) "Allocate enough memory to hold COUNT objects of type TYPE. If INITIAL-ELEMENT is supplied, each element of the newly allocated memory is initialized with its value. If INITIAL-CONTENTS is supplied, each of its elements will be used to initialize the contents of the newly allocated memory." (let (contents-length) ;; Some error checking, etc... (when (and null-terminated-p (not (eq (canonicalize-foreign-type type) :pointer))) (error "Cannot use :NULL-TERMINATED-P with non-pointer types.")) (when (and initial-element-p initial-contents-p) (error "Cannot specify both :INITIAL-ELEMENT and :INITIAL-CONTENTS")) (when initial-contents-p (setq contents-length (length initial-contents)) (if count-p (assert (>= count contents-length)) (setq count contents-length))) ;; Everything looks good. (let ((ptr (%foreign-alloc (* (foreign-type-size type) (if null-terminated-p (1+ count) count))))) (when initial-element-p (dotimes (i count) (setf (mem-aref ptr type i) initial-element))) (when initial-contents-p (dotimes (i contents-length) (setf (mem-aref ptr type i) (elt initial-contents i)))) (when null-terminated-p (setf (mem-aref ptr :pointer count) (null-pointer))) ptr))) ;;; Simple compiler macro that kicks in when TYPE is constant and only ;;; the COUNT argument is passed. (Note: hard-coding the type's size ;;; into the fasl will likely break CLISP fasl cross-platform ;;; compatibilty.) (define-compiler-macro foreign-alloc (&whole form type &rest args &key (count 1 count-p) &allow-other-keys) (if (or (and count-p (<= (length args) 2)) (null args)) (cond ((and (constantp type) (constantp count)) `(%foreign-alloc ,(* (eval count) (foreign-type-size (eval type))))) ((constantp type) `(%foreign-alloc (* ,count ,(foreign-type-size (eval type))))) (t form)) form)) (defmacro with-foreign-object ((var type &optional (count 1)) &body body) "Bind VAR to a pointer to COUNT objects of TYPE during BODY. The buffer has dynamic extent and may be stack allocated." `(with-foreign-pointer (,var ,(if (constantp type) ;; with-foreign-pointer may benefit from constant folding: (if (constantp count) (* (eval count) (foreign-type-size (eval type))) `(* ,count ,(foreign-type-size (eval type)))) `(* ,count (foreign-type-size ,type)))) ,@body)) (defmacro with-foreign-objects (bindings &body body) (if bindings `(with-foreign-object ,(car bindings) (with-foreign-objects ,(cdr bindings) ,@body)) `(progn ,@body))) ;;;## Anonymous Type Translators ;;; ;;; (:wrapper :to-c some-function :from-c another-function) ;;; ;;; TODO: We will need to add a FREE function to this as well I think. ;;; --james (define-foreign-type foreign-type-wrapper () ((to-c :initarg :to-c :reader wrapper-to-c) (from-c :initarg :from-c :reader wrapper-from-c)) (:documentation "Wrapper type.")) (define-parse-method :wrapper (base-type &key to-c from-c) (make-instance 'foreign-type-wrapper :actual-type (parse-type base-type) :to-c (or to-c 'identity) :from-c (or from-c 'identity))) (defmethod translate-to-foreign (value (type foreign-type-wrapper)) (translate-to-foreign (funcall (slot-value type 'to-c) value) (actual-type type))) (defmethod translate-from-foreign (value (type foreign-type-wrapper)) (funcall (slot-value type 'from-c) (translate-from-foreign value (actual-type type)))) ;;;# Other types ;;; Boolean type. Maps to an :int by default. Only accepts integer types. (define-foreign-type foreign-boolean-type () ()) (define-parse-method :boolean (&optional (base-type :int)) (make-instance 'foreign-boolean-type :actual-type (ecase (canonicalize-foreign-type base-type) ((:char :unsigned-char :int :unsigned-int :long :unsigned-long #-cffi-sys::no-long-long :long-long #-cffi-sys::no-long-long :unsigned-long-long) base-type)))) (defmethod translate-to-foreign (value (type foreign-boolean-type)) (if value 1 0)) (defmethod translate-from-foreign (value (type foreign-boolean-type)) (not (zerop value))) (defmethod expand-to-foreign (value (type foreign-boolean-type)) "Optimization for the :boolean type." (if (constantp value) (if (eval value) 1 0) `(if ,value 1 0))) (defmethod expand-from-foreign (value (type foreign-boolean-type)) "Optimization for the :boolean type." (if (constantp value) ; very unlikely, heh (not (zerop (eval value))) `(not (zerop ,value)))) ;;;# Typedefs for built-in types. (defctype :uchar :unsigned-char) (defctype :ushort :unsigned-short) (defctype :uint :unsigned-int) (defctype :ulong :unsigned-long) (defctype :llong :long-long) (defctype :ullong :unsigned-long-long) ;;; We try to define the :[u]int{8,16,32,64} types by looking at ;;; the sizes of the built-in integer types and defining typedefs. (eval-when (:compile-toplevel :load-toplevel :execute) (macrolet ((match-types (sized-types mtypes) `(progn ,@(loop for (type . size-or-type) in sized-types for m = (car (member (if (keywordp size-or-type) (foreign-type-size size-or-type) size-or-type) mtypes :key #'foreign-type-size)) when m collect `(defctype ,type ,m))))) ;; signed (match-types ((:int8 . 1) (:int16 . 2) (:int32 . 4) (:int64 . 8) (:intptr . :pointer)) (:char :short :int :long :long-long)) ;; unsigned (match-types ((:uint8 . 1) (:uint16 . 2) (:uint32 . 4) (:uint64 . 8) (:uintptr . :pointer)) (:unsigned-char :unsigned-short :unsigned-int :unsigned-long :unsigned-long-long))))
36,836
Common Lisp
.lisp
767
41.143416
93
0.655525
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
41c12810268e915d195c8f90007510aec141ebbd131217c6809ee023b80a7320
21,632
[ -1 ]
21,633
cffi-clisp.lisp
rheaplex_minara/lib/cffi/src/cffi-clisp.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; cffi-clisp.lisp --- CFFI-SYS implementation for CLISP. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; Copyright (C) 2005-2006, Joerg Hoehle <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;;# Administrivia (defpackage #:cffi-sys (:use #:common-lisp #:alexandria) (:export #:canonicalize-symbol-name-case #:foreign-pointer #:pointerp #:pointer-eq #:null-pointer #:null-pointer-p #:inc-pointer #:make-pointer #:pointer-address #:%foreign-alloc #:foreign-free #:with-foreign-pointer #:%foreign-funcall #:%foreign-funcall-pointer #:%foreign-type-alignment #:%foreign-type-size #:%load-foreign-library #:%close-foreign-library #:native-namestring #:%mem-ref #:%mem-set #:make-shareable-byte-vector #:with-pointer-to-vector-data #:%foreign-symbol-pointer #:%defcallback #:%callback)) (in-package #:cffi-sys) ;;;# Symbol Case (defun canonicalize-symbol-name-case (name) (declare (string name)) (string-upcase name)) ;;;# Built-In Foreign Types (defun convert-foreign-type (type) "Convert a CFFI built-in type keyword to a CLisp FFI type." (ecase type (:char 'ffi:char) (:unsigned-char 'ffi:uchar) (:short 'ffi:short) (:unsigned-short 'ffi:ushort) (:int 'ffi:int) (:unsigned-int 'ffi:uint) (:long 'ffi:long) (:unsigned-long 'ffi:ulong) (:long-long 'ffi:sint64) (:unsigned-long-long 'ffi:uint64) (:float 'ffi:single-float) (:double 'ffi:double-float) ;; Clisp's FFI:C-POINTER converts NULL to NIL. For now ;; we have a workaround in the pointer operations... (:pointer 'ffi:c-pointer) (:void nil))) (defun %foreign-type-size (type) "Return the size in bytes of objects having foreign type TYPE." (nth-value 0 (ffi:sizeof (convert-foreign-type type)))) ;; Remind me to buy a beer for whoever made getting the alignment ;; of foreign types part of the public interface in CLisp. :-) (defun %foreign-type-alignment (type) "Return the structure alignment in bytes of foreign TYPE." #+(and darwin ppc) (case type ((:double :long-long :unsigned-long-long) (return-from %foreign-type-alignment 8))) ;; Override not necessary for the remaining types... (nth-value 1 (ffi:sizeof (convert-foreign-type type)))) ;;;# Basic Pointer Operations (deftype foreign-pointer () '(or null ffi:foreign-address)) (defun pointerp (ptr) "Return true if PTR is a foreign pointer." (or (null ptr) (typep ptr 'ffi:foreign-address))) (defun pointer-eq (ptr1 ptr2) "Return true if PTR1 and PTR2 point to the same address." (eql (ffi:foreign-address-unsigned ptr1) (ffi:foreign-address-unsigned ptr2))) (defun null-pointer () "Return a null foreign pointer." (ffi:unsigned-foreign-address 0)) (defun null-pointer-p (ptr) "Return true if PTR is a null foreign pointer." (or (null ptr) (zerop (ffi:foreign-address-unsigned ptr)))) (defun inc-pointer (ptr offset) "Return a pointer pointing OFFSET bytes past PTR." (ffi:unsigned-foreign-address (+ offset (if (null ptr) 0 (ffi:foreign-address-unsigned ptr))))) (defun make-pointer (address) "Return a pointer pointing to ADDRESS." (ffi:unsigned-foreign-address address)) (defun pointer-address (ptr) "Return the address pointed to by PTR." (ffi:foreign-address-unsigned ptr)) ;;;# Foreign Memory Allocation (defun %foreign-alloc (size) "Allocate SIZE bytes of foreign-addressable memory and return a pointer to the allocated block. An implementation-specific error is signalled if the memory cannot be allocated." (ffi:foreign-address (ffi:allocate-shallow 'ffi:uint8 :count size))) (defun foreign-free (ptr) "Free a pointer PTR allocated by FOREIGN-ALLOC. The results are undefined if PTR is used after being freed." (ffi:foreign-free ptr)) (defmacro with-foreign-pointer ((var size &optional size-var) &body body) "Bind VAR to a pointer to SIZE bytes of foreign-addressable memory during BODY. Both PTR and the memory block pointed to have dynamic extent and may be stack allocated if supported by the implementation. If SIZE-VAR is supplied, it will be bound to SIZE during BODY." (unless size-var (setf size-var (gensym "SIZE"))) (let ((obj-var (gensym))) `(let ((,size-var ,size)) (ffi:with-foreign-object (,obj-var `(ffi:c-array ffi:uint8 ,,size-var)) (let ((,var (ffi:foreign-address ,obj-var))) ,@body))))) ;;;# Memory Access (defun %mem-ref (ptr type &optional (offset 0)) "Dereference a pointer OFFSET bytes from PTR to an object of built-in foreign TYPE. Returns the object as a foreign pointer or Lisp number." (ffi:memory-as ptr (convert-foreign-type type) offset)) (define-compiler-macro %mem-ref (&whole form ptr type &optional (offset 0)) "Compiler macro to open-code when TYPE is constant." (if (constantp type) `(ffi:memory-as ,ptr ',(convert-foreign-type (eval type)) ,offset) form)) (defun %mem-set (value ptr type &optional (offset 0)) "Set a pointer OFFSET bytes from PTR to an object of built-in foreign TYPE to VALUE." (setf (ffi:memory-as ptr (convert-foreign-type type) offset) value)) (define-compiler-macro %mem-set (&whole form value ptr type &optional (offset 0)) (if (constantp type) ;; (setf (ffi:memory-as) value) is exported, but not so nice ;; w.r.t. the left to right evaluation rule `(ffi::write-memory-as ,value ,ptr ',(convert-foreign-type (eval type)) ,offset) form)) ;;;# Shareable Vectors ;;; ;;; This interface is very experimental. WITH-POINTER-TO-VECTOR-DATA ;;; should be defined to perform a copy-in/copy-out if the Lisp ;;; implementation can't do this. (declaim (inline make-shareable-byte-vector)) (defun make-shareable-byte-vector (size) "Create a Lisp vector of SIZE bytes can passed to WITH-POINTER-TO-VECTOR-DATA." (make-array size :element-type '(unsigned-byte 8))) (deftype shareable-byte-vector () `(vector (unsigned-byte 8))) (defmacro with-pointer-to-vector-data ((ptr-var vector) &body body) "Bind PTR-VAR to a foreign pointer to the data in VECTOR." (with-unique-names (vector-var size-var) `(let ((,vector-var ,vector)) (check-type ,vector-var shareable-byte-vector) (with-foreign-pointer (,ptr-var (length ,vector-var) ,size-var) ;; copy-in (loop for i below ,size-var do (%mem-set (aref ,vector-var i) ,ptr-var :unsigned-char i)) (unwind-protect (progn ,@body) ;; copy-out (loop for i below ,size-var do (setf (aref ,vector-var i) (%mem-ref ,ptr-var :unsigned-char i)))))))) ;;;# Foreign Function Calling (defun parse-foreign-funcall-args (args) "Return three values, a list of CLISP FFI types, a list of values to pass to the function, and the CLISP FFI return type." (let ((return-type nil)) (loop for (type arg) on args by #'cddr if arg collect (list (gensym) (convert-foreign-type type)) into types and collect arg into fargs else do (setf return-type (convert-foreign-type type)) finally (return (values types fargs return-type))))) (defun convert-cconv (calling-convention) (ecase calling-convention (:stdcall :stdc-stdcall) (:cdecl :stdc))) (defun c-function-type (arg-types rettype calling-convention) "Generate the apropriate CLISP foreign type specification. Also takes care of converting the calling convention names." `(ffi:c-function (:arguments ,@arg-types) (:return-type ,rettype) (:language ,(convert-cconv calling-convention)))) ;;; Quick hack around the fact that the CFFI package is not yet ;;; defined when this file is loaded. I suppose we could arrange for ;;; the CFFI package to be defined a bit earlier, though. (defun library-handle-form (name) (flet ((find-cffi-symbol (symbol) (find-symbol (symbol-name symbol) '#:cffi))) `(,(find-cffi-symbol '#:foreign-library-handle) (,(find-cffi-symbol '#:get-foreign-library) ',name)))) (eval-when (:compile-toplevel :load-toplevel :execute) ;; version 2.40 (CVS 2006-09-03, to be more precise) added a ;; PROPERTIES argument to FFI::FOREIGN-LIBRARY-FUNCTION. (defun post-2.40-ffi-interface-p () (let ((f-l-f (find-symbol (string '#:foreign-library-function) '#:ffi))) (if (and f-l-f (= (length (ext:arglist f-l-f)) 5)) '(:and) '(:or)))) ;; FFI::FOREIGN-LIBRARY-FUNCTION and FFI::FOREIGN-LIBRARY-VARIABLE ;; were deprecated in 2.41 and removed in 2.45. (defun post-2.45-ffi-interface-p () (if (find-symbol (string '#:foreign-library-function) '#:ffi) '(:or) '(:and)))) #+#.(cffi-sys::post-2.45-ffi-interface-p) (defun %foreign-funcall-aux (name type library) `(ffi::find-foreign-function ,name ,type nil ,library nil nil)) #-#.(cffi-sys::post-2.45-ffi-interface-p) (defun %foreign-funcall-aux (name type library) `(ffi::foreign-library-function ,name ,library nil #+#.(cffi-sys::post-2.40-ffi-interface-p) nil ,type)) (defmacro %foreign-funcall (name args &key library calling-convention) "Invoke a foreign function called NAME, taking pairs of foreign-type/value pairs from ARGS. If a single element is left over at the end of ARGS, it specifies the foreign return type of the function call." (multiple-value-bind (types fargs rettype) (parse-foreign-funcall-args args) `(funcall (load-time-value (handler-case ,(%foreign-funcall-aux name `(ffi:parse-c-type ',(c-function-type types rettype calling-convention)) (if (eq library :default) :default (library-handle-form library))) (error (err) (warn "~A" err)))) ,@fargs))) (defmacro %foreign-funcall-pointer (ptr args &key calling-convention) "Similar to %foreign-funcall but takes a pointer instead of a string." (multiple-value-bind (types fargs rettype) (parse-foreign-funcall-args args) `(funcall (ffi:foreign-function ,ptr (load-time-value (ffi:parse-c-type ',(c-function-type types rettype calling-convention)))) ,@fargs))) ;;;# Callbacks ;;; *CALLBACKS* contains the callbacks defined by the CFFI DEFCALLBACK ;;; macro. The symbol naming the callback is the key, and the value ;;; is a list containing a Lisp function, the parsed CLISP FFI type of ;;; the callback, and a saved pointer that should not persist across ;;; saved images. (defvar *callbacks* (make-hash-table)) ;;; Return a CLISP FFI function type for a CFFI callback function ;;; given a return type and list of argument names and types. (eval-when (:compile-toplevel :load-toplevel :execute) (defun callback-type (rettype arg-names arg-types calling-convention) (ffi:parse-c-type `(ffi:c-function (:arguments ,@(mapcar (lambda (sym type) (list sym (convert-foreign-type type))) arg-names arg-types)) (:return-type ,(convert-foreign-type rettype)) (:language ,(convert-cconv calling-convention)))))) ;;; Register and create a callback function. (defun register-callback (name function parsed-type) (setf (gethash name *callbacks*) (list function parsed-type (ffi:with-foreign-object (ptr 'ffi:c-pointer) ;; Create callback by converting Lisp function to foreign (setf (ffi:memory-as ptr parsed-type) function) (ffi:foreign-value ptr))))) ;;; Restore all saved callback pointers when restarting the Lisp ;;; image. This is pushed onto CUSTOM:*INIT-HOOKS*. ;;; Needs clisp > 2.35, bugfix 2005-09-29 (defun restore-callback-pointers () (maphash (lambda (name list) (register-callback name (first list) (second list))) *callbacks*)) ;;; Add RESTORE-CALLBACK-POINTERS to the lists of functions to run ;;; when an image is restarted. (eval-when (:load-toplevel :execute) (pushnew 'restore-callback-pointers custom:*init-hooks*)) ;;; Define a callback function NAME to run BODY with arguments ;;; ARG-NAMES translated according to ARG-TYPES and the return type ;;; translated according to RETTYPE. Obtain a pointer that can be ;;; passed to C code for this callback by calling %CALLBACK. (defmacro %defcallback (name rettype arg-names arg-types body &key calling-convention) `(register-callback ',name (lambda ,arg-names ,body) ,(callback-type rettype arg-names arg-types calling-convention))) ;;; Look up the name of a callback and return a pointer that can be ;;; passed to a C function. Signals an error if no callback is ;;; defined called NAME. (defun %callback (name) (multiple-value-bind (list winp) (gethash name *callbacks*) (unless winp (error "Undefined callback: ~S" name)) (third list))) ;;;# Loading and Closing Foreign Libraries (defun %load-foreign-library (name path) "Load a foreign library from PATH." (declare (ignore name)) #+#.(cffi-sys::post-2.45-ffi-interface-p) (ffi:open-foreign-library path) #-#.(cffi-sys::post-2.45-ffi-interface-p) (ffi::foreign-library path)) (defun %close-foreign-library (handle) "Close a foreign library." (ffi:close-foreign-library handle)) (defun native-namestring (pathname) (namestring pathname)) ;;;# Foreign Globals (defun %foreign-symbol-pointer (name library) "Returns a pointer to a foreign symbol NAME." (prog1 (ignore-errors (ffi:foreign-address #+#.(cffi-sys::post-2.45-ffi-interface-p) (ffi::find-foreign-variable name nil library nil nil) #-#.(cffi-sys::post-2.45-ffi-interface-p) (ffi::foreign-library-variable name library nil nil)))))
15,091
Common Lisp
.lisp
352
38.03125
79
0.687755
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
f6006314144151d9f2e26a341deff9971b629af1d8d56f15750a38f1e8063968
21,633
[ -1 ]
21,634
enum.lisp
rheaplex_minara/lib/cffi/src/enum.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; enum.lisp --- Defining foreign constants as Lisp keywords. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi) ;;;# Foreign Constants as Lisp Keywords ;;; ;;; This module defines the DEFCENUM macro, which provides an ;;; interface for defining a type and associating a set of integer ;;; constants with keyword symbols for that type. ;;; ;;; The keywords are automatically translated to the appropriate ;;; constant for the type by a type translator when passed as ;;; arguments or a return value to a foreign function. (defclass foreign-enum (foreign-typedef enhanced-foreign-type) ((keyword-values :initform (make-hash-table :test 'eq) :reader keyword-values) (value-keywords :initform (make-hash-table) :reader value-keywords)) (:documentation "Describes a foreign enumerated type.")) (defun make-foreign-enum (type-name base-type values) "Makes a new instance of the foreign-enum class." (let ((type (make-instance 'foreign-enum :name type-name :actual-type (parse-type base-type))) (default-value 0)) (dolist (pair values) (destructuring-bind (keyword &optional (value default-value)) (ensure-list pair) (check-type keyword keyword) (check-type value integer) (if (gethash keyword (keyword-values type)) (error "A foreign enum cannot contain duplicate keywords: ~S." keyword) (setf (gethash keyword (keyword-values type)) value)) ;; This is completely arbitrary behaviour: we keep the last we ;; value->keyword mapping. I suppose the opposite would be ;; just as good (keeping the first). Returning a list with all ;; the keywords might be a solution too? Suggestions ;; welcome. --luis (setf (gethash value (value-keywords type)) keyword) (setq default-value (1+ value)))) type)) (defmacro defcenum (name-and-options &body enum-list) "Define an foreign enumerated type." (discard-docstring enum-list) (destructuring-bind (name &optional (base-type :int)) (ensure-list name-and-options) `(eval-when (:compile-toplevel :load-toplevel :execute) (notice-foreign-type ',name (make-foreign-enum ',name ',base-type ',enum-list))))) (defun hash-keys-to-list (ht) (loop for k being the hash-keys in ht collect k)) (defun foreign-enum-keyword-list (enum-type) "Return a list of KEYWORDS defined in ENUM-TYPE." (hash-keys-to-list (keyword-values (parse-type enum-type)))) ;;; These [four] functions could be good canditates for compiler macros ;;; when the value or keyword is constant. I am not going to bother ;;; until someone has a serious performance need to do so though. --jamesjb (defun %foreign-enum-value (type keyword &key errorp) (check-type keyword keyword) (or (gethash keyword (keyword-values type)) (when errorp (error "~S is not defined as a keyword for enum type ~S." keyword type)))) (defun foreign-enum-value (type keyword &key (errorp t)) "Convert a KEYWORD into an integer according to the enum TYPE." (let ((type-obj (parse-type type))) (if (not (typep type-obj 'foreign-enum)) (error "~S is not a foreign enum type." type) (%foreign-enum-value type-obj keyword :errorp errorp)))) (defun %foreign-enum-keyword (type value &key errorp) (check-type value integer) (or (gethash value (value-keywords type)) (when errorp (error "~S is not defined as a value for enum type ~S." value type)))) (defun foreign-enum-keyword (type value &key (errorp t)) "Convert an integer VALUE into a keyword according to the enum TYPE." (let ((type-obj (parse-type type))) (if (not (typep type-obj 'foreign-enum)) (error "~S is not a foreign enum type." type) (%foreign-enum-keyword type-obj value :errorp errorp)))) (defmethod translate-to-foreign (value (type foreign-enum)) (if (keywordp value) (%foreign-enum-value type value :errorp t) value)) (defmethod translate-from-foreign (value (type foreign-enum)) (%foreign-enum-keyword type value :errorp t)) ;;;# Foreign Bitfields as Lisp keywords ;;; ;;; DEFBITFIELD is an abstraction similar to the one provided by DEFCENUM. ;;; With some changes to DEFCENUM, this could certainly be implemented on ;;; top of it. (defclass foreign-bitfield (foreign-typedef enhanced-foreign-type) ((symbol-values :initform (make-hash-table :test 'eq) :reader symbol-values) (value-symbols :initform (make-hash-table) :reader value-symbols)) (:documentation "Describes a foreign bitfield type.")) (defun make-foreign-bitfield (type-name base-type values) "Makes a new instance of the foreign-bitfield class." (let ((type (make-instance 'foreign-bitfield :name type-name :actual-type (parse-type base-type))) (bit-floor 1)) (dolist (pair values) ;; bit-floor rule: find the greatest single-bit int used so far, ;; and store its left-shift (destructuring-bind (symbol &optional (value (prog1 bit-floor (setf bit-floor (ash bit-floor 1))) value-p)) (ensure-list pair) (check-type symbol symbol) (when value-p (check-type value integer) (when (and (>= value bit-floor) (single-bit-p value)) (setf bit-floor (ash value 1)))) (if (gethash symbol (symbol-values type)) (error "A foreign bitfield cannot contain duplicate symbols: ~S." symbol) (setf (gethash symbol (symbol-values type)) value)) (push symbol (gethash value (value-symbols type))))) type)) (defmacro defbitfield (name-and-options &body masks) "Define an foreign enumerated type." (discard-docstring masks) (destructuring-bind (name &optional (base-type :int)) (ensure-list name-and-options) `(eval-when (:compile-toplevel :load-toplevel :execute) (notice-foreign-type ',name (make-foreign-bitfield ',name ',base-type ',masks))))) (defun foreign-bitfield-symbol-list (bitfield-type) "Return a list of SYMBOLS defined in BITFIELD-TYPE." (hash-keys-to-list (symbol-values (parse-type bitfield-type)))) (defun %foreign-bitfield-value (type symbols) (reduce #'logior symbols :key (lambda (symbol) (check-type symbol symbol) (or (gethash symbol (symbol-values type)) (error "~S is not a valid symbol for bitfield type ~S." symbol type))))) (defun foreign-bitfield-value (type symbols) "Convert a list of symbols into an integer according to the TYPE bitfield." (let ((type-obj (parse-type type))) (if (not (typep type-obj 'foreign-bitfield)) (error "~S is not a foreign bitfield type." type) (%foreign-bitfield-value type-obj symbols)))) (defun %foreign-bitfield-symbols (type value) (check-type value integer) (loop for mask being the hash-keys in (value-symbols type) using (hash-value symbols) when (= (logand value mask) mask) append symbols)) (defun foreign-bitfield-symbols (type value) "Convert an integer VALUE into a list of matching symbols according to the bitfield TYPE." (let ((type-obj (parse-type type))) (if (not (typep type-obj 'foreign-bitfield)) (error "~S is not a foreign bitfield type." type) (%foreign-bitfield-symbols type-obj value)))) (defmethod translate-to-foreign (value (type foreign-bitfield)) (if (integerp value) value (%foreign-bitfield-value type (ensure-list value)))) (defmethod translate-from-foreign (value (type foreign-bitfield)) (%foreign-bitfield-symbols type value))
9,017
Common Lisp
.lisp
192
41.151042
77
0.682991
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
33d947fc22da2bd89567fd6fffc260408745fcbb8ac9d3036225f7e73498d4bc
21,634
[ 432997 ]
21,635
strings.lisp
rheaplex_minara/lib/cffi/src/strings.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; strings.lisp --- Operations on foreign strings. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; Copyright (C) 2005-2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi) ;;;# Foreign String Conversion ;;; ;;; Functions for converting NULL-terminated C-strings to Lisp strings ;;; and vice versa. The string functions accept an ENCODING keyword ;;; argument which is used to specify the encoding to use when ;;; converting to/from foreign strings. (defvar *default-foreign-encoding* :utf-8 "Default foreign encoding.") ;;; TODO: refactor, sigh. Also, this should probably be a function. (defmacro bget (ptr off &optional (bytes 1) (endianness :ne)) (let ((big-endian (member endianness '(:be #+big-endian :ne #+little-endian :re)))) (once-only (ptr off) (ecase bytes (1 `(mem-ref ,ptr :uint8 ,off)) (2 (if big-endian #+big-endian `(mem-ref ,ptr :uint16 ,off) #-big-endian `(dpb (mem-ref ,ptr :uint8 ,off) (byte 8 8) (mem-ref ,ptr :uint8 (1+ ,off))) #+little-endian `(mem-ref ,ptr :uint16 ,off) #-little-endian `(dpb (mem-ref ,ptr :uint8 (1+ ,off)) (byte 8 8) (mem-ref ,ptr :uint8 ,off)))) (4 (if big-endian #+big-endian `(mem-ref ,ptr :uint32 ,off) #-big-endian `(dpb (mem-ref ,ptr :uint8 ,off) (byte 8 24) (dpb (mem-ref ,ptr :uint8 (1+ ,off)) (byte 8 16) (dpb (mem-ref ,ptr :uint8 (+ ,off 2)) (byte 8 8) (mem-ref ,ptr :uint8 (+ ,off 3))))) #+little-endian `(mem-ref ,ptr :uint32 ,off) #-little-endian `(dpb (mem-ref ,ptr :uint8 (+ ,off 3)) (byte 8 24) (dpb (mem-ref ,ptr :uint8 (+ ,off 2)) (byte 8 16) (dpb (mem-ref ,ptr :uint8 (1+ ,off)) (byte 8 8) (mem-ref ,ptr :uint8 ,off)))))))))) (defmacro bset (val ptr off &optional (bytes 1) (endianness :ne)) (let ((big-endian (member endianness '(:be #+big-endian :ne #+little-endian :re)))) (ecase bytes (1 `(setf (mem-ref ,ptr :uint8 ,off) ,val)) (2 (if big-endian #+big-endian `(setf (mem-ref ,ptr :uint16 ,off) ,val) #-big-endian `(setf (mem-ref ,ptr :uint8 (1+ ,off)) (ldb (byte 8 0) val) (mem-ref ,ptr :uint8 ,off) (ldb (byte 8 8) val)) #+little-endian `(setf (mem-ref ,ptr :uint16 ,off) ,val) #-little-endian `(setf (mem-ref ,ptr :uint8 ,off) (ldb (byte 8 0) val) (mem-ref ,ptr :uint8 (1+ ,off)) (ldb (byte 8 8) val)))) (4 (if big-endian #+big-endian `(setf (mem-ref ,ptr :uint32 ,off) ,val) #-big-endian `(setf (mem-ref ,ptr :uint8 (+ 3 ,off)) (ldb (byte 8 0) val) (mem-ref ,ptr :uint8 (+ 2 ,off)) (ldb (byte 8 8) val) (mem-ref ,ptr :uint8 (1+ ,off)) (ldb (byte 8 16) val) (mem-ref ,ptr :uint8 ,off) (ldb (byte 8 24) val)) #+little-endian `(setf (mem-ref ,ptr :uint32 ,off) ,val) #-little-endian `(setf (mem-ref ,ptr :uint8 ,off) (ldb (byte 8 0) val) (mem-ref ,ptr :uint8 (1+ ,off)) (ldb (byte 8 8) val) (mem-ref ,ptr :uint8 (+ ,off 2)) (ldb (byte 8 16) val) (mem-ref ,ptr :uint8 (+ ,off 3)) (ldb (byte 8 24) val))))))) ;;; TODO: tackle optimization notes. (defparameter *foreign-string-mappings* (instantiate-concrete-mappings ;; :optimize ((speed 3) (debug 0) (compilation-speed 0) (safety 0)) :octet-seq-getter bget :octet-seq-setter bset :octet-seq-type foreign-pointer :code-point-seq-getter babel::string-get :code-point-seq-setter babel::string-set :code-point-seq-type babel:simple-unicode-string)) (defun null-terminator-len (encoding) (length (enc-nul-encoding (get-character-encoding encoding)))) (defun lisp-string-to-foreign (string buffer bufsize &key (start 0) end offset (encoding *default-foreign-encoding*)) (check-type string string) (when offset (setq buffer (inc-pointer buffer offset))) (with-checked-simple-vector ((string (coerce string 'babel:unicode-string)) (start start) (end end)) (declare (type simple-string string)) (let ((mapping (lookup-mapping *foreign-string-mappings* encoding)) (nul-len (null-terminator-len encoding))) (assert (plusp bufsize)) (multiple-value-bind (size end) (funcall (octet-counter mapping) string start end (- bufsize nul-len)) (funcall (encoder mapping) string start end buffer 0) (dotimes (i nul-len) (setf (mem-ref buffer :char (+ size i)) 0)))) buffer)) ;;; Expands into a loop that calculates the length of the foreign ;;; string at PTR plus OFFSET, using ACCESSOR and looking for a null ;;; terminator of LENGTH bytes. (defmacro %foreign-string-length (ptr offset type length) (once-only (ptr offset) `(do ((i 0 (+ i ,length))) ((zerop (mem-ref ,ptr ,type (+ ,offset i))) i) (declare (fixnum i))))) ;;; Return the length in octets of the null terminated foreign string ;;; at POINTER plus OFFSET octets, assumed to be encoded in ENCODING, ;;; a CFFI encoding. This should be smart enough to look for 8-bit vs ;;; 16-bit null terminators, as appropriate for the encoding. (defun foreign-string-length (pointer &key (encoding *default-foreign-encoding*) (offset 0)) (ecase (null-terminator-len encoding) (1 (%foreign-string-length pointer offset :uint8 1)) (2 (%foreign-string-length pointer offset :uint16 2)) (4 (%foreign-string-length pointer offset :uint32 4)))) (defun foreign-string-to-lisp (pointer &key (offset 0) count (max-chars (1- array-total-size-limit)) (encoding *default-foreign-encoding*)) "Copy at most COUNT bytes from POINTER plus OFFSET encoded in ENCODING into a Lisp string and return it. If POINTER is a null pointer, NIL is returned." (unless (null-pointer-p pointer) (let ((count (or count (foreign-string-length pointer :encoding encoding :offset offset))) (mapping (lookup-mapping *foreign-string-mappings* encoding))) (assert (plusp max-chars)) (multiple-value-bind (size new-end) (funcall (code-point-counter mapping) pointer offset (+ offset count) max-chars) (let ((string (make-string size :element-type 'babel:unicode-char))) (funcall (decoder mapping) pointer offset new-end string 0) (values string (- new-end offset))))))) ;;;# Using Foreign Strings (defun foreign-string-alloc (string &key (encoding *default-foreign-encoding*) (null-terminated-p t) (start 0) end) "Allocate a foreign string containing Lisp string STRING. The string must be freed with FOREIGN-STRING-FREE." (check-type string string) (with-checked-simple-vector ((string (coerce string 'babel:unicode-string)) (start start) (end end)) (declare (type simple-string string)) (let* ((mapping (lookup-mapping *foreign-string-mappings* encoding)) (count (funcall (octet-counter mapping) string start end 0)) (length (if null-terminated-p (+ count (null-terminator-len encoding)) count)) (ptr (foreign-alloc :char :count length))) (funcall (encoder mapping) string start end ptr 0) (when null-terminated-p (dotimes (i (null-terminator-len encoding)) (setf (mem-ref ptr :char (+ count i)) 0))) (values ptr length)))) (defun foreign-string-free (ptr) "Free a foreign string allocated by FOREIGN-STRING-ALLOC." (foreign-free ptr)) (defmacro with-foreign-string ((var-or-vars lisp-string &rest args) &body body) "VAR-OR-VARS is not evaluated ans should a list of the form \(VAR &OPTIONAL BYTE-SIZE-VAR) or just a VAR symbol. VAR is bound to a foreign string containing LISP-STRING in BODY. When BYTE-SIZE-VAR is specified then bind the C buffer size \(including the possible null terminator\(s)) to this variable." (destructuring-bind (var &optional size-var) (ensure-list var-or-vars) `(multiple-value-bind (,var ,@(when size-var (list size-var))) (foreign-string-alloc ,lisp-string ,@args) (unwind-protect (progn ,@body) (foreign-string-free ,var))))) (defmacro with-foreign-strings (bindings &body body) "See WITH-FOREIGN-STRING's documentation." (if bindings `(with-foreign-string ,(first bindings) (with-foreign-strings ,(rest bindings) ,@body)) `(progn ,@body))) (defmacro with-foreign-pointer-as-string ((var-or-vars size &rest args) &body body) "VAR-OR-VARS is not evaluated and should be a list of the form \(VAR &OPTIONAL SIZE-VAR) or just a VAR symbol. VAR is bound to a foreign buffer of size SIZE within BODY. The return value is constructed by calling FOREIGN-STRING-TO-LISP on the foreign buffer along with ARGS." ; fix wording, sigh (destructuring-bind (var &optional size-var) (ensure-list var-or-vars) `(with-foreign-pointer (,var ,size ,size-var) (progn ,@body (values (foreign-string-to-lisp ,var ,@args)))))) ;;;# Automatic Conversion of Foreign Strings (define-foreign-type foreign-string-type () (;; CFFI encoding of this string. (encoding :initform nil :initarg :encoding :reader encoding) ;; Should we free after translating from foreign? (free-from-foreign :initarg :free-from-foreign :reader fst-free-from-foreign-p :initform nil :type boolean) ;; Should we free after translating to foreign? (free-to-foreign :initarg :free-to-foreign :reader fst-free-to-foreign-p :initform t :type boolean)) (:actual-type :pointer) (:simple-parser :string)) ;;; describe me (defun fst-encoding (type) (or (encoding type) *default-foreign-encoding*)) ;;; Display the encoding when printing a FOREIGN-STRING-TYPE instance. (defmethod print-object ((type foreign-string-type) stream) (print-unreadable-object (type stream :type t) (format stream "~S" (fst-encoding type)))) (defmethod translate-to-foreign ((s string) (type foreign-string-type)) (values (foreign-string-alloc s :encoding (fst-encoding type)) (fst-free-to-foreign-p type))) (defmethod translate-to-foreign (obj (type foreign-string-type)) (cond ((pointerp obj) (values obj nil)) ;; FIXME: we used to support UB8 vectors but not anymore. ;; ((typep obj '(array (unsigned-byte 8))) ;; (values (foreign-string-alloc obj) t)) (t (error "~A is not a Lisp string or pointer." obj)))) (defmethod translate-from-foreign (ptr (type foreign-string-type)) (unwind-protect (values (foreign-string-to-lisp ptr :encoding (fst-encoding type))) (when (fst-free-from-foreign-p type) (foreign-free ptr)))) (defmethod free-translated-object (ptr (type foreign-string-type) free-p) (when free-p (foreign-string-free ptr))) ;;;# STRING+PTR (define-foreign-type foreign-string+ptr-type (foreign-string-type) () (:simple-parser :string+ptr)) (defmethod translate-from-foreign (value (type foreign-string+ptr-type)) (list (call-next-method) value))
13,004
Common Lisp
.lisp
267
40.651685
80
0.626013
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
c67aa7345ed14f2f9bcc09a7e2bedac441aa0aa8a82745a64e7f38209305c8a0
21,635
[ 226213 ]
21,636
utils.lisp
rheaplex_minara/lib/cffi/src/utils.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; utils.lisp --- Various utilities. ;;; ;;; Copyright (C) 2005-2008, Luis Oliveira <loliveira(@)common-lisp.net> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi) (defmacro discard-docstring (body-var &optional force) "Discards the first element of the list in body-var if it's a string and the only element (or if FORCE is T)." `(when (and (stringp (car ,body-var)) (or ,force (cdr ,body-var))) (pop ,body-var))) (defun single-bit-p (integer) "Answer whether INTEGER, which must be an integer, is a single set twos-complement bit." (if (<= integer 0) nil ; infinite set bits for negatives (loop until (logbitp 0 integer) do (setf integer (ash integer -1)) finally (return (zerop (ash integer -1)))))) ;;; This function is here because it needs to be defined early. It's ;;; used by DEFINE-PARSE-METHOD and DEFCTYPE to warn users when ;;; they're defining types whose names belongs to the KEYWORD or CL ;;; packages. CFFI itself gets to use keywords without a warning. (defun warn-if-kw-or-belongs-to-cl (name) (let ((package (symbol-package name))) (when (or (eq package (find-package '#:cl)) (and (not (eq *package* (find-package '#:cffi))) (eq package (find-package '#:keyword)))) (warn "Defining a foreign type named ~S. This symbol belongs to the ~A ~ package and that may interfere with other code using CFFI." name (package-name package)))))
2,631
Common Lisp
.lisp
52
47.230769
79
0.696311
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
cc99d137eeb8639d61abd1de3b19b05f57caffcbe5a6422d32e4838559f10dde
21,636
[ 412601 ]
21,637
cffi-sbcl.lisp
rheaplex_minara/lib/cffi/src/cffi-sbcl.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; cffi-sbcl.lisp --- CFFI-SYS implementation for SBCL. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;;# Administrivia (defpackage #:cffi-sys (:use #:common-lisp #:sb-alien) (:import-from #:alexandria #:once-only #:with-unique-names #:when-let #:removef) (:export #:canonicalize-symbol-name-case #:foreign-pointer #:pointerp #:pointer-eq #:null-pointer #:null-pointer-p #:inc-pointer #:make-pointer #:pointer-address #:%foreign-alloc #:foreign-free #:with-foreign-pointer #:%foreign-funcall #:%foreign-funcall-pointer #:%foreign-type-alignment #:%foreign-type-size #:%load-foreign-library #:%close-foreign-library #:native-namestring #:%mem-ref #:%mem-set #:make-shareable-byte-vector #:with-pointer-to-vector-data #:%foreign-symbol-pointer #:%defcallback #:%callback)) (in-package #:cffi-sys) ;;;# Misfeatures (pushnew 'flat-namespace *features*) ;;;# Symbol Case (declaim (inline canonicalize-symbol-name-case)) (defun canonicalize-symbol-name-case (name) (declare (string name)) (string-upcase name)) ;;;# Basic Pointer Operations (deftype foreign-pointer () 'sb-sys:system-area-pointer) (declaim (inline pointerp)) (defun pointerp (ptr) "Return true if PTR is a foreign pointer." (sb-sys:system-area-pointer-p ptr)) (declaim (inline pointer-eq)) (defun pointer-eq (ptr1 ptr2) "Return true if PTR1 and PTR2 point to the same address." (declare (type system-area-pointer ptr1 ptr2)) (sb-sys:sap= ptr1 ptr2)) (declaim (inline null-pointer)) (defun null-pointer () "Construct and return a null pointer." (sb-sys:int-sap 0)) (declaim (inline null-pointer-p)) (defun null-pointer-p (ptr) "Return true if PTR is a null pointer." (declare (type system-area-pointer ptr)) (zerop (sb-sys:sap-int ptr))) (declaim (inline inc-pointer)) (defun inc-pointer (ptr offset) "Return a pointer pointing OFFSET bytes past PTR." (declare (type system-area-pointer ptr) (type integer offset)) (sb-sys:sap+ ptr offset)) (declaim (inline make-pointer)) (defun make-pointer (address) "Return a pointer pointing to ADDRESS." ;; (declare (type (unsigned-byte 32) address)) (sb-sys:int-sap address)) (declaim (inline pointer-address)) (defun pointer-address (ptr) "Return the address pointed to by PTR." (declare (type system-area-pointer ptr)) (sb-sys:sap-int ptr)) ;;;# Allocation ;;; ;;; Functions and macros for allocating foreign memory on the stack ;;; and on the heap. The main CFFI package defines macros that wrap ;;; FOREIGN-ALLOC and FOREIGN-FREE in UNWIND-PROTECT for the common usage ;;; when the memory has dynamic extent. (declaim (inline %foreign-alloc)) (defun %foreign-alloc (size) "Allocate SIZE bytes on the heap and return a pointer." ;; (declare (type (unsigned-byte 32) size)) (alien-sap (make-alien (unsigned 8) size))) (declaim (inline foreign-free)) (defun foreign-free (ptr) "Free a PTR allocated by FOREIGN-ALLOC." (declare (type system-area-pointer ptr)) (free-alien (sap-alien ptr (* (unsigned 8))))) (defmacro with-foreign-pointer ((var size &optional size-var) &body body) "Bind VAR to SIZE bytes of foreign memory during BODY. The pointer in VAR is invalid beyond the dynamic extent of BODY, and may be stack-allocated if supported by the implementation. If SIZE-VAR is supplied, it will be bound to SIZE during BODY." (unless size-var (setf size-var (gensym "SIZE"))) ;; If the size is constant we can stack-allocate. (if (constantp size) (let ((alien-var (gensym "ALIEN"))) `(with-alien ((,alien-var (array (unsigned 8) ,(eval size)))) (let ((,size-var ,(eval size)) (,var (alien-sap ,alien-var))) (declare (ignorable ,size-var)) ,@body))) `(let* ((,size-var ,size) (,var (%foreign-alloc ,size-var))) (unwind-protect (progn ,@body) (foreign-free ,var))))) ;;;# Shareable Vectors ;;; ;;; This interface is very experimental. WITH-POINTER-TO-VECTOR-DATA ;;; should be defined to perform a copy-in/copy-out if the Lisp ;;; implementation can't do this. (declaim (inline make-shareable-byte-vector)) (defun make-shareable-byte-vector (size) "Create a Lisp vector of SIZE bytes can passed to WITH-POINTER-TO-VECTOR-DATA." ; (declare (type sb-int:index size)) (make-array size :element-type '(unsigned-byte 8))) (defmacro with-pointer-to-vector-data ((ptr-var vector) &body body) "Bind PTR-VAR to a foreign pointer to the data in VECTOR." (let ((vector-var (gensym "VECTOR"))) `(let ((,vector-var ,vector)) (declare (type (sb-kernel:simple-unboxed-array (*)) ,vector-var)) (sb-sys:with-pinned-objects (,vector-var) (let ((,ptr-var (sb-sys:vector-sap ,vector-var))) ,@body))))) ;;;# Dereferencing ;;; Define the %MEM-REF and %MEM-SET functions, as well as compiler ;;; macros that optimize the case where the type keyword is constant ;;; at compile-time. (defmacro define-mem-accessors (&body pairs) `(progn (defun %mem-ref (ptr type &optional (offset 0)) (ecase type ,@(loop for (keyword fn) in pairs collect `(,keyword (,fn ptr offset))))) (defun %mem-set (value ptr type &optional (offset 0)) (ecase type ,@(loop for (keyword fn) in pairs collect `(,keyword (setf (,fn ptr offset) value))))) (define-compiler-macro %mem-ref (&whole form ptr type &optional (offset 0)) (if (constantp type) (ecase (eval type) ,@(loop for (keyword fn) in pairs collect `(,keyword `(,',fn ,ptr ,offset)))) form)) (define-compiler-macro %mem-set (&whole form value ptr type &optional (offset 0)) (if (constantp type) (once-only (value) (ecase (eval type) ,@(loop for (keyword fn) in pairs collect `(,keyword `(setf (,',fn ,ptr ,offset) ,value))))) form)))) (define-mem-accessors (:char sb-sys:signed-sap-ref-8) (:unsigned-char sb-sys:sap-ref-8) (:short sb-sys:signed-sap-ref-16) (:unsigned-short sb-sys:sap-ref-16) (:int sb-sys:signed-sap-ref-32) (:unsigned-int sb-sys:sap-ref-32) (:long sb-sys:signed-sap-ref-word) (:unsigned-long sb-sys:sap-ref-word) (:long-long sb-sys:signed-sap-ref-64) (:unsigned-long-long sb-sys:sap-ref-64) (:float sb-sys:sap-ref-single) (:double sb-sys:sap-ref-double) (:pointer sb-sys:sap-ref-sap)) ;;;# Calling Foreign Functions (defun convert-foreign-type (type-keyword) "Convert a CFFI type keyword to an SB-ALIEN type." (ecase type-keyword (:char 'char) (:unsigned-char 'unsigned-char) (:short 'short) (:unsigned-short 'unsigned-short) (:int 'int) (:unsigned-int 'unsigned-int) (:long 'long) (:unsigned-long 'unsigned-long) (:long-long 'long-long) (:unsigned-long-long 'unsigned-long-long) (:float 'single-float) (:double 'double-float) (:pointer 'system-area-pointer) (:void 'void))) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (/ (sb-alien-internals:alien-type-bits (sb-alien-internals:parse-alien-type (convert-foreign-type type-keyword) nil)) 8)) (defun %foreign-type-alignment (type-keyword) "Return the alignment in bytes of a foreign type." #+(and darwin ppc (not ppc64)) (case type-keyword ((:double :long-long :unsigned-long-long) (return-from %foreign-type-alignment 8))) ;; No override necessary for other types... (/ (sb-alien-internals:alien-type-alignment (sb-alien-internals:parse-alien-type (convert-foreign-type type-keyword) nil)) 8)) (defun foreign-funcall-type-and-args (args) "Return an SB-ALIEN function type for ARGS." (let ((return-type 'void)) (loop for (type arg) on args by #'cddr if arg collect (convert-foreign-type type) into types and collect arg into fargs else do (setf return-type (convert-foreign-type type)) finally (return (values types fargs return-type))))) (defmacro %%foreign-funcall (name types fargs rettype) "Internal guts of %FOREIGN-FUNCALL." `(alien-funcall (extern-alien ,name (function ,rettype ,@types)) ,@fargs)) (defmacro %foreign-funcall (name args &key library calling-convention) "Perform a foreign function call, document it more later." (declare (ignore library calling-convention)) (multiple-value-bind (types fargs rettype) (foreign-funcall-type-and-args args) `(%%foreign-funcall ,name ,types ,fargs ,rettype))) (defmacro %foreign-funcall-pointer (ptr args &key calling-convention) "Funcall a pointer to a foreign function." (declare (ignore calling-convention)) (multiple-value-bind (types fargs rettype) (foreign-funcall-type-and-args args) (with-unique-names (function) `(with-alien ((,function (* (function ,rettype ,@types)) ,ptr)) (alien-funcall ,function ,@fargs))))) ;;;# Callbacks ;;; The *CALLBACKS* hash table contains a direct mapping of CFFI ;;; callback names to SYSTEM-AREA-POINTERs obtained by ALIEN-LAMBDA. ;;; SBCL will maintain the addresses of the callbacks across saved ;;; images, so it is safe to store the pointers directly. (defvar *callbacks* (make-hash-table)) (defmacro %defcallback (name rettype arg-names arg-types body &key calling-convention) (declare (ignore calling-convention)) `(setf (gethash ',name *callbacks*) (alien-sap (sb-alien::alien-lambda ,(convert-foreign-type rettype) ,(mapcar (lambda (sym type) (list sym (convert-foreign-type type))) arg-names arg-types) ,body)))) (defun %callback (name) (or (gethash name *callbacks*) (error "Undefined callback: ~S" name))) ;;;# Loading and Closing Foreign Libraries (declaim (inline %load-foreign-library)) (defun %load-foreign-library (name path) "Load a foreign library." (declare (ignore name)) (load-shared-object path)) ;;; SBCL 1.0.21.15 renamed SB-ALIEN::SHARED-OBJECT-FILE but introduced ;;; SB-ALIEN:UNLOAD-SHARED-OBJECT which we can use instead. (eval-when (:compile-toplevel :load-toplevel :execute) (defun unload-shared-object-present-p () (multiple-value-bind (foundp kind) (find-symbol "UNLOAD-SHARED-OBJECT" "SB-ALIEN") (if (and foundp (eq kind :external)) '(:and) '(:or))))) (defun %close-foreign-library (handle) "Closes a foreign library." #+#.(cffi-sys::unload-shared-object-present-p) (sb-alien:unload-shared-object handle) #-#.(cffi-sys::unload-shared-object-present-p) (sb-thread:with-mutex (sb-alien::*shared-objects-lock*) (let ((obj (find (sb-ext:native-namestring handle) sb-alien::*shared-objects* :key #'sb-alien::shared-object-file :test #'string=))) (when obj (sb-alien::dlclose-or-lose obj) (removef sb-alien::*shared-objects* obj) #+(and linkage-table (not win32)) (sb-alien::update-linkage-table))))) (defun native-namestring (pathname) (sb-ext:native-namestring pathname)) ;;;# Foreign Globals (defun %foreign-symbol-pointer (name library) "Returns a pointer to a foreign symbol NAME." (declare (ignore library)) (when-let (address (sb-sys:find-foreign-symbol-address name)) (sb-sys:int-sap address)))
12,900
Common Lisp
.lisp
319
35.564263
73
0.668395
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e067e715aebdc8085a2cf4b9806472210af2a19065e79072fb344561d22477f3
21,637
[ 296541 ]
21,638
cffi-openmcl.lisp
rheaplex_minara/lib/cffi/src/cffi-openmcl.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; cffi-openmcl.lisp --- CFFI-SYS implementation for OpenMCL. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;;# Administrivia (defpackage #:cffi-sys (:use #:common-lisp #:ccl) (:import-from #:alexandria #:once-only) (:export #:canonicalize-symbol-name-case #:foreign-pointer #:pointerp ; ccl:pointerp #:pointer-eq #:%foreign-alloc #:foreign-free #:with-foreign-pointer #:null-pointer #:null-pointer-p #:inc-pointer #:make-pointer #:pointer-address #:%mem-ref #:%mem-set #:%foreign-funcall #:%foreign-funcall-pointer #:%foreign-type-alignment #:%foreign-type-size #:%load-foreign-library #:%close-foreign-library #:native-namestring #:make-shareable-byte-vector #:with-pointer-to-vector-data #:%foreign-symbol-pointer #:%defcallback #:%callback)) (in-package #:cffi-sys) ;;;# Misfeatures (pushnew 'flat-namespace *features*) ;;;# Symbol Case (defun canonicalize-symbol-name-case (name) (declare (string name)) (string-upcase name)) ;;;# Allocation ;;; ;;; Functions and macros for allocating foreign memory on the stack ;;; and on the heap. The main CFFI package defines macros that wrap ;;; FOREIGN-ALLOC and FOREIGN-FREE in UNWIND-PROTECT for the common ;;; usage when the memory has dynamic extent. (defun %foreign-alloc (size) "Allocate SIZE bytes on the heap and return a pointer." (ccl::malloc size)) (defun foreign-free (ptr) "Free a PTR allocated by FOREIGN-ALLOC." ;; TODO: Should we make this a dead macptr? (ccl::free ptr)) (defmacro with-foreign-pointer ((var size &optional size-var) &body body) "Bind VAR to SIZE bytes of foreign memory during BODY. The pointer in VAR is invalid beyond the dynamic extent of BODY, and may be stack-allocated if supported by the implementation. If SIZE-VAR is supplied, it will be bound to SIZE during BODY." (unless size-var (setf size-var (gensym "SIZE"))) `(let ((,size-var ,size)) (%stack-block ((,var ,size-var)) ,@body))) ;;;# Misc. Pointer Operations (deftype foreign-pointer () 'ccl:macptr) (defun null-pointer () "Construct and return a null pointer." (ccl:%null-ptr)) (defun null-pointer-p (ptr) "Return true if PTR is a null pointer." (ccl:%null-ptr-p ptr)) (defun inc-pointer (ptr offset) "Return a pointer OFFSET bytes past PTR." (ccl:%inc-ptr ptr offset)) (defun pointer-eq (ptr1 ptr2) "Return true if PTR1 and PTR2 point to the same address." (ccl:%ptr-eql ptr1 ptr2)) (defun make-pointer (address) "Return a pointer pointing to ADDRESS." (ccl:%int-to-ptr address)) (defun pointer-address (ptr) "Return the address pointed to by PTR." (ccl:%ptr-to-int ptr)) ;;;# Shareable Vectors ;;; ;;; This interface is very experimental. WITH-POINTER-TO-VECTOR-DATA ;;; should be defined to perform a copy-in/copy-out if the Lisp ;;; implementation can't do this. (defun make-shareable-byte-vector (size) "Create a Lisp vector of SIZE bytes that can passed to WITH-POINTER-TO-VECTOR-DATA." (make-array size :element-type '(unsigned-byte 8))) (defmacro with-pointer-to-vector-data ((ptr-var vector) &body body) "Bind PTR-VAR to a foreign pointer to the data in VECTOR." `(ccl:with-pointer-to-ivector (,ptr-var ,vector) ,@body)) ;;;# Dereferencing ;;; Define the %MEM-REF and %MEM-SET functions, as well as compiler ;;; macros that optimize the case where the type keyword is constant ;;; at compile-time. (defmacro define-mem-accessors (&body pairs) `(progn (defun %mem-ref (ptr type &optional (offset 0)) (ecase type ,@(loop for (keyword fn) in pairs collect `(,keyword (,fn ptr offset))))) (defun %mem-set (value ptr type &optional (offset 0)) (ecase type ,@(loop for (keyword fn) in pairs collect `(,keyword (setf (,fn ptr offset) value))))) (define-compiler-macro %mem-ref (&whole form ptr type &optional (offset 0)) (if (constantp type) (ecase (eval type) ,@(loop for (keyword fn) in pairs collect `(,keyword `(,',fn ,ptr ,offset)))) form)) (define-compiler-macro %mem-set (&whole form value ptr type &optional (offset 0)) (if (constantp type) (once-only (value) (ecase (eval type) ,@(loop for (keyword fn) in pairs collect `(,keyword `(setf (,',fn ,ptr ,offset) ,value))))) form)))) (define-mem-accessors (:char %get-signed-byte) (:unsigned-char %get-unsigned-byte) (:short %get-signed-word) (:unsigned-short %get-unsigned-word) (:int %get-signed-long) (:unsigned-int %get-unsigned-long) #+32-bit-target (:long %get-signed-long) #+64-bit-target (:long ccl::%%get-signed-longlong) #+32-bit-target (:unsigned-long %get-unsigned-long) #+64-bit-target (:unsigned-long ccl::%%get-unsigned-longlong) (:long-long ccl::%get-signed-long-long) (:unsigned-long-long ccl::%get-unsigned-long-long) (:float %get-single-float) (:double %get-double-float) (:pointer %get-ptr)) ;;;# Calling Foreign Functions (defun convert-foreign-type (type-keyword) "Convert a CFFI type keyword to an OpenMCL type." (ecase type-keyword (:char :signed-byte) (:unsigned-char :unsigned-byte) (:short :signed-short) (:unsigned-short :unsigned-short) (:int :signed-int) (:unsigned-int :unsigned-int) (:long :signed-long) (:unsigned-long :unsigned-long) (:long-long :signed-doubleword) (:unsigned-long-long :unsigned-doubleword) (:float :single-float) (:double :double-float) (:pointer :address) (:void :void))) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (/ (ccl::foreign-type-bits (ccl::parse-foreign-type (convert-foreign-type type-keyword))) 8)) ;; There be dragons here. See the following thread for details: ;; http://clozure.com/pipermail/openmcl-devel/2005-June/002777.html (defun %foreign-type-alignment (type-keyword) "Return the alignment in bytes of a foreign type." (/ (ccl::foreign-type-alignment (ccl::parse-foreign-type (convert-foreign-type type-keyword))) 8)) (defun convert-foreign-funcall-types (args) "Convert foreign types for a call to FOREIGN-FUNCALL." (loop for (type arg) on args by #'cddr collect (convert-foreign-type type) if arg collect arg)) (defun convert-external-name (name) "Add an underscore to NAME if necessary for the ABI." #+darwinppc-target (concatenate 'string "_" name) #-darwinppc-target name) (defmacro %foreign-funcall (function-name args &key library calling-convention) "Perform a foreign function call, document it more later." (declare (ignore library calling-convention)) `(external-call ,(convert-external-name function-name) ,@(convert-foreign-funcall-types args))) (defmacro %foreign-funcall-pointer (ptr args &key calling-convention) (declare (ignore calling-convention)) `(ff-call ,ptr ,@(convert-foreign-funcall-types args))) ;;;# Callbacks ;;; The *CALLBACKS* hash table maps CFFI callback names to OpenMCL "macptr" ;;; entry points. It is safe to store the pointers directly because ;;; OpenMCL will update the address of these pointers when a saved image ;;; is loaded (see CCL::RESTORE-PASCAL-FUNCTIONS). (defvar *callbacks* (make-hash-table)) ;;; Create a package to contain the symbols for callback functions. We ;;; want to redefine callbacks with the same symbol so the internal data ;;; structures are reused. (defpackage #:cffi-callbacks (:use)) ;;; Intern a symbol in the CFFI-CALLBACKS package used to name the internal ;;; callback for NAME. (defun intern-callback (name) (intern (format nil "~A::~A" (package-name (symbol-package name)) (symbol-name name)) '#:cffi-callbacks)) (defmacro %defcallback (name rettype arg-names arg-types body &key calling-convention) (declare (ignore calling-convention)) (let ((cb-name (intern-callback name))) `(progn (defcallback ,cb-name (,@(mapcan (lambda (sym type) (list (convert-foreign-type type) sym)) arg-names arg-types) ,(convert-foreign-type rettype)) ,body) (setf (gethash ',name *callbacks*) (symbol-value ',cb-name))))) (defun %callback (name) (or (gethash name *callbacks*) (error "Undefined callback: ~S" name))) ;;;# Loading Foreign Libraries (defun %load-foreign-library (name path) "Load the foreign library NAME." (declare (ignore name)) (open-shared-library path)) (defun %close-foreign-library (name) "Close the foreign library NAME." (close-shared-library name)) ; :completely t ? (defun native-namestring (pathname) (ccl::native-translated-namestring pathname)) ;;;# Foreign Globals (defun %foreign-symbol-pointer (name library) "Returns a pointer to a foreign symbol NAME." (declare (ignore library)) (foreign-symbol-address (convert-external-name name)))
10,413
Common Lisp
.lisp
262
35.583969
79
0.682268
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
6e67e42a65372be1599175925cdca53a912567f0abc8e2eb1e1f0e6006144c2d
21,638
[ -1 ]
21,639
early-types.lisp
rheaplex_minara/lib/cffi/src/early-types.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; early-types.lisp --- Low-level foreign type operations. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; Copyright (C) 2005-2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;;# Early Type Definitions ;;; ;;; This module contains basic operations on foreign types. These ;;; definitions are in a separate file because they may be used in ;;; compiler macros defined later on. (in-package #:cffi) ;;;# Foreign Types ;;; ;;; Type specifications are of the form (type {args}*). The type ;;; parser can specify how its arguments should look like through a ;;; lambda list. ;;; ;;; "type" is a shortcut for "(type)", ie, no args were specified. ;;; ;;; Examples of such types: boolean, (boolean), (boolean :int) If the ;;; boolean type parser specifies the lambda list: &optional ;;; (base-type :int), then all of the above three type specs would be ;;; parsed to an identical type. ;;; ;;; Type parsers, defined with DEFINE-PARSE-METHOD should return a ;;; subtype of the foreign-type class. (defvar *type-parsers* (make-hash-table) "Hash table of defined type parsers.") (defun find-type-parser (symbol) "Return the type parser for SYMBOL." (or (gethash symbol *type-parsers*) (error "Unknown CFFI type: ~S." symbol))) (defun (setf find-type-parser) (func symbol) "Set the type parser for SYMBOL." (setf (gethash symbol *type-parsers*) func)) ;;; Using a generic function would have been nicer but generates lots ;;; of style warnings in SBCL. (Silly reason, yes.) (defmacro define-parse-method (name lambda-list &body body) "Define a type parser on NAME and lists whose CAR is NAME." (discard-docstring body) (warn-if-kw-or-belongs-to-cl name) `(eval-when (:compile-toplevel :load-toplevel :execute) (setf (find-type-parser ',name) (lambda ,lambda-list ,@body)) ',name)) ;;; Utility function for the simple case where the type takes no ;;; arguments. (defun notice-foreign-type (name type) (setf (find-type-parser name) (lambda () type)) name) ;;;# Generic Functions on Types (defgeneric canonicalize (foreign-type) (:documentation "Return the built-in foreign type for FOREIGN-TYPE. Signals an error if FOREIGN-TYPE is undefined.")) (defgeneric aggregatep (foreign-type) (:documentation "Return true if FOREIGN-TYPE is an aggregate type.")) (defgeneric foreign-type-alignment (foreign-type) (:documentation "Return the structure alignment in bytes of a foreign type.")) (defgeneric foreign-type-size (foreign-type) (:documentation "Return the size in bytes of a foreign type.")) (defgeneric unparse-type (foreign-type) (:documentation "Unparse FOREIGN-TYPE to a type specification (symbol or list).")) ;;;# Foreign Types (defclass foreign-type () () (:documentation "Base class for all foreign types.")) (defmethod make-load-form ((type foreign-type) &optional env) "Return the form used to dump types to a FASL file." (declare (ignore env)) `(parse-type ',(unparse-type type))) (defmethod foreign-type-size (type) "Return the size in bytes of a foreign type." (foreign-type-size (parse-type type))) (defclass named-foreign-type (foreign-type) ((name ;; Name of this foreign type, a symbol. :initform (error "Must specify a NAME.") :initarg :name :accessor name))) (defmethod print-object ((type named-foreign-type) stream) "Print a FOREIGN-TYPEDEF instance to STREAM unreadably." (print-unreadable-object (type stream :type t :identity nil) (format stream "~S" (name type)))) ;;; Return the type's name which can be passed to PARSE-TYPE. If ;;; that's not the case for some subclass of NAMED-FOREIGN-TYPE then ;;; it should specialize UNPARSE-TYPE. (defmethod unparse-type ((type named-foreign-type)) (name type)) ;;;# Built-In Foreign Types (defclass foreign-built-in-type (foreign-type) ((type-keyword ;; Keyword in CFFI-SYS representing this type. :initform (error "A type keyword is required.") :initarg :type-keyword :accessor type-keyword)) (:documentation "A built-in foreign type.")) (defmethod canonicalize ((type foreign-built-in-type)) "Return the built-in type keyword for TYPE." (type-keyword type)) (defmethod aggregatep ((type foreign-built-in-type)) "Returns false, built-in types are never aggregate types." nil) (defmethod foreign-type-alignment ((type foreign-built-in-type)) "Return the alignment of a built-in type." (%foreign-type-alignment (type-keyword type))) (defmethod foreign-type-size ((type foreign-built-in-type)) "Return the size of a built-in type." (%foreign-type-size (type-keyword type))) (defmethod unparse-type ((type foreign-built-in-type)) "Returns the symbolic representation of a built-in type." (type-keyword type)) (defmethod print-object ((type foreign-built-in-type) stream) "Print a FOREIGN-TYPE instance to STREAM unreadably." (print-unreadable-object (type stream :type t :identity nil) (format stream "~S" (type-keyword type)))) (defmacro define-built-in-foreign-type (keyword) "Defines a built-in foreign-type." `(eval-when (:compile-toplevel :load-toplevel :execute) (notice-foreign-type ,keyword (make-instance 'foreign-built-in-type :type-keyword ,keyword)))) ;;;# Foreign Pointer Types (defclass foreign-pointer-type (foreign-built-in-type) ((pointer-type ;; Type of object pointed at by this pointer, or nil for an ;; untyped (void) pointer. :initform nil :initarg :pointer-type :accessor pointer-type)) (:default-initargs :type-keyword :pointer)) ;;; Define the type parser for the :POINTER type. If no type argument ;;; is provided, a void pointer will be created. (let ((void-pointer (make-instance 'foreign-pointer-type))) (define-parse-method :pointer (&optional type) (if type (make-instance 'foreign-pointer-type :pointer-type (parse-type type)) ;; A bit of premature optimization here. void-pointer))) ;;; Unparse a foreign pointer type when dumping to a fasl. (defmethod unparse-type ((type foreign-pointer-type)) (if (pointer-type type) `(:pointer ,(unparse-type (pointer-type type))) :pointer)) ;;; Print a foreign pointer type unreadably in unparsed form. (defmethod print-object ((type foreign-pointer-type) stream) (print-unreadable-object (type stream :type t :identity nil) (format stream "~S" (unparse-type type)))) ;;;# Structure Type (defclass foreign-struct-type (named-foreign-type) ((slots ;; Hash table of slots in this structure, keyed by name. :initform (make-hash-table) :initarg :slots :accessor slots) (size ;; Cached size in bytes of this structure. :initarg :size :accessor size) (alignment ;; This struct's alignment requirements :initarg :alignment :accessor alignment)) (:documentation "Hash table of plists containing slot information.")) (defmethod canonicalize ((type foreign-struct-type)) "Returns :POINTER, since structures can not be passed by value." :pointer) (defmethod aggregatep ((type foreign-struct-type)) "Returns true, structure types are aggregate." t) (defmethod foreign-type-size ((type foreign-struct-type)) "Return the size in bytes of a foreign structure type." (size type)) (defmethod foreign-type-alignment ((type foreign-struct-type)) "Return the alignment requirements for this struct." (alignment type)) ;;;# Foreign Typedefs (defclass foreign-type-alias (foreign-type) ((actual-type ;; The FOREIGN-TYPE instance this type is an alias for. :initarg :actual-type :accessor actual-type :initform (error "Must specify an ACTUAL-TYPE."))) (:documentation "A type that aliases another type.")) (defmethod canonicalize ((type foreign-type-alias)) "Return the built-in type keyword for TYPE." (canonicalize (actual-type type))) (defmethod aggregatep ((type foreign-type-alias)) "Return true if TYPE's actual type is aggregate." (aggregatep (actual-type type))) (defmethod foreign-type-alignment ((type foreign-type-alias)) "Return the alignment of a foreign typedef." (foreign-type-alignment (actual-type type))) (defmethod foreign-type-size ((type foreign-type-alias)) "Return the size in bytes of a foreign typedef." (foreign-type-size (actual-type type))) (defclass foreign-typedef (foreign-type-alias named-foreign-type) ()) (defun follow-typedefs (type) (if (eq (type-of type) 'foreign-typedef) (follow-typedefs (actual-type type)) type)) ;;;# Type Translators ;;; ;;; Type translation is done with generic functions at runtime for ;;; subclasses of ENHANCED-FOREIGN-TYPE/ ;;; ;;; The main interface for defining type translations is through the ;;; generic functions TRANSLATE-{TO,FROM}-FOREIGN and ;;; FREE-TRANSLATED-OBJECT. (defclass enhanced-foreign-type (foreign-type-alias) ((unparsed-type :accessor unparsed-type))) ;;; If actual-type isn't parsed already, let's parse it. This way we ;;; don't have to export PARSE-TYPE and users don't have to worry ;;; about this in DEFINE-FOREIGN-TYPE or DEFINE-PARSE-METHOD. (defmethod initialize-instance :after ((type enhanced-foreign-type) &key) (unless (typep (actual-type type) 'foreign-type) (setf (actual-type type) (parse-type (actual-type type))))) (defmethod unparse-type ((type enhanced-foreign-type)) (unparsed-type type)) ;;; Checks NAMEs, not object identity. (defun check-for-typedef-cycles (type) (let ((seen (make-hash-table :test 'eq))) (labels ((%check (cur-type) (when (typep cur-type 'foreign-typedef) (when (gethash (name cur-type) seen) (error "Detected cycle in type ~S." type)) (setf (gethash (name cur-type) seen) t) (%check (actual-type cur-type))))) (%check type)))) ;;; Only now we define PARSE-TYPE because it needs to do some extra ;;; work for ENHANCED-FOREIGN-TYPES. (defun parse-type (type) (let* ((spec (ensure-list type)) (ptype (apply (find-type-parser (car spec)) (cdr spec)))) (when (typep ptype 'foreign-typedef) (check-for-typedef-cycles ptype)) (when (typep ptype 'enhanced-foreign-type) (setf (unparsed-type ptype) type)) ptype)) (defun canonicalize-foreign-type (type) "Convert TYPE to a built-in type by following aliases. Signals an error if the type cannot be resolved." (canonicalize (parse-type type))) ;;; Translate VALUE to a foreign object of the type represented by ;;; TYPE, which will be a subclass of ENHANCED-FOREIGN-TYPE. Returns ;;; the foreign value and an optional second value which will be ;;; passed to FREE-TRANSLATED-OBJECT as the PARAM argument. (defgeneric translate-to-foreign (value type) (:method (value type) (declare (ignore type)) value)) ;;; Translate the foreign object VALUE from the type repsented by ;;; TYPE, which will be a subclass of ENHANCED-FOREIGN-TYPE. Returns ;;; the converted Lisp value. (defgeneric translate-from-foreign (value type) (:method (value type) (declare (ignore type)) value)) ;;; Free an object allocated by TRANSLATE-TO-FOREIGN. VALUE is a ;;; foreign object of the type represented by TYPE, which will be a ;;; ENHANCED-FOREIGN-TYPE subclass. PARAM, if present, contains the ;;; second value returned by TRANSLATE-TO-FOREIGN, and is used to ;;; communicate between the two functions. (defgeneric free-translated-object (value type param) (:method (value type param) (declare (ignore value type param)))) ;;;## Macroexpansion Time Translation ;;; ;;; The following EXPAND-* generic functions are similar to their ;;; TRANSLATE-* counterparts but are usually called at macroexpansion ;;; time. They offer a way to optimize the runtime translators. ;;; This special variable is bound by the various :around methods ;;; below to the respective form generated by the above %EXPAND-* ;;; functions. This way, an expander can "bail out" by calling the ;;; next method. All 6 of the below-defined GFs have a default method ;;; that simply answers the rtf bound by the default :around method. (defvar *runtime-translator-form*) ;;; EXPAND-FROM-FOREIGN (defgeneric expand-from-foreign (value type) (:method (value type) (declare (ignore type)) value)) (defmethod expand-from-foreign :around (value (type enhanced-foreign-type)) (let ((*runtime-translator-form* `(translate-from-foreign ,value ,type))) (call-next-method))) (defmethod expand-from-foreign (value (type enhanced-foreign-type)) (declare (ignore value)) *runtime-translator-form*) ;;; EXPAND-TO-FOREIGN ;; The second return value is used to tell EXPAND-TO-FOREIGN-DYN that ;; an unspecialized method was called. (defgeneric expand-to-foreign (value type) (:method (value type) (declare (ignore type)) (values value t))) (defmethod expand-to-foreign :around (value (type enhanced-foreign-type)) (let ((*runtime-translator-form* `(values (translate-to-foreign ,value ,type)))) (call-next-method))) (defmethod expand-to-foreign (value (type enhanced-foreign-type)) (declare (ignore value)) (values *runtime-translator-form* t)) ;;; EXPAND-TO-FOREIGN-DYN (defgeneric expand-to-foreign-dyn (value var body type) (:method (value var body type) (declare (ignore type)) `(let ((,var ,value)) ,@body))) (defmethod expand-to-foreign-dyn :around (value var body (type enhanced-foreign-type)) (let ((*runtime-translator-form* (with-unique-names (param) `(multiple-value-bind (,var ,param) (translate-to-foreign ,value ,type) (unwind-protect (progn ,@body) (free-translated-object ,var ,type ,param)))))) (call-next-method))) ;;; If this method is called it means the user hasn't defined a ;;; to-foreign-dyn expansion, so we use the to-foreign expansion. ;;; ;;; However, we do so *only* if there's a specialized ;;; EXPAND-TO-FOREIGN for TYPE because otherwise we want to use the ;;; above *RUNTIME-TRANSLATOR-FORM* which includes a call to ;;; FREE-TRANSLATED-OBJECT. (Or else there would occur no translation ;;; at all.) (defmethod expand-to-foreign-dyn (value var body (type enhanced-foreign-type)) (multiple-value-bind (expansion default-etp-p) (expand-to-foreign value type) (if default-etp-p *runtime-translator-form* `(let ((,var ,expansion)) ,@body)))) ;;; User interface for converting values from/to foreign using the ;;; type translators. The compiler macros use the expanders when ;;; possible. (defun convert-to-foreign (value type) (translate-to-foreign value (parse-type type))) (define-compiler-macro convert-to-foreign (value type) (if (constantp type) (expand-to-foreign value (parse-type (eval type))) `(translate-to-foreign ,value (parse-type ,type)))) (defun convert-from-foreign (value type) (translate-from-foreign value (parse-type type))) (define-compiler-macro convert-from-foreign (value type) (if (constantp type) (expand-from-foreign value (parse-type (eval type))) `(translate-from-foreign ,value (parse-type ,type)))) (defun free-converted-object (value type param) (free-translated-object value (parse-type type) param)) ;;;# Enhanced typedefs (defclass enhanced-typedef (foreign-typedef) ()) (defmethod translate-to-foreign (value (type enhanced-typedef)) (translate-to-foreign value (actual-type type))) (defmethod translate-from-foreign (value (type enhanced-typedef)) (translate-from-foreign value (actual-type type))) (defmethod free-translated-object (value (type enhanced-typedef) param) (free-translated-object value (actual-type type) param)) (defmethod expand-from-foreign (value (type enhanced-typedef)) (expand-from-foreign value (actual-type type))) (defmethod expand-to-foreign (value (type enhanced-typedef)) (expand-to-foreign value (actual-type type))) (defmethod expand-to-foreign-dyn (value var body (type enhanced-typedef)) (expand-to-foreign-dyn value var body (actual-type type))) ;;;# User-defined Types and Translations. (defmacro define-foreign-type (name supers slots &rest options) (multiple-value-bind (new-options simple-parser actual-type initargs) (let ((keywords '(:simple-parser :actual-type :default-initargs))) (apply #'values (remove-if (lambda (opt) (member (car opt) keywords)) options) (mapcar (lambda (kw) (cdr (assoc kw options))) keywords))) `(eval-when (:compile-toplevel :load-toplevel :execute) (defclass ,name ,(or supers '(enhanced-foreign-type)) ,slots (:default-initargs ,@(when actual-type `(:actual-type ',actual-type)) ,@initargs) ,@new-options) ,(when simple-parser `(define-parse-method ,(car simple-parser) (&rest args) (apply #'make-instance ',name args))) ',name))) (defmacro defctype (name base-type &optional documentation) "Utility macro for simple C-like typedefs." (declare (ignore documentation)) (warn-if-kw-or-belongs-to-cl name) (let* ((btype (parse-type base-type)) (dtype (if (typep btype 'enhanced-foreign-type) 'enhanced-typedef 'foreign-typedef))) `(eval-when (:compile-toplevel :load-toplevel :execute) (notice-foreign-type ',name (make-instance ',dtype :name ',name :actual-type ,btype))))) ;;; For Verrazano. We memoize the type this way to help detect cycles. (defmacro defctype* (name base-type) "Like DEFCTYPE but defers instantiation until parse-time." `(eval-when (:compile-toplevel :load-toplevel :execute) (let (memoized-type) (define-parse-method ,name () (unless memoized-type (setf memoized-type (make-instance 'foreign-typedef :name ',name :actual-type nil) (actual-type memoized-type) (parse-type ',base-type))) memoized-type))))
19,148
Common Lisp
.lisp
429
40.853147
79
0.71575
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
6ed8605636069d1c22d1b1dfe6a4027811f7bf25f5dfa3e1867031e0d0ed7ace
21,639
[ -1 ]
21,640
cffi-cmucl.lisp
rheaplex_minara/lib/cffi/src/cffi-cmucl.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; cffi-cmucl.lisp --- CFFI-SYS implementation for CMU CL. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;;# Administrivia (defpackage #:cffi-sys (:use #:common-lisp #:alien #:c-call) (:import-from #:alexandria #:once-only #:with-unique-names) (:export #:canonicalize-symbol-name-case #:foreign-pointer #:pointerp #:pointer-eq #:null-pointer #:null-pointer-p #:inc-pointer #:make-pointer #:pointer-address #:%foreign-alloc #:foreign-free #:with-foreign-pointer #:%foreign-funcall #:%foreign-funcall-pointer #:%foreign-type-alignment #:%foreign-type-size #:%load-foreign-library #:%close-foreign-library #:native-namestring #:%mem-ref #:%mem-set #:make-shareable-byte-vector #:with-pointer-to-vector-data #:%foreign-symbol-pointer #:%defcallback #:%callback)) (in-package #:cffi-sys) ;;;# Misfeatures (pushnew 'flat-namespace *features*) ;;;# Symbol Case (defun canonicalize-symbol-name-case (name) (declare (string name)) (string-upcase name)) ;;;# Basic Pointer Operations (deftype foreign-pointer () 'sys:system-area-pointer) (declaim (inline pointerp)) (defun pointerp (ptr) "Return true if PTR is a foreign pointer." (sys:system-area-pointer-p ptr)) (declaim (inline pointer-eq)) (defun pointer-eq (ptr1 ptr2) "Return true if PTR1 and PTR2 point to the same address." (sys:sap= ptr1 ptr2)) (declaim (inline null-pointer)) (defun null-pointer () "Construct and return a null pointer." (sys:int-sap 0)) (declaim (inline null-pointer-p)) (defun null-pointer-p (ptr) "Return true if PTR is a null pointer." (zerop (sys:sap-int ptr))) (declaim (inline inc-pointer)) (defun inc-pointer (ptr offset) "Return a pointer pointing OFFSET bytes past PTR." (sys:sap+ ptr offset)) (declaim (inline make-pointer)) (defun make-pointer (address) "Return a pointer pointing to ADDRESS." (sys:int-sap address)) (declaim (inline pointer-address)) (defun pointer-address (ptr) "Return the address pointed to by PTR." (sys:sap-int ptr)) (defmacro with-foreign-pointer ((var size &optional size-var) &body body) "Bind VAR to SIZE bytes of foreign memory during BODY. The pointer in VAR is invalid beyond the dynamic extent of BODY, and may be stack-allocated if supported by the implementation. If SIZE-VAR is supplied, it will be bound to SIZE during BODY." (unless size-var (setf size-var (gensym "SIZE"))) ;; If the size is constant we can stack-allocate. (if (constantp size) (let ((alien-var (gensym "ALIEN"))) `(with-alien ((,alien-var (array (unsigned 8) ,(eval size)))) (let ((,size-var ,(eval size)) (,var (alien-sap ,alien-var))) (declare (ignorable ,size-var)) ,@body))) `(let* ((,size-var ,size) (,var (%foreign-alloc ,size-var))) (unwind-protect (progn ,@body) (foreign-free ,var))))) ;;;# Allocation ;;; ;;; Functions and macros for allocating foreign memory on the stack ;;; and on the heap. The main CFFI package defines macros that wrap ;;; FOREIGN-ALLOC and FOREIGN-FREE in UNWIND-PROTECT for the common usage ;;; when the memory has dynamic extent. (defun %foreign-alloc (size) "Allocate SIZE bytes on the heap and return a pointer." (declare (type (unsigned-byte 32) size)) (alien-funcall (extern-alien "malloc" (function system-area-pointer unsigned)) size)) (defun foreign-free (ptr) "Free a PTR allocated by FOREIGN-ALLOC." (declare (type system-area-pointer ptr)) (alien-funcall (extern-alien "free" (function (values) system-area-pointer)) ptr)) ;;;# Shareable Vectors ;;; ;;; This interface is very experimental. WITH-POINTER-TO-VECTOR-DATA ;;; should be defined to perform a copy-in/copy-out if the Lisp ;;; implementation can't do this. (defun make-shareable-byte-vector (size) "Create a Lisp vector of SIZE bytes that can passed to WITH-POINTER-TO-VECTOR-DATA." (make-array size :element-type '(unsigned-byte 8))) (defmacro with-pointer-to-vector-data ((ptr-var vector) &body body) "Bind PTR-VAR to a foreign pointer to the data in VECTOR." `(sys:without-gcing (let ((,ptr-var (sys:vector-sap ,vector))) ,@body))) ;;;# Dereferencing ;;; Define the %MEM-REF and %MEM-SET functions, as well as compiler ;;; macros that optimize the case where the type keyword is constant ;;; at compile-time. (defmacro define-mem-accessors (&body pairs) `(progn (defun %mem-ref (ptr type &optional (offset 0)) (ecase type ,@(loop for (keyword fn) in pairs collect `(,keyword (,fn ptr offset))))) (defun %mem-set (value ptr type &optional (offset 0)) (ecase type ,@(loop for (keyword fn) in pairs collect `(,keyword (setf (,fn ptr offset) value))))) (define-compiler-macro %mem-ref (&whole form ptr type &optional (offset 0)) (if (constantp type) (ecase (eval type) ,@(loop for (keyword fn) in pairs collect `(,keyword `(,',fn ,ptr ,offset)))) form)) (define-compiler-macro %mem-set (&whole form value ptr type &optional (offset 0)) (if (constantp type) (once-only (value) (ecase (eval type) ,@(loop for (keyword fn) in pairs collect `(,keyword `(setf (,',fn ,ptr ,offset) ,value))))) form)))) (define-mem-accessors (:char sys:signed-sap-ref-8) (:unsigned-char sys:sap-ref-8) (:short sys:signed-sap-ref-16) (:unsigned-short sys:sap-ref-16) (:int sys:signed-sap-ref-32) (:unsigned-int sys:sap-ref-32) (:long sys:signed-sap-ref-32) (:unsigned-long sys:sap-ref-32) (:long-long sys:signed-sap-ref-64) (:unsigned-long-long sys:sap-ref-64) (:float sys:sap-ref-single) (:double sys:sap-ref-double) (:pointer sys:sap-ref-sap)) ;;;# Calling Foreign Functions (defun convert-foreign-type (type-keyword) "Convert a CFFI type keyword to an ALIEN type." (ecase type-keyword (:char 'char) (:unsigned-char 'unsigned-char) (:short 'short) (:unsigned-short 'unsigned-short) (:int 'int) (:unsigned-int 'unsigned-int) (:long 'long) (:unsigned-long 'unsigned-long) (:long-long '(signed 64)) (:unsigned-long-long '(unsigned 64)) (:float 'single-float) (:double 'double-float) (:pointer 'system-area-pointer) (:void 'void))) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (/ (alien-internals:alien-type-bits (alien-internals:parse-alien-type (convert-foreign-type type-keyword))) 8)) (defun %foreign-type-alignment (type-keyword) "Return the alignment in bytes of a foreign type." (/ (alien-internals:alien-type-alignment (alien-internals:parse-alien-type (convert-foreign-type type-keyword))) 8)) (defun foreign-funcall-type-and-args (args) "Return an ALIEN function type for ARGS." (let ((return-type nil)) (loop for (type arg) on args by #'cddr if arg collect (convert-foreign-type type) into types and collect arg into fargs else do (setf return-type (convert-foreign-type type)) finally (return (values types fargs return-type))))) (defmacro %%foreign-funcall (name types fargs rettype) "Internal guts of %FOREIGN-FUNCALL." `(alien-funcall (extern-alien ,name (function ,rettype ,@types)) ,@fargs)) (defmacro %foreign-funcall (name args &key library calling-convention) "Perform a foreign function call, document it more later." (declare (ignore library calling-convention)) (multiple-value-bind (types fargs rettype) (foreign-funcall-type-and-args args) `(%%foreign-funcall ,name ,types ,fargs ,rettype))) (defmacro %foreign-funcall-pointer (ptr args &key calling-convention) "Funcall a pointer to a foreign function." (declare (ignore calling-convention)) (multiple-value-bind (types fargs rettype) (foreign-funcall-type-and-args args) (with-unique-names (function) `(with-alien ((,function (* (function ,rettype ,@types)) ,ptr)) (alien-funcall ,function ,@fargs))))) ;;;# Callbacks (defvar *callbacks* (make-hash-table)) ;;; Create a package to contain the symbols for callback functions. We ;;; want to redefine callbacks with the same symbol so the internal data ;;; structures are reused. (defpackage #:cffi-callbacks (:use)) ;;; Intern a symbol in the CFFI-CALLBACKS package used to name the internal ;;; callback for NAME. (eval-when (:compile-toplevel :load-toplevel :execute) (defun intern-callback (name) (intern (format nil "~A::~A" (package-name (symbol-package name)) (symbol-name name)) '#:cffi-callbacks))) (defmacro %defcallback (name rettype arg-names arg-types body &key calling-convention) (declare (ignore calling-convention)) (let ((cb-name (intern-callback name))) `(progn (def-callback ,cb-name (,(convert-foreign-type rettype) ,@(mapcar (lambda (sym type) (list sym (convert-foreign-type type))) arg-names arg-types)) ,body) (setf (gethash ',name *callbacks*) (callback ,cb-name))))) (defun %callback (name) (multiple-value-bind (pointer winp) (gethash name *callbacks*) (unless winp (error "Undefined callback: ~S" name)) pointer)) ;;; CMUCL makes new callback trampolines when it reloads, so we need ;;; to update CFFI's copies. (defun reset-callbacks () (loop for k being the hash-keys of *callbacks* do (setf (gethash k *callbacks*) (alien::symbol-trampoline (intern-callback k))))) ;; Needs to be after cmucl's restore-callbacks, so put at the end... (unless (member 'reset-callbacks ext:*after-save-initializations*) (setf ext:*after-save-initializations* (append ext:*after-save-initializations* (list 'reset-callbacks)))) ;;;# Loading and Closing Foreign Libraries ;;; Work-around for compiling ffi code without loading the ;;; respective library at compile-time. (setf c::top-level-lambda-max 0) (defun %load-foreign-library (name path) "Load the foreign library NAME." ;; On some platforms SYS::LOAD-OBJECT-FILE signals an error when ;; loading fails, but on others (Linux for instance) it returns ;; two values: NIL and an error string. (declare (ignore name)) (multiple-value-bind (ret message) (sys::load-object-file path) (cond ;; Loading failed. ((stringp message) (error "~A" message)) ;; The library was already loaded. ((null ret) (cdr (rassoc path sys::*global-table* :test #'string=))) ;; The library has been loaded, but since SYS::LOAD-OBJECT-FILE ;; returns an alist of *all* loaded libraries along with their addresses ;; we return only the handler associated with the library just loaded. (t (cdr (rassoc path ret :test #'string=)))))) ;;; XXX: doesn't work on Darwin; does not check for errors. I suppose we'd ;;; want something like SBCL's dlclose-or-lose in foreign-load.lisp:66 (defun %close-foreign-library (handler) "Closes a foreign library." (let ((lib (rassoc (ext:unix-namestring handler) sys::*global-table* :test #'string=))) (sys::dlclose (car lib)) (setf (car lib) (sys:int-sap 0)))) (defun native-namestring (pathname) (ext:unix-namestring pathname nil)) ;;;# Foreign Globals (defun %foreign-symbol-pointer (name library) "Returns a pointer to a foreign symbol NAME." (declare (ignore library)) (let ((address (sys:alternate-get-global-address (vm:extern-alien-name name)))) (if (zerop address) nil (sys:int-sap address))))
13,163
Common Lisp
.lisp
332
34.921687
78
0.671569
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
7701488eb0ee70fc7db67ecda33f9353f08186a9a2f06cf9193e512747fd781b
21,640
[ -1 ]
21,643
functions.lisp
rheaplex_minara/lib/cffi/src/functions.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; functions.lisp --- High-level interface to foreign functions. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; Copyright (C) 2005-2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi) ;;;# Calling Foreign Functions ;;; ;;; FOREIGN-FUNCALL is the main primitive for calling foreign ;;; functions. It converts each argument based on the installed ;;; translators for its type, then passes the resulting list to ;;; CFFI-SYS:%FOREIGN-FUNCALL. ;;; ;;; For implementation-specific reasons, DEFCFUN doesn't use ;;; FOREIGN-FUNCALL directly and might use something else (passed to ;;; TRANSLATE-OBJECTS as the CALL-FORM argument) instead of ;;; CFFI-SYS:%FOREIGN-FUNCALL to call the foreign-function. (defun translate-objects (syms args types rettype call-form) "Helper function for FOREIGN-FUNCALL and DEFCFUN." (if (null args) (expand-from-foreign call-form (parse-type rettype)) (expand-to-foreign-dyn (car args) (car syms) (list (translate-objects (cdr syms) (cdr args) (cdr types) rettype call-form)) (parse-type (car types))))) (defun parse-args-and-types (args) "Returns 4 values. Types, canonicalized types, args and return type." (let ((return-type :void)) (loop for (type arg) on args by #'cddr if arg collect type into types and collect (canonicalize-foreign-type type) into ctypes and collect arg into fargs else do (setf return-type type) finally (return (values types ctypes fargs return-type))))) ;;; While the options passed directly to DEFCFUN/FOREIGN-FUNCALL have ;;; precedence, we also grab its library's options, if possible. (defun parse-function-options (options &key pointer) (destructuring-bind (&key (library :default libraryp) calling-convention (cconv calling-convention)) options (list* :calling-convention (or cconv (when libraryp (let ((lib-options (foreign-library-options (get-foreign-library library)))) (getf lib-options :cconv (getf lib-options :calling-convention)))) :cdecl) ;; Don't pass the library option if we're dealing with ;; FOREIGN-FUNCALL-POINTER. (unless pointer (list :library library))))) (defun foreign-funcall-form (thing options args pointerp) (multiple-value-bind (types ctypes fargs rettype) (parse-args-and-types args) (let ((syms (make-gensym-list (length fargs)))) (translate-objects syms fargs types rettype `(,(if pointerp '%foreign-funcall-pointer '%foreign-funcall) ,thing (,@(mapcan #'list ctypes syms) ,(canonicalize-foreign-type rettype)) ,@(parse-function-options options :pointer pointerp)))))) (defmacro foreign-funcall (name-and-options &rest args) "Wrapper around %FOREIGN-FUNCALL that translates its arguments." (let ((name (car (ensure-list name-and-options))) (options (cdr (ensure-list name-and-options)))) (foreign-funcall-form name options args nil))) (defmacro foreign-funcall-pointer (pointer options &rest args) (foreign-funcall-form pointer options args t)) (defun promote-varargs-type (builtin-type) "Default argument promotions." (case builtin-type (:float :double) ((:char :short) :int) ((:unsigned-char :unsigned-short) :unsigned-int) (t builtin-type))) (defun foreign-funcall-varargs-form (thing options fixed-args varargs pointerp) (multiple-value-bind (fixed-types fixed-ctypes fixed-fargs) (parse-args-and-types fixed-args) (multiple-value-bind (varargs-types varargs-ctypes varargs-fargs rettype) (parse-args-and-types varargs) (let ((fixed-syms (make-gensym-list (length fixed-fargs))) (varargs-syms (make-gensym-list (length varargs-fargs)))) (translate-objects (append fixed-syms varargs-syms) (append fixed-fargs varargs-fargs) (append fixed-types varargs-types) rettype `(,(if pointerp '%foreign-funcall-pointer '%foreign-funcall) ,thing ,(append (mapcan #'list (nconc fixed-ctypes (mapcar #'promote-varargs-type varargs-ctypes)) (append fixed-syms (loop for sym in varargs-syms and type in varargs-ctypes if (eq type :float) collect `(float ,sym 1.0d0) else collect sym))) (list (canonicalize-foreign-type rettype))) ,@options)))))) ;;; For now, the only difference between this macro and ;;; FOREIGN-FUNCALL is that it does argument promotion for that ;;; variadic argument. This could be useful to call an hypothetical ;;; %foreign-funcall-varargs on some hypothetical lisp on an ;;; hypothetical platform that has different calling conventions for ;;; varargs functions. :-) (defmacro foreign-funcall-varargs (name-and-options fixed-args &rest varargs) "Wrapper around %FOREIGN-FUNCALL that translates its arguments and does type promotion for the variadic arguments." (let ((name (car (ensure-list name-and-options))) (options (cdr (ensure-list name-and-options)))) (foreign-funcall-varargs-form name options fixed-args varargs nil))) (defmacro foreign-funcall-pointer-varargs (pointer options fixed-args &rest varargs) "Wrapper around %FOREIGN-FUNCALL-POINTER that translates its arguments and does type promotion for the variadic arguments." (foreign-funcall-varargs-form pointer options fixed-args varargs t)) ;;;# Defining Foreign Functions ;;; ;;; The DEFCFUN macro provides a declarative interface for defining ;;; Lisp functions that call foreign functions. ;; If cffi-sys doesn't provide a defcfun-helper-forms, ;; we define one that uses %foreign-funcall. (eval-when (:compile-toplevel :load-toplevel :execute) (unless (fboundp 'defcfun-helper-forms) (defun defcfun-helper-forms (name lisp-name rettype args types options) (declare (ignore lisp-name)) (values '() `(%foreign-funcall ,name ,(append (mapcan #'list types args) (list rettype)) ,@options))))) (defun %defcfun (lisp-name foreign-name return-type args options docstring) (let ((arg-names (mapcar #'car args)) (arg-types (mapcar #'cadr args)) (syms (make-gensym-list (length args)))) (multiple-value-bind (prelude caller) (defcfun-helper-forms foreign-name lisp-name (canonicalize-foreign-type return-type) syms (mapcar #'canonicalize-foreign-type arg-types) options) `(progn ,prelude (defun ,lisp-name ,arg-names ,@(ensure-list docstring) ,(translate-objects syms arg-names arg-types return-type caller)))))) (defun %defcfun-varargs (lisp-name foreign-name return-type args options doc) (with-unique-names (varargs) (let ((arg-names (mapcar #'car args))) `(defmacro ,lisp-name (,@arg-names &rest ,varargs) ,@(ensure-list doc) `(foreign-funcall-varargs ,'(,foreign-name ,@options) ,,`(list ,@(loop for (name type) in args collect `',type collect name)) ,@,varargs ,',return-type))))) ;;; The following four functions take care of parsing DEFCFUN's first ;;; argument whose syntax can be one of: ;;; ;;; 1. string ;;; 2. symbol ;;; 3. \( string [symbol] options* ) ;;; 4. \( symbol [string] options* ) ;;; ;;; The string argument denotes the foreign function's name. The ;;; symbol argument is used to name the Lisp function. If one isn't ;;; present, its name is derived from the other. See the user ;;; documentation for an explanation of the derivation rules. (defun lisp-name (spec &optional varp) (etypecase spec (list (if (keywordp (second spec)) (lisp-name (first spec) varp) (if (symbolp (first spec)) (first spec) (lisp-name (second spec) varp)))) (string (intern (format nil (if varp "*~A*" "~A") (canonicalize-symbol-name-case (substitute #\- #\_ spec))))) (symbol spec))) (defun foreign-name (spec &optional varp) (etypecase spec (list (if (stringp (second spec)) (second spec) (foreign-name (first spec) varp))) (string spec) (symbol (let ((name (substitute #\_ #\- (string-downcase (symbol-name spec))))) (if varp (string-trim '(#\*) name) name))))) (defun foreign-options (spec varp) (let ((opts (if (listp spec) (if (keywordp (second spec)) (cdr spec) (cddr spec)) nil))) (if varp (funcall 'parse-defcvar-options opts) (parse-function-options opts)))) (defun parse-name-and-options (spec &optional varp) (values (lisp-name spec varp) (foreign-name spec varp) (foreign-options spec varp))) ;;; If we find a &REST token at the end of ARGS, it means this is a ;;; varargs foreign function therefore we define a lisp macro using ;;; %DEFCFUN-VARARGS. Otherwise, a lisp function is defined with ;;; %DEFCFUN. (defmacro defcfun (name-and-options return-type &body args) "Defines a Lisp function that calls a foreign function." (let ((docstring (when (stringp (car args)) (pop args)))) (multiple-value-bind (lisp-name foreign-name options) (parse-name-and-options name-and-options) (if (eq (car (last args)) '&rest) (%defcfun-varargs lisp-name foreign-name return-type (butlast args) options docstring) (%defcfun lisp-name foreign-name return-type args options docstring))))) ;;;# Defining Callbacks (defun inverse-translate-objects (args types declarations rettype call) `(let (,@(loop for arg in args and type in types collect (list arg (expand-from-foreign arg (parse-type type))))) ,@declarations ,(expand-to-foreign call (parse-type rettype)))) (defun parse-defcallback-options (options) (destructuring-bind (&key (calling-convention :cdecl) (cconv calling-convention)) options (list :calling-convention cconv))) (defmacro defcallback (name-and-options return-type args &body body) (multiple-value-bind (body declarations) (parse-body body :documentation t) (let ((arg-names (mapcar #'car args)) (arg-types (mapcar #'cadr args)) (name (car (ensure-list name-and-options))) (options (cdr (ensure-list name-and-options)))) `(progn (%defcallback ,name ,(canonicalize-foreign-type return-type) ,arg-names ,(mapcar #'canonicalize-foreign-type arg-types) ,(inverse-translate-objects arg-names arg-types declarations return-type `(block ,name ,@body)) ,@(parse-defcallback-options options)) ',name)))) (declaim (inline get-callback)) (defun get-callback (symbol) (%callback symbol)) (defmacro callback (name) `(%callback ',name))
12,837
Common Lisp
.lisp
278
37.920863
79
0.640093
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
cf77abb6853dbf1a3524a7cfcf48319c53f9ec88eb6830846a0fb2c0fd89cc52
21,643
[ -1 ]
21,644
libraries.lisp
rheaplex_minara/lib/cffi/src/libraries.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; libraries.lisp --- Finding and loading foreign libraries. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; Copyright (C) 2006-2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi) ;;;# Finding Foreign Libraries ;;; ;;; We offer two ways for the user of a CFFI library to define ;;; his/her own library directories: *FOREIGN-LIBRARY-DIRECTORIES* ;;; for regular libraries and *DARWIN-FRAMEWORK-DIRECTORIES* for ;;; Darwin frameworks. ;;; ;;; These two special variables behave similarly to ;;; ASDF:*CENTRAL-REGISTRY* as its arguments are evaluated before ;;; being used. We used our MINI-EVAL instead of the full-blown EVAL ;;; though. ;;; ;;; Only after failing to find a library through the normal ways ;;; (eg: on Linux LD_LIBRARY_PATH, /etc/ld.so.cache, /usr/lib/, /lib) ;;; do we try to find the library ourselves. (defvar *foreign-library-directories* '() "List onto which user-defined library paths can be pushed.") (defvar *darwin-framework-directories* '((merge-pathnames #p"Library/Frameworks/" (user-homedir-pathname)) #p"/Library/Frameworks/" #p"/System/Library/Frameworks/") "List of directories where Frameworks are searched for.") (defun mini-eval (form) "Simple EVAL-like function to evaluate the elements of *FOREIGN-LIBRARY-DIRECTORIES* and *DARWIN-FRAMEWORK-DIRECTORIES*." (typecase form (cons (apply (car form) (mapcar #'mini-eval (cdr form)))) (symbol (symbol-value form)) (t form))) (defun find-file (path directories) "Searches for PATH in a list of DIRECTORIES and returns the first it finds." (some (lambda (directory) (probe-file (merge-pathnames path directory))) directories)) (defun find-darwin-framework (framework-name) "Searches for FRAMEWORK-NAME in *DARWIN-FRAMEWORK-DIRECTORIES*." (dolist (framework-directory *darwin-framework-directories*) (let ((path (make-pathname :name framework-name :directory (append (pathname-directory (mini-eval framework-directory)) (list (format nil "~A.framework" framework-name)))))) (when (probe-file path) (return-from find-darwin-framework path))))) ;;;# Defining Foreign Libraries ;;; ;;; Foreign libraries can be defined using the ;;; DEFINE-FOREIGN-LIBRARY macro. Example usage: ;;; ;;; (define-foreign-library opengl ;;; (:darwin (:framework "OpenGL")) ;;; (:unix (:or "libGL.so" "libGL.so.1" ;;; #p"/myhome/mylibGL.so")) ;;; (:windows "opengl32.dll") ;;; ;; an hypothetical example of a particular platform ;;; ((:and :some-system :some-cpu) "libGL-support.lib") ;;; ;; if no other clauses apply, this one will and a type will be ;;; ;; automagically appended to the name passed to :default ;;; (t (:default "libGL"))) ;;; ;;; This information is stored in the *FOREIGN-LIBRARIES* hashtable ;;; and when the library is loaded through LOAD-FOREIGN-LIBRARY (or ;;; USE-FOREIGN-LIBRARY) the first clause matched by FEATUREP is ;;; processed. (defvar *foreign-libraries* (make-hash-table :test 'eq) "Hashtable of defined libraries.") (defclass foreign-library () ((spec :initarg :spec) (options :initform nil :initarg :options) (handle :initarg :handle :accessor foreign-library-handle))) (defun get-foreign-library (lib) "Look up a library by NAME, signalling an error if not found." (if (typep lib 'foreign-library) lib (or (gethash lib *foreign-libraries*) (error "Undefined foreign library: ~S" lib)))) (defun (setf get-foreign-library) (value name) (setf (gethash name *foreign-libraries*) value)) (defun %foreign-library-spec (lib) (assoc-if (lambda (feature) (or (eq feature t) (featurep feature))) (slot-value lib 'spec))) (defun foreign-library-spec (lib) (second (%foreign-library-spec lib))) (defun foreign-library-options (lib) (append (cddr (%foreign-library-spec lib)) (slot-value lib 'options))) ;;; Warn about unkown options. (defmethod initialize-instance :after ((lib foreign-library) &key) (loop for (opt nil) on (append (slot-value lib 'options) (mapcan (lambda (x) (copy-list (cddr x))) (slot-value lib 'spec))) by #'cddr when (not (member opt '(:cconv :calling-convention))) do (warn "Unkown option: ~A" opt))) (defmacro define-foreign-library (name-and-options &body pairs) "Defines a foreign library NAME that can be posteriorly used with the USE-FOREIGN-LIBRARY macro." (destructuring-bind (name . options) (ensure-list name-and-options) `(progn (setf (get-foreign-library ',name) (make-instance 'foreign-library :spec ',pairs :options ',options)) ',name))) ;;;# LOAD-FOREIGN-LIBRARY-ERROR condition ;;; ;;; The various helper functions that load foreign libraries can ;;; signal this error when something goes wrong. We ignore the host's ;;; error. We should probably reuse its error message. (define-condition load-foreign-library-error (simple-error) ()) (defun read-new-value () (format *query-io* "~&Enter a new value (unevaluated): ") (force-output *query-io*) (read *query-io*)) (defun fl-error (control &rest arguments) (error 'load-foreign-library-error :format-control control :format-arguments arguments)) ;;;# Loading Foreign Libraries (defun load-darwin-framework (name framework-name) "Tries to find and load a darwin framework in one of the directories in *DARWIN-FRAMEWORK-DIRECTORIES*. If unable to find FRAMEWORK-NAME, it signals a LOAD-FOREIGN-LIBRARY-ERROR." (let ((framework (find-darwin-framework framework-name))) (if framework (load-foreign-library-path name (native-namestring framework)) (fl-error "Unable to find framework ~A" framework-name)))) (defun report-simple-error (name error) (fl-error "Unable to load foreign library (~A).~% ~A" name (format nil "~?" (simple-condition-format-control error) (simple-condition-format-arguments error)))) ;;; FIXME: haven't double checked whether all Lisps signal a ;;; SIMPLE-ERROR on %load-foreign-library failure. In any case they ;;; should be throwing a more specific error. (defun load-foreign-library-path (name path) "Tries to load PATH using %LOAD-FOREIGN-LIBRARY which should try and find it using the OS's usual methods. If that fails we try to find it ourselves." (handler-case (%load-foreign-library name path) (error (error) (if-let (file (find-file path *foreign-library-directories*)) (handler-case (%load-foreign-library name (native-namestring file)) (simple-error (error) (report-simple-error name error))) (report-simple-error name error))))) (defun try-foreign-library-alternatives (name library-list) "Goes through a list of alternatives and only signals an error when none of alternatives were successfully loaded." (dolist (lib library-list) (when-let (handle (ignore-errors (load-foreign-library-helper name lib))) (return-from try-foreign-library-alternatives handle))) ;; Perhaps we should show the error messages we got for each ;; alternative if we can figure out a nice way to do that. (fl-error "Unable to load any of the alternatives:~% ~S" library-list)) (defparameter *cffi-feature-suffix-map* '((:windows . ".dll") (:darwin . ".dylib") (:unix . ".so") (t . ".so")) "Mapping of OS feature keywords to shared library suffixes.") (defun default-library-suffix () "Return a string to use as default library suffix based on the operating system. This is used to implement the :DEFAULT option. This will need to be extended as we test on more OSes." (or (cdr (assoc-if #'featurep *cffi-feature-suffix-map*)) (fl-error "Unable to determine the default library suffix on this OS."))) (defun load-foreign-library-helper (name thing) (etypecase thing (string (load-foreign-library-path name thing)) (pathname (load-foreign-library-path name (namestring thing))) (cons (ecase (first thing) (:framework (load-darwin-framework name (second thing))) (:default (unless (stringp (second thing)) (fl-error "Argument to :DEFAULT must be a string.")) (load-foreign-library-path name (concatenate 'string (second thing) (default-library-suffix)))) (:or (try-foreign-library-alternatives name (rest thing))))))) (defun load-foreign-library (library) "Loads a foreign LIBRARY which can be a symbol denoting a library defined through DEFINE-FOREIGN-LIBRARY; a pathname or string in which case we try to load it directly first then search for it in *FOREIGN-LIBRARY-DIRECTORIES*; or finally list: either (:or lib1 lib2) or (:framework <framework-name>)." (restart-case (typecase library (symbol (let* ((lib (get-foreign-library library)) (spec (foreign-library-spec lib))) (when spec (setf (foreign-library-handle lib) (load-foreign-library-helper library spec)) lib))) (t (make-instance 'foreign-library :spec (list (list library)) :handle (load-foreign-library-helper nil library)))) ;; Offer these restarts that will retry the call to ;; LOAD-FOREIGN-LIBRARY. (retry () :report "Try loading the foreign library again." (load-foreign-library library)) (use-value (new-library) :report "Use another library instead." :interactive read-new-value (load-foreign-library new-library)))) (defmacro use-foreign-library (name) `(load-foreign-library ',name)) ;;;# Closing Foreign Libraries (defun close-foreign-library (library) "Closes a foreign library." (let ((lib (get-foreign-library library))) (when (foreign-library-handle lib) (%close-foreign-library (foreign-library-handle lib)) (setf (foreign-library-handle lib) nil) t)))
11,310
Common Lisp
.lisp
251
40.223108
79
0.691457
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
27a7951295ff566aa975b0e3b55a39e20bde2f98ac1ef5dc879b28423cf2347f
21,644
[ 5310 ]
21,645
cffi-allegro.lisp
rheaplex_minara/lib/cffi/src/cffi-allegro.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; cffi-allegro.lisp --- CFFI-SYS implementation for Allegro CL. ;;; ;;; Copyright (C) 2005-2008, Luis Oliveira <loliveira(@)common-lisp.net> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;;# Administrivia (defpackage #:cffi-sys (:use #:common-lisp #:alexandria) (:export #:canonicalize-symbol-name-case #:foreign-pointer #:pointerp #:pointer-eq #:null-pointer #:null-pointer-p #:inc-pointer #:make-pointer #:pointer-address #:%foreign-alloc #:foreign-free #:with-foreign-pointer #:%foreign-funcall #:%foreign-funcall-pointer #:%foreign-type-alignment #:%foreign-type-size #:%load-foreign-library #:%close-foreign-library #:native-namestring #:%mem-ref #:%mem-set ;#:make-shareable-byte-vector ;#:with-pointer-to-vector-data #:%foreign-symbol-pointer #:defcfun-helper-forms #:%defcallback #:%callback)) (in-package #:cffi-sys) ;;;# Mis-features (pushnew 'no-long-long *features*) (pushnew 'flat-namespace *features*) ;;;# Symbol Case (defun canonicalize-symbol-name-case (name) (declare (string name)) (if (eq excl:*current-case-mode* :case-sensitive-lower) (string-downcase name) (string-upcase name))) ;;;# Basic Pointer Operations (deftype foreign-pointer () 'ff:foreign-address) (defun pointerp (ptr) "Return true if PTR is a foreign pointer." (ff:foreign-address-p ptr)) (defun pointer-eq (ptr1 ptr2) "Return true if PTR1 and PTR2 point to the same address." (eql ptr1 ptr2)) (defun null-pointer () "Return a null pointer." 0) (defun null-pointer-p (ptr) "Return true if PTR is a null pointer." (zerop ptr)) (defun inc-pointer (ptr offset) "Return a pointer pointing OFFSET bytes past PTR." (+ ptr offset)) (defun make-pointer (address) "Return a pointer pointing to ADDRESS." (check-type address ff:foreign-address) address) (defun pointer-address (ptr) "Return the address pointed to by PTR." (check-type ptr ff:foreign-address) ptr) ;;;# Allocation ;;; ;;; Functions and macros for allocating foreign memory on the stack ;;; and on the heap. The main CFFI package defines macros that wrap ;;; FOREIGN-ALLOC and FOREIGN-FREE in UNWIND-PROTECT for the common usage ;;; when the memory has dynamic extent. (defun %foreign-alloc (size) "Allocate SIZE bytes on the heap and return a pointer." (ff:allocate-fobject :char :c size)) (defun foreign-free (ptr) "Free a PTR allocated by FOREIGN-ALLOC." (ff:free-fobject ptr)) (defmacro with-foreign-pointer ((var size &optional size-var) &body body) "Bind VAR to SIZE bytes of foreign memory during BODY. The pointer in VAR is invalid beyond the dynamic extent of BODY, and may be stack-allocated if supported by the implementation. If SIZE-VAR is supplied, it will be bound to SIZE during BODY." (unless size-var (setf size-var (gensym "SIZE"))) #+(version>= 8 1) (cond ((and (constantp size) (<= (eval size) ff:*max-stack-fobject-bytes*)) ;; stack allocation pattern `(let ((,size-var ,size)) (declare (ignorable ,size-var)) (ff:with-stack-fobject (,var '(:array :char ,size)) (let ((,var (ff:fslot-address ,var))) ;; (excl::stack-allocated-p var) => T ,@body)))) (t ;; amalloc + free pattern `(let ((,size-var ,size)) (declare (ignorable ,size-var)) (ff:with-stack-fobject (,var :char :allocation :c :size ,size-var) (unwind-protect (progn ,@body) (ff:free-fobject ,var)))))) #-(version>= 8 1) `(let ((,size-var ,size)) (declare (ignorable ,size-var)) (ff:with-stack-fobject (,var :char :c ,size-var) ,@body))) ;;;# Shareable Vectors ;;; ;;; This interface is very experimental. WITH-POINTER-TO-VECTOR-DATA ;;; should be defined to perform a copy-in/copy-out if the Lisp ;;; implementation can't do this. ;(defun make-shareable-byte-vector (size) ; "Create a Lisp vector of SIZE bytes can passed to ;WITH-POINTER-TO-VECTOR-DATA." ; (make-array size :element-type '(unsigned-byte 8))) ; ;(defmacro with-pointer-to-vector-data ((ptr-var vector) &body body) ; "Bind PTR-VAR to a foreign pointer to the data in VECTOR." ; `(sb-sys:without-gcing ; (let ((,ptr-var (sb-sys:vector-sap ,vector))) ; ,@body))) ;;;# Dereferencing (defun convert-foreign-type (type-keyword &optional (context :normal)) "Convert a CFFI type keyword to an Allegro type." (ecase type-keyword (:char :char) (:unsigned-char :unsigned-char) (:short :short) (:unsigned-short :unsigned-short) (:int :int) (:unsigned-int :unsigned-int) (:long :long) (:unsigned-long :unsigned-long) (:float :float) (:double :double) (:pointer (ecase context (:normal '(* :void)) (:funcall :foreign-address))) (:void :void))) (defun %mem-ref (ptr type &optional (offset 0)) "Dereference an object of TYPE at OFFSET bytes from PTR." (unless (zerop offset) (setf ptr (inc-pointer ptr offset))) (ff:fslot-value-typed (convert-foreign-type type) :c ptr)) ;;; Compiler macro to open-code the call to FSLOT-VALUE-TYPED when the ;;; CFFI type is constant. Allegro does its own transformation on the ;;; call that results in efficient code. (define-compiler-macro %mem-ref (&whole form ptr type &optional (off 0)) (if (constantp type) (let ((ptr-form (if (eql off 0) ptr `(+ ,ptr ,off)))) `(ff:fslot-value-typed ',(convert-foreign-type (eval type)) :c ,ptr-form)) form)) (defun %mem-set (value ptr type &optional (offset 0)) "Set the object of TYPE at OFFSET bytes from PTR." (unless (zerop offset) (setf ptr (inc-pointer ptr offset))) (setf (ff:fslot-value-typed (convert-foreign-type type) :c ptr) value)) ;;; Compiler macro to open-code the call to (SETF FSLOT-VALUE-TYPED) ;;; when the CFFI type is constant. Allegro does its own ;;; transformation on the call that results in efficient code. (define-compiler-macro %mem-set (&whole form val ptr type &optional (off 0)) (if (constantp type) (once-only (val) (let ((ptr-form (if (eql off 0) ptr `(+ ,ptr ,off)))) `(setf (ff:fslot-value-typed ',(convert-foreign-type (eval type)) :c ,ptr-form) ,val))) form)) ;;;# Calling Foreign Functions (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (ff:sizeof-fobject (convert-foreign-type type-keyword))) (defun %foreign-type-alignment (type-keyword) "Returns the alignment in bytes of a foreign type." #+(and powerpc macosx32) (when (eq type-keyword :double) (return-from %foreign-type-alignment 8)) ;; No override necessary for the remaining types.... (ff::sized-ftype-prim-align (ff::iforeign-type-sftype (ff:get-foreign-type (convert-foreign-type type-keyword))))) (defun foreign-funcall-type-and-args (args) "Returns a list of types, list of args and return type." (let ((return-type :void)) (loop for (type arg) on args by #'cddr if arg collect (convert-foreign-type type :funcall) into types and collect arg into fargs else do (setf return-type (convert-foreign-type type :funcall)) finally (return (values types fargs return-type))))) (defun convert-to-lisp-type (type) (if (equal '(* :void) type) 'integer (ecase type (:char 'signed-byte) (:unsigned-char 'integer) ;'unsigned-byte) ((:short :unsigned-short :int :unsigned-int :long :unsigned-long) 'integer) (:float 'single-float) (:double 'double-float) (:foreign-address :foreign-address) (:void 'null)))) (defun foreign-allegro-type (type) (if (eq type :foreign-address) nil type)) (defun allegro-type-pair (type) (list (foreign-allegro-type type) (convert-to-lisp-type type))) #+ignore (defun note-named-foreign-function (symbol name types rettype) "Give Allegro's compiler a hint to perform a direct call." `(eval-when (:compile-toplevel :load-toplevel :execute) (setf (get ',symbol 'system::direct-ff-call) (list '(,name :language :c) t ; callback :c ; convention ;; return type '(:c-type lisp-type) ',(allegro-type-pair (convert-foreign-type rettype :funcall)) ;; arg types '({(:c-type lisp-type)}*) '(,@(loop for type in types collect (allegro-type-pair (convert-foreign-type type :funcall)))) nil ; arg-checking ff::ep-flag-never-release)))) (defmacro %foreign-funcall (name args &key calling-convention library) (declare (ignore calling-convention library)) (multiple-value-bind (types fargs rettype) (foreign-funcall-type-and-args args) `(system::ff-funcall (load-time-value (excl::determine-foreign-address '(,name :language :c) ff::ep-flag-never-release nil ; method-index )) ;; arg types {'(:c-type lisp-type) argN}* ,@(mapcan (lambda (type arg) `(',(allegro-type-pair type) ,arg)) types fargs) ;; return type '(:c-type lisp-type) ',(allegro-type-pair rettype)))) (defun defcfun-helper-forms (name lisp-name rettype args types options) "Return 2 values for DEFCFUN. A prelude form and a caller form." (declare (ignore options)) (let ((ff-name (intern (format nil "%cffi-foreign-function/~A" lisp-name)))) (values `(ff:def-foreign-call (,ff-name ,name) ,(mapcar (lambda (ty) (let ((allegro-type (convert-foreign-type ty))) (list (gensym) allegro-type (convert-to-lisp-type allegro-type)))) types) :returning ,(allegro-type-pair (convert-foreign-type rettype :funcall)) ;; Don't use call-direct when there are no arguments. ,@(unless (null args) '(:call-direct t)) :arg-checking nil :strings-convert nil) `(,ff-name ,@args)))) ;;; See doc/allegro-internals.txt for a clue about entry-vec. (defmacro %foreign-funcall-pointer (ptr args &key calling-convention) (declare (ignore calling-convention)) (multiple-value-bind (types fargs rettype) (foreign-funcall-type-and-args args) (with-unique-names (entry-vec) `(let ((,entry-vec (excl::make-entry-vec-boa))) (setf (aref ,entry-vec 1) ,ptr) ; set jump address (system::ff-funcall ,entry-vec ;; arg types {'(:c-type lisp-type) argN}* ,@(mapcan (lambda (type arg) `(',(allegro-type-pair type) ,arg)) types fargs) ;; return type '(:c-type lisp-type) ',(allegro-type-pair rettype)))))) ;;;# Callbacks ;;; The *CALLBACKS* hash table contains information about a callback ;;; for the Allegro FFI. The key is the name of the CFFI callback, ;;; and the value is a cons, the car containing the symbol the ;;; callback was defined on in the CFFI-CALLBACKS package, the cdr ;;; being an Allegro FFI pointer (a fixnum) that can be passed to C ;;; functions. ;;; ;;; These pointers must be restored when a saved Lisp image is loaded. ;;; The RESTORE-CALLBACKS function is added to *RESTART-ACTIONS* to ;;; re-register the callbacks during Lisp startup. (defvar *callbacks* (make-hash-table)) ;;; Register a callback in the *CALLBACKS* hash table. (defun register-callback (cffi-name callback-name) (setf (gethash cffi-name *callbacks*) (cons callback-name (ff:register-foreign-callable callback-name :reuse t)))) ;;; Restore the saved pointers in *CALLBACKS* when loading an image. (defun restore-callbacks () (maphash (lambda (key value) (register-callback key (car value))) *callbacks*)) ;;; Arrange for RESTORE-CALLBACKS to run when a saved image containing ;;; CFFI is restarted. (eval-when (:load-toplevel :execute) (pushnew 'restore-callbacks excl:*restart-actions*)) ;;; Create a package to contain the symbols for callback functions. (defpackage #:cffi-callbacks (:use)) (defun intern-callback (name) (intern (format nil "~A::~A" (package-name (symbol-package name)) (symbol-name name)) '#:cffi-callbacks)) (defun convert-cconv (cconv) (ecase cconv (:cdecl :c) (:stdcall :stdcall))) (defmacro %defcallback (name rettype arg-names arg-types body &key calling-convention) (declare (ignore rettype)) (let ((cb-name (intern-callback name))) `(progn (ff:defun-foreign-callable ,cb-name ,(mapcar (lambda (sym type) (list sym (convert-foreign-type type))) arg-names arg-types) (declare (:convention ,(convert-cconv calling-convention))) ,body) (register-callback ',name ',cb-name)))) ;;; Return the saved Lisp callback pointer from *CALLBACKS* for the ;;; CFFI callback named NAME. (defun %callback (name) (or (cdr (gethash name *callbacks*)) (error "Undefined callback: ~S" name))) ;;;# Loading and Closing Foreign Libraries (defun %load-foreign-library (name path) "Load a foreign library." ;; ACL 8.0 honors the :FOREIGN option and always tries to foreign load ;; the argument. However, previous versions do not and will only ;; foreign load the argument if its type is a member of the ;; EXCL::*LOAD-FOREIGN-TYPES* list. Therefore, we bind that special ;; to a list containing whatever type NAME has. (declare (ignore name)) (let ((excl::*load-foreign-types* (list (pathname-type (parse-namestring path))))) (handler-case (progn #+(version>= 7) (load path :foreign t) #-(version>= 7) (load path)) (file-error (fe) (error (change-class fe 'simple-error)))) path)) (defun %close-foreign-library (name) "Close the foreign library NAME." (ff:unload-foreign-library name)) (defun native-namestring (pathname) (namestring pathname)) ;;;# Foreign Globals (defun convert-external-name (name) "Add an underscore to NAME if necessary for the ABI." #+macosx (concatenate 'string "_" name) #-macosx name) (defun %foreign-symbol-pointer (name library) "Returns a pointer to a foreign symbol NAME." (declare (ignore library)) (prog1 (ff:get-entry-point (convert-external-name name))))
15,957
Common Lisp
.lisp
392
34.808673
79
0.64814
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
4493135d95869ce8b8a449fe4f6ef62884170c435502256b4f6d20e7c4e2dad1
21,645
[ -1 ]
21,646
cffi-lispworks.lisp
rheaplex_minara/lib/cffi/src/cffi-lispworks.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; cffi-lispworks.lisp --- Lispworks CFFI-SYS implementation. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;;# Administrivia (defpackage #:cffi-sys (:use #:cl #:alexandria) (:export #:canonicalize-symbol-name-case #:foreign-pointer #:pointerp #:pointer-eq #:null-pointer #:null-pointer-p #:inc-pointer #:make-pointer #:pointer-address #:%foreign-alloc #:foreign-free #:with-foreign-pointer #:%foreign-funcall #:%foreign-funcall-pointer #:%foreign-type-alignment #:%foreign-type-size #:%load-foreign-library #:%close-foreign-library #:native-namestring #:%mem-ref #:%mem-set #:make-shareable-byte-vector #:with-pointer-to-vector-data #:%foreign-symbol-pointer #:defcfun-helper-forms #:%defcallback #:%callback)) (in-package #:cffi-sys) ;;;# Misfeatures #-lispworks-64bit (pushnew 'no-long-long *features*) ;;;# Symbol Case (defun canonicalize-symbol-name-case (name) (declare (string name)) (string-upcase name)) ;;;# Basic Pointer Operations (deftype foreign-pointer () 'fli::pointer) (defun pointerp (ptr) "Return true if PTR is a foreign pointer." (fli:pointerp ptr)) (defun pointer-eq (ptr1 ptr2) "Return true if PTR1 and PTR2 point to the same address." (fli:pointer-eq ptr1 ptr2)) ;; We use FLI:MAKE-POINTER here instead of FLI:*NULL-POINTER* since old ;; versions of Lispworks don't seem to have it. (defun null-pointer () "Return a null foreign pointer." (fli:make-pointer :address 0 :type :void)) (defun null-pointer-p (ptr) "Return true if PTR is a null pointer." (fli:null-pointer-p ptr)) ;; FLI:INCF-POINTER won't work on FLI pointers to :void so we ;; increment "manually." (defun inc-pointer (ptr offset) "Return a pointer OFFSET bytes past PTR." (fli:make-pointer :type :void :address (+ (fli:pointer-address ptr) offset))) (defun make-pointer (address) "Return a pointer pointing to ADDRESS." (fli:make-pointer :type :void :address address)) (defun pointer-address (ptr) "Return the address pointed to by PTR." (fli:pointer-address ptr)) ;;;# Allocation (defun %foreign-alloc (size) "Allocate SIZE bytes of memory and return a pointer." (fli:allocate-foreign-object :type :byte :nelems size)) (defun foreign-free (ptr) "Free a pointer PTR allocated by FOREIGN-ALLOC." (fli:free-foreign-object ptr)) (defmacro with-foreign-pointer ((var size &optional size-var) &body body) "Bind VAR to SIZE bytes of foreign memory during BODY. Both the pointer in VAR and the memory it points to have dynamic extent and may be stack allocated if supported by the implementation." (unless size-var (setf size-var (gensym "SIZE"))) `(fli:with-dynamic-foreign-objects () (let* ((,size-var ,size) (,var (fli:alloca :type :byte :nelems ,size-var))) ,@body))) ;;;# Shareable Vectors (defun make-shareable-byte-vector (size) "Create a shareable byte vector." #+(or lispworks3 lispworks4 lispworks5.0) (sys:in-static-area (make-array size :element-type '(unsigned-byte 8))) #-(or lispworks3 lispworks4 lispworks5.0) (make-array size :element-type '(unsigned-byte 8) :allocation :static)) (defmacro with-pointer-to-vector-data ((ptr-var vector) &body body) "Bind PTR-VAR to a pointer at the data in VECTOR." `(fli:with-dynamic-lisp-array-pointer (,ptr-var ,vector) ,@body)) ;;;# Dereferencing (defun convert-foreign-type (cffi-type) "Convert a CFFI type keyword to an FLI type." (ecase cffi-type (:char :byte) (:unsigned-char '(:unsigned :byte)) (:short :short) (:unsigned-short '(:unsigned :short)) (:int :int) (:unsigned-int '(:unsigned :int)) (:long :long) (:unsigned-long '(:unsigned :long)) #+lispworks-64bit (:long-long '(:long :long)) #+lispworks-64bit (:unsigned-long-long '(:unsigned :long :long)) (:float :float) (:double :double) (:pointer :pointer) (:void :void))) ;;; Convert a CFFI type keyword to a symbol suitable for passing to ;;; FLI:FOREIGN-TYPED-AREF. #+#.(cl:if (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") '(and) '(or)) (defun convert-foreign-typed-aref-type (cffi-type) (ecase cffi-type ((:char :short :int :long #+lispworks-64bit :long-long) `(signed-byte ,(* 8 (%foreign-type-size cffi-type)))) ((:unsigned-char :unsigned-short :unsigned-int :unsigned-long #+lispworks-64bit :unsigned-long-long) `(unsigned-byte ,(* 8 (%foreign-type-size cffi-type)))) (:float 'single-float) (:double 'double-float))) (defun %mem-ref (ptr type &optional (offset 0)) "Dereference an object of type TYPE OFFSET bytes from PTR." (unless (zerop offset) (setf ptr (inc-pointer ptr offset))) (fli:dereference ptr :type (convert-foreign-type type))) ;; Lispworks 5.0 on 64-bit platforms doesn't have [u]int64 support in ;; FOREIGN-TYPED-AREF. That was implemented in 5.1. #+(and lispworks-64bit lispworks5.0) (defun 64-bit-type-p (type) (member type '(:long :unsigned-long :long-long :unsigned-long-long))) ;;; In LispWorks versions where FLI:FOREIGN-TYPED-AREF is fbound, use ;;; it instead of FLI:DEREFERENCE in the optimizer for %MEM-REF. #+#.(cl:if (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") '(and) '(or)) (define-compiler-macro %mem-ref (&whole form ptr type &optional (off 0)) (if (constantp type) (let ((type (eval type))) (if (or #+(and lispworks-64bit lispworks5.0) (64-bit-type-p type) (eql type :pointer)) (let ((fli-type (convert-foreign-type type)) (ptr-form (if (eql off 0) ptr `(inc-pointer ,ptr ,off)))) `(fli:dereference ,ptr-form :type ',fli-type)) (let ((lisp-type (convert-foreign-typed-aref-type type))) `(locally (declare (optimize (speed 3) (safety 0))) (fli:foreign-typed-aref ',lisp-type ,ptr (the fixnum ,off)))))) form)) ;;; Open-code the call to FLI:DEREFERENCE when TYPE is constant at ;;; macroexpansion time, when FLI:FOREIGN-TYPED-AREF is not available. #-#.(cl:if (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") '(and) '(or)) (define-compiler-macro %mem-ref (&whole form ptr type &optional (off 0)) (if (constantp type) (let ((ptr-form (if (eql off 0) ptr `(inc-pointer ,ptr ,off))) (type (convert-foreign-type (eval type)))) `(fli:dereference ,ptr-form :type ',type)) form)) (defun %mem-set (value ptr type &optional (offset 0)) "Set the object of TYPE at OFFSET bytes from PTR." (unless (zerop offset) (setf ptr (inc-pointer ptr offset))) (setf (fli:dereference ptr :type (convert-foreign-type type)) value)) ;;; In LispWorks versions where FLI:FOREIGN-TYPED-AREF is fbound, use ;;; it instead of FLI:DEREFERENCE in the optimizer for %MEM-SET. #+#.(cl:if (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") '(and) '(or)) (define-compiler-macro %mem-set (&whole form val ptr type &optional (off 0)) (if (constantp type) (once-only (val) (let ((type (eval type))) (if (or #+(and lispworks-64bit lispworks5.0) (64-bit-type-p type) (eql type :pointer)) (let ((fli-type (convert-foreign-type type)) (ptr-form (if (eql off 0) ptr `(inc-pointer ,ptr ,off)))) `(setf (fli:dereference ,ptr-form :type ',fli-type) ,val)) (let ((lisp-type (convert-foreign-typed-aref-type type))) `(locally (declare (optimize (speed 3) (safety 0))) (setf (fli:foreign-typed-aref ',lisp-type ,ptr (the fixnum ,off)) ,val)))))) form)) ;;; Open-code the call to (SETF FLI:DEREFERENCE) when TYPE is constant ;;; at macroexpansion time. #-#.(cl:if (cl:find-symbol "FOREIGN-TYPED-AREF" "FLI") '(and) '(or)) (define-compiler-macro %mem-set (&whole form val ptr type &optional (off 0)) (if (constantp type) (once-only (val) (let ((ptr-form (if (eql off 0) ptr `(inc-pointer ,ptr ,off))) (type (convert-foreign-type (eval type)))) `(setf (fli:dereference ,ptr-form :type ',type) ,val))) form)) ;;;# Foreign Type Operations (defun %foreign-type-size (type) "Return the size in bytes of a foreign type." (fli:size-of (convert-foreign-type type))) (defun %foreign-type-alignment (type) "Return the structure alignment in bytes of foreign type." #+(and darwin harp::powerpc) (when (eq type :double) (return-from %foreign-type-alignment 8)) ;; Override not necessary for the remaining types... (fli:align-of (convert-foreign-type type))) ;;;# Calling Foreign Functions (defvar *foreign-funcallable-cache* (make-hash-table :test 'equal) "Caches foreign funcallables created by %FOREIGN-FUNCALL or %FOREIGN-FUNCALL-POINTER. We only need to have one per each signature.") (defun foreign-funcall-type-and-args (args) "Returns a list of types, list of args and return type." (let ((return-type :void)) (loop for (type arg) on args by #'cddr if arg collect (convert-foreign-type type) into types and collect arg into fargs else do (setf return-type (convert-foreign-type type)) finally (return (values types fargs return-type))))) (defun create-foreign-funcallable (types rettype cconv) "Creates a foreign funcallable for the signature TYPES -> RETTYPE." (format t "~&Creating foreign funcallable for signature ~S -> ~S~%" types rettype) ;; yes, ugly, this most likely wants to be a top-level form... (let ((internal-name (gensym))) (funcall (compile nil `(lambda () (fli:define-foreign-funcallable ,internal-name ,(loop for type in types collect (list (gensym) type)) :result-type ,rettype :language :ansi-c ;; avoid warning about cdecl not being supported on mac #-mac ,@(list :calling-convention cconv))))) internal-name)) (defun get-foreign-funcallable (types rettype cconv) "Returns a foreign funcallable for the signature TYPES -> RETTYPE - either from the cache or newly created." (let ((signature (cons rettype types))) (or (gethash signature *foreign-funcallable-cache*) ;; (SETF GETHASH) is supposed to be thread-safe (setf (gethash signature *foreign-funcallable-cache*) (create-foreign-funcallable types rettype cconv))))) (defmacro %%foreign-funcall (foreign-function args cconv) "Does the actual work for %FOREIGN-FUNCALL-POINTER and %FOREIGN-FUNCALL. Checks if a foreign funcallable which fits ARGS already exists and creates and caches it if necessary. Finally calls it." (multiple-value-bind (types fargs rettype) (foreign-funcall-type-and-args args) `(funcall (load-time-value (get-foreign-funcallable ',types ',rettype ',cconv)) ,foreign-function ,@fargs))) (defmacro %foreign-funcall (name args &key library calling-convention) "Calls a foreign function named NAME passing arguments ARGS." `(%%foreign-funcall (fli:make-pointer :symbol-name ,name :module ',(if (eq library :default) nil library)) ,args ,calling-convention)) (defmacro %foreign-funcall-pointer (ptr args &key calling-convention) "Calls a foreign function pointed at by PTR passing arguments ARGS." `(%%foreign-funcall ,ptr ,args ,calling-convention)) (defun defcfun-helper-forms (name lisp-name rettype args types options) "Return 2 values for DEFCFUN. A prelude form and a caller form." (let ((ff-name (intern (format nil "%cffi-foreign-function/~A" lisp-name)))) (values `(fli:define-foreign-function (,ff-name ,name :source) ,(mapcar (lambda (ty) (list (gensym) (convert-foreign-type ty))) types) :result-type ,(convert-foreign-type rettype) :language :ansi-c :module ',(let ((lib (getf options :library))) (if (eq lib :default) nil lib)) ;; avoid warning about cdecl not being supported on mac platforms #-mac ,@(list :calling-convention (getf options :calling-convention))) `(,ff-name ,@args)))) ;;;# Callbacks (defvar *callbacks* (make-hash-table)) ;;; Create a package to contain the symbols for callback functions. We ;;; want to redefine callbacks with the same symbol so the internal data ;;; structures are reused. (defpackage #:cffi-callbacks (:use)) ;;; Intern a symbol in the CFFI-CALLBACKS package used to name the internal ;;; callback for NAME. (eval-when (:compile-toplevel :load-toplevel :execute) (defun intern-callback (name) (intern (format nil "~A::~A" (package-name (symbol-package name)) (symbol-name name)) '#:cffi-callbacks))) (defmacro %defcallback (name rettype arg-names arg-types body &key calling-convention) (let ((cb-name (intern-callback name))) `(progn (fli:define-foreign-callable (,cb-name :encode :lisp :result-type ,(convert-foreign-type rettype) :calling-convention ,calling-convention :language :ansi-c :no-check nil) ,(mapcar (lambda (sym type) (list sym (convert-foreign-type type))) arg-names arg-types) ,body) (setf (gethash ',name *callbacks*) ',cb-name)))) (defun %callback (name) (multiple-value-bind (symbol winp) (gethash name *callbacks*) (unless winp (error "Undefined callback: ~S" name)) (fli:make-pointer :symbol-name symbol :module :callbacks))) ;;;# Loading Foreign Libraries (defun %load-foreign-library (name path) "Load the foreign library NAME." (fli:register-module (or name path) :connection-style :immediate :real-name path)) (defun %close-foreign-library (name) "Close the foreign library NAME." (fli:disconnect-module name :remove t)) (defun native-namestring (pathname) (namestring pathname)) ;;;# Foreign Globals (defun %foreign-symbol-pointer (name library) "Returns a pointer to a foreign symbol NAME." (values (ignore-errors (fli:make-pointer :symbol-name name :type :void :module (if (eq library :default) nil library)))))
15,719
Common Lisp
.lisp
355
38.64507
80
0.660874
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
3786cc065302dc13f162515f7bad5296407164c2db4b9faa44913b4aee7f84fa
21,646
[ -1 ]
21,648
defcfun.lisp
rheaplex_minara/lib/cffi/tests/defcfun.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; defcfun.lisp --- Tests function definition and calling. ;;; ;;; Copyright (C) 2005-2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-tests) ;;;# Calling with built-in c types ;;; ;;; Tests calling standard C library functions both passing ;;; and returning each built-in type. (adapted from funcall.lisp) (defcfun "toupper" :char "toupper docstring" (char :char)) (deftest defcfun.char (toupper (char-code #\a)) #.(char-code #\A)) (deftest defcfun.docstring (documentation 'toupper 'function) "toupper docstring") (defcfun ("abs" c-abs) :int (n :int)) (deftest defcfun.int (c-abs -100) 100) (defcfun "labs" :long (n :long)) (deftest defcfun.long (labs -131072) 131072) #-cffi-features:no-long-long (progn (defcfun "my_llabs" :long-long (n :long-long)) (deftest defcfun.long-long (my-llabs -9223372036854775807) 9223372036854775807)) (defcfun "my_sqrtf" :float (n :float)) (deftest defcfun.float (my-sqrtf 16.0) 4.0) (defcfun ("sqrt" c-sqrt) :double (n :double)) (deftest defcfun.double (c-sqrt 36.0d0) 6.0d0) #+(and scl long-float) (defcfun ("sqrtl" c-sqrtl) :long-double (n :long-double)) #+(and scl long-float) (deftest defcfun.long-double (c-sqrtl 36.0l0) 6.0l0) (defcfun "strlen" :int (n :string)) (deftest defcfun.string.1 (strlen "Hello") 5) (defcfun "strcpy" (:pointer :char) (dest (:pointer :char)) (src :string)) (defcfun "strcat" (:pointer :char) (dest (:pointer :char)) (src :string)) (deftest defcfun.string.2 (with-foreign-pointer-as-string (s 100) (setf (mem-ref s :char) 0) (strcpy s "Hello") (strcat s ", world!")) "Hello, world!") (defcfun "strerror" :string (n :int)) (deftest defcfun.string.3 (typep (strerror 1) 'string) t) ;;; Regression test. Allegro would warn on direct calls to ;;; functions with no arguments. ;;; ;;; Also, let's check if void functions will return NIL. ;;; ;;; Check if a docstring without arguments doesn't cause problems. (defcfun "noargs" :int "docstring") (deftest defcfun.noargs (noargs) 42) (defcfun "noop" :void) #+(or allegro openmcl ecl) (pushnew 'defcfun.noop rt::*expected-failures*) (deftest defcfun.noop (noop) #|no values|#) ;;;# Calling varargs functions (defcfun "sprintf" :int "sprintf docstring" (str (:pointer :char)) (control :string) &rest) ;;; CLISP's compiler discards macro docstrings. #+clisp (pushnew 'defcfun.varargs.docstrings rt::*expected-failures*) (deftest defcfun.varargs.docstrings (documentation 'sprintf 'function) "sprintf docstring") (deftest defcfun.varargs.char (with-foreign-pointer-as-string (s 100) (sprintf s "%c" :char 65)) "A") (deftest defcfun.varargs.short (with-foreign-pointer-as-string (s 100) (sprintf s "%d" :short 42)) "42") (deftest defcfun.varargs.int (with-foreign-pointer-as-string (s 100) (sprintf s "%d" :int 1000)) "1000") (deftest defcfun.varargs.long (with-foreign-pointer-as-string (s 100) (sprintf s "%ld" :long 131072)) "131072") (deftest defcfun.varargs.float (with-foreign-pointer-as-string (s 100) (sprintf s "%.2f" :float (float pi))) "3.14") (deftest defcfun.varargs.double (with-foreign-pointer-as-string (s 100) (sprintf s "%.2f" :double (float pi 1.0d0))) "3.14") #+(and scl long-float) (deftest defcfun.varargs.long-double (with-foreign-pointer-as-string (s 100) (setf (mem-ref s :char) 0) (sprintf s "%.2Lf" :long-double pi)) "3.14") (deftest defcfun.varargs.string (with-foreign-pointer-as-string (s 100) (sprintf s "%s, %s!" :string "Hello" :string "world")) "Hello, world!") ;;; (let ((rettype (find-type :long)) ;;; (arg-types (n-random-types-no-ll 127))) ;;; (c-function rettype arg-types) ;;; (gen-function-test rettype arg-types)) #+(and (not ecl) #.(cl:if (cl:>= cl:lambda-parameters-limit 127) '(:and) '(:or))) (progn (defcfun "sum_127_no_ll" :long (a1 :long) (a2 :unsigned-long) (a3 :short) (a4 :unsigned-short) (a5 :float) (a6 :double) (a7 :unsigned-long) (a8 :float) (a9 :unsigned-char) (a10 :unsigned-short) (a11 :short) (a12 :unsigned-long) (a13 :double) (a14 :long) (a15 :unsigned-int) (a16 :pointer) (a17 :unsigned-int) (a18 :unsigned-short) (a19 :long) (a20 :float) (a21 :pointer) (a22 :float) (a23 :int) (a24 :int) (a25 :unsigned-short) (a26 :long) (a27 :long) (a28 :double) (a29 :unsigned-char) (a30 :unsigned-int) (a31 :unsigned-int) (a32 :int) (a33 :unsigned-short) (a34 :unsigned-int) (a35 :pointer) (a36 :double) (a37 :double) (a38 :long) (a39 :short) (a40 :unsigned-short) (a41 :long) (a42 :char) (a43 :long) (a44 :unsigned-short) (a45 :pointer) (a46 :int) (a47 :unsigned-int) (a48 :double) (a49 :unsigned-char) (a50 :unsigned-char) (a51 :float) (a52 :int) (a53 :unsigned-short) (a54 :double) (a55 :short) (a56 :unsigned-char) (a57 :unsigned-long) (a58 :float) (a59 :float) (a60 :float) (a61 :pointer) (a62 :pointer) (a63 :unsigned-int) (a64 :unsigned-long) (a65 :char) (a66 :short) (a67 :unsigned-short) (a68 :unsigned-long) (a69 :pointer) (a70 :float) (a71 :double) (a72 :long) (a73 :unsigned-long) (a74 :short) (a75 :unsigned-int) (a76 :unsigned-short) (a77 :int) (a78 :unsigned-short) (a79 :char) (a80 :double) (a81 :short) (a82 :unsigned-char) (a83 :float) (a84 :char) (a85 :int) (a86 :double) (a87 :unsigned-char) (a88 :int) (a89 :unsigned-long) (a90 :double) (a91 :short) (a92 :short) (a93 :unsigned-int) (a94 :unsigned-char) (a95 :float) (a96 :long) (a97 :float) (a98 :long) (a99 :long) (a100 :int) (a101 :int) (a102 :unsigned-int) (a103 :char) (a104 :char) (a105 :unsigned-short) (a106 :unsigned-int) (a107 :unsigned-short) (a108 :unsigned-short) (a109 :int) (a110 :long) (a111 :char) (a112 :double) (a113 :unsigned-int) (a114 :char) (a115 :short) (a116 :unsigned-long) (a117 :unsigned-int) (a118 :short) (a119 :unsigned-char) (a120 :float) (a121 :pointer) (a122 :double) (a123 :int) (a124 :long) (a125 :char) (a126 :unsigned-short) (a127 :float)) (deftest defcfun.bff.1 (sum-127-no-ll 1442906394 520035521 -4715 50335 -13557.0 -30892.0d0 24061483 -23737.0 22 2348 4986 104895680 8073.0d0 -571698147 102484400 (make-pointer 507907275) 12733353 7824 -1275845284 13602.0 (make-pointer 286958390) -8042.0 -773681663 -1289932452 31199 -154985357 -170994216 16845.0d0 177 218969221 2794350893 6068863 26327 127699339 (make-pointer 184352771) 18512.0d0 -12345.0d0 -179853040 -19981 37268 -792845398 116 -1084653028 50494 (make-pointer 2105239646) -1710519651 1557813312 2839.0d0 90 180 30580.0 -532698978 8623 9537.0d0 -10882 54 184357206 14929.0 -8190.0 -25615.0 (make-pointer 235310526) (make-pointer 220476977) 7476055 1576685 -117 -11781 31479 23282640 (make-pointer 8627281) -17834.0 10391.0d0 -1904504370 114393659 -17062 637873619 16078 -891210259 8107 0 760.0d0 -21268 104 14133.0 10 588598141 310.0d0 20 1351785456 16159552 -10121.0d0 -25866 24821 68232851 60 -24132.0 -1660411658 13387.0 -786516668 -499825680 -1128144619 111849719 2746091587 -2 95 14488 326328135 64781 18204 150716680 -703859275 103 16809.0d0 852235610 -43 21088 242356110 324325428 -22380 23 24814.0 (make-pointer 40362014) -14322.0d0 -1864262539 523684371 -21 49995 -29175.0) 796447501)) ;;; (let ((rettype (find-type :long-long)) ;;; (arg-types (n-random-types 127))) ;;; (c-function rettype arg-types) ;;; (gen-function-test rettype arg-types)) #-(or ecl cffi-sys::no-long-long #.(cl:if (cl:>= cl:lambda-parameters-limit 127) '(:or) '(:and))) (progn (defcfun "sum_127" :long-long (a1 :pointer) (a2 :pointer) (a3 :float) (a4 :unsigned-long) (a5 :pointer) (a6 :long-long) (a7 :double) (a8 :double) (a9 :unsigned-short) (a10 :int) (a11 :long-long) (a12 :long) (a13 :short) (a14 :unsigned-int) (a15 :long) (a16 :unsigned-char) (a17 :int) (a18 :double) (a19 :short) (a20 :short) (a21 :long-long) (a22 :unsigned-int) (a23 :unsigned-short) (a24 :short) (a25 :pointer) (a26 :short) (a27 :unsigned-short) (a28 :unsigned-short) (a29 :int) (a30 :long-long) (a31 :pointer) (a32 :int) (a33 :unsigned-long) (a34 :unsigned-long) (a35 :pointer) (a36 :unsigned-long-long) (a37 :float) (a38 :int) (a39 :short) (a40 :pointer) (a41 :unsigned-long-long) (a42 :long-long) (a43 :unsigned-long) (a44 :unsigned-long) (a45 :unsigned-long-long) (a46 :unsigned-long) (a47 :char) (a48 :double) (a49 :long) (a50 :unsigned-int) (a51 :int) (a52 :short) (a53 :pointer) (a54 :long) (a55 :unsigned-long-long) (a56 :int) (a57 :unsigned-short) (a58 :unsigned-long-long) (a59 :float) (a60 :pointer) (a61 :float) (a62 :unsigned-short) (a63 :unsigned-long) (a64 :float) (a65 :unsigned-int) (a66 :unsigned-long-long) (a67 :pointer) (a68 :double) (a69 :unsigned-long-long) (a70 :double) (a71 :double) (a72 :long-long) (a73 :pointer) (a74 :unsigned-short) (a75 :long) (a76 :pointer) (a77 :short) (a78 :double) (a79 :long) (a80 :unsigned-char) (a81 :pointer) (a82 :unsigned-char) (a83 :long) (a84 :double) (a85 :pointer) (a86 :int) (a87 :double) (a88 :unsigned-char) (a89 :double) (a90 :short) (a91 :long) (a92 :int) (a93 :long) (a94 :double) (a95 :unsigned-short) (a96 :unsigned-int) (a97 :int) (a98 :char) (a99 :long-long) (a100 :double) (a101 :float) (a102 :unsigned-long) (a103 :short) (a104 :pointer) (a105 :float) (a106 :long-long) (a107 :int) (a108 :long-long) (a109 :long-long) (a110 :double) (a111 :unsigned-long-long) (a112 :double) (a113 :unsigned-long) (a114 :char) (a115 :char) (a116 :unsigned-long) (a117 :short) (a118 :unsigned-char) (a119 :unsigned-char) (a120 :int) (a121 :int) (a122 :float) (a123 :unsigned-char) (a124 :unsigned-char) (a125 :double) (a126 :unsigned-long-long) (a127 :char)) (deftest defcfun.bff.2 (sum-127 (make-pointer 2746181372) (make-pointer 177623060) -32334.0 3158055028 (make-pointer 242315091) 4288001754991016425 -21047.0d0 287.0d0 18722 243379286 -8677366518541007140 581399424 -13872 4240394881 1353358999 226 969197676 -26207.0d0 6484 11150 1241680089902988480 106068320 61865 2253 (make-pointer 866809333) -31613 35616 11715 1393601698 8940888681199591845 (make-pointer 1524606024) 805638893 3315410736 3432596795 (make-pointer 1490355706) 696175657106383698 -25438.0 1294381547 26724 (make-pointer 3196569545) 2506913373410783697 -4405955718732597856 4075932032 3224670123 2183829215657835866 1318320964 -22 -3786.0d0 -2017024146 1579225515 -626617701 -1456 (make-pointer 3561444187) 395687791 1968033632506257320 -1847773261 48853 142937735275669133 -17974.0 (make-pointer 2791749948) -14140.0 2707 3691328585 3306.0 1132012981 303633191773289330 (make-pointer 981183954) 9114.0d0 8664374572369470 -19013.0d0 -10288.0d0 -3679345119891954339 (make-pointer 3538786709) 23761 -154264605 (make-pointer 2694396308) 7023 997.0d0 1009561368 241 (make-pointer 2612292671) 48 1431872408 -32675.0d0 (make-pointer 1587599336) 958916472 -9857.0d0 111 -14370.0d0 -7308 -967514912 488790941 2146978095 -24111.0d0 13711 86681861 717987770 111 1013402998690933877 17234.0d0 -8772.0 3959216275 -8711 (make-pointer 3142780851) 9480.0 -3820453146461186120 1616574376 -3336232268263990050 -1906114671562979758 -27925.0d0 9695970875869913114 27033.0d0 1096518219 -12 104 3392025403 -27911 60 89 509297051 -533066551 29158.0 110 54 -9802.0d0 593950442165910888 -79) 7758614658402721936)) ;;; regression test: defining an undefined foreign function should only ;;; throw some sort of warning, not signal an error. #+(or cmu (and sbcl (or (not linkage-table) win32))) (pushnew 'defcfun.undefined rt::*expected-failures*) (deftest defcfun.undefined (progn (eval '(defcfun ("undefined_foreign_function" undefined-foreign-function) :void)) (compile 'undefined-foreign-function) t) t) ;;; Test whether all doubles are passed correctly. On some platforms, eg. ;;; darwin/ppc, some are passed on registers others on the stack. (defcfun "sum_double26" :double (a1 :double) (a2 :double) (a3 :double) (a4 :double) (a5 :double) (a6 :double) (a7 :double) (a8 :double) (a9 :double) (a10 :double) (a11 :double) (a12 :double) (a13 :double) (a14 :double) (a15 :double) (a16 :double) (a17 :double) (a18 :double) (a19 :double) (a20 :double) (a21 :double) (a22 :double) (a23 :double) (a24 :double) (a25 :double) (a26 :double)) (deftest defcfun.double26 (sum-double26 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0 3.14d0) 81.64d0) ;;; Same as above for floats. (defcfun "sum_float26" :float (a1 :float) (a2 :float) (a3 :float) (a4 :float) (a5 :float) (a6 :float) (a7 :float) (a8 :float) (a9 :float) (a10 :float) (a11 :float) (a12 :float) (a13 :float) (a14 :float) (a15 :float) (a16 :float) (a17 :float) (a18 :float) (a19 :float) (a20 :float) (a21 :float) (a22 :float) (a23 :float) (a24 :float) (a25 :float) (a26 :float)) (deftest defcfun.float26 (sum-float26 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0) 130.0) ;;;# Namespaces #-cffi-sys::flat-namespace (progn (defcfun ("ns_function" ns-fun1 :library libtest) :boolean) (defcfun ("ns_function" ns-fun2 :library libtest2) :boolean) (deftest defcfun.namespace.1 (values (ns-fun1) (ns-fun2)) t nil)) ;;;# stdcall #+(and x86 windows (not cffi-sys::no-stdcall)) (progn (defcfun ("stdcall_fun@12" stdcall-fun :cconv :stdcall) :int (a :int) (b :int) (c :int)) (deftest defcfun.stdcall.1 (loop repeat 100 do (stdcall-fun 1 2 3) finally (return (stdcall-fun 1 2 3))) 6))
15,376
Common Lisp
.lisp
337
41.41543
87
0.679471
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
1542acd2e8eea4480a2d1c8ede501e166cff41da2edf948068133c8e6508fe3b
21,648
[ 277112 ]
21,649
callbacks.lisp
rheaplex_minara/lib/cffi/tests/callbacks.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; callbacks.lisp --- Tests on callbacks. ;;; ;;; Copyright (C) 2005-2006, Luis Oliveira <loliveira(@)common-lisp.net> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-tests) (defcfun "expect_char_sum" :int (f :pointer)) (defcfun "expect_unsigned_char_sum" :int (f :pointer)) (defcfun "expect_short_sum" :int (f :pointer)) (defcfun "expect_unsigned_short_sum" :int (f :pointer)) (defcfun "expect_int_sum" :int (f :pointer)) (defcfun "expect_unsigned_int_sum" :int (f :pointer)) (defcfun "expect_long_sum" :int (f :pointer)) (defcfun "expect_unsigned_long_sum" :int (f :pointer)) (defcfun "expect_float_sum" :int (f :pointer)) (defcfun "expect_double_sum" :int (f :pointer)) (defcfun "expect_pointer_sum" :int (f :pointer)) (defcfun "expect_strcat" :int (f :pointer)) #-cffi-sys::no-long-long (progn (defcfun "expect_long_long_sum" :int (f :pointer)) (defcfun "expect_unsigned_long_long_sum" :int (f :pointer))) #+(and scl long-float) (defcfun "expect_long_double_sum" :int (f :pointer)) (defcallback sum-char :char ((a :char) (b :char)) "Test if the named block is present and the docstring too." ;(format t "~%}}} a: ~A, b: ~A {{{~%" a b) (return-from sum-char (+ a b))) (defcallback sum-unsigned-char :unsigned-char ((a :unsigned-char) (b :unsigned-char)) ;(format t "~%}}} a: ~A, b: ~A {{{~%" a b) (+ a b)) (defcallback sum-short :short ((a :short) (b :short)) ;(format t "~%}}} a: ~A, b: ~A {{{~%" a b) (+ a b)) (defcallback sum-unsigned-short :unsigned-short ((a :unsigned-short) (b :unsigned-short)) ;(format t "~%}}} a: ~A, b: ~A {{{~%" a b) (+ a b)) (defcallback sum-int :int ((a :int) (b :int)) (+ a b)) (defcallback sum-unsigned-int :unsigned-int ((a :unsigned-int) (b :unsigned-int)) (+ a b)) (defcallback sum-long :long ((a :long) (b :long)) (+ a b)) (defcallback sum-unsigned-long :unsigned-long ((a :unsigned-long) (b :unsigned-long)) (+ a b)) #-cffi-sys::no-long-long (progn (defcallback sum-long-long :long-long ((a :long-long) (b :long-long)) (+ a b)) (defcallback sum-unsigned-long-long :unsigned-long-long ((a :unsigned-long-long) (b :unsigned-long-long)) (+ a b))) (defcallback sum-float :float ((a :float) (b :float)) ;(format t "~%}}} a: ~A, b: ~A {{{~%" a b) (+ a b)) (defcallback sum-double :double ((a :double) (b :double)) ;(format t "~%}}} a: ~A, b: ~A {{{~%" a b) (+ a b)) #+(and scl long-float) (defcallback sum-long-double :long-double ((a :long-double) (b :long-double)) ;(format t "~%}}} a: ~A, b: ~A {{{~%" a b) (+ a b)) (defcallback sum-pointer :pointer ((ptr :pointer) (offset :int)) (inc-pointer ptr offset)) (defcallback lisp-strcat :string ((a :string) (b :string)) (concatenate 'string a b)) (deftest callbacks.char (expect-char-sum (get-callback 'sum-char)) 1) (deftest callbacks.unsigned-char (expect-unsigned-char-sum (get-callback 'sum-unsigned-char)) 1) (deftest callbacks.short (expect-short-sum (callback sum-short)) 1) (deftest callbacks.unsigned-short (expect-unsigned-short-sum (callback sum-unsigned-short)) 1) (deftest callbacks.int (expect-int-sum (callback sum-int)) 1) (deftest callbacks.unsigned-int (expect-unsigned-int-sum (callback sum-unsigned-int)) 1) (deftest callbacks.long (expect-long-sum (callback sum-long)) 1) (deftest callbacks.unsigned-long (expect-unsigned-long-sum (callback sum-unsigned-long)) 1) #-cffi-sys::no-long-long (progn #+openmcl (push 'callbacks.long-long rt::*expected-failures*) (deftest callbacks.long-long (expect-long-long-sum (callback sum-long-long)) 1) (deftest callbacks.unsigned-long-long (expect-unsigned-long-long-sum (callback sum-unsigned-long-long)) 1)) (deftest callbacks.float (expect-float-sum (callback sum-float)) 1) (deftest callbacks.double (expect-double-sum (callback sum-double)) 1) #+(and scl long-float) (deftest callbacks.long-double (expect-long-double-sum (callback sum-long-double)) 1) (deftest callbacks.pointer (expect-pointer-sum (callback sum-pointer)) 1) (deftest callbacks.string (expect-strcat (callback lisp-strcat)) 1) #-cffi-sys::no-foreign-funcall (defcallback return-a-string-not-nil :string () "abc") #-cffi-sys::no-foreign-funcall (deftest callbacks.string-not-docstring (foreign-funcall-pointer (callback return-a-string-not-nil) () :string) "abc") ;;; This one tests mem-aref too. (defcfun "qsort" :void (base :pointer) (nmemb :int) (size :int) (fun-compar :pointer)) (defcallback < :int ((a :pointer) (b :pointer)) (let ((x (mem-ref a :int)) (y (mem-ref b :int))) (cond ((> x y) 1) ((< x y) -1) (t 0)))) (deftest callbacks.qsort (with-foreign-object (array :int 10) ;; Initialize array. (loop for i from 0 and n in '(7 2 10 4 3 5 1 6 9 8) do (setf (mem-aref array :int i) n)) ;; Sort it. (qsort array 10 (foreign-type-size :int) (callback <)) ;; Return it as a list. (loop for i from 0 below 10 collect (mem-aref array :int i))) (1 2 3 4 5 6 7 8 9 10)) ;;; void callback (defparameter *int* -1) (defcfun "pass_int_ref" :void (f :pointer)) ;;; CMUCL chokes on this one for some reason. #-(and darwin cmu) (defcallback read-int-from-pointer :void ((a :pointer)) (setq *int* (mem-ref a :int))) #+(and darwin cmu) (pushnew 'callbacks.void rt::*expected-failures*) (deftest callbacks.void (progn (pass-int-ref (callback read-int-from-pointer)) *int*) 1984) ;;; test funcalling of a callback and also declarations inside ;;; callbacks. #-cffi-sys::no-foreign-funcall (progn (defcallback sum-2 :int ((a :int) (b :int) (c :int)) (declare (ignore c)) (+ a b)) (deftest callbacks.funcall.1 (foreign-funcall-pointer (callback sum-2) () :int 2 :int 3 :int 1 :int) 5) (defctype foo-float :float) (defcallback sum-2f foo-float ((a foo-float) (b foo-float) (c foo-float) (d foo-float) (e foo-float)) "This one ignores the middle 3 arguments." (declare (ignore b c)) (declare (ignore d)) (+ a e)) (deftest callbacks.funcall.2 (foreign-funcall-pointer (callback sum-2f) () foo-float 1.0 foo-float 2.0 foo-float 3.0 foo-float 4.0 foo-float 5.0 foo-float) 6.0)) ;;; (cb-test :no-long-long t) (defcfun "call_sum_127_no_ll" :long (cb :pointer)) ;;; CMUCL, ECL and CCL choke on this one. #-(or ecl cmu clozure #.(cl:if (cl:>= cl:lambda-parameters-limit 127) '(:or) '(:and))) (defcallback sum-127-no-ll :long ((a1 :unsigned-long) (a2 :pointer) (a3 :long) (a4 :double) (a5 :unsigned-long) (a6 :float) (a7 :float) (a8 :int) (a9 :unsigned-int) (a10 :double) (a11 :double) (a12 :double) (a13 :pointer) (a14 :unsigned-short) (a15 :unsigned-short) (a16 :pointer) (a17 :long) (a18 :long) (a19 :int) (a20 :short) (a21 :unsigned-short) (a22 :unsigned-short) (a23 :char) (a24 :long) (a25 :pointer) (a26 :pointer) (a27 :char) (a28 :unsigned-char) (a29 :unsigned-long) (a30 :short) (a31 :int) (a32 :int) (a33 :unsigned-char) (a34 :short) (a35 :long) (a36 :long) (a37 :pointer) (a38 :unsigned-short) (a39 :char) (a40 :double) (a41 :unsigned-short) (a42 :pointer) (a43 :short) (a44 :unsigned-long) (a45 :unsigned-short) (a46 :float) (a47 :unsigned-char) (a48 :short) (a49 :float) (a50 :short) (a51 :char) (a52 :unsigned-long) (a53 :unsigned-long) (a54 :char) (a55 :float) (a56 :long) (a57 :pointer) (a58 :short) (a59 :float) (a60 :unsigned-int) (a61 :float) (a62 :unsigned-int) (a63 :double) (a64 :unsigned-int) (a65 :unsigned-char) (a66 :int) (a67 :long) (a68 :char) (a69 :short) (a70 :double) (a71 :int) (a72 :pointer) (a73 :char) (a74 :unsigned-short) (a75 :pointer) (a76 :unsigned-short) (a77 :pointer) (a78 :unsigned-long) (a79 :double) (a80 :pointer) (a81 :long) (a82 :float) (a83 :unsigned-short) (a84 :unsigned-short) (a85 :pointer) (a86 :float) (a87 :int) (a88 :unsigned-int) (a89 :double) (a90 :float) (a91 :long) (a92 :pointer) (a93 :unsigned-short) (a94 :float) (a95 :unsigned-char) (a96 :unsigned-char) (a97 :float) (a98 :unsigned-int) (a99 :float) (a100 :unsigned-short) (a101 :double) (a102 :unsigned-short) (a103 :unsigned-long) (a104 :unsigned-int) (a105 :unsigned-long) (a106 :pointer) (a107 :unsigned-char) (a108 :char) (a109 :char) (a110 :unsigned-short) (a111 :unsigned-long) (a112 :float) (a113 :short) (a114 :pointer) (a115 :long) (a116 :unsigned-short) (a117 :short) (a118 :double) (a119 :short) (a120 :int) (a121 :char) (a122 :unsigned-long) (a123 :long) (a124 :int) (a125 :pointer) (a126 :double) (a127 :unsigned-char)) (let ((args (list a1 (pointer-address a2) a3 (floor a4) a5 (floor a6) (floor a7) a8 a9 (floor a10) (floor a11) (floor a12) (pointer-address a13) a14 a15 (pointer-address a16) a17 a18 a19 a20 a21 a22 a23 a24 (pointer-address a25) (pointer-address a26) a27 a28 a29 a30 a31 a32 a33 a34 a35 a36 (pointer-address a37) a38 a39 (floor a40) a41 (pointer-address a42) a43 a44 a45 (floor a46) a47 a48 (floor a49) a50 a51 a52 a53 a54 (floor a55) a56 (pointer-address a57) a58 (floor a59) a60 (floor a61) a62 (floor a63) a64 a65 a66 a67 a68 a69 (floor a70) a71 (pointer-address a72) a73 a74 (pointer-address a75) a76 (pointer-address a77) a78 (floor a79) (pointer-address a80) a81 (floor a82) a83 a84 (pointer-address a85) (floor a86) a87 a88 (floor a89) (floor a90) a91 (pointer-address a92) a93 (floor a94) a95 a96 (floor a97) a98 (floor a99) a100 (floor a101) a102 a103 a104 a105 (pointer-address a106) a107 a108 a109 a110 a111 (floor a112) a113 (pointer-address a114) a115 a116 a117 (floor a118) a119 a120 a121 a122 a123 a124 (pointer-address a125) (floor a126) a127))) #-(and) (loop for i from 1 and arg in args do (format t "a~A: ~A~%" i arg)) (reduce #'+ args))) #+(or openmcl cmu ecl (and darwin (or allegro lispworks))) (push 'callbacks.bff.1 regression-test::*expected-failures*) #+#.(cl:if (cl:>= cl:lambda-parameters-limit 127) '(:and) '(:or)) (deftest callbacks.bff.1 (call-sum-127-no-ll (callback sum-127-no-ll)) 2008547941) ;;; (cb-test) #-(or cffi-sys::no-long-long #.(cl:if (cl:>= cl:lambda-parameters-limit 127) '(or) '(and))) (progn (defcfun "call_sum_127" :long-long (cb :pointer)) ;;; CMUCL, ECL and CCL choke on this one. #-(or cmu ecl clozure) (defcallback sum-127 :long-long ((a1 :short) (a2 :char) (a3 :pointer) (a4 :float) (a5 :long) (a6 :double) (a7 :unsigned-long-long) (a8 :unsigned-short) (a9 :unsigned-char) (a10 :char) (a11 :char) (a12 :unsigned-short) (a13 :unsigned-long-long) (a14 :unsigned-short) (a15 :long-long) (a16 :unsigned-short) (a17 :unsigned-long-long) (a18 :unsigned-char) (a19 :unsigned-char) (a20 :unsigned-long-long) (a21 :long-long) (a22 :char) (a23 :float) (a24 :unsigned-int) (a25 :float) (a26 :float) (a27 :unsigned-int) (a28 :float) (a29 :char) (a30 :unsigned-char) (a31 :long) (a32 :long-long) (a33 :unsigned-char) (a34 :double) (a35 :long) (a36 :double) (a37 :unsigned-int) (a38 :unsigned-short) (a39 :long-long) (a40 :unsigned-int) (a41 :int) (a42 :unsigned-long-long) (a43 :long) (a44 :short) (a45 :unsigned-int) (a46 :unsigned-int) (a47 :unsigned-long-long) (a48 :unsigned-int) (a49 :long) (a50 :pointer) (a51 :unsigned-char) (a52 :char) (a53 :long-long) (a54 :unsigned-short) (a55 :unsigned-int) (a56 :float) (a57 :unsigned-char) (a58 :unsigned-long) (a59 :long-long) (a60 :float) (a61 :long) (a62 :float) (a63 :int) (a64 :float) (a65 :unsigned-short) (a66 :unsigned-long-long) (a67 :short) (a68 :unsigned-long) (a69 :long) (a70 :char) (a71 :unsigned-short) (a72 :long-long) (a73 :short) (a74 :double) (a75 :pointer) (a76 :unsigned-int) (a77 :char) (a78 :unsigned-int) (a79 :pointer) (a80 :pointer) (a81 :unsigned-char) (a82 :pointer) (a83 :unsigned-short) (a84 :unsigned-char) (a85 :long) (a86 :pointer) (a87 :char) (a88 :long) (a89 :unsigned-short) (a90 :unsigned-char) (a91 :double) (a92 :unsigned-long-long) (a93 :unsigned-short) (a94 :unsigned-short) (a95 :unsigned-int) (a96 :long) (a97 :char) (a98 :long) (a99 :char) (a100 :short) (a101 :unsigned-short) (a102 :unsigned-long) (a103 :unsigned-long) (a104 :short) (a105 :long-long) (a106 :long-long) (a107 :long-long) (a108 :double) (a109 :unsigned-short) (a110 :unsigned-char) (a111 :short) (a112 :unsigned-char) (a113 :long) (a114 :long-long) (a115 :unsigned-long-long) (a116 :unsigned-int) (a117 :unsigned-long) (a118 :unsigned-char) (a119 :long-long) (a120 :unsigned-char) (a121 :unsigned-long-long) (a122 :double) (a123 :unsigned-char) (a124 :long-long) (a125 :unsigned-char) (a126 :char) (a127 :long-long)) (+ a1 a2 (pointer-address a3) (values (floor a4)) a5 (values (floor a6)) a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 (values (floor a23)) a24 (values (floor a25)) (values (floor a26)) a27 (values (floor a28)) a29 a30 a31 a32 a33 (values (floor a34)) a35 (values (floor a36)) a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48 a49 (pointer-address a50) a51 a52 a53 a54 a55 (values (floor a56)) a57 a58 a59 (values (floor a60)) a61 (values (floor a62)) a63 (values (floor a64)) a65 a66 a67 a68 a69 a70 a71 a72 a73 (values (floor a74)) (pointer-address a75) a76 a77 a78 (pointer-address a79) (pointer-address a80) a81 (pointer-address a82) a83 a84 a85 (pointer-address a86) a87 a88 a89 a90 (values (floor a91)) a92 a93 a94 a95 a96 a97 a98 a99 a100 a101 a102 a103 a104 a105 a106 a107 (values (floor a108)) a109 a110 a111 a112 a113 a114 a115 a116 a117 a118 a119 a120 a121 (values (floor a122)) a123 a124 a125 a126 a127)) #+(or openmcl cmu ecl) (push 'callbacks.bff.2 rt::*expected-failures*) (deftest callbacks.bff.2 (call-sum-127 (callback sum-127)) 8166570665645582011)) ;;; regression test: (callback non-existant-callback) should throw an error (deftest callbacks.non-existant (not (null (nth-value 1 (ignore-errors (callback doesnt-exist))))) t) ;;; Handling many arguments of type double. Many lisps (used to) fail ;;; this one on darwin/ppc. This test might be bogus due to floating ;;; point arithmetic rounding errors. ;;; ;;; CMUCL chokes on this one. #-(and darwin cmu) (defcallback double26 :double ((a1 :double) (a2 :double) (a3 :double) (a4 :double) (a5 :double) (a6 :double) (a7 :double) (a8 :double) (a9 :double) (a10 :double) (a11 :double) (a12 :double) (a13 :double) (a14 :double) (a15 :double) (a16 :double) (a17 :double) (a18 :double) (a19 :double) (a20 :double) (a21 :double) (a22 :double) (a23 :double) (a24 :double) (a25 :double) (a26 :double)) (let ((args (list a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26))) #-(and) (loop for i from 1 and arg in args do (format t "a~A: ~A~%" i arg)) (reduce #'+ args))) (defcfun "call_double26" :double (f :pointer)) #+(and darwin (or allegro cmu)) (pushnew 'callbacks.double26 rt::*expected-failures*) (deftest callbacks.double26 (call-double26 (callback double26)) 81.64d0) #+(and darwin cmu) (pushnew 'callbacks.double26.funcall rt::*expected-failures*) #-cffi-sys::no-foreign-funcall (deftest callbacks.double26.funcall (foreign-funcall-pointer (callback double26) () :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double) 81.64d0) ;;; Same as above, for floats. #-(and darwin cmu) (defcallback float26 :float ((a1 :float) (a2 :float) (a3 :float) (a4 :float) (a5 :float) (a6 :float) (a7 :float) (a8 :float) (a9 :float) (a10 :float) (a11 :float) (a12 :float) (a13 :float) (a14 :float) (a15 :float) (a16 :float) (a17 :float) (a18 :float) (a19 :float) (a20 :float) (a21 :float) (a22 :float) (a23 :float) (a24 :float) (a25 :float) (a26 :float)) (let ((args (list a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26))) #-(and) (loop for i from 1 and arg in args do (format t "a~A: ~A~%" i arg)) (reduce #'+ args))) (defcfun "call_float26" :float (f :pointer)) #+(and darwin (or lispworks openmcl cmu)) (pushnew 'callbacks.float26 regression-test::*expected-failures*) (deftest callbacks.float26 (call-float26 (callback float26)) 130.0) #+(and darwin (or lispworks openmcl cmu)) (pushnew 'callbacks.float26.funcall regression-test::*expected-failures*) #-cffi-sys::no-foreign-funcall (deftest callbacks.float26.funcall (foreign-funcall-pointer (callback float26) () :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float) 130.0) ;;; Defining a callback as a non-toplevel form. Not portable. Doesn't ;;; work for CMUCL or Allegro. #-(and) (let ((n 42)) (defcallback non-toplevel-cb :int () n)) #-(and) (deftest callbacks.non-toplevel (foreign-funcall (callback non-toplevel-cb) :int) 42) ;;;# Stdcall #+(and x86 (not cffi-sys::no-stdcall)) (progn (defcallback (stdcall-cb :cconv :stdcall) :int ((a :int) (b :int) (c :int)) (+ a b c)) (defcfun "call_stdcall_fun" :int (f :pointer)) (deftest callbacks.stdcall.1 (call-stdcall-fun (callback stdcall-cb)) 42))
19,806
Common Lisp
.lisp
432
40.835648
81
0.64108
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
da647de1a50ef5e04d4eff3e84499c8e7a7605c3764ed87a348de972b4347dde
21,649
[ -1 ]
21,650
foreign-globals.lisp
rheaplex_minara/lib/cffi/tests/foreign-globals.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; foreign-globals.lisp --- Tests on foreign globals. ;;; ;;; Copyright (C) 2005-2007, Luis Oliveira <loliveira(@)common-lisp.net> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-tests) (defcvar ("var_char" *char-var*) :char) (defcvar "var_unsigned_char" :unsigned-char) (defcvar "var_short" :short) (defcvar "var_unsigned_short" :unsigned-short) (defcvar "var_int" :int) (defcvar "var_unsigned_int" :unsigned-int) (defcvar "var_long" :long) (defcvar "var_unsigned_long" :unsigned-long) (defcvar "var_float" :float) (defcvar "var_double" :double) (defcvar "var_pointer" :pointer) (defcvar "var_string" :string) (defcvar "var_long_long" :long-long) (defcvar "var_unsigned_long_long" :unsigned-long-long) ;;; The expected failures marked below result from this odd behaviour: ;;; ;;; (foreign-symbol-pointer "var_char") => NIL ;;; ;;; (foreign-symbol-pointer "var_char" :library 'libtest) ;;; => #<Pointer to type :VOID = #xF7F50740> ;;; ;;; Why is this happening? --luis #+lispworks (mapc (lambda (x) (pushnew x rtest::*expected-failures*)) '(foreign-globals.ref.char foreign-globals.get-var-pointer.1 foreign-globals.get-var-pointer.2 foreign-globals.symbol-name foreign-globals.read-only.1 )) (deftest foreign-globals.ref.char *char-var* -127) (deftest foreign-globals.ref.unsigned-char *var-unsigned-char* 255) (deftest foreign-globals.ref.short *var-short* -32767) (deftest foreign-globals.ref.unsigned-short *var-unsigned-short* 65535) (deftest foreign-globals.ref.int *var-int* -32767) (deftest foreign-globals.ref.unsigned-int *var-unsigned-int* 65535) (deftest foreign-globals.ref.long *var-long* -2147483647) (deftest foreign-globals.ref.unsigned-long *var-unsigned-long* 4294967295) (deftest foreign-globals.ref.float *var-float* 42.0) (deftest foreign-globals.ref.double *var-double* 42.0d0) (deftest foreign-globals.ref.pointer (null-pointer-p *var-pointer*) t) (deftest foreign-globals.ref.string *var-string* "Hello, foreign world!") #+openmcl (push 'foreign-globals.set.long-long rt::*expected-failures*) (deftest foreign-globals.ref.long-long *var-long-long* -9223372036854775807) (deftest foreign-globals.ref.unsigned-long-long *var-unsigned-long-long* 18446744073709551615) ;; The *.set.* tests restore the old values so that the *.ref.* ;; don't fail when re-run. (defmacro with-old-value-restored ((place) &body body) (let ((old (gensym))) `(let ((,old ,place)) (prog1 (progn ,@body) (setq ,place ,old))))) (deftest foreign-globals.set.int (with-old-value-restored (*var-int*) (setq *var-int* 42) *var-int*) 42) (deftest foreign-globals.set.string (with-old-value-restored (*var-string*) (setq *var-string* "Ehxosxangxo") (prog1 *var-string* ;; free the string we just allocated (foreign-free (mem-ref (get-var-pointer '*var-string*) :pointer)))) "Ehxosxangxo") (deftest foreign-globals.set.long-long (with-old-value-restored (*var-long-long*) (setq *var-long-long* -9223000000000005808) *var-long-long*) -9223000000000005808) (deftest foreign-globals.get-var-pointer.1 (pointerp (get-var-pointer '*char-var*)) t) (deftest foreign-globals.get-var-pointer.2 (mem-ref (get-var-pointer '*char-var*) :char) -127) ;;; Symbol case. (defcvar "UPPERCASEINT1" :int) (defcvar "UPPER_CASE_INT1" :int) (defcvar "MiXeDCaSeInT1" :int) (defcvar "MiXeD_CaSe_InT1" :int) (deftest foreign-globals.ref.uppercaseint1 *uppercaseint1* 12345) (deftest foreign-globals.ref.upper-case-int1 *upper-case-int1* 23456) (deftest foreign-globals.ref.mixedcaseint1 *mixedcaseint1* 34567) (deftest foreign-globals.ref.mixed-case-int1 *mixed-case-int1* 45678) (when (string= (symbol-name 'nil) "NIL") (let ((*readtable* (copy-readtable))) (setf (readtable-case *readtable*) :invert) (eval (read-from-string "(defcvar \"UPPERCASEINT2\" :int)")) (eval (read-from-string "(defcvar \"UPPER_CASE_INT2\" :int)")) (eval (read-from-string "(defcvar \"MiXeDCaSeInT2\" :int)")) (eval (read-from-string "(defcvar \"MiXeD_CaSe_InT2\" :int)")) (setf (readtable-case *readtable*) :preserve) (eval (read-from-string "(DEFCVAR \"UPPERCASEINT3\" :INT)")) (eval (read-from-string "(DEFCVAR \"UPPER_CASE_INT3\" :INT)")) (eval (read-from-string "(DEFCVAR \"MiXeDCaSeInT3\" :INT)")) (eval (read-from-string "(DEFCVAR \"MiXeD_CaSe_InT3\" :INT)")))) ;;; EVAL gets rid of SBCL's unreachable code warnings. (when (string= (symbol-name (eval nil)) "nil") (let ((*readtable* (copy-readtable))) (setf (readtable-case *readtable*) :invert) (eval (read-from-string "(DEFCVAR \"UPPERCASEINT2\" :INT)")) (eval (read-from-string "(DEFCVAR \"UPPER_CASE_INT2\" :INT)")) (eval (read-from-string "(DEFCVAR \"MiXeDCaSeInT2\" :INT)")) (eval (read-from-string "(DEFCVAR \"MiXeD_CaSe_InT2\" :INT)")) (setf (readtable-case *readtable*) :downcase) (eval (read-from-string "(defcvar \"UPPERCASEINT3\" :int)")) (eval (read-from-string "(defcvar \"UPPER_CASE_INT3\" :int)")) (eval (read-from-string "(defcvar \"MiXeDCaSeInT3\" :int)")) (eval (read-from-string "(defcvar \"MiXeD_CaSe_InT3\" :int)")))) (deftest foreign-globals.ref.uppercaseint2 *uppercaseint2* 12345) (deftest foreign-globals.ref.upper-case-int2 *upper-case-int2* 23456) (deftest foreign-globals.ref.mixedcaseint2 *mixedcaseint2* 34567) (deftest foreign-globals.ref.mixed-case-int2 *mixed-case-int2* 45678) (deftest foreign-globals.ref.uppercaseint3 *uppercaseint3* 12345) (deftest foreign-globals.ref.upper-case-int3 *upper-case-int3* 23456) (deftest foreign-globals.ref.mixedcaseint3 *mixedcaseint3* 34567) (deftest foreign-globals.ref.mixed-case-int3 *mixed-case-int3* 45678) ;;; regression test: ;;; gracefully accept symbols in defcvar (defcvar *var-char* :char) (defcvar var-char :char) (deftest foreign-globals.symbol-name (values *var-char* var-char) -127 -127) ;;;# Namespace #-cffi-sys::flat-namespace (progn (deftest foreign-globals.namespace.1 (values (mem-ref (foreign-symbol-pointer "var_char" :library 'libtest) :char) (foreign-symbol-pointer "var_char" :library 'libtest2)) -127 nil) (deftest foreign-globals.namespace.2 (values (mem-ref (foreign-symbol-pointer "ns_var" :library 'libtest) :boolean) (mem-ref (foreign-symbol-pointer "ns_var" :library 'libtest2) :boolean)) t nil) ;; For its "default" module, Lispworks seems to cache lookups from ;; the newest module tried. If a lookup happens to have failed ;; subsequent lookups will fail even the symbol exists in other ;; modules. So this test fails. #+lispworks (pushnew 'foreign-globals.namespace.3 regression-test::*expected-failures*) (deftest foreign-globals.namespace.3 (values (foreign-symbol-pointer "var_char" :library 'libtest2) (mem-ref (foreign-symbol-pointer "var_char") :char)) nil -127) (defcvar ("ns_var" *ns-var1* :library libtest) :boolean) (defcvar ("ns_var" *ns-var2* :library libtest2) :boolean) (deftest foreign-globals.namespace.4 (values *ns-var1* *ns-var2*) t nil)) ;;;# Read-only (defcvar ("var_char" *var-char-ro* :read-only t) :char "Testing the docstring too.") (deftest foreign-globals.read-only.1 (values *var-char-ro* (ignore-errors (setf *var-char-ro* 12))) -127 nil)
8,871
Common Lisp
.lisp
238
33.865546
79
0.689241
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
f240b5ef5d98ea879bb0fc1b9acec834899381feed40b24a052a79751397a24f
21,650
[ -1 ]
21,651
memory.lisp
rheaplex_minara/lib/cffi/tests/memory.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; memory.lisp --- Tests for memory referencing. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-tests) (deftest deref.char (with-foreign-object (p :char) (setf (mem-ref p :char) -127) (mem-ref p :char)) -127) (deftest deref.unsigned-char (with-foreign-object (p :unsigned-char) (setf (mem-ref p :unsigned-char) 255) (mem-ref p :unsigned-char)) 255) (deftest deref.short (with-foreign-object (p :short) (setf (mem-ref p :short) -32767) (mem-ref p :short)) -32767) (deftest deref.unsigned-short (with-foreign-object (p :unsigned-short) (setf (mem-ref p :unsigned-short) 65535) (mem-ref p :unsigned-short)) 65535) (deftest deref.int (with-foreign-object (p :int) (setf (mem-ref p :int) -131072) (mem-ref p :int)) -131072) (deftest deref.unsigned-int (with-foreign-object (p :unsigned-int) (setf (mem-ref p :unsigned-int) 262144) (mem-ref p :unsigned-int)) 262144) (deftest deref.long (with-foreign-object (p :long) (setf (mem-ref p :long) -536870911) (mem-ref p :long)) -536870911) (deftest deref.unsigned-long (with-foreign-object (p :unsigned-long) (setf (mem-ref p :unsigned-long) 536870912) (mem-ref p :unsigned-long)) 536870912) #+(and darwin openmcl) (pushnew 'deref.long-long rt::*expected-failures*) (deftest deref.long-long (with-foreign-object (p :long-long) (setf (mem-ref p :long-long) -9223372036854775807) (mem-ref p :long-long)) -9223372036854775807) (deftest deref.unsigned-long-long (with-foreign-object (p :unsigned-long-long) (setf (mem-ref p :unsigned-long-long) 18446744073709551615) (mem-ref p :unsigned-long-long)) 18446744073709551615) (deftest deref.float.1 (with-foreign-object (p :float) (setf (mem-ref p :float) 0.0) (mem-ref p :float)) 0.0) (deftest deref.float.2 (with-foreign-object (p :float) (setf (mem-ref p :float) *float-max*) (mem-ref p :float)) #.*float-max*) (deftest deref.float.3 (with-foreign-object (p :float) (setf (mem-ref p :float) *float-min*) (mem-ref p :float)) #.*float-min*) (deftest deref.double.1 (with-foreign-object (p :double) (setf (mem-ref p :double) 0.0d0) (mem-ref p :double)) 0.0d0) (deftest deref.double.2 (with-foreign-object (p :double) (setf (mem-ref p :double) *double-max*) (mem-ref p :double)) #.*double-max*) (deftest deref.double.3 (with-foreign-object (p :double) (setf (mem-ref p :double) *double-min*) (mem-ref p :double)) #.*double-min*) ;;; TODO: use something like *DOUBLE-MIN/MAX* above once we actually ;;; have an available lisp that supports long double. ;#-cffi-sys::no-long-float #+(and scl long-double) (progn (deftest deref.long-double.1 (with-foreign-object (p :long-double) (setf (mem-ref p :long-double) 0.0l0) (mem-ref p :long-double)) 0.0l0) (deftest deref.long-double.2 (with-foreign-object (p :long-double) (setf (mem-ref p :long-double) most-positive-long-float) (mem-ref p :long-double)) #.most-positive-long-float) (deftest deref.long-double.3 (with-foreign-object (p :long-double) (setf (mem-ref p :long-double) least-positive-long-float) (mem-ref p :long-double)) #.least-positive-long-float)) ;;; make sure the lisp doesn't convert NULL to NIL (deftest deref.pointer.null (with-foreign-object (p :pointer) (setf (mem-ref p :pointer) (null-pointer)) (null-pointer-p (mem-ref p :pointer))) t) ;;; regression test. lisp-string-to-foreign should handle empty strings (deftest lisp-string-to-foreign.empty (with-foreign-pointer (str 2) (setf (mem-ref str :unsigned-char) 42) (lisp-string-to-foreign "" str 1) (mem-ref str :unsigned-char)) 0) ;; regression test. with-foreign-pointer shouldn't evaluate ;; the size argument twice. (deftest with-foreign-pointer.evalx2 (let ((count 0)) (with-foreign-pointer (x (incf count) size-var) (values count size-var))) 1 1) (deftest mem-ref.left-to-right (let ((i 0)) (with-foreign-object (p :char 3) (setf (mem-ref p :char 0) 66 (mem-ref p :char 1) 92) (setf (mem-ref p :char (incf i)) (incf i)) (values (mem-ref p :char 0) (mem-ref p :char 1) i))) 66 2 2) ;;; This needs to be in a real function for at least Allegro CL or the ;;; compiler macro on %MEM-REF is not expanded and the test doesn't ;;; actually test anything! (defun %mem-ref-left-to-right () (let ((result nil)) (with-foreign-object (p :char) (%mem-set 42 p :char) (%mem-ref (progn (push 1 result) p) :char (progn (push 2 result) 0)) (nreverse result)))) ;;; Test left-to-right evaluation of the arguments to %MEM-REF when ;;; optimized by the compiler macro. (deftest %mem-ref.left-to-right (%mem-ref-left-to-right) (1 2)) ;;; This needs to be in a top-level function for at least Allegro CL ;;; or the compiler macro on %MEM-SET is not expanded and the test ;;; doesn't actually test anything! (defun %mem-set-left-to-right () (let ((result nil)) (with-foreign-object (p :char) (%mem-set (progn (push 1 result) 0) (progn (push 2 result) p) :char (progn (push 3 result) 0)) (nreverse result)))) ;;; Test left-to-right evaluation of the arguments to %MEM-SET when ;;; optimized by the compiler macro. (deftest %mem-set.left-to-right (%mem-set-left-to-right) (1 2 3)) ;; regression test. mem-aref's setf expansion evaluated its type argument twice. (deftest mem-aref.eval-type-x2 (let ((count 0)) (with-foreign-pointer (p 1) (setf (mem-aref p (progn (incf count) :char) 0) 127)) count) 1) (deftest mem-aref.left-to-right (let ((count -1)) (with-foreign-pointer (p 2) (values (setf (mem-aref p (progn (incf count) :char) (incf count)) (incf count)) (setq count -1) (mem-aref (progn (incf count) p) :char (incf count)) count))) 2 -1 2 1) ;; regression tests. nested mem-ref's and mem-aref's had bogus getters (deftest mem-ref.nested (with-foreign-object (p :pointer) (with-foreign-object (i :int) (setf (mem-ref p :pointer) i) (setf (mem-ref i :int) 42) (setf (mem-ref (mem-ref p :pointer) :int) 1984) (mem-ref i :int))) 1984) (deftest mem-aref.nested (with-foreign-object (p :pointer) (with-foreign-object (i :int 2) (setf (mem-aref p :pointer 0) i) (setf (mem-aref i :int 1) 42) (setf (mem-aref (mem-ref p :pointer 0) :int 1) 1984) (mem-aref i :int 1))) 1984) ;;; regression tests. dereferencing an aggregate type. dereferencing a ;;; struct should return a pointer to the struct itself, not return the ;;; first 4 bytes (or whatever the size of :pointer is) as a pointer. ;;; ;;; This important for accessing an array of structs, which is ;;; what the deref.array-of-aggregates test does. (defcstruct some-struct (x :int)) (deftest deref.aggregate (with-foreign-object (s 'some-struct) (pointer-eq s (mem-ref s 'some-struct))) t) (deftest deref.array-of-aggregates (with-foreign-object (arr 'some-struct 3) (loop for i below 3 do (setf (foreign-slot-value (mem-aref arr 'some-struct i) 'some-struct 'x) 112)) (loop for i below 3 collect (foreign-slot-value (mem-aref arr 'some-struct i) 'some-struct 'x))) (112 112 112)) ;;; pointer operations (deftest pointer.1 (pointer-address (make-pointer 42)) 42) ;;; I suppose this test is not very good. --luis (deftest pointer.2 (pointer-address (null-pointer)) 0) ;;; Ensure that a pointer to the highest possible address can be ;;; created using MAKE-POINTER. Regression test for CLISP/X86-64. (deftest make-pointer.high (let* ((pointer-length (foreign-type-size :pointer)) (high-address (1- (expt 2 (* pointer-length 8)))) (pointer (make-pointer high-address))) (- high-address (pointer-address pointer))) 0) ;;; Ensure that incrementing a pointer by zero bytes returns an ;;; equivalent pointer. (deftest inc-pointer.zero (with-foreign-object (x :int) (pointer-eq x (inc-pointer x 0))) t) ;;; Test the INITIAL-ELEMENT keyword argument to FOREIGN-ALLOC. (deftest foreign-alloc.1 (let ((ptr (foreign-alloc :int :initial-element 42))) (unwind-protect (mem-ref ptr :int) (foreign-free ptr))) 42) ;;; Test the INITIAL-ELEMENT and COUNT arguments to FOREIGN-ALLOC. (deftest foreign-alloc.2 (let ((ptr (foreign-alloc :int :count 4 :initial-element 100))) (unwind-protect (loop for i from 0 below 4 collect (mem-aref ptr :int i)) (foreign-free ptr))) (100 100 100 100)) ;;; Test the INITIAL-CONTENTS and COUNT arguments to FOREIGN-ALLOC, ;;; passing a list of initial values. (deftest foreign-alloc.3 (let ((ptr (foreign-alloc :int :count 4 :initial-contents '(4 3 2 1)))) (unwind-protect (loop for i from 0 below 4 collect (mem-aref ptr :int i)) (foreign-free ptr))) (4 3 2 1)) ;;; Test INITIAL-CONTENTS and COUNT with FOREIGN-ALLOC passing a ;;; vector of initial values. (deftest foreign-alloc.4 (let ((ptr (foreign-alloc :int :count 4 :initial-contents #(10 20 30 40)))) (unwind-protect (loop for i from 0 below 4 collect (mem-aref ptr :int i)) (foreign-free ptr))) (10 20 30 40)) ;;; Ensure calling FOREIGN-ALLOC with both INITIAL-ELEMENT and ;;; INITIAL-CONTENTS signals an error. (deftest foreign-alloc.5 (values (ignore-errors (let ((ptr (foreign-alloc :int :initial-element 1 :initial-contents '(1)))) (foreign-free ptr)) t)) nil) ;;; Regression test: FOREIGN-ALLOC shouldn't actually perform translation ;;; on initial-element/initial-contents since MEM-AREF will do that already. (define-foreign-type not-an-int () () (:actual-type :int) (:simple-parser not-an-int)) (defmethod translate-to-foreign (value (type not-an-int)) (assert (not (integerp value))) 0) (deftest foreign-alloc.6 (let ((ptr (foreign-alloc 'not-an-int :initial-element 'foooo))) (foreign-free ptr) t) t) ;;; Ensure calling FOREIGN-ALLOC with NULL-TERMINATED-P and a non-pointer ;;; type signals an error. (deftest foreign-alloc.7 (values (ignore-errors (let ((ptr (foreign-alloc :int :null-terminated-p t))) (foreign-free ptr)) t)) nil) ;;; The opposite of the above test. (defctype pointer-alias :pointer) (deftest foreign-alloc.8 (progn (foreign-free (foreign-alloc 'pointer-alias :count 0 :null-terminated-p t)) t) t) ;;; Ensure calling FOREIGN-ALLOC with NULL-TERMINATED-P actually places ;;; a null pointer at the end. Not a very reliable test apparently. (deftest foreign-alloc.9 (let ((ptr (foreign-alloc :pointer :count 0 :null-terminated-p t))) (unwind-protect (null-pointer-p (mem-ref ptr :pointer)) (foreign-free ptr))) t) ;;; Tests for mem-ref with a non-constant type. This is a way to test ;;; the functional interface (without compiler macros). (deftest deref.nonconst.char (let ((type :char)) (with-foreign-object (p type) (setf (mem-ref p type) -127) (mem-ref p type))) -127) (deftest deref.nonconst.unsigned-char (let ((type :unsigned-char)) (with-foreign-object (p type) (setf (mem-ref p type) 255) (mem-ref p type))) 255) (deftest deref.nonconst.short (let ((type :short)) (with-foreign-object (p type) (setf (mem-ref p type) -32767) (mem-ref p type))) -32767) (deftest deref.nonconst.unsigned-short (let ((type :unsigned-short)) (with-foreign-object (p type) (setf (mem-ref p type) 65535) (mem-ref p type))) 65535) (deftest deref.nonconst.int (let ((type :int)) (with-foreign-object (p type) (setf (mem-ref p type) -131072) (mem-ref p type))) -131072) (deftest deref.nonconst.unsigned-int (let ((type :unsigned-int)) (with-foreign-object (p type) (setf (mem-ref p type) 262144) (mem-ref p type))) 262144) (deftest deref.nonconst.long (let ((type :long)) (with-foreign-object (p type) (setf (mem-ref p type) -536870911) (mem-ref p type))) -536870911) (deftest deref.nonconst.unsigned-long (let ((type :unsigned-long)) (with-foreign-object (p type) (setf (mem-ref p type) 536870912) (mem-ref p type))) 536870912) #+(and darwin openmcl) (pushnew 'deref.nonconst.long-long rt::*expected-failures*) (deftest deref.nonconst.long-long (let ((type :long-long)) (with-foreign-object (p type) (setf (mem-ref p type) -9223372036854775807) (mem-ref p type))) -9223372036854775807) (deftest deref.nonconst.unsigned-long-long (let ((type :unsigned-long-long)) (with-foreign-object (p type) (setf (mem-ref p type) 18446744073709551615) (mem-ref p type))) 18446744073709551615) (deftest deref.nonconst.float.1 (let ((type :float)) (with-foreign-object (p type) (setf (mem-ref p type) 0.0) (mem-ref p type))) 0.0) (deftest deref.nonconst.float.2 (let ((type :float)) (with-foreign-object (p type) (setf (mem-ref p type) *float-max*) (mem-ref p type))) #.*float-max*) (deftest deref.nonconst.float.3 (let ((type :float)) (with-foreign-object (p type) (setf (mem-ref p type) *float-min*) (mem-ref p type))) #.*float-min*) (deftest deref.nonconst.double.1 (let ((type :double)) (with-foreign-object (p type) (setf (mem-ref p type) 0.0d0) (mem-ref p type))) 0.0d0) (deftest deref.nonconst.double.2 (let ((type :double)) (with-foreign-object (p type) (setf (mem-ref p type) *double-max*) (mem-ref p type))) #.*double-max*) (deftest deref.nonconst.double.3 (let ((type :double)) (with-foreign-object (p type) (setf (mem-ref p type) *double-min*) (mem-ref p type))) #.*double-min*) ;;; regression tests: lispworks's %mem-ref and %mem-set compiler ;;; macros were misbehaving. (defun mem-ref-rt-1 () (with-foreign-object (a :int 2) (setf (mem-aref a :int 0) 123 (mem-aref a :int 1) 456) (values (mem-aref a :int 0) (mem-aref a :int 1)))) (deftest mem-ref.rt.1 (mem-ref-rt-1) 123 456) (defun mem-ref-rt-2 () (with-foreign-object (a :double 2) (setf (mem-aref a :double 0) 123.0d0 (mem-aref a :double 1) 456.0d0) (values (mem-aref a :double 0) (mem-aref a :double 1)))) (deftest mem-ref.rt.2 (mem-ref-rt-2) 123.0d0 456.0d0) (deftest incf-pointer.1 (let ((ptr (null-pointer))) (incf-pointer ptr) (pointer-address ptr)) 1) (deftest incf-pointer.2 (let ((ptr (null-pointer))) (incf-pointer ptr 42) (pointer-address ptr)) 42) (deftest pointerp.1 (values (pointerp (null-pointer)) (null-pointer-p (null-pointer)) (typep (null-pointer) 'foreign-pointer)) t t t) (deftest pointerp.2 (let ((p (make-pointer #xFEFF))) (values (pointerp p) (typep p 'foreign-pointer))) t t)
16,711
Common Lisp
.lisp
482
29.649378
82
0.648916
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
9c75a3af9143e9ffbf2a0849729de429d39f3135c46e3134fa27401bcdab1498
21,651
[ -1 ]
21,653
strings.lisp
rheaplex_minara/lib/cffi/tests/strings.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; strings.lisp --- Tests for foreign string conversion. ;;; ;;; Copyright (C) 2005, James Bielman <[email protected]> ;;; Copyright (C) 2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-tests) ;;;# Foreign String Conversion Tests ;;; ;;; With the implementation of encoding support, there are a lot of ;;; things that can go wrong with foreign string conversions. This is ;;; a start at defining tests for strings and encoding conversion, but ;;; there needs to be a lot more. (babel:enable-sharp-backslash-syntax) ;;; *ASCII-TEST-STRING* contains the characters in the ASCII character ;;; set that we will convert to a foreign string and check against ;;; *ASCII-TEST-BYTES*. We don't bother with control characters. ;;; ;;; FIXME: It would probably be good to move these tables into files ;;; in "tests/", especially if we ever want to get fancier and have ;;; tests for more encodings. (eval-when (:compile-toplevel :load-toplevel :execute) (defparameter *ascii-test-string* (concatenate 'string " !\"#$%&'()*+,-./0123456789:;" "<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]" "^_`abcdefghijklmnopqrstuvwxyz{|}~"))) ;;; *ASCII-TEST-BYTES* contains the expected ASCII encoded values ;;; for each character in *ASCII-TEST-STRING*. (eval-when (:compile-toplevel :load-toplevel :execute) (defparameter *ascii-test-bytes* (let ((vector (make-array 95 :element-type '(unsigned-byte 8)))) (loop for i from 0 for code from 32 below 127 do (setf (aref vector i) code) finally (return vector))))) ;;; Test basic consistency converting a string to and from Lisp using ;;; the default encoding. (deftest string.conversion.basic (with-foreign-string (s *ascii-test-string*) (foreign-string-to-lisp s)) #.*ascii-test-string* 95) (deftest string.conversion.basic.2 (with-foreign-string ((ptr size) "123" :null-terminated-p nil) (values (foreign-string-to-lisp ptr :count 3) size)) "123" 3) ;;; Ensure that conversion of *ASCII-TEST-STRING* to a foreign buffer ;;; and back preserves ASCII encoding. (deftest string.encoding.ascii (with-foreign-string (s *ascii-test-string* :encoding :ascii) (let ((vector (make-array 95 :element-type '(unsigned-byte 8)))) (loop for i from 0 below (length vector) do (setf (aref vector i) (mem-ref s :unsigned-char i))) vector)) #.*ascii-test-bytes*) ;;; FIXME: bogus test. We need support for BOM or UTF-16{BE,LE}. (pushnew 'string.encoding.utf-16.basic rtest::*expected-failures*) ;;; Test UTF-16 conversion of a string back and forth. Tests proper ;;; null terminator handling for wide character strings and ensures no ;;; byte order marks are added. (Why no BOM? --luis) #-babel::8-bit-chars (deftest string.encoding.utf-16.basic (with-foreign-string (s *ascii-test-string* :encoding :utf-16) (foreign-string-to-lisp s :encoding :utf-16)) #-ecl ; ECL (CVS 2008-06-19 17:09) chokes here, no idea why. #.*ascii-test-string* 190) ;;; Ensure that writing a long string into a short buffer does not ;;; attempt to write beyond the edge of the buffer, and that the ;;; resulting string is still null terminated. (deftest string.short-write.1 (with-foreign-pointer (buf 6) (setf (mem-ref buf :unsigned-char 5) 70) (lisp-string-to-foreign "ABCDE" buf 5 :encoding :ascii) (values (mem-ref buf :unsigned-char 4) (mem-ref buf :unsigned-char 5))) 0 70) #-babel::8-bit-chars (deftest string.encoding.utf-8.basic (with-foreign-pointer (buf 7 size) (let ((string (concatenate 'babel:unicode-string '(#\u03bb #\u00e3 #\u03bb)))) (lisp-string-to-foreign string buf size :encoding :utf-8) (loop for i from 0 below size collect (mem-ref buf :unsigned-char i)))) (206 187 195 163 206 187 0)) (defparameter *basic-latin-alphabet* "abcdefghijklmnopqrstuvwxyz") (defparameter *non-latin-compatible-encodings* '()) (defun list-latin-compatible-encodings () (remove-if (lambda (x) (member x *non-latin-compatible-encodings*)) (babel:list-character-encodings))) ;;; FIXME: bogus wrt UTF-16. See STRING.ENCODING.UTF-16.BASIC. (pushnew 'string.encodings.all.basic rtest::*expected-failures*) (deftest string.encodings.all.basic (let (failed) (dolist (encoding (list-latin-compatible-encodings) failed) ;; (format t "Testing ~S~%" encoding) (with-foreign-string (ptr *basic-latin-alphabet* :encoding encoding) (let ((string (foreign-string-to-lisp ptr :encoding encoding))) ;; (format t " got ~S~%" string) (unless (string= *basic-latin-alphabet* string) (push encoding failed)))))) nil) ;;; rt: make sure *default-foreign-enconding* binds to a keyword (deftest string.encodings.default (keywordp *default-foreign-encoding*) t)
6,097
Common Lisp
.lisp
127
43.874016
76
0.699093
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ea01ab91942fc9f99c016f8667ac775e19f675135a6c311e836d2e3edc0c5803
21,653
[ 15950 ]
21,654
run-tests.lisp
rheaplex_minara/lib/cffi/tests/run-tests.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; run-tests.lisp --- Simple script to run the unit tests. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (format t "~&;;; -------- Running tests in ~A --------~%" (lisp-implementation-type)) (setf *load-verbose* nil *compile-verbose* nil *compile-print* nil) #+cmu (setf ext:*gc-verbose* nil) #+(and (not asdf) (or sbcl openmcl ecl)) (require "asdf") (asdf:operate 'asdf:load-op 'cffi-tests :verbose nil) (asdf:operate 'asdf:test-op 'cffi-tests) (in-package #:cl-user) (terpri) (force-output) #-allegro (quit) #+allegro (exit)
1,723
Common Lisp
.lisp
39
42.820513
70
0.724672
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
3ca2ada193b8ca7cbb6845bdda8a868fcca71f7cdaae3c4053d0a430b69ed14e
21,654
[ 175697 ]
21,655
bindings.lisp
rheaplex_minara/lib/cffi/tests/bindings.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; libtest.lisp --- Setup CFFI bindings for libtest. ;;; ;;; Copyright (C) 2005-2007, Luis Oliveira <loliveira(@)common-lisp.net> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-tests) (define-foreign-library libtest (:unix (:or "libtest.so" "libtest32.so")) (:windows "libtest.dll") (t (:default "libtest"))) (define-foreign-library libtest2 (:unix (:or "libtest2.so" "libtest2_32.so")) (:darwin "libtest2.so") (t (:default "libtest2"))) (define-foreign-library libc (:windows "msvcrt.dll")) (define-foreign-library libm (t (:default "libm"))) ;;; Return the directory containing the source when compiling or ;;; loading this file. We don't use *LOAD-TRUENAME* because the fasl ;;; file may be in a different directory than the source with certain ;;; ASDF extensions loaded. (defun load-directory () (let ((here #.(or *compile-file-truename* *load-truename*))) (make-pathname :name nil :type nil :version nil :defaults here))) (defun load-test-libraries () (let ((*foreign-library-directories* (list (load-directory)))) (load-foreign-library 'libtest) (load-foreign-library 'libtest2) (load-foreign-library 'libc) #+lispworks (load-foreign-library 'libm))) #-(:and :ecl (:not :dffi)) (load-test-libraries) #+(:and :ecl (:not :dffi)) (ffi:load-foreign-library #.(make-pathname :name "libtest" :type "so" :defaults (or *compile-file-truename* *load-truename*))) ;;; check libtest version (defparameter *required-dll-version* "20060907") (defcvar "dll_version" :string) (unless (string= *dll-version* *required-dll-version*) (error "version check failed: expected ~s but libtest reports ~s" *required-dll-version* *dll-version*)) ;;; The maximum and minimum values for single and double precision C ;;; floating point values, which may be quite different from the ;;; corresponding Lisp versions. (defcvar "float_max" :float) (defcvar "float_min" :float) (defcvar "double_max" :double) (defcvar "double_min" :double) (defun run-cffi-tests (&key (compiled nil)) (let ((regression-test::*compile-tests* compiled) (*package* (find-package '#:cffi-tests))) (format t "~&;;; running tests (~Acompiled)" (if compiled "" "un")) (do-tests)))
3,394
Common Lisp
.lisp
78
40.846154
74
0.711084
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e0cd9b0df56ba20dfe465648075d82682e36a4657940410841246cc85c05caee
21,655
[ 177701 ]
21,656
misc-types.lisp
rheaplex_minara/lib/cffi/tests/misc-types.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; misc-types.lisp --- Various tests on the type system. ;;; ;;; Copyright (C) 2005-2006, Luis Oliveira <loliveira(@)common-lisp.net> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-tests) (defcfun ("my_strdup" strdup) :string+ptr (str :string)) (deftest misc-types.string+ptr (destructuring-bind (string pointer) (strdup "foo") (foreign-free pointer) string) "foo") #-(and) (deftest misc-types.string+ptr.ub8 (destructuring-bind (string pointer) (strdup (make-array 3 :element-type '(unsigned-byte 8) :initial-contents (map 'list #'char-code "foo"))) (foreign-free pointer) string) "foo") #-(and) (deftest misc-types.string.ub8.1 (let ((array (make-array 7 :element-type '(unsigned-byte 8) :initial-contents '(84 117 114 97 110 103 97)))) (with-foreign-string (foreign-string array) (foreign-string-to-lisp foreign-string))) "Turanga") #-(and) (deftest misc-types.string.ub8.2 (let ((str (foreign-string-alloc (make-array 7 :element-type '(unsigned-byte 8) :initial-contents '(84 117 114 97 110 103 97))))) (prog1 (foreign-string-to-lisp str) (foreign-string-free str))) "Turanga") (defcfun "equalequal" :boolean (a (:boolean :int)) (b (:boolean :unsigned-int))) (defcfun "bool_and" (:boolean :char) (a (:boolean :unsigned-char)) (b (:boolean :char))) (defcfun "bool_xor" (:boolean :unsigned-long) (a (:boolean :long)) (b (:boolean :unsigned-long))) (deftest misc-types.boolean.1 (list (equalequal nil nil) (equalequal t t) (equalequal t 23) (bool-and 'a 'b) (bool-and "foo" nil) (bool-xor t nil) (bool-xor nil nil)) (t t t t nil t nil)) ;;; Regression test: boolean type only worked with canonicalized ;;; built-in integer types. Should work for any type that canonicalizes ;;; to a built-in integer type. (defctype int-for-bool :int) (defcfun ("equalequal" equalequal2) :boolean (a (:boolean int-for-bool)) (b (:boolean :uint))) (deftest misc-types.boolean.2 (equalequal2 nil t) nil) (defctype my-string :string+ptr) (defun funkify (str) (concatenate 'string "MORE " (string-upcase str))) (defun 3rd-person (value) (list (concatenate 'string "Strdup says: " (first value)) (second value))) ;; (defctype funky-string ;; (:wrapper my-string ;; :to-c #'funkify ;; :from-c (lambda (value) ;; (list ;; (concatenate 'string "Strdup says: " ;; (first value)) ;; (second value)))) ;; "A useful type.") (defctype funky-string (:wrapper my-string :to-c funkify :from-c 3rd-person)) (defcfun ("my_strdup" funky-strdup) funky-string (str funky-string)) (deftest misc-types.wrapper (destructuring-bind (string ptr) (funky-strdup "code") (foreign-free ptr) string) "Strdup says: MORE CODE") (deftest misc-types.sized-ints (mapcar #'foreign-type-size '(:int8 :uint8 :int16 :uint16 :int32 :uint32 :int64 :uint64)) (1 1 2 2 4 4 8 8)) (define-foreign-type error-error () () (:actual-type :int) (:simple-parser error-error)) (defmethod translate-to-foreign (value (type error-error)) (declare (ignore value)) (error "translate-to-foreign invoked.")) (defmethod translate-from-foreign (value (type error-error)) (declare (ignore value)) (error "translate-from-foreign invoked.")) (eval-when (:load-toplevel :compile-toplevel :execute) (defmethod expand-to-foreign (value (type error-error)) value) (defmethod expand-from-foreign (value (type error-error)) value)) (defcfun ("abs" expand-abs) error-error (n error-error)) (defcvar ("var_int" *expand-var-int*) error-error) (defcfun ("expect_int_sum" expand-expect-int-sum) :boolean (cb :pointer)) (defcallback expand-int-sum error-error ((x error-error) (y error-error)) (+ x y)) ;;; Ensure that macroexpansion-time translators are called where this ;;; is guaranteed (defcfun, defcvar, foreign-funcall and defcallback) (deftest misc-types.expand.1 (expand-abs -1) 1) #-cffi-sys::no-foreign-funcall (deftest misc-types.expand.2 (foreign-funcall "abs" error-error -1 error-error) 1) (deftest misc-types.expand.3 (let ((old (mem-ref (get-var-pointer '*expand-var-int*) :int))) (unwind-protect (progn (setf *expand-var-int* 42) *expand-var-int*) (setf (mem-ref (get-var-pointer '*expand-var-int*) :int) old))) 42) (deftest misc-types.expand.4 (expand-expect-int-sum (callback expand-int-sum)) t) (define-foreign-type translate-tracker () () (:actual-type :int) (:simple-parser translate-tracker)) (declaim (special .fto-called.)) (defmethod free-translated-object (value (type translate-tracker) param) (declare (ignore value param)) (setf .fto-called. t)) (define-foreign-type expand-tracker () () (:actual-type :int) (:simple-parser expand-tracker)) (defmethod free-translated-object (value (type expand-tracker) param) (declare (ignore value param)) (setf .fto-called. t)) (eval-when (:compile-toplevel :load-toplevel :execute) (defmethod expand-to-foreign (value (type expand-tracker)) (declare (ignore value)) (call-next-method))) (defcfun ("abs" ttracker-abs) :int (n translate-tracker)) (defcfun ("abs" etracker-abs) :int (n expand-tracker)) ;; free-translated-object must be called when there is no etf (deftest misc-types.expand.5 (let ((.fto-called. nil)) (ttracker-abs -1) .fto-called.) t) ;; free-translated-object must be called when there is an etf, but ;; they answer *runtime-translator-form* (deftest misc-types.expand.6 (let ((.fto-called. nil)) (etracker-abs -1) .fto-called.) t)
7,064
Common Lisp
.lisp
191
33.052356
77
0.668912
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e073565efddac5813a93e153c946d1fba0a09c9d601416c70212d5551c5533a8
21,656
[ 257359 ]
21,657
funcall.lisp
rheaplex_minara/lib/cffi/tests/funcall.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; funcall.lisp --- Tests function calling. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; Copyright (C) 2005-2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-tests) ;;;# Calling with Built-In C Types ;;; ;;; Tests calling standard C library functions both passing and ;;; returning each built-in type. ;;; Don't run these tests if the implementation does not support ;;; foreign-funcall. #-cffi-sys::no-foreign-funcall (progn (deftest funcall.char (foreign-funcall "toupper" :char (char-code #\a) :char) #.(char-code #\A)) (deftest funcall.int.1 (foreign-funcall "abs" :int -100 :int) 100) (defun funcall-abs (n) (foreign-funcall "abs" :int n :int)) ;;; regression test: lispworks's %foreign-funcall based on creating ;;; and caching foreign-funcallables at macro-expansion time. (deftest funcall.int.2 (funcall-abs -42) 42) (deftest funcall.long (foreign-funcall "labs" :long -131072 :long) 131072) #-cffi-sys::no-long-long (deftest funcall.long-long (foreign-funcall "my_llabs" :long-long -9223372036854775807 :long-long) 9223372036854775807) (deftest funcall.float (foreign-funcall "my_sqrtf" :float 16.0 :float) 4.0) (deftest funcall.double (foreign-funcall "sqrt" :double 36.0d0 :double) 6.0d0) #+(and scl long-float) (deftest funcall.long-double (foreign-funcall "sqrtl" :long-double 36.0l0 :long-double) 6.0l0) (deftest funcall.string.1 (foreign-funcall "strlen" :string "Hello" :int) 5) (deftest funcall.string.2 (with-foreign-pointer-as-string (s 100) (setf (mem-ref s :char) 0) (foreign-funcall "strcpy" :pointer s :string "Hello" :pointer) (foreign-funcall "strcat" :pointer s :string ", world!" :pointer)) "Hello, world!") (deftest funcall.string.3 (with-foreign-pointer (ptr 100) (lisp-string-to-foreign "Hello, " ptr 8) (foreign-funcall "strcat" :pointer ptr :string "world!" :string)) "Hello, world!") ;;;# Calling Varargs Functions ;; The CHAR argument must be passed as :INT because chars are promoted ;; to ints when passed as variable arguments. (deftest funcall.varargs.char (with-foreign-pointer-as-string (s 100) (setf (mem-ref s :char) 0) (foreign-funcall "sprintf" :pointer s :string "%c" :int 65 :int)) "A") (deftest funcall.varargs.int (with-foreign-pointer-as-string (s 100) (setf (mem-ref s :char) 0) (foreign-funcall "sprintf" :pointer s :string "%d" :int 1000 :int)) "1000") (deftest funcall.varargs.long (with-foreign-pointer-as-string (s 100) (setf (mem-ref s :char) 0) (foreign-funcall "sprintf" :pointer s :string "%ld" :long 131072 :int)) "131072") ;;; There is no FUNCALL.VARARGS.FLOAT as floats are promoted to double ;;; when passed as variable arguments. Currently this fails in SBCL ;;; and CMU CL on Darwin/ppc. (deftest funcall.varargs.double (with-foreign-pointer-as-string (s 100) (setf (mem-ref s :char) 0) (foreign-funcall "sprintf" :pointer s :string "%.2f" :double (coerce pi 'double-float) :int)) "3.14") #+(and scl long-float) (deftest funcall.varargs.long-double (with-foreign-pointer-as-string (s 100) (setf (mem-ref s :char) 0) (foreign-funcall "sprintf" :pointer s :string "%.2Lf" :long-double pi :int)) "3.14") (deftest funcall.varargs.string (with-foreign-pointer-as-string (s 100) (setf (mem-ref s :char) 0) (foreign-funcall "sprintf" :pointer s :string "%s, %s!" :string "Hello" :string "world" :int)) "Hello, world!") ;;; See DEFCFUN.DOUBLE26. (deftest funcall.double26 (foreign-funcall "sum_double26" :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double 3.14d0 :double) 81.64d0) ;;; See DEFCFUN.FLOAT26. (deftest funcall.float26 (foreign-funcall "sum_float26" :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float 5.0 :float) 130.0) ;;; Funcalling a pointer. (deftest funcall.f-s-p.1 (foreign-funcall-pointer (foreign-symbol-pointer "abs") nil :int -42 :int) 42) ;;;# Namespaces #-cffi-sys::flat-namespace (deftest funcall.namespace.1 (values (foreign-funcall ("ns_function" :library libtest) :boolean) (foreign-funcall ("ns_function" :library libtest2) :boolean)) t nil) ;;;# stdcall #+(and x86 windows (not cffi-sys::no-stdcall)) (deftest funcall.stdcall.1 (flet ((fun () (foreign-funcall ("stdcall_fun@12" :cconv :stdcall) :int 1 :int 2 :int 3 :int))) (loop repeat 100 do (fun) finally (return (fun)))) 6) ) ;; #-cffi-sys::no-foreign-funcall
6,692
Common Lisp
.lisp
163
35.619632
78
0.658871
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
d648c5cf46892229425b232294c84a1294dbdc8d3ab81d70b16be7cd074a05ff
21,657
[ -1 ]
21,658
misc.lisp
rheaplex_minara/lib/cffi/tests/misc.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; misc.lisp --- Miscellaneous tests. ;;; ;;; Copyright (C) 2006, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-tests) ;;;# foreign-symbol-pointer tests ;;; This might be useful for some libraries that compare function ;;; pointers. http://thread.gmane.org/gmane.lisp.cffi.devel/694 (defcfun "compare_against_abs" :boolean (p :pointer)) (deftest foreign-symbol-pointer.1 (compare-against-abs (foreign-symbol-pointer "abs")) t) (defcfun "compare_against_xpto_fun" :boolean (p :pointer)) (deftest foreign-symbol-pointer.2 (compare-against-xpto-fun (foreign-symbol-pointer "xpto_fun")) t) ;;;# Library tests ;;; ;;; Need to figure out a way to test this. CLISP, for instance, will ;;; automatically reopen the foreign-library when we call a foreign ;;; function so we can't test CLOSE-FOREIGN-LIBRARY this way. ;;; ;;; IIRC, GCC has some extensions to have code run when a library is ;;; loaded and stuff like that. That could work. #|| #-(and ecl (not dffi)) (deftest library.close.2 (unwind-protect (progn (close-foreign-library 'libtest) (ignore-errors (my-sqrtf 16.0))) (load-test-libraries)) nil) #-(or (and ecl (not dffi)) cffi-sys::flat-namespace cffi-sys::no-foreign-funcall) (deftest library.close.2 (unwind-protect (values (foreign-funcall ("ns_function" :library libtest) :boolean) (close-foreign-library 'libtest) (foreign-funcall "ns_function" :boolean) (close-foreign-library 'libtest2) (close-foreign-library 'libtest2) (ignore-errors (foreign-funcall "ns_function" :boolean))) (load-test-libraries)) t t nil t nil nil) ||# (deftest library.error.1 (handler-case (load-foreign-library "libdoesnotexistimsure") (load-foreign-library-error () 'error)) error) (define-foreign-library pseudo-library (t pseudo-library-spec)) ;;; RT: T clause was being handled as :T by FEATUREP. ;;; ;;; We might want to export (and clean up) the API used in this test ;;; when the need arises. (deftest library.t-clause (eq (cffi::foreign-library-spec (cffi::get-foreign-library 'pseudo-library)) 'pseudo-library-spec) t) ;;;# Shareable Byte Vector Tests #+(or ecl allegro) (mapc (lambda (x) (pushnew x rt::*expected-failures*)) '(shareable-vector.1 shareable-vector.2)) (deftest shareable-vector.1 (let ((vector (cffi-sys::make-shareable-byte-vector 5))) (cffi::with-pointer-to-vector-data (pointer vector) (strcpy pointer "xpto")) vector) #(120 112 116 111 0)) (deftest shareable-vector.2 (block nil (let ((vector (cffi-sys::make-shareable-byte-vector 5))) (cffi::with-pointer-to-vector-data (pointer vector) (strcpy pointer "xpto") (return vector)))) #(120 112 116 111 0))
4,017
Common Lisp
.lisp
102
35.705882
70
0.701975
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
af3e02a0cb63f829be2fa032aefc9553f31bf3dffd03752b706381d37e1ff29e
21,658
[ -1 ]
21,659
union.lisp
rheaplex_minara/lib/cffi/tests/union.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; union.lisp --- Tests on C unions. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-tests) (defcunion uint32-bytes (int-value :unsigned-int) (bytes :unsigned-char :count 4)) (defun int-to-bytes (n) "Convert N to a list of bytes using a union." (with-foreign-object (obj 'uint32-bytes) (setf (foreign-slot-value obj 'uint32-bytes 'int-value) n) (loop for i from 0 below 4 collect (mem-aref (foreign-slot-value obj 'uint32-bytes 'bytes) :unsigned-char i)))) (deftest union.1 (let ((bytes (int-to-bytes #x12345678))) (cond ((equal bytes '(#x12 #x34 #x56 #x78)) t) ((equal bytes '(#x78 #x56 #x34 #x12)) t) (t bytes))) t)
1,947
Common Lisp
.lisp
46
38.5
70
0.686347
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
0b4d0b74e96fa1536c5f3a2fd4c84084549b9813af1452ea88284b3e21212fc1
21,659
[ 188543 ]
21,660
struct.lisp
rheaplex_minara/lib/cffi/tests/struct.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; struct.lisp --- Foreign structure type tests. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; (in-package #:cffi-tests) (defcstruct timeval (tv-secs :long) (tv-usecs :long)) (defparameter *timeval-size* (* 2 (max (foreign-type-size :long) (foreign-type-alignment :long)))) ;;;# Basic Structure Tests (deftest struct.1 (- (foreign-type-size 'timeval) *timeval-size*) 0) (deftest struct.2 (with-foreign-object (tv 'timeval) (setf (foreign-slot-value tv 'timeval 'tv-secs) 0) (setf (foreign-slot-value tv 'timeval 'tv-usecs) 1) (values (foreign-slot-value tv 'timeval 'tv-secs) (foreign-slot-value tv 'timeval 'tv-usecs))) 0 1) (deftest struct.3 (with-foreign-object (tv 'timeval) (with-foreign-slots ((tv-secs tv-usecs) tv timeval) (setf tv-secs 100 tv-usecs 200) (values tv-secs tv-usecs))) 100 200) ;; regression test: accessing a struct through a typedef (defctype xpto timeval) (deftest struct.4 (with-foreign-object (tv 'xpto) (setf (foreign-slot-value tv 'xpto 'tv-usecs) 1) (values (foreign-slot-value tv 'xpto 'tv-usecs) (foreign-slot-value tv 'timeval 'tv-usecs))) 1 1) (deftest struct.names (sort (foreign-slot-names 'xpto) #'< :key (lambda (x) (foreign-slot-offset 'xpto x))) (tv-secs tv-usecs)) ;; regression test: compiler macro not quoting the type in the ;; resulting mem-ref form. The compiler macro on foreign-slot-value ;; is not guaranteed to be expanded though. (defctype my-int :int) (defcstruct s5 (a my-int)) (deftest struct.5 (with-foreign-object (s 's5) (setf (foreign-slot-value s 's5 'a) 42) (foreign-slot-value s 's5 'a)) 42) ;;;# Structs with type translators (defcstruct struct-string (s :string)) (deftest struct.string.1 (with-foreign-object (ptr 'struct-string) (with-foreign-slots ((s) ptr struct-string) (setf s "So long and thanks for all the fish!") s)) "So long and thanks for all the fish!") (deftest struct.string.2 (with-foreign-object (ptr 'struct-string) (setf (foreign-slot-value ptr 'struct-string 's) "Cha") (foreign-slot-value ptr 'struct-string 's)) "Cha") ;;;# Structure Alignment Tests ;;; ;;; See libtest.c and types.lisp for some comments about alignments. (defcstruct s-ch (a-char :char)) (defcstruct s-s-ch (another-char :char) (a-s-ch s-ch)) (defcvar "the_s_s_ch" s-s-ch) (deftest struct.alignment.1 (list 'a-char (foreign-slot-value (foreign-slot-value *the-s-s-ch* 's-s-ch 'a-s-ch) 's-ch 'a-char) 'another-char (foreign-slot-value *the-s-s-ch* 's-s-ch 'another-char)) (a-char 1 another-char 2)) (defcstruct s-short (a-char :char) (another-char :char) (a-short :short)) (defcstruct s-s-short (yet-another-char :char) (a-s-short s-short)) (defcvar "the_s_s_short" s-s-short) (deftest struct.alignment.2 (with-foreign-slots ((yet-another-char a-s-short) *the-s-s-short* s-s-short) (with-foreign-slots ((a-char another-char a-short) a-s-short s-short) (list 'a-char a-char 'another-char another-char 'a-short a-short 'yet-another-char yet-another-char))) (a-char 1 another-char 2 a-short 3 yet-another-char 4)) (defcstruct s-double (a-char :char) (a-double :double) (another-char :char)) (defcstruct s-s-double (yet-another-char :char) (a-s-double s-double) (a-short :short)) (defcvar "the_s_s_double" s-s-double) (deftest struct.alignment.3 (with-foreign-slots ((yet-another-char a-s-double a-short) *the-s-s-double* s-s-double) (with-foreign-slots ((a-char a-double another-char) a-s-double s-double) (list 'a-char a-char 'a-double a-double 'another-char another-char 'yet-another-char yet-another-char 'a-short a-short))) (a-char 1 a-double 2.0d0 another-char 3 yet-another-char 4 a-short 5)) (defcstruct s-s-s-double (another-short :short) (a-s-s-double s-s-double) (last-char :char)) (defcvar "the_s_s_s_double" s-s-s-double) (deftest struct.alignment.4 (with-foreign-slots ((another-short a-s-s-double last-char) *the-s-s-s-double* s-s-s-double) (with-foreign-slots ((yet-another-char a-s-double a-short) a-s-s-double s-s-double) (with-foreign-slots ((a-char a-double another-char) a-s-double s-double) (list 'a-char a-char 'a-double a-double 'another-char another-char 'yet-another-char yet-another-char 'a-short a-short 'another-short another-short 'last-char last-char)))) (a-char 1 a-double 2.0d0 another-char 3 yet-another-char 4 a-short 5 another-short 6 last-char 7)) (defcstruct s-double2 (a-double :double) (a-short :short)) (defcstruct s-s-double2 (a-char :char) (a-s-double2 s-double2) (another-short :short)) (defcvar "the_s_s_double2" s-s-double2) (deftest struct.alignment.5 (with-foreign-slots ((a-char a-s-double2 another-short) *the-s-s-double2* s-s-double2) (with-foreign-slots ((a-double a-short) a-s-double2 s-double2) (list 'a-double a-double 'a-short a-short 'a-char a-char 'another-short another-short))) (a-double 1.0d0 a-short 2 a-char 3 another-short 4)) (defcstruct s-long-long (a-long-long :long-long) (a-short :short)) (defcstruct s-s-long-long (a-char :char) (a-s-long-long s-long-long) (another-short :short)) (defcvar "the_s_s_long_long" s-s-long-long) (deftest struct.alignment.6 (with-foreign-slots ((a-char a-s-long-long another-short) *the-s-s-long-long* s-s-long-long) (with-foreign-slots ((a-long-long a-short) a-s-long-long s-long-long) (list 'a-long-long a-long-long 'a-short a-short 'a-char a-char 'another-short another-short))) (a-long-long 1 a-short 2 a-char 3 another-short 4)) (defcstruct s-s-double3 (a-s-double2 s-double2) (another-short :short)) (defcstruct s-s-s-double3 (a-s-s-double3 s-s-double3) (a-char :char)) (defcvar "the_s_s_s_double3" s-s-s-double3) (deftest struct.alignment.7 (with-foreign-slots ((a-s-s-double3 a-char) *the-s-s-s-double3* s-s-s-double3) (with-foreign-slots ((a-s-double2 another-short) a-s-s-double3 s-s-double3) (with-foreign-slots ((a-double a-short) a-s-double2 s-double2) (list 'a-double a-double 'a-short a-short 'another-short another-short 'a-char a-char)))) (a-double 1.0d0 a-short 2 another-short 3 a-char 4)) (defcstruct empty-struct) (defcstruct with-empty-struct (foo empty-struct) (an-int :int)) ;; commented out this test because an empty struct is not valid/standard C ;; left the struct declarations anyway because they should be handled ;; gracefuly anyway. ; (defcvar "the_with_empty_struct" with-empty-struct) ; ; (deftest struct.alignment.5 ; (with-foreign-slots ((foo an-int) *the-with-empty-struct* with-empty-struct) ; an-int) ; 42) ;; regression test, setf-ing nested foreign-slot-value forms ;; the setf expander used to return a bogus getter (defcstruct s1 (an-int :int)) (defcstruct s2 (an-s1 s1)) (deftest struct.nested-setf (with-foreign-object (an-s2 's2) (setf (foreign-slot-value (foreign-slot-value an-s2 's2 'an-s1) 's1 'an-int) 1984) (foreign-slot-value (foreign-slot-value an-s2 's2 'an-s1) 's1 'an-int)) 1984) ;; regression test, some Lisps were returning 4 instead of 8 for ;; (foreign-type-alignment :unsigned-long-long) on darwin/ppc32 (defcstruct s-unsigned-long-long (an-unsigned-long-long :unsigned-long-long) (a-short :short)) (defcstruct s-s-unsigned-long-long (a-char :char) (a-s-unsigned-long-long s-unsigned-long-long) (another-short :short)) (defcvar "the_s_s_unsigned_long_long" s-s-unsigned-long-long) (deftest struct.alignment.8 (with-foreign-slots ((a-char a-s-unsigned-long-long another-short) *the-s-s-unsigned-long-long* s-s-unsigned-long-long) (with-foreign-slots ((an-unsigned-long-long a-short) a-s-unsigned-long-long s-unsigned-long-long) (list 'an-unsigned-long-long an-unsigned-long-long 'a-short a-short 'a-char a-char 'another-short another-short))) (an-unsigned-long-long 1 a-short 2 a-char 3 another-short 4)) ;;;# C Struct Wrappers (define-c-struct-wrapper timeval ()) (define-c-struct-wrapper (timeval2 timeval) () (tv-secs)) (defmacro with-example-timeval (var &body body) `(with-foreign-object (,var 'timeval) (with-foreign-slots ((tv-secs tv-usecs) ,var timeval) (setf tv-secs 42 tv-usecs 1984) ,@body))) (deftest struct-wrapper.1 (with-example-timeval ptr (let ((obj (make-instance 'timeval :pointer ptr))) (values (timeval-tv-secs obj) (timeval-tv-usecs obj)))) 42 1984) (deftest struct-wrapper.2 (with-example-timeval ptr (let ((obj (make-instance 'timeval2 :pointer ptr))) (timeval2-tv-secs obj))) 42)
10,804
Common Lisp
.lisp
273
34.113553
82
0.643021
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
8da5937ddde8a5a8d3ca7b62735d9acd6bd5f6c66fc020ca232153dfff48d9d4
21,660
[ 50575 ]
21,661
uffi-compat.lisp
rheaplex_minara/lib/cffi/uffi-compat/uffi-compat.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; uffi-compat.lisp --- UFFI compatibility layer for CFFI. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; Copyright (C) 2005-2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;; Code borrowed from UFFI is Copyright (c) Kevin M. Rosenberg. (defpackage #:cffi-uffi-compat (:nicknames #:uffi) ;; is this a good idea? (:use #:cl) (:export ;; immediate types #:def-constant #:def-foreign-type #:def-type #:null-char-p ;; aggregate types #:def-enum #:def-struct #:get-slot-value #:get-slot-pointer #:def-array-pointer #:deref-array #:def-union ;; objects #:allocate-foreign-object #:free-foreign-object #:with-foreign-object #:with-foreign-objects #:size-of-foreign-type #:pointer-address #:deref-pointer #:ensure-char-character #:ensure-char-integer #:ensure-char-storable #:null-pointer-p #:make-null-pointer #:make-pointer #:+null-cstring-pointer+ #:char-array-to-pointer #:with-cast-pointer #:def-foreign-var #:convert-from-foreign-usb8 #:def-pointer-var ;; string functions #:convert-from-cstring #:convert-to-cstring #:free-cstring #:with-cstring #:with-cstrings #:convert-from-foreign-string #:convert-to-foreign-string #:allocate-foreign-string #:with-foreign-string #:with-foreign-strings #:foreign-string-length ; not implemented ;; function call #:def-function ;; libraries #:find-foreign-library #:load-foreign-library #:default-foreign-library-type #:foreign-library-types ;; os #:getenv #:run-shell-command )) (in-package #:cffi-uffi-compat) #+clisp (eval-when (:compile-toplevel :load-toplevel :execute) (when (equal (machine-type) "POWER MACINTOSH") (pushnew :ppc *features*))) (defun convert-uffi-type (uffi-type) "Convert a UFFI primitive type to a CFFI type." ;; Many CFFI types are the same as UFFI. This list handles the ;; exceptions only. (case uffi-type (:cstring :pointer) (:pointer-void :pointer) (:pointer-self :pointer) (:char '(uffi-char :char)) (:unsigned-char '(uffi-char :unsigned-char)) (:byte :char) (:unsigned-byte :unsigned-char) (t (if (listp uffi-type) (case (car uffi-type) ;; this is imho gross but it is what uffi does (quote (convert-uffi-type (second uffi-type))) (* :pointer) (:array `(uffi-array ,(convert-uffi-type (second uffi-type)) ,(third uffi-type))) (:union (second uffi-type)) (:struct (convert-uffi-type (second uffi-type))) (:struct-pointer :pointer)) uffi-type)))) (cffi:define-foreign-type uffi-array-type () ;; ELEMENT-TYPE should be /unparsed/, suitable for passing to mem-aref. ((element-type :initform (error "An element-type is required.") :accessor element-type :initarg :element-type) (nelems :initform (error "nelems is required.") :accessor nelems :initarg :nelems)) (:actual-type :pointer) (:documentation "UFFI's :array type.")) (cffi:define-parse-method uffi-array (element-type count) (make-instance 'uffi-array-type :element-type element-type :nelems (or count 1))) (defmethod cffi:foreign-type-size ((type uffi-array-type)) (* (cffi:foreign-type-size (element-type type)) (nelems type))) (defmethod cffi::aggregatep ((type uffi-array-type)) t) ;; UFFI's :(unsigned-)char (cffi:define-foreign-type uffi-char () ()) (cffi:define-parse-method uffi-char (base-type) (make-instance 'uffi-char :actual-type base-type)) (defmethod cffi:translate-to-foreign ((value character) (type uffi-char)) (char-code value)) (defmethod cffi:translate-from-foreign (obj (type uffi-char)) (code-char obj)) (defmacro def-type (name type) "Define a Common Lisp type NAME for UFFI type TYPE." (declare (ignore type)) `(deftype ,name () t)) (defmacro def-foreign-type (name type) "Define a new foreign type." `(cffi:defctype ,name ,(convert-uffi-type type))) (defmacro def-constant (name value &key export) "Define a constant and conditionally export it." `(eval-when (:compile-toplevel :load-toplevel :execute) (defconstant ,name ,value) ,@(when export `((export ',name))) ',name)) (defmacro null-char-p (val) "Return true if character is null." `(zerop (char-code ,val))) (defmacro def-enum (enum-name args &key (separator-string "#")) "Creates a constants for a C type enum list, symbols are created in the created in the current package. The symbol is the concatenation of the enum-name name, separator-string, and field-name" (let ((counter 0) (cmds nil) (constants nil)) (declare (fixnum counter)) (dolist (arg args) (let ((name (if (listp arg) (car arg) arg)) (value (if (listp arg) (prog1 (setq counter (cadr arg)) (incf counter)) (prog1 counter (incf counter))))) (setq name (intern (concatenate 'string (symbol-name enum-name) separator-string (symbol-name name)))) (push `(def-constant ,name ,value) constants))) (setf cmds (append '(progn) `((cffi:defctype ,enum-name :int)) (nreverse constants))) cmds)) (defmacro def-struct (name &body fields) "Define a C structure." `(cffi:defcstruct ,name ,@(loop for (name uffi-type) in fields for cffi-type = (convert-uffi-type uffi-type) collect (list name cffi-type)))) ;; TODO: figure out why the compiler macro is kicking in before ;; the setf expander. (defun %foreign-slot-value (obj type field) (cffi:foreign-slot-value obj type field)) (defun (setf %foreign-slot-value) (value obj type field) (setf (cffi:foreign-slot-value obj type field) value)) (defmacro get-slot-value (obj type field) "Access a slot value from a structure." `(%foreign-slot-value ,obj ,type ,field)) ;; UFFI uses a different function when accessing a slot whose ;; type is a pointer. We don't need that in CFFI so we use ;; foreign-slot-value too. (defmacro get-slot-pointer (obj type field) "Access a pointer slot value from a structure." `(cffi:foreign-slot-value ,obj ,type ,field)) (defmacro def-array-pointer (name type) "Define a foreign array type." `(cffi:defctype ,name (uffi-array ,(convert-uffi-type type) 1))) (defmacro deref-array (array type position) "Dereference an array." `(cffi:mem-aref ,array ,(if (constantp type) `',(element-type (cffi::parse-type (convert-uffi-type (eval type)))) `(element-type (cffi::parse-type (convert-uffi-type ,type)))) ,position)) ;; UFFI's documentation on DEF-UNION is a bit scarce, I'm not sure ;; if DEFCUNION and DEF-UNION are strictly compatible. (defmacro def-union (name &body fields) "Define a foreign union type." `(cffi:defcunion ,name ,@(loop for (name uffi-type) in fields for cffi-type = (convert-uffi-type uffi-type) collect (list name cffi-type)))) (defmacro allocate-foreign-object (type &optional (size 1)) "Allocate one or more instance of a foreign type." `(cffi:foreign-alloc ,(if (constantp type) `',(convert-uffi-type (eval type)) `(convert-uffi-type ,type)) :count ,size)) (defmacro free-foreign-object (ptr) "Free a foreign object allocated by ALLOCATE-FOREIGN-OBJECT." `(cffi:foreign-free ,ptr)) (defmacro with-foreign-object ((var type) &body body) "Wrap the allocation of a foreign object around BODY." `(cffi:with-foreign-object (,var (convert-uffi-type ,type)) ,@body)) ;; Taken from UFFI's src/objects.lisp (defmacro with-foreign-objects (bindings &rest body) (if bindings `(with-foreign-object ,(car bindings) (with-foreign-objects ,(cdr bindings) ,@body)) `(progn ,@body))) (defmacro size-of-foreign-type (type) "Return the size in bytes of a foreign type." `(cffi:foreign-type-size (convert-uffi-type ,type))) (defmacro pointer-address (ptr) "Return the address of a pointer." `(cffi:pointer-address ,ptr)) (defmacro deref-pointer (ptr type) "Dereference a pointer." `(cffi:mem-ref ,ptr (convert-uffi-type ,type))) (defsetf deref-pointer (ptr type) (value) `(setf (cffi:mem-ref ,ptr (convert-uffi-type ,type)) ,value)) (defmacro ensure-char-character (obj &environment env) "Convert OBJ to a character if it is an integer." (if (constantp obj env) (if (characterp obj) obj (code-char obj)) (let ((obj-var (gensym))) `(let ((,obj-var ,obj)) (if (characterp ,obj-var) ,obj-var (code-char ,obj-var)))))) (defmacro ensure-char-integer (obj &environment env) "Convert OBJ to an integer if it is a character." (if (constantp obj env) (let ((the-obj (eval obj))) (if (characterp the-obj) (char-code the-obj) the-obj)) (let ((obj-var (gensym))) `(let ((,obj-var ,obj)) (if (characterp ,obj-var) (char-code ,obj-var) ,obj-var))))) (defmacro ensure-char-storable (obj) "Ensure OBJ is storable as a character." `(ensure-char-integer ,obj)) (defmacro make-null-pointer (type) "Create a NULL pointer." (declare (ignore type)) `(cffi:null-pointer)) (defmacro make-pointer (address type) "Create a pointer to ADDRESS." (declare (ignore type)) `(cffi:make-pointer ,address)) (defmacro null-pointer-p (ptr) "Return true if PTR is a null pointer." `(cffi:null-pointer-p ,ptr)) (defparameter +null-cstring-pointer+ (cffi:null-pointer) "A constant NULL string pointer.") (defmacro char-array-to-pointer (obj) obj) (defmacro with-cast-pointer ((var ptr type) &body body) "Cast a pointer, does nothing in CFFI." (declare (ignore type)) `(let ((,var ,ptr)) ,@body)) (defmacro def-foreign-var (name type module) "Define a symbol macro to access a foreign variable." (declare (ignore module)) (flet ((lisp-name (name) (intern (cffi-sys:canonicalize-symbol-name-case (substitute #\- #\_ name))))) `(cffi:defcvar ,(if (listp name) name (list name (lisp-name name))) ,(convert-uffi-type type)))) (defmacro def-pointer-var (name value &optional doc) #-openmcl `(defvar ,name ,value ,@(if doc (list doc))) #+openmcl `(ccl::defloadvar ,name ,value ,doc)) (defmacro convert-from-cstring (s) "Convert a cstring to a Lisp string." (let ((ret (gensym))) `(let ((,ret (cffi:foreign-string-to-lisp ,s))) (if (equal ,ret "") nil ,ret)))) (defmacro convert-to-cstring (obj) "Convert a Lisp string to a cstring." (let ((str (gensym))) `(let ((,str ,obj)) (if (null ,str) (cffi:null-pointer) (cffi:foreign-string-alloc ,str))))) (defmacro free-cstring (ptr) "Free a cstring." `(cffi:foreign-string-free ,ptr)) (defmacro with-cstring ((foreign-string lisp-string) &body body) "Binds a newly creating string." (let ((str (gensym)) (body-proc (gensym))) `(flet ((,body-proc (,foreign-string) ,@body)) (let ((,str ,lisp-string)) (if (null ,str) (,body-proc (cffi:null-pointer)) (cffi:with-foreign-string (,foreign-string ,str) (,body-proc ,foreign-string))))))) ;; Taken from UFFI's src/strings.lisp (defmacro with-cstrings (bindings &rest body) (if bindings `(with-cstring ,(car bindings) (with-cstrings ,(cdr bindings) ,@body)) `(progn ,@body))) (defmacro def-function (name args &key module (returning :void)) "Define a foreign function." (declare (ignore module)) `(cffi:defcfun ,name ,(convert-uffi-type returning) ,@(loop for (name type) in args collect `(,name ,(convert-uffi-type type))))) ;;; Taken from UFFI's src/libraries.lisp (defvar *loaded-libraries* nil "List of foreign libraries loaded. Used to prevent reloading a library") (defun default-foreign-library-type () "Returns string naming default library type for platform" #+(or win32 cygwin mswindows) "dll" #+(or macos macosx darwin ccl-5.0) "dylib" #-(or win32 cygwin mswindows macos macosx darwin ccl-5.0) "so") (defun foreign-library-types () "Returns list of string naming possible library types for platform, sorted by preference" #+(or win32 cygwin mswindows) '("dll" "lib" "so") #+(or macos macosx darwin ccl-5.0) '("dylib" "bundle") #-(or win32 cygwin mswindows macos macosx darwin ccl-5.0) '("so" "a" "o")) (defun find-foreign-library (names directories &key types drive-letters) "Looks for a foreign library. directories can be a single string or a list of strings of candidate directories. Use default library type if type is not specified." (unless types (setq types (foreign-library-types))) (unless (listp types) (setq types (list types))) (unless (listp names) (setq names (list names))) (unless (listp directories) (setq directories (list directories))) #+(or win32 mswindows) (unless (listp drive-letters) (setq drive-letters (list drive-letters))) #-(or win32 mswindows) (setq drive-letters '(nil)) (dolist (drive-letter drive-letters) (dolist (name names) (dolist (dir directories) (dolist (type types) (let ((path (make-pathname #+lispworks :host #+lispworks (when drive-letter drive-letter) #-lispworks :device #-lispworks (when drive-letter drive-letter) :name name :type type :directory (etypecase dir (pathname (pathname-directory dir)) (list dir) (string (pathname-directory (parse-namestring dir))))))) (when (probe-file path) (return-from find-foreign-library path))))))) nil) (defun convert-supporting-libraries-to-string (libs) (let (lib-load-list) (dolist (lib libs) (push (format nil "-l~A" lib) lib-load-list)) (nreverse lib-load-list))) (defun load-foreign-library (filename &key module supporting-libraries force-load) #+(or allegro mcl sbcl clisp) (declare (ignore module supporting-libraries)) #+(or cmu scl sbcl) (declare (ignore module)) (when (and filename (or (null (pathname-directory filename)) (probe-file filename))) (if (pathnamep filename) ;; ensure filename is a string to check if (setq filename (namestring filename))) ; already loaded (if (and (not force-load) (find filename *loaded-libraries* :test #'string-equal)) t ;; return T, but don't reload library (progn ;; FIXME: Hmm, what are these two for? #+cmu (let ((type (pathname-type (parse-namestring filename)))) (if (string-equal type "so") (sys::load-object-file filename) (alien:load-foreign filename :libraries (convert-supporting-libraries-to-string supporting-libraries)))) #+scl (let ((type (pathname-type (parse-namestring filename)))) (if (string-equal type "so") (sys::load-dynamic-object filename) (alien:load-foreign filename :libraries (convert-supporting-libraries-to-string supporting-libraries)))) #-(or cmu scl) (cffi:load-foreign-library filename) (push filename *loaded-libraries*) t)))) ;; Taken from UFFI's src/os.lisp (defun getenv (var) "Return the value of the environment variable." #+allegro (sys::getenv (string var)) #+clisp (sys::getenv (string var)) #+(or cmu scl) (cdr (assoc (string var) ext:*environment-list* :test #'equalp :key #'string)) #+gcl (si:getenv (string var)) #+lispworks (lw:environment-variable (string var)) #+lucid (lcl:environment-variable (string var)) #+(or mcl ccl) (ccl::getenv var) #+sbcl (sb-ext:posix-getenv var) #-(or allegro clisp cmu scl gcl lispworks lucid mcl ccl sbcl) (error 'not-implemented :proc (list 'getenv var))) ;; Taken from UFFI's src/os.lisp ;; modified from function ASDF -- Copyright Dan Barlow and Contributors (defun run-shell-command (control-string &rest args &key output) "Interpolate ARGS into CONTROL-STRING as if by FORMAT, and synchronously execute the result using a Bourne-compatible shell, with output to *trace-output*. Returns the shell's exit code." (unless output (setq output *trace-output*)) (let ((command (apply #'format nil control-string args))) #+sbcl (sb-impl::process-exit-code (sb-ext:run-program "/bin/sh" (list "-c" command) :input nil :output output)) #+(or cmu scl) (ext:process-exit-code (ext:run-program "/bin/sh" (list "-c" command) :input nil :output output)) #+allegro (excl:run-shell-command command :input nil :output output) #+lispworks (system:call-system-showing-output command :shell-type "/bin/sh" :output-stream output) #+clisp ;XXX not exactly *trace-output*, I know (ext:run-shell-command command :output :terminal :wait t) #+openmcl (nth-value 1 (ccl:external-process-status (ccl:run-program "/bin/sh" (list "-c" command) :input nil :output output :wait t))) #-(or openmcl clisp lispworks allegro scl cmu sbcl) (error "RUN-SHELL-PROGRAM not implemented for this Lisp") )) ;;; Some undocumented UFFI operators... (defmacro convert-from-foreign-string (obj &key length (locale :default) (null-terminated-p t)) ;; in effect, (eq NULL-TERMINATED-P (null LENGTH)). Hopefully, ;; that's compatible with the intended semantics, which are ;; undocumented. If that's not the case, we can implement ;; NULL-TERMINATED-P in CFFI:FOREIGN-STRING-TO-LISP. (declare (ignore locale null-terminated-p)) (let ((ret (gensym))) `(let ((,ret (cffi:foreign-string-to-lisp ,obj :count ,length))) (if (equal ,ret "") nil ,ret)))) ;; What's the difference between this and convert-to-cstring? (defmacro convert-to-foreign-string (obj) (let ((str (gensym))) `(let ((,str ,obj)) (if (null ,str) (cffi:null-pointer) (cffi:foreign-string-alloc ,str))))) (defmacro allocate-foreign-string (size &key unsigned) (declare (ignore unsigned)) `(cffi:foreign-alloc :char :count ,size)) ;; Ditto. (defmacro with-foreign-string ((foreign-string lisp-string) &body body) (let ((str (gensym))) `(let ((,str ,lisp-string)) (if (null ,str) (let ((,foreign-string (cffi:null-pointer))) ,@body) (cffi:with-foreign-string (,foreign-string ,str) ,@body))))) (defmacro with-foreign-strings (bindings &body body) `(with-foreign-string ,(car bindings) ,@(if (cdr bindings) `((with-foreign-strings ,(cdr bindings) ,@body)) body))) ;; This function returns a form? Where is this used in user-code? (defun foreign-string-length (foreign-string) (declare (ignore foreign-string)) (error "FOREIGN-STRING-LENGTH not implemented.")) ;; This should be optimized. (defun convert-from-foreign-usb8 (s len) (let ((a (make-array len :element-type '(unsigned-byte 8)))) (dotimes (i len a) (setf (aref a i) (cffi:mem-ref s :unsigned-char i)))))
21,319
Common Lisp
.lisp
540
32.892593
79
0.638446
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
a5c2d9070b61a84a3229a6f0955d8184258855af4631f99de8cda41c2492427d
21,661
[ 6988 ]
21,662
collecting.lisp
rheaplex_minara/lib/cl-utilities/collecting.lisp
;; Opinions differ on how a collection macro should work. There are ;; two major points for discussion: multiple collection variables and ;; implementation method. ;; ;; There are two main ways of implementing collection: sticking ;; successive elements onto the end of the list with tail-collection, ;; and using the PUSH/NREVERSE idiom. Tail-collection is usually ;; faster, except on CLISP, where PUSH/NREVERSE is a little faster. ;; ;; The COLLECTING macro only allows collection into one list, and you ;; can't nest them to get the same effect as multiple collection since ;; it always uses the COLLECT function. If you want to collect into ;; multiple lists, use the WITH-COLLECT macro. (in-package :cl-utilities) ;; This should only be called inside of COLLECTING macros, but we ;; define it here to provide an informative error message and to make ;; it easier for SLIME (et al.) to get documentation for the COLLECT ;; function when it's used in the COLLECTING macro. (defun collect (thing) "Collect THING in the context established by the COLLECTING macro" (error "Can't collect ~S outside the context of the COLLECTING macro" thing)) (defmacro collecting (&body body) "Collect things into a list forwards. Within the body of this macro, the COLLECT function will collect its argument into the list returned by COLLECTING." (with-unique-names (collector tail) `(let (,collector ,tail) (labels ((collect (thing) (if ,collector (setf (cdr ,tail) (setf ,tail (list thing))) (setf ,collector (setf ,tail (list thing)))))) ,@body) ,collector))) (defmacro with-collectors ((&rest collectors) &body body) "Collect some things into lists forwards. The names in COLLECTORS are defined as local functions which each collect into a separate list. Returns as many values as there are collectors, in the order they were given." (%with-collectors-check-collectors collectors) (let ((gensyms-alist (%with-collectors-gensyms-alist collectors))) `(let ,(loop for collector in collectors for tail = (cdr (assoc collector gensyms-alist)) nconc (list collector tail)) (labels ,(loop for collector in collectors for tail = (cdr (assoc collector gensyms-alist)) collect `(,collector (thing) (if ,collector (setf (cdr ,tail) (setf ,tail (list thing))) (setf ,collector (setf ,tail (list thing)))))) ,@body) (values ,@collectors)))) (defun %with-collectors-check-collectors (collectors) "Check that all of the COLLECTORS are symbols. If not, raise an error." (let ((bad-collector (find-if-not #'symbolp collectors))) (when bad-collector (error 'type-error :datum bad-collector :expected-type 'symbol)))) (defun %with-collectors-gensyms-alist (collectors) "Return an alist mapping the symbols in COLLECTORS to gensyms" (mapcar #'cons collectors (mapcar (compose #'gensym #'(lambda (x) (format nil "~A-TAIL-" x))) collectors))) ;; Some test code which would be too hard to move to the test suite. #+nil (with-collectors (one-through-nine abc) (mapcar #'abc '(a b c)) (dotimes (x 10) (one-through-nine x) (print one-through-nine)) (terpri) (terpri))
3,237
Common Lisp
.lisp
77
38.402597
73
0.721306
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
95ca2860dc1179a8e23a829712305ac908e8ff1fef9d6949029e887779f34de6
21,662
[ 421750 ]
21,663
rotate-byte.lisp
rheaplex_minara/lib/cl-utilities/rotate-byte.lisp
(in-package :cl-utilities) (defun rotate-byte (count bytespec integer) "Rotates a field of bits within INTEGER; specifically, returns an integer that contains the bits of INTEGER rotated COUNT times leftwards within the byte specified by BYTESPEC, and elsewhere contains the bits of INTEGER. See http://www.cliki.net/ROTATE-BYTE" (declare (optimize (speed 3) (safety 0) (space 0) (debug 1))) #-sbcl (let ((size (byte-size bytespec))) (when (= size 0) (return-from rotate-byte integer)) (let ((count (mod count size))) (labels ((rotate-byte-from-0 (count size integer) (let ((bytespec (byte size 0))) (if (> count 0) (logior (ldb bytespec (ash integer count)) (ldb bytespec (ash integer (- count size)))) (logior (ldb bytespec (ash integer count)) (ldb bytespec (ash integer (+ count size)))))))) (dpb (rotate-byte-from-0 count size (ldb bytespec integer)) bytespec integer)))) ;; On SBCL, we use the SB-ROTATE-BYTE extension. #+sbcl-uses-sb-rotate-byte (sb-rotate-byte:rotate-byte count bytespec integer)) ;; If we're using the SB-ROTATE-BYTE extension, we should inline our ;; call and let SBCL handle optimization from there. #+sbcl-uses-sb-rotate-byte (declaim (inline rotate-byte))
1,397
Common Lisp
.lisp
27
42.925926
81
0.6355
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
53c3ce2bb65883ada083faf75f4052948a32672332ff464d5f1eb809877a3b3d
21,663
[ 349223 ]
21,664
package.lisp
rheaplex_minara/lib/cl-utilities/package.lisp
(defpackage :cl-utilities (:use :common-lisp) (:export #:split-sequence #:split-sequence-if #:split-sequence-if-not #:partition #:partition-if #:partition-if-not #:extremum #:no-extremum #:extremum-fastkey #:extrema #:n-most-extreme #:n-most-extreme-not-enough-elements #:n-most-extreme-not-enough-elements-n #:n-most-extreme-not-enough-elements-subsequence #:read-delimited #:read-delimited-bounds-error #:read-delimited-bounds-error-start #:read-delimited-bounds-error-end #:read-delimited-bounds-error-sequence #:expt-mod #:collecting #:collect #:with-collectors #:with-unique-names #:with-gensyms #:list-binding-not-supported #:list-binding-not-supported-binding #:once-only #:rotate-byte #:copy-array #:compose)) #+split-sequence-deprecated (defpackage :split-sequence (:documentation "This package mimics SPLIT-SEQUENCE for compatibility with packages that expect that system.") (:use :cl-utilities) (:export #:split-sequence #:split-sequence-if #:split-sequence-if-not))
1,146
Common Lisp
.lisp
39
24.076923
76
0.70159
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
d78ff7953986cf496e07dc640041c132bf79dfa1b757b02b9e01279bac042eb0
21,664
[ 332134 ]
21,665
split-sequence.lisp
rheaplex_minara/lib/cl-utilities/split-sequence.lisp
;;;; SPLIT-SEQUENCE ;;; ;;; This code was based on Arthur Lemmens' in ;;; <URL:http://groups.google.com/groups?as_umsgid=39F36F1A.B8F19D20%40simplex.nl>; ;;; ;;; changes include: ;;; ;;; * altering the behaviour of the :from-end keyword argument to ;;; return the subsequences in original order, for consistency with ;;; CL:REMOVE, CL:SUBSTITUTE et al. (:from-end being non-NIL only ;;; affects the answer if :count is less than the number of ;;; subsequences, by analogy with the above-referenced functions). ;;; ;;; * changing the :maximum keyword argument to :count, by analogy ;;; with CL:REMOVE, CL:SUBSTITUTE, and so on. ;;; ;;; * naming the function SPLIT-SEQUENCE rather than PARTITION rather ;;; than SPLIT. ;;; ;;; * adding SPLIT-SEQUENCE-IF and SPLIT-SEQUENCE-IF-NOT. ;;; ;;; * The second return value is now an index rather than a copy of a ;;; portion of the sequence; this index is the `right' one to feed to ;;; CL:SUBSEQ for continued processing. ;;; There's a certain amount of code duplication here, which is kept ;;; to illustrate the relationship between the SPLIT-SEQUENCE ;;; functions and the CL:POSITION functions. ;;; Examples: ;;; ;;; * (split-sequence #\; "a;;b;c") ;;; -> ("a" "" "b" "c"), 6 ;;; ;;; * (split-sequence #\; "a;;b;c" :from-end t) ;;; -> ("a" "" "b" "c"), 0 ;;; ;;; * (split-sequence #\; "a;;b;c" :from-end t :count 1) ;;; -> ("c"), 4 ;;; ;;; * (split-sequence #\; "a;;b;c" :remove-empty-subseqs t) ;;; -> ("a" "b" "c"), 6 ;;; ;;; * (split-sequence-if (lambda (x) (member x '(#\a #\b))) "abracadabra") ;;; -> ("" "" "r" "c" "d" "" "r" ""), 11 ;;; ;;; * (split-sequence-if-not (lambda (x) (member x '(#\a #\b))) "abracadabra") ;;; -> ("ab" "a" "a" "ab" "a"), 11 ;;; ;;; * (split-sequence #\; ";oo;bar;ba;" :start 1 :end 9) ;;; -> ("oo" "bar" "b"), 9 ;; cl-utilities note: the license of this file is unclear, and I don't ;; even know whom to contact to clarify it. If anybody objects to my ;; assumption that it is public domain, please contact me so I can do ;; something about it. Previously I required the split-sequence ; package as a dependency, but that was so unwieldy that it was *the* ;; sore spot sticking out in the design of cl-utilities. -Peter Scott (in-package :cl-utilities) (defun split-sequence (delimiter seq &key (count nil) (remove-empty-subseqs nil) (from-end nil) (start 0) (end nil) (test nil test-supplied) (test-not nil test-not-supplied) (key nil key-supplied)) "Return a list of subsequences in seq delimited by delimiter. If :remove-empty-subseqs is NIL, empty subsequences will be included in the result; otherwise they will be discarded. All other keywords work analogously to those for CL:SUBSTITUTE. In particular, the behaviour of :from-end is possibly different from other versions of this function; :from-end values of NIL and T are equivalent unless :count is supplied. The second return value is an index suitable as an argument to CL:SUBSEQ into the sequence indicating where processing stopped." (let ((len (length seq)) (other-keys (nconc (when test-supplied (list :test test)) (when test-not-supplied (list :test-not test-not)) (when key-supplied (list :key key))))) (unless end (setq end len)) (if from-end (loop for right = end then left for left = (max (or (apply #'position delimiter seq :end right :from-end t other-keys) -1) (1- start)) unless (and (= right (1+ left)) remove-empty-subseqs) ; empty subseq we don't want if (and count (>= nr-elts count)) ;; We can't take any more. Return now. return (values (nreverse subseqs) right) else collect (subseq seq (1+ left) right) into subseqs and sum 1 into nr-elts until (< left start) finally (return (values (nreverse subseqs) (1+ left)))) (loop for left = start then (+ right 1) for right = (min (or (apply #'position delimiter seq :start left other-keys) len) end) unless (and (= right left) remove-empty-subseqs) ; empty subseq we don't want if (and count (>= nr-elts count)) ;; We can't take any more. Return now. return (values subseqs left) else collect (subseq seq left right) into subseqs and sum 1 into nr-elts until (>= right end) finally (return (values subseqs right)))))) (defun split-sequence-if (predicate seq &key (count nil) (remove-empty-subseqs nil) (from-end nil) (start 0) (end nil) (key nil key-supplied)) "Return a list of subsequences in seq delimited by items satisfying predicate. If :remove-empty-subseqs is NIL, empty subsequences will be included in the result; otherwise they will be discarded. All other keywords work analogously to those for CL:SUBSTITUTE-IF. In particular, the behaviour of :from-end is possibly different from other versions of this function; :from-end values of NIL and T are equivalent unless :count is supplied. The second return value is an index suitable as an argument to CL:SUBSEQ into the sequence indicating where processing stopped." (let ((len (length seq)) (other-keys (when key-supplied (list :key key)))) (unless end (setq end len)) (if from-end (loop for right = end then left for left = (max (or (apply #'position-if predicate seq :end right :from-end t other-keys) -1) (1- start)) unless (and (= right (1+ left)) remove-empty-subseqs) ; empty subseq we don't want if (and count (>= nr-elts count)) ;; We can't take any more. Return now. return (values (nreverse subseqs) right) else collect (subseq seq (1+ left) right) into subseqs and sum 1 into nr-elts until (< left start) finally (return (values (nreverse subseqs) (1+ left)))) (loop for left = start then (+ right 1) for right = (min (or (apply #'position-if predicate seq :start left other-keys) len) end) unless (and (= right left) remove-empty-subseqs) ; empty subseq we don't want if (and count (>= nr-elts count)) ;; We can't take any more. Return now. return (values subseqs left) else collect (subseq seq left right) into subseqs and sum 1 into nr-elts until (>= right end) finally (return (values subseqs right)))))) (defun split-sequence-if-not (predicate seq &key (count nil) (remove-empty-subseqs nil) (from-end nil) (start 0) (end nil) (key nil key-supplied)) "Return a list of subsequences in seq delimited by items satisfying (CL:COMPLEMENT predicate). If :remove-empty-subseqs is NIL, empty subsequences will be included in the result; otherwise they will be discarded. All other keywords work analogously to those for CL:SUBSTITUTE-IF-NOT. In particular, the behaviour of :from-end is possibly different from other versions of this function; :from-end values of NIL and T are equivalent unless :count is supplied. The second return value is an index suitable as an argument to CL:SUBSEQ into the sequence indicating where processing stopped." ; Emacs syntax highlighting is broken, and this helps: " (let ((len (length seq)) (other-keys (when key-supplied (list :key key)))) (unless end (setq end len)) (if from-end (loop for right = end then left for left = (max (or (apply #'position-if-not predicate seq :end right :from-end t other-keys) -1) (1- start)) unless (and (= right (1+ left)) remove-empty-subseqs) ; empty subseq we don't want if (and count (>= nr-elts count)) ;; We can't take any more. Return now. return (values (nreverse subseqs) right) else collect (subseq seq (1+ left) right) into subseqs and sum 1 into nr-elts until (< left start) finally (return (values (nreverse subseqs) (1+ left)))) (loop for left = start then (+ right 1) for right = (min (or (apply #'position-if-not predicate seq :start left other-keys) len) end) unless (and (= right left) remove-empty-subseqs) ; empty subseq we don't want if (and count (>= nr-elts count)) ;; We can't take any more. Return now. return (values subseqs left) else collect (subseq seq left right) into subseqs and sum 1 into nr-elts until (>= right end) finally (return (values subseqs right)))))) ;;; clean deprecation (defun partition (&rest args) (apply #'split-sequence args)) (defun partition-if (&rest args) (apply #'split-sequence-if args)) (defun partition-if-not (&rest args) (apply #'split-sequence-if-not args)) (define-compiler-macro partition (&whole form &rest args) (declare (ignore args)) (warn "PARTITION is deprecated; use SPLIT-SEQUENCE instead.") form) (define-compiler-macro partition-if (&whole form &rest args) (declare (ignore args)) (warn "PARTITION-IF is deprecated; use SPLIT-SEQUENCE-IF instead.") form) (define-compiler-macro partition-if-not (&whole form &rest args) (declare (ignore args)) (warn "PARTITION-IF-NOT is deprecated; use SPLIT-SEQUENCE-IF-NOT instead") form) (pushnew :split-sequence *features*)
9,903
Common Lisp
.lisp
226
36.561947
197
0.624288
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
faf2df7cfac8bb514d9625c6e771a54bf21f5a7397ac0bc0b0cc2ad168cef805
21,665
[ 144180 ]
21,666
once-only.lisp
rheaplex_minara/lib/cl-utilities/once-only.lisp
;; The ONCE-ONLY macro is hard to explain, hard to understand, hard to ;; write, hard to modify, and hard to live without once you figure out ;; how to use it. It's used in macros to guard against multiple ;; evaluation of arguments. My version is longer than most, but it ;; does some error checking and it gives gensym'd variables more ;; meaningful names than usual. (in-package :cl-utilities) (defun %check-once-only-names (names) "Check that all of the NAMES are symbols. If not, raise an error." ;; This only raises an error for the first non-symbol argument ;; found. While this won't report multiple errors, it is probably ;; more convenient to only report one. (let ((bad-name (find-if-not #'symbolp names))) (when bad-name (error "ONCE-ONLY expected a symbol but got ~S" bad-name)))) (defmacro once-only (names &body body) ;; Check the NAMES list for validity. (%check-once-only-names names) ;; Do not touch this code unless you really know what you're doing. (let ((gensyms (loop for name in names collect (gensym (string name))))) `(let (,@(loop for g in gensyms for name in names collect `(,g (gensym ,(string name))))) `(let (,,@(loop for g in gensyms for n in names collect ``(,,g ,,n))) ,(let (,@(loop for n in names for g in gensyms collect `(,n ,g))) ,@body)))))
1,431
Common Lisp
.lisp
28
44.75
74
0.650964
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
fc870eec3751a12f7d080a8ea9d1157c71acdaf4bfbe98b085bb23604c7666b5
21,666
[ 478541 ]
21,667
extremum.lisp
rheaplex_minara/lib/cl-utilities/extremum.lisp
(in-package :cl-utilities) (define-condition no-extremum (error) () (:report "Cannot find extremum of empty sequence") (:documentation "Raised when EXTREMUM is called on an empty sequence, since there is no morally smallest element")) (defun comparator (test &optional (key #'identity)) "Comparison operator: auxilliary function used by EXTREMUM" (declare (optimize (speed 3) (safety 0) (space 0) (debug 1))) (lambda (a b) (if (funcall test (funcall key a) (funcall key b)) a b))) ;; This optimizes the case where KEY is #'identity (define-compiler-macro comparator (&whole whole test &optional (key #'identity)) (if (eql key #'identity) `(lambda (a b) (declare (optimize (speed 3) (safety 0) (space 0) (debug 1))) (if (funcall ,test a b) a b)) whole)) ;; The normal way of testing the if length of a proper sequence equals ;; zero is to just use (zerop (length sequence)). And, while some ;; implementations may optimize this, it's probably a good idea to ;; just write an optimized version and use it. This method can speed ;; up list length testing. (defun zero-length-p (sequence) "Is the length of SEQUENCE equal to zero?" (declare (optimize (speed 3) (safety 0) (space 0) (debug 1))) (or (null sequence) (when (vectorp sequence) (zerop (length sequence))))) (declaim (inline zero-length-p)) ;; Checks the length of the subsequence of SEQUENCE specified by START ;; and END, and if it's 0 then a NO-EXTREMUM error is signalled. This ;; should only be used in EXTREMUM functions. (defmacro with-check-length ((sequence start end) &body body) (once-only (sequence start end) `(if (or (zero-length-p ,sequence) (>= ,start (or ,end (length ,sequence)))) (restart-case (error 'no-extremum) (continue () :report "Return NIL instead" nil)) (progn ,@body)))) ;; This is an extended version which takes START and END keyword ;; arguments. Any spec-compliant use of EXTREMUM will also work with ;; this extended version. (defun extremum (sequence predicate &key (key #'identity) (start 0) end) "Returns the element of SEQUENCE that would appear first if the sequence were ordered according to SORT using PREDICATE and KEY using an unstable sorting algorithm. See http://www.cliki.net/EXTREMUM for the full specification." (with-check-length (sequence start end) (reduce (comparator predicate key) sequence :start start :end end))) ;; This optimizes the case where KEY is #'identity (define-compiler-macro extremum (&whole whole sequence predicate &key (key #'identity) (start 0) end) (if (eql key #'identity) (once-only (sequence predicate start end) `(with-check-length (,sequence ,start ,end) (locally (declare (optimize (speed 3) (safety 0) (space 0) (debug 1))) (reduce (comparator ,predicate) ,sequence :start ,start :end ,end)))) whole)) ;; This is an "optimized" version which calls KEY less. REDUCE is ;; already so optimized that this will actually be slower unless KEY ;; is expensive. And on CLISP, of course, the regular version will be ;; much faster since built-in functions are ridiculously faster than ;; ones implemented in Lisp. Be warned, this isn't as carefully tested ;; as regular EXTREMUM and there's more that could go wrong. (defun extremum-fastkey (sequence predicate &key (key #'identity) (start 0) end) "EXTREMUM implemented so that it calls KEY less. This is only faster if the KEY function is so slow that calling it less often would be a significant improvement; ordinarily it's slower." (declare (optimize (speed 3) (safety 0) (space 0) (debug 1))) (with-check-length (sequence start end) (let* ((smallest (elt sequence 0)) (smallest-key (funcall key smallest)) (current-index 0) (real-end (or end (1- most-positive-fixnum)))) (declare (type (integer 0) current-index real-end start) (fixnum current-index real-end start)) (map nil #'(lambda (x) (when (<= start current-index real-end) (let ((x-key (funcall key x))) (when (funcall predicate x-key smallest-key) (setf smallest x) (setf smallest-key x-key)))) (incf current-index)) sequence) smallest))) ;; EXTREMA and N-MOST-EXTREME are based on code and ideas from Tobias ;; C. Rittweiler. They deal with the cases in which you are not ;; looking for a single extreme element, but for the extreme identical ;; elements or the N most extreme elements. (defun extrema (sequence predicate &key (key #'identity) (start 0) end) (with-check-length (sequence start end) (let* ((sequence (subseq sequence start end)) (smallest-elements (list (elt sequence 0))) (smallest-key (funcall key (elt smallest-elements 0)))) (map nil #'(lambda (x) (let ((x-key (funcall key x))) (cond ((funcall predicate x-key smallest-key) (setq smallest-elements (list x)) (setq smallest-key x-key)) ;; both elements are considered equal if the predicate ;; returns false for (PRED A B) and (PRED B A) ((not (funcall predicate smallest-key x-key)) (push x smallest-elements))))) (subseq sequence 1)) ;; We use NREVERSE to make this stable (in the sorting algorithm ;; sense of the word 'stable'). (nreverse smallest-elements)))) (define-condition n-most-extreme-not-enough-elements (warning) ((n :initarg :n :reader n-most-extreme-not-enough-elements-n :documentation "The number of elements that need to be returned") (subsequence :initarg :subsequence :reader n-most-extreme-not-enough-elements-subsequence :documentation "The subsequence from which elements must be taken. This is determined by the sequence and the :start and :end arguments to N-MOST-EXTREME.")) (:report (lambda (condition stream) (with-slots (n subsequence) condition (format stream "There are not enough elements in the sequence ~S~% to return the ~D most extreme elements" subsequence n)))) (:documentation "There are not enough elements in the sequence given to N-MOST-EXTREME to return the N most extreme elements.")) (defun n-most-extreme (n sequence predicate &key (key #'identity) (start 0) end) "Returns a list of the N elements of SEQUENCE that would appear first if the sequence were ordered according to SORT using PREDICATE and KEY with a stable sorting algorithm. If there are less than N elements in the relevant part of the sequence, this will return all the elements it can and signal the warning N-MOST-EXTREME-NOT-ENOUGH-ELEMENTS" (check-type n (integer 0)) (with-check-length (sequence start end) ;; This is faster on vectors than on lists. (let ((sequence (subseq sequence start end))) (if (> n (length sequence)) (progn (warn 'n-most-extreme-not-enough-elements :n n :subsequence sequence) (stable-sort (copy-seq sequence) predicate :key key)) (subseq (stable-sort (copy-seq sequence) predicate :key key) 0 n)))))
7,082
Common Lisp
.lisp
152
42.131579
114
0.70402
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
8fe83bda95be73de9223de9afcc25c31fcd6d53fb21bc411de45b4a9c7cbe3b5
21,667
[ 351500 ]
21,668
compose.lisp
rheaplex_minara/lib/cl-utilities/compose.lisp
;; This version of COMPOSE can only handle functions which take one ;; value and return one value. There are other ways of writing ;; COMPOSE, but this is the most commonly used. (in-package :cl-utilities) ;; This is really slow and conses a lot. Fortunately we can speed it ;; up immensely with a compiler macro. (defun compose (&rest functions) "Compose FUNCTIONS right-associatively, returning a function" #'(lambda (x) (reduce #'funcall functions :initial-value x :from-end t))) ;; Here's some benchmarking code that compares various methods of ;; doing the same thing. If the first method, using COMPOSE, is ;; notably slower than the rest, the compiler macro probably isn't ;; being run. #+nil (labels ((2* (x) (* 2 x))) (macrolet ((repeat ((x) &body body) (with-unique-names (counter) `(dotimes (,counter ,x) (declare (type (integer 0 ,x) ,counter) (ignorable ,counter)) ,@body)))) ;; Make sure the compiler macro gets run (declare (optimize (speed 3) (safety 0) (space 0) (debug 1))) (time (repeat (30000000) (funcall (compose #'1+ #'2* #'1+) 6))) (time (repeat (30000000) (funcall (lambda (x) (1+ (2* (1+ x)))) 6))) (time (repeat (30000000) (funcall (lambda (x) (funcall #'1+ (funcall #'2* (funcall #'1+ x)))) 6))))) ;; Converts calls to COMPOSE to lambda forms with everything written ;; out and some things written as direct function calls. ;; Example: (compose #'1+ #'2* #'1+) => (LAMBDA (X) (1+ (2* (1+ X)))) (define-compiler-macro compose (&rest functions) (labels ((sharp-quoted-p (x) (and (listp x) (eql (first x) 'function) (symbolp (second x))))) `(lambda (x) ,(reduce #'(lambda (fun arg) (if (sharp-quoted-p fun) (list (second fun) arg) (list 'funcall fun arg))) functions :initial-value 'x :from-end t))))
1,884
Common Lisp
.lisp
47
35.723404
72
0.642312
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
6a8b914e462d335a0f2bb63739d647d1ee849f3931328dea693586598baa37d2
21,668
[ 345392 ]
21,669
with-unique-names.lisp
rheaplex_minara/lib/cl-utilities/with-unique-names.lisp
(in-package :cl-utilities) ;; Defined at http://www.cliki.net/WITH-UNIQUE-NAMES (defmacro with-unique-names ((&rest bindings) &body body) "Executes a series of forms with each var bound to a fresh, uninterned symbol. See http://www.cliki.net/WITH-UNIQUE-NAMES" `(let ,(mapcar #'(lambda (binding) (multiple-value-bind (var prefix) (%with-unique-names-binding-parts binding) (check-type var symbol) `(,var (gensym ,(format nil "~A" (or prefix var)))))) bindings) ,@body)) (defun %with-unique-names-binding-parts (binding) "Return (values var prefix) from a WITH-UNIQUE-NAMES binding form. If PREFIX is not given in the binding, NIL is returned to indicate that the default should be used." (if (consp binding) (values (first binding) (second binding)) (values binding nil))) (define-condition list-binding-not-supported (warning) ((binding :initarg :binding :reader list-binding-not-supported-binding)) (:report (lambda (condition stream) (format stream "List binding ~S not supported by WITH-GENSYMS. It will work, but you should use WITH-UNIQUE-NAMES instead." (list-binding-not-supported-binding condition)))) (:documentation "List bindings aren't supported by WITH-GENSYMS, and if you want to use them you should use WITH-UNIQUE-NAMES instead. That said, they will work; they'll just signal this warning to complain about it.")) (defmacro with-gensyms ((&rest bindings) &body body) "Synonym for WITH-UNIQUE-NAMES, but BINDINGS should only consist of atoms; lists are not supported. If you try to give list bindings, a LIST-BINDING-NOT-SUPPORTED warning will be signalled, but it will work the same way as WITH-UNIQUE-NAMES. Don't do it, though." ;; Signal a warning for each list binding, if there are any (dolist (binding (remove-if-not #'listp bindings)) (warn 'list-binding-not-supported :binding binding)) ;; Otherwise, this is a synonym for WITH-UNIQUE-NAMES `(with-unique-names ,bindings ,@body))
2,039
Common Lisp
.lisp
40
46.625
74
0.722668
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
fc7ba5ac993bb6b9292c10430e442049a4bb347ab6d239acd5ec321c28acd2aa
21,669
[ 459560 ]
21,670
expt-mod.lisp
rheaplex_minara/lib/cl-utilities/expt-mod.lisp
(in-package :cl-utilities) ;; This is portable Common Lisp, but implementation-specific code may ;; improve performance considerably. (defun expt-mod (n exponent modulus) "As (mod (expt n exponent) modulus), but more efficient." (declare (optimize (speed 3) (safety 0) (space 0) (debug 1))) ;; It's much faster on SBCL and ACL to use the simple method, and ;; trust the compiler to optimize it. This may be the case on other ;; Lisp implementations as well. #+(or sbcl allegro) (mod (expt n exponent) modulus) #-(or sbcl allegro) (if (some (complement #'integerp) (list n exponent modulus)) (mod (expt n exponent) modulus) (loop with result = 1 for i of-type fixnum from 0 below (integer-length exponent) for sqr = n then (mod (* sqr sqr) modulus) when (logbitp i exponent) do (setf result (mod (* result sqr) modulus)) finally (return result)))) ;; If the compiler is going to expand compiler macros, we should ;; directly inline the simple expansion; this lets the compiler do all ;; sorts of fancy optimizations based on type information that ;; wouldn't be used to optimize the normal EXPT-MOD function. #+(or sbcl allegro) (define-compiler-macro expt-mod (n exponent modulus) `(mod (expt ,n ,exponent) ,modulus)) ;; Here's some benchmarking code that may be useful. I probably ;; completely wasted my time declaring ITERATIONS to be a fixnum. #+nil (defun test (&optional (iterations 50000000)) (declare (optimize (speed 3) (safety 0) (space 0) (debug 1)) (fixnum iterations)) (time (loop repeat iterations do (mod (expt 12 34) 235))) (time (loop repeat iterations do (expt-mod 12 34 235))))
1,665
Common Lisp
.lisp
34
45.970588
70
0.719287
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ed5ab8606d847e3750ec377c9431a9e05ab8ffb9b0b144a49be593045c4e806e
21,670
[ 355911 ]
21,671
copy-array.lisp
rheaplex_minara/lib/cl-utilities/copy-array.lisp
(in-package :cl-utilities) (defun copy-array (array &key (undisplace nil)) "Shallow copies the contents of any array into another array with equivalent properties. If array is displaced, then this function will normally create another displaced array with similar properties, unless UNDISPLACE is non-NIL, in which case the contents of the array will be copied into a completely new, not displaced, array." (declare (type array array)) (let ((copy (%make-array-with-same-properties array undisplace))) (unless (array-displacement copy) (dotimes (n (array-total-size copy)) (setf (row-major-aref copy n) (row-major-aref array n)))) copy)) (defun %make-array-with-same-properties (array undisplace) "Make an array with the same properties (size, adjustability, etc.) as another array, optionally undisplacing the array." (apply #'make-array (list* (array-dimensions array) :element-type (array-element-type array) :adjustable (adjustable-array-p array) :fill-pointer (when (array-has-fill-pointer-p array) (fill-pointer array)) (multiple-value-bind (displacement offset) (array-displacement array) (when (and displacement (not undisplace)) (list :displaced-to displacement :displaced-index-offset offset))))))
1,277
Common Lisp
.lisp
27
43.777778
70
0.747798
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
c48e297088fcae6f1329dc9712dab76ab410ab6fbaba1a5041fc8338f0642f09
21,671
[ 350408 ]
21,672
read-delimited.lisp
rheaplex_minara/lib/cl-utilities/read-delimited.lisp
(in-package :cl-utilities) (defun read-delimited (sequence stream &key (start 0) end (delimiter #\Newline) (test #'eql) (key #'identity)) ;; Check bounds on SEQUENCE (multiple-value-setq (start end) (%read-delimited-bounds-check sequence start end)) ;; Loop until we run out of input characters or places to put them, ;; or until we encounter the delimiter. (loop for index from start for char = (read-char stream nil nil) for test-result = (funcall test (funcall key char) delimiter) while (and char (< index end) (not test-result)) do (setf (elt sequence index) char) finally (return-from read-delimited (values index test-result)))) ;; Conditions ;;;;;;;;;;;;; (define-condition read-delimited-bounds-error (error) ((start :initarg :start :reader read-delimited-bounds-error-start) (end :initarg :end :reader read-delimited-bounds-error-end) (sequence :initarg :sequence :reader read-delimited-bounds-error-sequence)) (:report (lambda (condition stream) (with-slots (start end sequence) condition (format stream "The bounding indices ~S and ~S are bad for a sequence of length ~S" start end (length sequence))))) (:documentation "There's a problem with the indices START and END for SEQUENCE. See CLHS SUBSEQ-OUT-OF-BOUNDS:IS-AN-ERROR issue.")) ;; Error checking for bounds ;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun %read-delimited-bounds-check (sequence start end) "Check to make sure START and END are in bounds when calling READ-DELIMITED with SEQUENCE" (check-type start (or integer null)) (check-type end (or integer null)) (let ((start (%read-delimited-bounds-check-start sequence start end)) (end (%read-delimited-bounds-check-end sequence start end))) ;; Returns (values start end) (%read-delimited-bounds-check-order sequence start end))) (defun %read-delimited-bounds-check-order (sequence start end) "Check the order of START and END bounds, and return them in the correct order." (when (< end start) (restart-case (error 'read-delimited-bounds-error :start start :end end :sequence sequence) (continue () :report "Switch start and end" (rotatef start end)))) (values start end)) (defun %read-delimited-bounds-check-start (sequence start end) "Check to make sure START is in bounds when calling READ-DELIMITED with SEQUENCE" (when (and start (< start 0)) (restart-case (error 'read-delimited-bounds-error :start start :end end :sequence sequence) (continue () :report "Use default for START instead" (setf start 0)))) start) (defun %read-delimited-bounds-check-end (sequence start end) "Check to make sure END is in bounds when calling READ-DELIMITED with SEQUENCE" (when (and end (> end (length sequence))) (restart-case (error 'read-delimited-bounds-error :start start :end end :sequence sequence) (continue () :report "Use default for END instead" (setf end nil)))) (or end (length sequence)))
2,972
Common Lisp
.lisp
70
39.071429
91
0.718135
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e567d11d36efa94e84265b46288e7f7361fa32221ffcce16e5aac8a013e070f8
21,672
[ 391990 ]
21,673
test.lisp
rheaplex_minara/lib/cl-utilities/test.lisp
;; This file requires the FiveAM unit testing framework. (eval-when (:compile-toplevel :load-toplevel :execute) (asdf:oos 'asdf:load-op :fiveam) (asdf:oos 'asdf:load-op :cl-utilities)) ;; To run all the tests: ;; (5am:run! 'cl-utilities-tests::cl-utilities-suite) (defpackage :cl-utilities-tests (:use :common-lisp :cl-utilities :5am)) (in-package :cl-utilities-tests) (def-suite cl-utilities-suite :description "Test suite for cl-utilities") (in-suite cl-utilities-suite) ;; These tests were taken directly from the comments at the top of ;; split-sequence.lisp (test split-sequence (is (tree-equal (values (split-sequence #\; "a;;b;c")) '("a" "" "b" "c") :test #'equal)) (is (tree-equal (values (split-sequence #\; "a;;b;c" :from-end t)) '("a" "" "b" "c") :test #'equal)) (is (tree-equal (values (split-sequence #\; "a;;b;c" :from-end t :count 1)) '("c") :test #'equal)) (is (tree-equal (values (split-sequence #\; "a;;b;c" :remove-empty-subseqs t)) '("a" "b" "c") :test #'equal)) (is (tree-equal (values (split-sequence-if (lambda (x) (member x '(#\a #\b))) "abracadabra")) '("" "" "r" "c" "d" "" "r" "") :test #'equal)) (is (tree-equal (values (split-sequence-if-not (lambda (x) (member x '(#\a #\b))) "abracadabra")) '("ab" "a" "a" "ab" "a") :test #'equal)) (is (tree-equal (values (split-sequence #\; ";oo;bar;ba;" :start 1 :end 9)) '("oo" "bar" "b") :test #'equal))) (test extremum (is (= (extremum '(1 23 3 4 5 0) #'< :start 1 :end 4) 3)) (signals no-extremum (extremum '() #'<)) (is-false (handler-bind ((no-extremum #'continue)) (extremum '() #'<))) (is (= (extremum '(2/3 2 3 4) #'> :key (lambda (x) (/ 1 x))) 2/3)) (is (= (locally (declare (optimize (speed 3) (safety 0))) (extremum #(1 23 3 4 5 0) #'>)) 23)) (is (= (extremum-fastkey '(2/3 2 3 4) #'> :key (lambda (x) (/ 1 x))) 2/3))) (test extrema (is (tree-equal (extrema '(3 2 1 1 2 1) #'<) '(1 1 1))) (is (tree-equal (extrema #(3 2 1 1 2 1) #'<) '(1 1 1))) (is (tree-equal (extrema #(3 2 1 1 2 1) #'< :end 4) '(1 1))) (is (tree-equal (extrema '(3 2 1 1 2 1) #'< :end 4) '(1 1))) (is (tree-equal (extrema #(3 2 1 1 2 1) #'< :start 3 :end 4) '(1))) (is (tree-equal (extrema '((A . 3) (B . 1) (C . 2) (D . 1)) #'< :key #'cdr) '((B . 1) (D . 1))))) (defmacro quietly (&body body) "Perform BODY quietly, muffling any warnings that may arise" `(handler-bind ((warning #'muffle-warning)) ,@body)) (test n-most-extreme (is (tree-equal (n-most-extreme 1 '(3 1 2 1) #'>) '(3))) (is (tree-equal (n-most-extreme 2 '(3 1 2 1) #'>) '(3 2))) (is (tree-equal (n-most-extreme 2 '(3 1 2 1) #'<) '(1 1))) (is (tree-equal (n-most-extreme 1 '((A . 3) (B . 1) (C . 2) (D . 1)) #'> :key #'cdr) '((A . 3)))) (is (tree-equal (n-most-extreme 2 '((A . 3) (B . 1) (C . 2) (D . 1)) #'< :key #'cdr) '((B . 1) (D . 1)))) (is (tree-equal (quietly (n-most-extreme 20 '((A . 3) (B . 1) (C . 2) (D . 1)) #'< :key #'cdr)) '((B . 1) (D . 1) (C . 2) (A . 3)))) (is (tree-equal (quietly (n-most-extreme 2 '((A . 3) (B . 1) (C . 2) (D . 1)) #'< :key #'cdr :start 1 :end 2)) '((B . 1)))) (signals n-most-extreme-not-enough-elements (n-most-extreme 2 '((A . 3) (B . 1) (C . 2) (D . 1)) #'< :key #'cdr :start 1 :end 2))) (defun delimited-test (&key (delimiter #\|) (start 0) end (string "foogo|ogreogrjejgierjijri|bar|baz")) (with-input-from-string (str string) (let ((buffer (copy-seq " "))) (multiple-value-bind (position delimited-p) (read-delimited buffer str :delimiter delimiter :start start :end end) (declare (ignore delimited-p)) (subseq buffer 0 position))))) (test read-delimited (is (string= (delimited-test) "foogo")) (is (string= (delimited-test :delimiter #\t) "foogo|ogreog")) (is (string= (delimited-test :delimiter #\t :start 3) " foogo|ogr")) (is (string= (delimited-test :start 3) " foogo")) (is (string= (delimited-test :end 3) "foo")) (is (string= (delimited-test :start 1 :end 3) " fo")) (is (string= (delimited-test :string "Hello") "Hello")) (is (string= (delimited-test :string "Hello" :start 3) " Hello")) (is (string= (handler-bind ((read-delimited-bounds-error #'continue)) (delimited-test :start 3 :end 1)) " fo")) (signals type-error (delimited-test :start 3/2)) (signals read-delimited-bounds-error (delimited-test :start -3)) (signals read-delimited-bounds-error (delimited-test :end 30)) (signals read-delimited-bounds-error (delimited-test :start 3 :end 1))) ;; Random testing would probably work better here. (test expt-mod (is (= (expt-mod 2 34 54) (mod (expt 2 34) 54))) (is (= (expt-mod 20 3 54) (mod (expt 20 3) 54))) (is (= (expt-mod 2.5 3.8 34.9) (mod (expt 2.5 3.8) 34.9))) (is (= (expt-mod 2/5 3/8 34/9) (mod (expt 2/5 3/8) 34/9)))) (test collecting (is (tree-equal (collecting (dotimes (x 10) (collect x))) '(0 1 2 3 4 5 6 7 8 9))) (is (tree-equal (collecting (labels ((collect-it (x) (collect x))) (mapcar #'collect-it (reverse '(c b a))))) '(a b c))) (is (tree-equal (multiple-value-bind (a b) (with-collectors (x y) (x 1) (y 2) (x 3)) (append a b)) '(1 3 2)))) (test with-unique-names (is (equalp (subseq (with-unique-names (foo) (string foo)) 0 3) "foo")) (is (equalp (subseq (with-unique-names ((foo "bar")) (string foo)) 0 3) "bar")) (is (equalp (subseq (with-unique-names ((foo baz)) (string foo)) 0 3) "baz")) (is (equalp (subseq (with-unique-names ((foo #\y)) (string foo)) 0 1) "y")) (is (equalp (subseq (with-gensyms (foo) (string foo)) 0 3) "foo"))) ;; Taken from spec (test rotate-byte (is (= (rotate-byte 3 (byte 32 0) 3) 24)) (is (= (rotate-byte 3 (byte 5 5) 3) 3)) (is (= (rotate-byte 6 (byte 8 0) -3) -129))) (test copy-array (let ((test-array (make-array '(10 10) :initial-element 5))) (is (not (eq (copy-array test-array) test-array))) (is (equalp (copy-array test-array) test-array)))) (test compose (labels ((2* (x) (* 2 x))) (is (= (funcall (compose #'1+ #'1+) 1) 3)) (is (= (funcall (compose '1+ #'2*) 5) 11)) (is (= (funcall (compose #'1+ #'2* '1+) 6) 15)) ;; This should signal an undefined function error, since we're ;; using '2* rather than #'2*, which means that COMPOSE will use ;; the dynamic binding at the time it is called rather than the ;; lexical binding here. (signals undefined-function (= (funcall (compose #'1+ '2* '1+) 6) 15))))
6,657
Common Lisp
.lisp
161
37.242236
132
0.572377
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
7f67b98672b4fff81418996487964a8f155c10e8c704cb1135a9ecded80a38c5
21,673
[ 306025 ]
21,674
strings.lisp
rheaplex_minara/lib/babel/src/strings.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; strings.lisp --- Conversions between strings and UB8 vectors. ;;; ;;; Copyright (C) 2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. (in-package #:babel) ;;; The usefulness of this string/octets interface of Babel's is very ;;; limited on Lisps with 8-bit characters which will in effect only ;;; support the latin-1 subset of Unicode. That is, all encodings are ;;; supported but we can only store the first 256 code points in Lisp ;;; strings. Support for using other 8-bit encodings for strings on ;;; these Lisps could be added with an extra encoding/decoding step. ;;; Supporting other encodings with larger code units would be silly ;;; (it would break expectations about common string operations) and ;;; better done with something like Closure's runes. ;;; Can we handle unicode fully? (eval-when (:compile-toplevel :load-toplevel :execute) ;; The EVAL is just here to avoid warnings... (case (eval char-code-limit) (#x100 (pushnew '8-bit-chars *features*)) (#x10000 (pushnew 'ucs-2-chars *features*)) (#x110000 #| yay |#) ;; This is here mostly because if the CHAR-CODE-LIMIT is bigger ;; than #x11000, strange things might happen but we probably ;; shouldn't descriminate against other, smaller, values. (t (error "Strange CHAR-CODE-LIMIT (#x~X), bailing out." char-code-limit)))) ;;; Adapted from Ironclad. TODO: check if it's worthwhile adding ;;; implementation-specific accessors such as SAP-REF-* for SBCL. (defmacro ub-get (vector index &optional (bytes 1) (endianness :ne)) (let ((big-endian (member endianness '(:be #+big-endian :ne #+little-endian :re)))) (once-only (vector index) `(logand ,(1- (ash 1 (* 8 bytes))) (logior ,@(loop for i from 0 below bytes for offset = (if big-endian i (- bytes i 1)) for shift = (if big-endian (* (- bytes i 1) 8) (* offset 8)) collect `(ash (aref ,vector (+ ,index ,offset)) ,shift))))))) (defmacro ub-set (value vector index &optional (bytes 1) (endianness :ne)) (let ((big-endian (member endianness '(:be #+big-endian :ne #+little-endian :re)))) `(progn ,@(loop for i from 1 to bytes for offset = (if big-endian (- bytes i) (1- i)) collect `(setf (aref ,vector (+ ,index ,offset)) (ldb (byte 8 ,(* 8 (1- i))) ,value))) (values)))) (defmacro string-get (string index) `(char-code (schar ,string ,index))) (defmacro string-set (code string index) `(setf (schar ,string ,index) (code-char ,code))) ;;; SIMPLE-BASE-STRING would also be a subtype of SIMPLE-STRING so we ;;; don't use that because on SBCL BASE-CHARs can only hold ASCII. ;;; Also, with (> SPEED SAFETY) (setf (schar base-str n) big-char) ;;; will quietly work, sort of. ;;; ;;; XXX: test this on various lisps. (defconstant unicode-char-code-limit char-code-limit "An alias for CL:CHAR-CODE-LIMIT which might be lower than #x110000 on some Lisps.") (deftype unicode-char () "This character type can hold any characters whose CHAR-CODEs are less than UNICODE-CHAR-CODE-LIMIT." #+lispworks 'lw:simple-char #-lispworks 'character) (deftype simple-unicode-string () "Alias for (SIMPLE-ARRAY UNICODE-CHAR (*))." '(simple-array unicode-char (*))) (deftype unicode-string () "Alias for (VECTOR UNICODE-CHAR *)." '(vector unicode-char *)) (defparameter *string-vector-mappings* (instantiate-concrete-mappings ;; :optimize ((speed 3) (safety 0) (debug 0) (compilation-speed 0)) :octet-seq-setter ub-set :octet-seq-getter ub-get :octet-seq-type (simple-array (unsigned-byte 8) (*)) :code-point-seq-setter string-set :code-point-seq-getter string-get :code-point-seq-type simple-unicode-string)) (defun lookup-string-vector-mapping (encoding) (lookup-mapping *string-vector-mappings* encoding)) ;;; debugging stuff, TODO: refactor #-(and) (defmacro recompile-mappings (encodings &key (optimize '((debug 3) (safety 3))) (hash-table-place '*string-vector-mappings*) (octet-seq-setter 'ub-set) (octet-seq-getter 'ub-get) (octet-seq-type '(simple-array (unsigned-byte 8) (*))) (code-point-seq-setter 'string-set) (code-pointer-seq-getter 'string-get) (code-point-seq-type 'simple-unicode-string)) (let ((encodings (ensure-list encodings))) `(locally (declare (optimize ,@optimize)) ,@(loop for enc in encodings for am = (gethash enc babel-encodings::*abstract-mappings*) collect `(let ((cm (make-instance 'babel-encodings::concrete-mapping))) ,(babel-encodings::%am-to-cm 'cm am octet-seq-getter octet-seq-setter octet-seq-type code-pointer-seq-getter code-point-seq-setter code-point-seq-type) (setf (gethash ,enc ,hash-table-place) cm))) (values)))) #-(and) (defun debug-mappings (encodings &key (optimize '((debug 3) (safety 3))) (hash-table-place '*string-vector-mappings*) (octet-seq-setter 'ub-set) (octet-seq-getter 'ub-get) (octet-seq-type '(simple-array (unsigned-byte 8) (*))) (code-point-seq-setter 'string-set) (code-pointer-seq-getter 'string-get) (code-point-seq-type 'simple-unicode-string)) (let ((encodings (ensure-list encodings)) (*package* (find-package :babel-encodings)) (*print-case* :downcase)) (pprint `(locally (declare (optimize ,@optimize)) (setf ,hash-table-place (make-hash-table :test 'eq)) ,@(loop for enc in encodings for am = (gethash enc babel-encodings::*abstract-mappings*) collect `(let ((cm (make-instance 'babel-encodings::concrete-mapping))) ,(babel-encodings::%am-to-cm 'cm am octet-seq-getter octet-seq-setter octet-seq-type code-pointer-seq-getter code-point-seq-setter code-point-seq-type) (setf (gethash ,enc ,hash-table-place) cm)))))) (values)) ;;; Do we want a more a specific error condition here? (defun check-vector-bounds (vector start end) (unless (<= 0 start end (length vector)) (error "Invalid start (~A) and end (~A) values for vector of length ~A." start end (length vector)))) (defmacro with-simple-vector (((v vector) (s start) (e end)) &body body) "If VECTOR is a displaced or adjustable array, binds V to the underlying simple vector, adds an adequate offset to START and END and binds those offset values to S and E. Otherwise, if VECTOR is already a simple array, it's simply bound to V with no further changes. START and END are unchecked and assumed to be within bounds. Note that in some Lisps, a slow copying implementation is necessary to obtain a simple vector thus V will be bound to a copy of VECTOR coerced to a simple-vector. Therefore, you shouldn't attempt to modify V." #+sbcl `(sb-kernel:with-array-data ((,v ,vector) (,s ,start) (,e ,end)) ,@body) #+cmu `(lisp::with-array-data ((,v ,vector) (,s ,start) (,e ,end)) ,@body) #+openmcl (with-unique-names (offset) `(multiple-value-bind (,v ,offset) (ccl::array-data-and-offset ,vector) (let ((,s (+ ,start ,offset)) (,e (+ ,end ,offset))) ,@body))) #+allegro (with-unique-names (offset) `(excl::with-underlying-simple-vector (,vector ,v ,offset) (let ((,e (+ ,end ,offset)) (,s (+ ,start ,offset))) ,@body))) ;; slow, copying implementation #-(or sbcl cmu openmcl allegro) (once-only (vector) `(funcall (if (adjustable-array-p ,vector) #'call-with-array-data/copy #'call-with-array-data/fast) ,vector ,start ,end (lambda (,v ,s ,e) ,@body)))) #-(or sbcl cmu openmcl allegro) (progn ;; Stolen from f2cl. (defun array-data-and-offset (array) (loop with offset = 0 do (multiple-value-bind (displaced-to index-offset) (array-displacement array) (when (null displaced-to) (return-from array-data-and-offset (values array offset))) (incf offset index-offset) (setf array displaced-to)))) (defun call-with-array-data/fast (vector start end fn) (multiple-value-bind (data offset) (array-data-and-offset vector) (funcall fn data (+ offset start) (+ offset end)))) (defun call-with-array-data/copy (vector start end fn) (funcall fn (replace (make-array (- end start) :element-type (array-element-type vector)) vector :start2 start :end2 end) 0 (- end start)))) (defmacro with-checked-simple-vector (((v vector) (s start) (e end)) &body body) "Like WITH-SIMPLE-VECTOR but bound-checks START and END." (once-only (vector start) `(let ((,e (or ,end (length ,vector)))) (check-vector-bounds ,vector ,start ,e) (with-simple-vector ((,v ,vector) (,s ,start) (,e ,e)) ,@body)))) ;;; In the these 4 functions below, ERRORP defaults to NIL. But it ;;; might as well default to T. TODO: find out a good reason to go ;;; either way. ;;; ;;; Future features these functions should have: ;;; ;;; * null-terminate ;;; * specify target vector/string + offset ;;; * documentation :) (declaim (inline octets-to-string string-to-octets string-size-in-octets vector-size-in-chars concatenate-strings-to-octets)) (defun octets-to-string (vector &key (start 0) end (errorp (not *suppress-character-coding-errors*)) (encoding *default-character-encoding*)) (check-type vector (vector (unsigned-byte 8))) (with-checked-simple-vector ((vector vector) (start start) (end end)) (declare (type (simple-array (unsigned-byte 8) (*)) vector)) (let ((*suppress-character-coding-errors* (not errorp)) (mapping (lookup-string-vector-mapping encoding))) (multiple-value-bind (size new-end) (funcall (code-point-counter mapping) vector start end -1) (let ((string (make-string size :element-type 'unicode-char))) (funcall (decoder mapping) vector start new-end string 0) string))))) (defun bom-vector (encoding use-bom) (check-type use-bom (member :default t nil)) (if (null use-bom) #() (let ((enc (get-character-encoding encoding))) (if (or (eq use-bom t) (and (eq use-bom :default) (enc-use-bom enc))) (enc-bom-encoding enc) #())))) ;;; FIXME: we shouldn't really need that coercion to UNICODE-STRING ;;; but we kind of because it's declared all over. To avoid that, ;;; we'd need different types for input and output strings. Or maybe ;;; this is not a problem; figure that out. (defun string-to-octets (string &key (encoding *default-character-encoding*) (start 0) end (use-bom :default) (errorp (not *suppress-character-coding-errors*))) (check-type string string) (with-checked-simple-vector ((string (coerce string 'unicode-string)) (start start) (end end)) (declare (type simple-unicode-string string)) (let* ((*suppress-character-coding-errors* (not errorp)) (mapping (lookup-string-vector-mapping encoding)) (bom (bom-vector encoding use-bom)) (vector (make-array (the array-index (+ (funcall (octet-counter mapping) string start end -1) (length bom))) :element-type '(unsigned-byte 8)))) (replace vector bom) (funcall (encoder mapping) string start end vector (length bom)) vector))) (defun concatenate-strings-to-octets (encoding &rest strings) "Optimized equivalent of \(string-to-octets \(apply #'concatenate 'string strings) :encoding encoding)" (declare (dynamic-extent strings)) (let* ((mapping (lookup-mapping *string-vector-mappings* encoding)) (octet-counter (octet-counter mapping)) (vector (make-array (the array-index (reduce #'+ strings :key (lambda (string) (funcall octet-counter string 0 (length string) -1)))) :element-type '(unsigned-byte 8))) (current-index 0)) (declare (type array-index current-index)) (dolist (string strings) (check-type string string) (with-checked-simple-vector ((string (coerce string 'unicode-string)) (start 0) (end (length string))) (declare (type simple-unicode-string string)) (incf current-index (funcall (encoder mapping) string start end vector current-index)))) vector)) (defun string-size-in-octets (string &key (start 0) end (max -1 maxp) (errorp (not *suppress-character-coding-errors*)) (encoding *default-character-encoding*)) (check-type string string) (with-checked-simple-vector ((string (coerce string 'unicode-string)) (start start) (end end)) (declare (type simple-unicode-string string)) (let ((mapping (lookup-string-vector-mapping encoding)) (*suppress-character-coding-errors* (not errorp))) (when maxp (assert (plusp max))) (funcall (octet-counter mapping) string start end max)))) (defun vector-size-in-chars (vector &key (start 0) end (max -1 maxp) (errorp (not *suppress-character-coding-errors*)) (encoding *default-character-encoding*)) (check-type vector (vector (unsigned-byte 8))) (with-checked-simple-vector ((vector vector) (start start) (end end)) (declare (type (simple-array (unsigned-byte 8) (*)) vector)) (let ((mapping (lookup-string-vector-mapping encoding)) (*suppress-character-coding-errors* (not errorp))) (when maxp (assert (plusp max))) (funcall (code-point-counter mapping) vector start end max)))) (declaim (notinline octets-to-string string-to-octets string-size-in-octets vector-size-in-chars concatenate-strings-to-octets))
16,125
Common Lisp
.lisp
330
39.878788
80
0.617727
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
847bf8cd23db461b67ffa67a453c7260ac603c2ce95d0be8d4b087d618b4a2c0
21,674
[ 445123 ]
21,675
enc-ebcdic.lisp
rheaplex_minara/lib/babel/src/enc-ebcdic.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; enc-ebcdic.lisp --- EBCDIC encodings. ;;; ;;; Copyright (C) 2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. (in-package #:babel-encodings) (define-character-encoding :ebcdic-us "An alleged character set used on IBM dinosaurs." :aliases '(:ibm-037)) (declaim (type (simple-array (unsigned-byte 8) (256)) *ebcdic-decode-table*)) (defparameter *ebcdic-decode-table* (make-array 256 :element-type 'ub8 :initial-contents '(#x00 #x01 #x02 #x03 #x9c #x09 #x86 #x7f #x97 #x8d #x8e #x0b #x0c #x0d #x0e #x0f #x10 #x11 #x12 #x13 #x9d #x85 #x08 #x87 #x18 #x19 #x92 #x8f #x1c #x1d #x1e #x1f #x80 #x81 #x82 #x83 #x84 #x0a #x17 #x1b #x88 #x89 #x8a #x8b #x8c #x05 #x06 #x07 #x90 #x91 #x16 #x93 #x94 #x95 #x96 #x04 #x98 #x99 #x9a #x9b #x14 #x15 #x9e #x1a #x20 #xa0 #xe2 #xe4 #xe0 #xe1 #xe3 #xe5 #xe7 #xf1 #xa2 #x2e #x3c #x28 #x2b #x7c #x26 #xe9 #xea #xeb #xe8 #xed #xee #xef #xec #xdf #x21 #x24 #x2a #x29 #x3b #xac #x2d #x2f #xc2 #xc4 #xc0 #xc1 #xc3 #xc5 #xc7 #xd1 #xa6 #x2c #x25 #x5f #x3e #x3f #xf8 #xc9 #xca #xcb #xc8 #xcd #xce #xcf #xcc #x60 #x3a #x23 #x40 #x27 #x3d #x22 #xd8 #x61 #x62 #x63 #x64 #x65 #x66 #x67 #x68 #x69 #xab #xbb #xf0 #xfd #xfe #xb1 #xb0 #x6a #x6b #x6c #x6d #x6e #x6f #x70 #x71 #x72 #xaa #xba #xe6 #xb8 #xc6 #xa4 #xb5 #x7e #x73 #x74 #x75 #x76 #x77 #x78 #x79 #x7a #xa1 #xbf #xd0 #xdd #xde #xae #x5e #xa3 #xa5 #xb7 #xa9 #xa7 #xb6 #xbc #xbd #xbe #x5b #x5d #xaf #xa8 #xb4 #xd7 #x7b #x41 #x42 #x43 #x44 #x45 #x46 #x47 #x48 #x49 #xad #xf4 #xf6 #xf2 #xf3 #xf5 #x7d #x4a #x4b #x4c #x4d #x4e #x4f #x50 #x51 #x52 #xb9 #xfb #xfc #xf9 #xfa #xff #x5c #xf7 #x53 #x54 #x55 #x56 #x57 #x58 #x59 #x5a #xb2 #xd4 #xd6 #xd2 #xd3 #xd5 #x30 #x31 #x32 #x33 #x34 #x35 #x36 #x37 #x38 #x39 #xb3 #xdb #xdc #xd9 #xda #x9f))) (declaim (type (simple-array (unsigned-byte 8) (256)) *ebcdic-encode-table*)) (defparameter *ebcdic-encode-table* (loop with rt = (make-array 256 :element-type 'ub8 :initial-element 0) for code across *ebcdic-decode-table* for i from 0 do (assert (= 0 (aref rt code))) (setf (aref rt code) i) finally (return rt))) (define-unibyte-encoder :ebcdic-us (code) (if (>= code 256) (handle-error) (aref *ebcdic-encode-table* code))) (define-unibyte-decoder :ebcdic-us (octet) (aref *ebcdic-decode-table* octet))
3,524
Common Lisp
.lisp
65
50.753846
77
0.661743
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
9f56f0a202496701e8bd9061c0567cdd44400fa936d7b4c1da4c99fbb40e95d0
21,675
[ 167980 ]
21,676
sharp-backslash.lisp
rheaplex_minara/lib/babel/src/sharp-backslash.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; sharp-backslash.lisp --- Alternative #\ dispatch code. ;;; ;;; Copyright (C) 2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. (in-package #:babel) #-allegro (defun sharp-backslash-reader (original-reader stream char numarg) (let ((1st-char (read-char stream))) (if (and (char-equal 1st-char #\u) ;; because #\z is not a digit char... (digit-char-p (peek-char nil stream nil #\z) 16)) ;; something better than READ would be nice here (let ((token (let ((*read-base* 16)) (read stream)))) (if (typep token 'babel-encodings::code-point) (code-char token) (simple-reader-error stream "Unrecognized character name: u~A" token))) (funcall original-reader (make-concatenated-stream (make-string-input-stream (string 1st-char)) stream) char numarg)))) ;;; Allegro's PEEK-CHAR seems broken in some situations, and the code ;;; above would generate an error about too many calls to UNREAD-CHAR. ;;; Then Allegro's original SHARP-BACKSLASH wants to UNREAD-CHAR ;;; twice, very weird. This is the best workaround I could think of. ;;; It sucks. #+allegro (defun sharp-backslash-reader (original-reader stream char numarg) (let* ((1st-char (read-char stream)) (rest (ignore-errors (excl::read-extended-token stream))) (code (when (and rest (char-equal 1st-char #\u)) (ignore-errors (parse-integer rest :radix 16))))) (if code (code-char code) (with-input-from-string (s (concatenate 'string "#\\" (string 1st-char) rest)) (read-char s) (read-char s) (funcall original-reader s char numarg))))) (defun make-sharp-backslash-reader () (let ((original-sharp-backslash (get-dispatch-macro-character #\# #\\))) (lambda (stream char numarg) (sharp-backslash-reader original-sharp-backslash stream char numarg)))) (defmacro enable-sharp-backslash-syntax () `(eval-when (:compile-toplevel :execute) (setf *readtable* (copy-readtable *readtable*)) (set-sharp-backslash-syntax-in-readtable) (values))) (defun set-sharp-backslash-syntax-in-readtable () (set-dispatch-macro-character #\# #\\ (make-sharp-backslash-reader)) (values))
3,570
Common Lisp
.lisp
74
41.77027
77
0.661318
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
f3848f9a720c19f2a79b94f9760004063cb67217bfa75162e469267e6b04e6a4
21,676
[ 22947 ]
21,677
external-format.lisp
rheaplex_minara/lib/babel/src/external-format.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; external-format.lisp --- External format classes and functions. ;;; ;;; Copyright (C) 2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. (in-package #:babel) (defvar *default-eol-style* #+windows :crlf #-windows :lf "The end-of-line style used by external formats if none is explicitly given. Depends on the OS the code is compiled on.") (deftype eol-style () "Possible end-of-line styles." '(member :cr :lf :crlf)) (defclass external-format () ((encoding :initarg :encoding :reader external-format-encoding :type character-encoding) (eol-style :initarg :eol-style :reader external-format-eol-style :type eol-style :initform *default-eol-style*)) (:documentation "An EXTERNAL-FORMAT consists in a combination of a Babel CHARACTER-ENCODING and an end-of-line style.")) (defmethod print-object ((ef external-format) stream) (print-unreadable-object (ef stream :type t :identity t) (format stream "~A ~A" (enc-name (external-format-encoding ef)) (external-format-eol-style ef)))) ;;; This interface is still somewhat sketchy. The rest of Babel ;;; doesn't really understand external formats, for instance. (defun make-external-format (encoding &key (eol-style *default-eol-style*)) (check-type eol-style eol-style) (make-instance 'external-format :encoding (get-character-encoding encoding) :eol-style eol-style)) (defun ensure-external-format (thing) (etypecase thing (external-format thing) (character-encoding (make-instance 'external-format :encoding thing)) (symbol (make-external-format thing)) (list (apply #'make-external-format thing)))) (defun external-format-equal (ef1 ef2) (and (eq (external-format-encoding ef1) (external-format-encoding ef2)) (eq (external-format-eol-style ef1) (external-format-eol-style ef2)))) (defun lookup-mapping (ht encoding) "HT should be an hashtable created by INSTANTIATE-CONCRETE-MAPPINGS. ENCODING should be either an external format, an encoding object or a keyword symbol denoting a character encoding name or one of its aliases." (or (gethash (etypecase encoding (keyword encoding) (character-encoding (enc-name encoding)) (external-format (enc-name (external-format-encoding encoding)))) ht) (error "signal proper error here")))
3,559
Common Lisp
.lisp
74
44.027027
82
0.721519
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
20b4eff541de398127cdd26e9670b8b8c3920c5001577fda87117c676859dcad
21,677
[ 209456 ]
21,680
streams.lisp
rheaplex_minara/lib/babel/src/streams.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; streams.lisp --- Conversions between strings and UB8 vectors. ;;; ;;; Copyright (c) 2005-2007, Dr. Edmund Weitz. All rights reserved. ;;; Copyright (c) 2008, Attila Lendvai. All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; STATUS ;; - in-memory output streams support binary/bivalent/character element-types and file-position ;; TODO ;; - filter-stream types/mixins that can wrap a binary stream and turn it into a bivalent/character stream ;; - in-memory input streams with file-position similar to in-memory output streams (in-package :babel) (defpackage :babel-streams (:use :common-lisp :babel :trivial-gray-streams :alexandria) (:export #:in-memory-stream #:vector-output-stream #:vector-input-stream #:make-in-memory-output-stream #:get-output-stream-sequence #:with-output-to-sequence )) (in-package :babel-streams) (declaim (inline check-if-open check-if-accepts-octets check-if-accepts-characters stream-accepts-characters? stream-accepts-octets? vector-extend extend-vector-output-stream-buffer)) ;;; Some utilities (on top due to inlining) (defun vector-extend (extension vector &key (start 0) (end (length extension))) ;; copied over from cl-quasi-quote (declare (optimize speed) (type vector extension vector) (type array-index start end)) (let* ((original-length (length vector)) (extension-length (- end start)) (new-length (+ original-length extension-length)) (original-dimension (array-dimension vector 0))) (when (< original-dimension new-length) (setf vector (adjust-array vector (max (* 2 original-dimension) new-length)))) (setf (fill-pointer vector) new-length) (replace vector extension :start1 original-length :start2 start :end2 end) vector)) (defclass in-memory-stream (trivial-gray-stream-mixin) ((element-type :initform :default ; which means bivalent :initarg :element-type :accessor element-type-of) (external-format :initform (ensure-external-format *default-character-encoding*) :initarg :external-format :accessor external-format-of) #+:cmu (open-p :initform t :accessor in-memory-stream-open-p :documentation "For CMUCL we have to keep track of this manually.")) (:documentation "An IN-MEMORY-STREAM is a binary stream that reads octets from or writes octets to a sequence in RAM.")) (defmethod stream-element-type ((self in-memory-stream)) ;; stream-element-type is a CL symbol, we may not install an accessor on it. ;; so, go through this extra step. (element-type-of self)) (defun stream-accepts-octets? (stream) (let ((element-type (element-type-of stream))) (or (eq element-type :default) (equal element-type '(unsigned-byte 8)) (subtypep element-type '(unsigned-byte 8))))) (defun stream-accepts-characters? (stream) (let ((element-type (element-type-of stream))) (member element-type '(:default character base-char)))) (defclass in-memory-input-stream (in-memory-stream fundamental-binary-input-stream) () (:documentation "An IN-MEMORY-INPUT-STREAM is a binary stream that reads octets from a sequence in RAM.")) #+:cmu (defmethod output-stream-p ((stream in-memory-input-stream)) "Explicitly states whether this is an output stream." (declare (optimize speed)) nil) (defclass in-memory-output-stream (in-memory-stream fundamental-binary-output-stream) () (:documentation "An IN-MEMORY-OUTPUT-STREAM is a binary stream that writes octets to a sequence in RAM.")) #+:cmu (defmethod input-stream-p ((stream in-memory-output-stream)) "Explicitly states whether this is an input stream." (declare (optimize speed)) nil) (defun make-in-memory-output-stream (&key (element-type :default) external-format initial-buffer-size) "Returns a binary output stream which accepts objects of type ELEMENT-TYPE \(a subtype of OCTET) and makes available a sequence that contains the octes that were actually output." (declare (optimize speed)) (unless external-format (setf external-format *default-character-encoding*)) (when (eq element-type :bivalent) (setf element-type :default)) (make-instance 'vector-output-stream :vector (make-vector-stream-buffer :element-type (cond ((or (eq element-type :default) (equal element-type '(unsigned-byte 8))) '(unsigned-byte 8)) ((eq element-type 'character) 'character) ((subtypep element-type '(unsigned-byte 8)) '(unsigned-byte 8)) (t (error "Illegal element-type ~S" element-type))) :initial-size initial-buffer-size) :element-type element-type :external-format (ensure-external-format external-format))) (defclass vector-stream () ((vector :initarg :vector :accessor vector-stream-vector :documentation "The underlying vector of the stream which \(for output) must always be adjustable and have a fill pointer.") (index :initform 0 :initarg :index :accessor vector-stream-index :type (integer 0 #.array-dimension-limit) :documentation "An index into the underlying vector denoting the current position.")) (:documentation "A VECTOR-STREAM is a mixin for IN-MEMORY streams where the underlying sequence is a vector.")) (defclass vector-input-stream (vector-stream in-memory-input-stream) ((end :initarg :end :accessor vector-stream-end :type (integer 0 #.array-dimension-limit) :documentation "An index into the underlying vector denoting the end of the available data.")) (:documentation "A binary input stream that gets its data from an associated vector of octets.")) (defclass vector-output-stream (vector-stream in-memory-output-stream) () (:documentation "A binary output stream that writes its data to an associated vector.")) (define-condition in-memory-stream-error (stream-error) () (:documentation "Superclass for all errors related to IN-MEMORY streams.")) (define-condition in-memory-stream-closed-error (in-memory-stream-error) () (:report (lambda (condition stream) (format stream "~S is closed." (stream-error-stream condition)))) (:documentation "An error that is signalled when someone is trying to read from or write to a closed IN-MEMORY stream.")) (define-condition wrong-element-type-stream-error (stream-error) ((expected-type :accessor expected-type-of :initarg :expected-type)) (:report (lambda (condition output) (let ((stream (stream-error-stream condition))) (format output "The element-type of ~S is ~S while expecting a stream that accepts ~S." stream (element-type-of stream) (expected-type-of condition)))))) (defun wrong-element-type-stream-error (stream expected-type) (error 'wrong-element-type-stream-error :stream stream :expected-type expected-type)) #+:cmu (defmethod open-stream-p ((stream in-memory-stream)) "Returns a true value if STREAM is open. See ANSI standard." (declare (optimize speed)) (in-memory-stream-open-p stream)) #+:cmu (defmethod close ((stream in-memory-stream) &key abort) "Closes the stream STREAM. See ANSI standard." (declare (ignore abort) (optimize speed)) (prog1 (in-memory-stream-open-p stream) (setf (in-memory-stream-open-p stream) nil))) (defun check-if-open (stream) "Checks if STREAM is open and signals an error otherwise." (declare (optimize speed)) (unless (open-stream-p stream) (error 'in-memory-stream-closed-error :stream stream))) (defun check-if-accepts-octets (stream) (declare (optimize speed)) (unless (stream-accepts-octets? stream) (wrong-element-type-stream-error stream '(unsigned-byte 8)))) (defun check-if-accepts-characters (stream) (declare (optimize speed)) (unless (stream-accepts-characters? stream) (wrong-element-type-stream-error stream 'character))) (defmethod stream-read-byte ((stream vector-input-stream)) "Reads one byte and increments INDEX pointer unless we're beyond END pointer." (declare (optimize speed)) (check-if-open stream) (let ((index (vector-stream-index stream))) (cond ((< index (vector-stream-end stream)) (incf (vector-stream-index stream)) (aref (vector-stream-vector stream) index)) (t :eof)))) (defmethod stream-listen ((stream vector-input-stream)) "Checking whether INDEX is beyond END." (declare (optimize speed)) (check-if-open stream) (< (vector-stream-index stream) (vector-stream-end stream))) (defmethod stream-read-sequence ((stream vector-input-stream) sequence start end &key) (declare (optimize speed) (type array-index start end)) ;; TODO check the sequence type, assert for the element-type and use the external-format (loop with vector-end of-type array-index = (vector-stream-end stream) with vector = (vector-stream-vector stream) for index from start below end for vector-index of-type array-index = (vector-stream-index stream) while (< vector-index vector-end) do (setf (elt sequence index) (aref vector vector-index)) (incf (vector-stream-index stream)) finally (return index))) (defmethod stream-write-byte ((stream vector-output-stream) byte) "Writes a byte \(octet) by extending the underlying vector." (declare (optimize speed)) (check-if-open stream) (check-if-accepts-octets stream) (vector-push-extend byte (vector-stream-vector stream)) (incf (vector-stream-index stream)) byte) (defun extend-vector-output-stream-buffer (extension stream &key (start 0) (end (length extension))) (declare (optimize speed) (type array-index start end) (type vector extension)) (vector-extend extension (vector-stream-vector stream) :start start :end end) (incf (vector-stream-index stream) (- end start)) (values)) (defmethod stream-write-char ((stream vector-output-stream) char) (declare (optimize speed)) (check-if-open stream) (check-if-accepts-characters stream) ;; TODO this is naiive here, there's room for optimization (let ((octets (string-to-octets (string char) :encoding (external-format-of stream)))) (extend-vector-output-stream-buffer octets stream)) char) (defmethod stream-write-sequence ((stream vector-output-stream) sequence start end &key) "Just calls VECTOR-PUSH-EXTEND repeatedly." (declare (optimize speed) (type array-index start end)) (etypecase sequence (string (if (stream-accepts-octets? stream) ;; TODO this is naiive here, there's room for optimization (let ((octets (string-to-octets sequence :encoding (external-format-of stream) :start start :end end))) (extend-vector-output-stream-buffer octets stream)) (progn (assert (stream-accepts-characters? stream)) (extend-vector-output-stream-buffer sequence stream :start start :end end)))) ((vector (unsigned-byte 8)) ;; specialized branch to help inlining (check-if-accepts-octets stream) (extend-vector-output-stream-buffer sequence stream :start start :end end)) (vector (check-if-accepts-octets stream) (extend-vector-output-stream-buffer sequence stream :start start :end end))) sequence) (defmethod stream-file-position ((stream vector-stream)) "Simply returns the index into the underlying vector." (declare (optimize speed)) (vector-stream-index stream)) (defun make-vector-stream-buffer (&key (element-type '(unsigned-byte 8)) initial-size) "Creates and returns an array which can be used as the underlying vector for a VECTOR-OUTPUT-STREAM." (declare (optimize speed) (type (or null array-index) initial-size)) (make-array (the array-index (or initial-size 32)) :adjustable t :fill-pointer 0 :element-type element-type)) (defmethod get-output-stream-sequence ((stream in-memory-output-stream) &key (return-as 'vector)) "Returns a vector containing, in order, all the octets that have been output to the IN-MEMORY stream STREAM. This operation clears any octets on STREAM, so the vector contains only those octets which have been output since the last call to GET-OUTPUT-STREAM-SEQUENCE or since the creation of the stream, whichever occurred most recently. If AS-LIST is true the return value is coerced to a list." (declare (optimize speed)) (prog1 (ecase return-as (vector (vector-stream-vector stream)) (string (octets-to-string (vector-stream-vector stream) :encoding (external-format-of stream))) (list (coerce (vector-stream-vector stream) 'list))) (setf (vector-stream-vector stream) (make-vector-stream-buffer)))) (defmacro with-output-to-sequence ((var &key (return-as ''vector) (element-type '':default) (external-format '*default-character-encoding*) initial-buffer-size) &body body) "Creates an IN-MEMORY output stream, binds VAR to this stream and then executes the code in BODY. The stream stores data of type ELEMENT-TYPE \(a subtype of OCTET). The stream is automatically closed on exit from WITH-OUTPUT-TO-SEQUENCE, no matter whether the exit is normal or abnormal. The return value of this macro is a vector \(or a list if AS-LIST is true) containing the octets that were sent to the stream within BODY." (multiple-value-bind (body declarations) (parse-body body) `(let (,var) ,@declarations (unwind-protect (progn (setq ,var (make-in-memory-output-stream :element-type ,element-type :external-format ,external-format :initial-buffer-size ,initial-buffer-size)) ,@body (get-output-stream-sequence ,var :return-as ,return-as)) (when ,var (close ,var))))))
16,011
Common Lisp
.lisp
300
45.616667
430
0.679219
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
5af7a527414b31aa72e4c379fbe5f6eb6b48c49c7f5fbf56430bfe6d434c01ad
21,680
[ 451083 ]
21,681
enc-unicode.lisp
rheaplex_minara/lib/babel/src/enc-unicode.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; enc-unicode.lisp --- Unicode encodings. ;;; ;;; Copyright (C) 2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; This implementation is largely based on OpenMCL's l1-unicode.lisp ;;; Copyright (C) 2006 Clozure Associates and contributors. (in-package #:babel-encodings) (eval-when (:compile-toplevel :load-toplevel :execute) (defconstant +repl+ #xfffd "Unicode replacement character code point.") (defconstant +byte-order-mark-code+ #xfeff) (defconstant +swapped-byte-order-mark-code+ #xfffe) (defconstant +swapped-byte-order-mark-code-32+ #xfffe0000)) ;;; Some convenience macros adding FIXNUM declarations. (defmacro f-ash (integer count) `(the fixnum (ash ,integer ,count))) (defmacro f-logior (&rest integers) `(the fixnum (logior ,@integers))) (defmacro f-logand (&rest integers) `(the fixnum (logand ,@integers))) (defmacro f-logxor (&rest integers) `(the fixnum (logxor ,@integers))) ;;;; UTF-8 (define-character-encoding :utf-8 "An 8-bit, variable-length character encoding in which character code points in the range #x00-#x7f can be encoded in a single octet; characters with larger code values can be encoded in 2 to 4 bytes." :max-units-per-char 4 :literal-char-code-limit #x80 :bom-encoding #(#xef #xbb #xbf) :default-replacement #xfffd) (define-condition invalid-utf8-starter-byte (character-decoding-error) () (:documentation "Signalled when an invalid UTF-8 starter byte is found.")) (define-condition invalid-utf8-continuation-byte (character-decoding-error) () (:documentation "Signalled when an invalid UTF-8 continuation byte is found.")) (define-condition overlong-utf8-sequence (character-decoding-error) () (:documentation "Signalled upon overlong UTF-8 sequences.")) (define-octet-counter :utf-8 (getter type) `(lambda (seq start end max) (declare (type ,type seq) (fixnum start end max)) (loop with noctets fixnum = 0 for i fixnum from start below end for code of-type code-point = (,getter seq i) do (let ((new (+ (cond ((< code #x80) 1) ((< code #x800) 2) ((< code #x10000) 3) (t 4)) noctets))) (if (and (plusp max) (> new max)) (loop-finish) (setq noctets new))) finally (return (values noctets i))))) (define-code-point-counter :utf-8 (getter type) `(lambda (seq start end max) (declare (type ,type seq) (fixnum start end max)) (loop with nchars fixnum = 0 with i fixnum = start while (< i end) do ;; check for invalid continuation bytes (macrolet ((invalid-cb-p (n) `(and (< (+ i ,n) end) (not (< #x7f (,',getter seq (+ i ,n)) #xc0))))) ;; wrote this code with LET instead of FOR because CLISP's ;; LOOP doesn't like WHILE clauses before FOR clauses. (let* ((octet (,getter seq i)) (next-i (+ i (cond ((or (< octet #xc0) (invalid-cb-p 1)) 1) ((or (< octet #xe0) (invalid-cb-p 2)) 2) ((or (< octet #xf0) (invalid-cb-p 3)) 3) ((or (< octet #xf8) (invalid-cb-p 4)) 4) ((or (< octet #xfc) (invalid-cb-p 5)) 5) (t 6))))) (declare (type ub8 octet) (fixnum next-i)) (cond ((> next-i end) ;; Should we add restarts to this error, we'll have ;; to figure out a way to communicate with the ;; decoder since we probably want to do something ;; about it right here when we have a chance to ;; change the count or something. (Like an ;; alternative replacement character or perhaps the ;; existence of this error so that the decoder ;; doesn't have to check for it on every iteration ;; like we do.) ;; ;; FIXME: The data for this error is not right. (decoding-error (vector octet) :utf-8 seq i nil 'end-of-input-in-character) (return (values (1+ nchars) end))) (t (setq nchars (1+ nchars) i next-i) (when (and (plusp max) (= nchars max)) (return (values nchars i))))))) finally (progn (assert (= i end)) (return (values nchars i)))))) (define-encoder :utf-8 (getter src-type setter dest-type) `(lambda (src start end dest d-start) (declare (type ,src-type src) (type ,dest-type dest) (fixnum start end d-start)) (loop with di fixnum = d-start for i fixnum from start below end for code of-type code-point = (,getter src i) do (macrolet ((set-octet (offset value) `(,',setter ,value dest (the fixnum (+ di ,offset))))) (cond ;; 1 octet ((< code #x80) (set-octet 0 code) (incf di)) ;; 2 octets ((< code #x800) (set-octet 0 (logior #xc0 (f-ash code -6))) (set-octet 1 (logior #x80 (f-logand code #x3f))) (incf di 2)) ;; 3 octets ((< code #x10000) (set-octet 0 (logior #xe0 (f-ash code -12))) (set-octet 1 (logior #x80 (f-logand #x3f (f-ash code -6)))) (set-octet 2 (logior #x80 (f-logand code #x3f))) (incf di 3)) ;; 4 octets (t (set-octet 0 (logior #xf0 (f-logand #x07 (f-ash code -18)))) (set-octet 1 (logior #x80 (f-logand #x3f (f-ash code -12)))) (set-octet 2 (logior #x80 (f-logand #x3f (f-ash code -6)))) (set-octet 3 (logior #x80 (logand code #x3f))) (incf di 4)))) finally (return (the fixnum (- di d-start)))))) (define-decoder :utf-8 (getter src-type setter dest-type) `(lambda (src start end dest d-start) (declare (type ,src-type src) (type ,dest-type dest) (fixnum start end d-start)) (let ((u2 0) (u3 0) (u4 0) (u5 0) (u6 0)) (declare (type ub8 u2 u3 u4 u5 u6)) (loop for di fixnum from d-start for i fixnum from start below end for u1 of-type ub8 = (,getter src i) do ;; Note: CONSUME-OCTET doesn't check if I is being ;; incremented past END. We're assuming that END has ;; been calculated with the CODE-POINT-POINTER above that ;; checks this. (macrolet ((consume-octet () `(let ((next-i (incf i))) (if (= next-i end) ;; FIXME: data for this error is incomplete. ;; and signalling this error twice (return-from setter-block (decoding-error nil :utf-8 src i +repl+ 'end-of-input-in-character)) (,',getter src next-i)))) (handle-error (n &optional (c 'character-decoding-error)) `(decoding-error (vector ,@(subseq '(u1 u2 u3 u4 u5 u6) 0 n)) :utf-8 src (1+ (- i ,n)) +repl+ ',c)) (handle-error-if-icb (var n) `(when (not (< #x7f ,var #xc0)) (decf i) (return-from setter-block (handle-error ,n invalid-utf8-continuation-byte))))) (,setter (block setter-block (cond ((< u1 #x80) u1) ; 1 octet ((< u1 #xc0) (handle-error 1 invalid-utf8-starter-byte)) (t (setq u2 (consume-octet)) (handle-error-if-icb u2 1) (cond ((< u1 #xc2) (handle-error 2 overlong-utf8-sequence)) ((< u1 #xe0) ; 2 octets (logior (f-ash (f-logand #x1f u1) 6) (f-logxor u2 #x80))) (t (setq u3 (consume-octet)) (handle-error-if-icb u3 2) (cond ((and (= u1 #xe0) (< u2 #xa0)) (handle-error 3 overlong-utf8-sequence)) ((< u1 #xf0) ; 3 octets (logior (f-ash (f-logand u1 #x0f) 12) (f-logior (f-ash (f-logand u2 #x3f) 6) (f-logand u3 #x3f)))) (t ; 4 octets (setq u4 (consume-octet)) (handle-error-if-icb u4 3) (cond ((and (= u1 #xf0) (< u2 #x90)) (handle-error 4 overlong-utf8-sequence)) ((< u1 #xf8) (if (or (> u1 #xf4) (and (= u1 #xf4) (> u2 #x8f))) (handle-error 4 character-out-of-range) (f-logior (f-ash (f-logand u1 7) 18) (f-ash (f-logxor u2 #x80) 12) (f-ash (f-logxor u3 #x80) 6) (f-logxor u4 #x80)))) ;; from here on we'll be getting either ;; invalid continuation bytes or overlong ;; 5-byte or 6-byte sequences. (t (setq u5 (consume-octet)) (handle-error-if-icb u5 4) (cond ((and (= u1 #xf8) (< u2 #x88)) (handle-error 5 overlong-utf8-sequence)) ((< u1 #xfc) (handle-error 5 character-out-of-range)) (t (setq u6 (consume-octet)) (handle-error-if-icb u6 5) (cond ((and (= u1 #xfc) (< u2 #x84)) (handle-error 6 overlong-utf8-sequence)) (t (handle-error 6 character-out-of-range) ))))))))))))) dest di)) finally (return (the fixnum (- di d-start))))))) ;;;; UTF-8B ;;; The following excerpt from a linux-utf8 message by Markus Kuhn is ;;; the closest thing to a UTF-8B specification: ;;; ;;; <http://mail.nl.linux.org/linux-utf8/2000-07/msg00040.html> ;;; ;;; "D) Emit a malformed UTF-16 sequence for every byte in a malformed ;;; UTF-8 sequence ;;; ;;; All the previous options for converting malformed UTF-8 sequences ;;; to UTF-16 destroy information. This can be highly undesirable in ;;; applications such as text file editors, where guaranteed binary ;;; transparency is a desireable feature. (E.g., I frequently edit ;;; executable code or graphic files with the Emacs text editor and I ;;; hate the idea that my editor might automatically make U+FFFD ;;; substitutions at locations that I haven't even edited when I save ;;; the file again.) ;;; ;;; I therefore suggested 1999-11-02 on the unicode@xxxxxxxxxxx ;;; mailing list the following approach. Instead of using U+FFFD, ;;; simply encode malformed UTF-8 sequences as malformed UTF-16 ;;; sequences. Malformed UTF-8 sequences consist excludively of the ;;; bytes 0x80 - 0xff, and each of these bytes can be represented ;;; using a 16-bit value from the UTF-16 low-half surrogate zone ;;; U+DC80 to U+DCFF. Thus, the overlong "K" (U+004B) 0xc1 0x8b from ;;; the above example would be represented in UTF-16 as U+DCC1 ;;; U+DC8B. If we simply make sure that every UTF-8 encoded surrogate ;;; character is also treated like a malformed sequence, then there ;;; is no way that a single high-half surrogate could precede the ;;; encoded malformed sequence and cause a valid UTF-16 sequence to ;;; emerge. ;;; ;;; This way 100% binary transparent UTF-8 -> UTF-16 -> UTF-8 ;;; round-trip compatibility can be achieved quite easily. ;;; ;;; On an output device, a lonely low-half surrogate character should ;;; be treated just like a character outside the adopted subset of ;;; representable characters, that is for the end user, the display ;;; would look exactly like with semantics B), i.e. one symbol per ;;; byte of a malformed sequence. However in contrast to semantics ;;; B), no information is thrown away, and a cut&paste in an editor ;;; or terminal emulator will be guaranteed to reconstruct the ;;; original byte sequence. This should greatly reduce the incidence ;;; of accidental corruption of binary data by UTF-8 -> UTF-16 -> ;;; UTF-8 conversion round trips." (define-character-encoding :utf-8b "An 8-bit, variable-length character encoding in which character code points in the range #x00-#x7f can be encoded in a single octet; characters with larger code values can be encoded in 2 to 4 bytes. Invalid UTF-8 sequences are encoded with #xDCXX code points for each invalid byte." :max-units-per-char 4 :literal-char-code-limit #x80 :bom-encoding #(#xef #xbb #xbf) :default-replacement nil) ;;; TODO: reuse the :UTF-8 octet counter through a simple macro. (define-octet-counter :utf-8b (getter type) `(lambda (seq start end max) (declare (type ,type seq) (fixnum start end max)) (loop with noctets fixnum = 0 for i fixnum from start below end for code of-type code-point = (,getter seq i) do (let ((new (+ (cond ((< code #x80) 1) ((< code #x800) 2) ((<= #xdc80 code #xdcff) 1) ((< code #x10000) 3) (t 4)) noctets))) (if (and (plusp max) (> new max)) (loop-finish) (setq noctets new))) finally (return (values noctets i))))) (define-code-point-counter :utf-8b (getter type) `(lambda (seq start end max) (declare (type ,type seq) (fixnum start end max)) (loop with nchars fixnum = 0 with i fixnum = start while (< i end) do ;; wrote this code with LET instead of FOR because CLISP's ;; LOOP doesn't like WHILE clauses before FOR clauses. (let* ((octet (,getter seq i)) (noctets (cond ((< octet #x80) 1) ((< octet #xe0) 2) ((< octet #xf0) 3) (t 4)))) (declare (type ub8 octet) (fixnum noctets)) (cond ((> (+ i noctets) end) ;; If this error is suppressed these last few bytes ;; will be encoded as raw bytes later. (decoding-error (vector octet) :utf-8 seq i nil 'end-of-input-in-character) (return (values (+ nchars (- end i)) end))) (t ;; FIXME: clean this mess up. (let* ((u1 octet) (u2 (if (>= noctets 2) (,getter seq (1+ i)) 0)) (u3 (if (>= noctets 3) (,getter seq (+ i 2)) 0)) (u4 (if (= noctets 4) (,getter seq (+ i 3)) 0)) (inc (or (and (> noctets 1) (< u1 #xc2)) (and (= noctets 2) (not (logior u2 #x40))) (and (= noctets 3) (not (and (< (f-logxor u2 #x80) #x40) (< (f-logxor u3 #x80) #x40) (or (>= u1 #xe1) (>= u2 #xa0))))) (and (= noctets 4) (not (and (< (f-logxor u2 #x80) #x40) (< (f-logxor u3 #x80) #x40) (< (f-logxor u4 #x80) #x40) (or (>= u1 #xf1) (>= u2 #x90)))))))) (let ((new-nchars (if inc (+ nchars noctets) (1+ nchars)))) (when (and (plusp max) (> new-nchars max)) (return (values nchars i))) (incf i noctets) (setq nchars new-nchars)))))) finally (progn (assert (= i end)) (return (values nchars i)))))) ;;; TODO: reuse the :UTF-8 encoder with through a simple macro. (define-encoder :utf-8b (getter src-type setter dest-type) `(lambda (src start end dest d-start) (declare (type ,src-type src) (type ,dest-type dest) (fixnum start end d-start)) (loop with di fixnum = d-start for i fixnum from start below end for code of-type code-point = (,getter src i) do (macrolet ((set-octet (offset value) `(,',setter ,value dest (the fixnum (+ di ,offset))))) (cond ;; 1 octet ((< code #x80) (set-octet 0 code) (incf di)) ;; 2 octets ((< code #x800) (set-octet 0 (logior #xc0 (f-ash code -6))) (set-octet 1 (logior #x80 (f-logand code #x3f))) (incf di 2)) ;; 1 octet (invalid octet) ((<= #xdc80 code #xdcff) (set-octet 0 (f-logand code #xff)) (incf di)) ;; 3 octets ((< code #x10000) (set-octet 0 (logior #xe0 (f-ash code -12))) (set-octet 1 (logior #x80 (f-logand #x3f (f-ash code -6)))) (set-octet 2 (logior #x80 (f-logand code #x3f))) (incf di 3)) ;; 4 octets (t (set-octet 0 (logior #xf0 (f-logand #x07 (f-ash code -18)))) (set-octet 1 (logior #x80 (f-logand #x3f (f-ash code -12)))) (set-octet 2 (logior #x80 (f-logand #x3f (f-ash code -6)))) (set-octet 3 (logand #x3f code)) (incf di 4)))) finally (return (the fixnum (- di d-start)))))) (define-decoder :utf-8b (getter src-type setter dest-type) `(lambda (src start end dest d-start) (declare (type ,src-type src) (type ,dest-type dest) (fixnum start end d-start)) (let ((u2 0) (u3 0) (u4 0)) (declare (type ub8 u2 u3 u4)) (loop for di fixnum from d-start for i fixnum from start below end for u1 of-type ub8 = (,getter src i) do ;; Unlike the UTF-8 version, this version of ;; CONSUME-OCTET needs to check if I is being incremented ;; past END because we might have trailing binary ;; garbage. (macrolet ((consume-octet (n) `(if (= i (1- end)) (encode-raw-octets ,n) (,',getter src (incf i)))) (encode-raw-octets (n) `(progn ,@(loop for i below n and var in '(u1 u2 u3 u4) collect `(,',setter (logior #xdc00 ,var) dest di) unless (= i (1- n)) collect '(incf di)) (return-from set-body)))) (block set-body (,setter (cond ((< u1 #x80) ; 1 octet u1) ((>= u1 #xc2) (setq u2 (consume-octet 1)) (cond ((< u1 #xe0) ; 2 octets (if (< (f-logxor u2 #x80) #x40) (logior (f-ash (f-logand #x1f u1) 6) (f-logxor u2 #x80)) (encode-raw-octets 2))) (t (setq u3 (consume-octet 2)) (cond ((< u1 #xf0) ; 3 octets (if (and (< (f-logxor u2 #x80) #x40) (< (f-logxor u3 #x80) #x40) (or (>= u1 #xe1) (>= u2 #xa0))) (logior (f-ash (f-logand u1 #x0f) 12) (f-logior (f-ash (f-logand u2 #x3f) 6) (f-logand u3 #x3f))) (encode-raw-octets 3))) (t ; 4 octets (setq u4 (consume-octet 3)) (if (and (< (f-logxor u2 #x80) #x40) (< (f-logxor u3 #x80) #x40) (< (f-logxor u4 #x80) #x40) (or (>= u1 #xf1) (>= u2 #x90))) (logior (f-logior (f-ash (f-logand u1 7) 18) (f-ash (f-logxor u2 #x80) 12)) (f-logior (f-ash (f-logxor u3 #x80) 6) (f-logxor u4 #x80))) (encode-raw-octets 4))))))) (t (encode-raw-octets 1))) dest di))) finally (return (the fixnum (- di d-start))))))) ;;;; UTF-16 ;;; TODO: add a way to pass some info at compile-time telling us that, ;;; for example, the maximum code-point will always be < #x10000 in ;;; which case we could simply return (* 2 (- end start)). (defmacro utf16-octet-counter (getter type) `(lambda (seq start end max) (declare (type ,type seq) (fixnum start end max)) (loop with noctets fixnum = 0 for i fixnum from start below end for code of-type code-point = (,getter seq i) do (let ((new (the fixnum (+ (if (< code #x10000) 2 4) noctets)))) (if (and (plusp max) (> new max)) (loop-finish) (setq noctets new))) finally (return (values noctets i))))) (defmacro utf-16-combine-surrogate-pairs (u1 u2) `(the (unsigned-byte 21) (+ #x10000 (the (unsigned-byte 20) (logior (the (unsigned-byte 20) (ash (the (unsigned-byte 10) (- ,u1 #xd800)) 10)) (the (unsigned-byte 10) (- ,u2 #xdc00))))))) (define-character-encoding :utf-16 "A 16-bit, variable-length encoding in which characters with code points less than #x10000 can be encoded in a single 16-bit word and characters with larger codes can be encoded in a pair of 16-bit words. The endianness of the encoded data is indicated by the endianness of a byte-order-mark character (#\u+feff) prepended to the data; in the absence of such a character on input, the data is assumed to be in big-endian order. Output is written in native byte-order with a leading byte-order mark." :max-units-per-char 2 :code-unit-size 16 :native-endianness t ; not necessarily true when decoding :decode-literal-code-unit-limit #xd800 :encode-literal-code-unit-limit #x10000 :use-bom #+big-endian :utf-16be #+little-endian :utf-16le :bom-encoding #+big-endian #(#xfe #xff) #+little-endian #(#xff #xfe) :nul-encoding #(0 0) :default-replacement #xfffd) (define-octet-counter :utf-16 (getter type) `(utf16-octet-counter ,getter ,type)) (define-code-point-counter :utf-16 (getter type) `(lambda (seq start end max) (declare (type ,type seq) (fixnum start end max)) (let* ((swap (when (> end start) (case (,getter seq start 2) (#.+byte-order-mark-code+ (incf start 2) nil) (#.+swapped-byte-order-mark-code+ (incf start 2) t) (t #+little-endian t))))) (loop with count fixnum = 0 with i fixnum = start while (<= i (- end 2)) do (let* ((code (if swap (,getter seq i 2 :re) (,getter seq i 2))) (next-i (+ i (if (or (< code #xd800) (>= code #xdc00)) 2 4)))) (declare (type (unsigned-byte 16) code) (fixnum next-i)) (cond ((> next-i end) (decoding-error (vector (,getter seq i) (,getter seq (1+ i))) :utf-16 seq i nil 'end-of-input-in-character) (return (values count i))) (t (setq i next-i count (1+ count)) (when (and (plusp max) (= count max)) (return (values count i)))))) finally (progn (assert (= i end)) (return (values count i))))))) (define-encoder :utf-16 (getter src-type setter dest-type) `(lambda (src start end dest d-start) (declare (type ,src-type src) (type ,dest-type dest) (fixnum start end d-start)) (loop with di fixnum = d-start for i fixnum from start below end for code of-type code-point = (,getter src i) for high-bits fixnum = (- code #x10000) do (cond ((< high-bits 0) (,setter code dest di 2) (incf di 2)) (t (,setter (logior #xd800 (f-ash high-bits -10)) dest di 2) (,setter (logior #xdc00 (f-logand high-bits #x3ff)) dest (+ di 2) 2) (incf di 4))) finally (return (the fixnum (- di d-start)))))) (define-decoder :utf-16 (getter src-type setter dest-type) `(lambda (src start end dest d-start) (declare (type ,src-type src) (type ,dest-type dest) (fixnum start end d-start)) (let ((swap (when (> end start) (case (,getter src start 2) (#.+byte-order-mark-code+ (incf start 2) nil) (#.+swapped-byte-order-mark-code+ (incf start 2) t) (t #+little-endian t))))) (loop with i fixnum = start for di fixnum from d-start until (= i end) do (let ((u1 (if swap (,getter src i 2 :re) (,getter src i 2)))) (declare (type (unsigned-byte 16) u1)) (incf i 2) (,setter (cond ((or (< u1 #xd800) (>= u1 #xe000)) ; 2 octets u1) ((< u1 #xdc00) ; 4 octets (let ((u2 (if swap (,getter src i 2 :re) (,getter src i 2)))) (declare (type (unsigned-byte 16) u2)) (incf i 2) (if (and (>= u2 #xdc00) (< u2 #xe000)) (utf-16-combine-surrogate-pairs u1 u2) (decoding-error (vector (,getter src (- i 4)) (,getter src (- i 3)) (,getter src (- i 2)) (,getter src (- i 1))) :utf-16 src i +repl+)))) (t (decoding-error (vector (,getter src (- i 2)) (,getter src (- i 1))) :utf-16 src i +repl+))) dest di)) finally (return (the fixnum (- di d-start))))))) ;;;; UTF-32 (defmacro utf32-octet-counter (getter type) (declare (ignore getter type)) `(lambda (seq start end max) (declare (ignore seq) (fixnum start end max)) ;; XXX: the result can be bigger than a fixnum and we don't want ;; that to happen. Possible solution: signal a warning (hmm, ;; make that an actual error) and truncate. (if (plusp max) (let ((count (the fixnum (min (floor max 4) (- end start))))) (values (the fixnum (* 4 count)) (the fixnum (+ start count)))) (values (the fixnum (* 4 (the fixnum (- end start)))) end)))) (define-character-encoding :utf-32 "A 32-bit, fixed-length encoding in which all Unicode characters can be encoded in a single 32-bit word. The endianness of the encoded data is indicated by the endianness of a byte-order-mark character (#\u+feff) prepended to the data; in the absence of such a character on input, input data is assumed to be in big-endian order. Output is written in native byte order with a leading byte-order mark." :max-units-per-char 1 :code-unit-size 32 :native-endianness t ; not necessarily true when decoding :literal-char-code-limit #x110000 :use-bom #+little-endian :utf-32le #+big-endian :utf-32be :bom-encoding #+big-endian #(#x00 #x00 #xfe #xff) #+little-endian #(#xff #xfe #x00 #x00) :nul-encoding #(0 0 0 0)) (define-octet-counter :utf-32 (getter type) `(utf32-octet-counter ,getter ,type)) (define-code-point-counter :utf-32 (getter type) `(lambda (seq start end max) (declare (type ,type seq) (fixnum start end max)) ;; check for bom (when (and (/= start end) (case (,getter seq 0 4) ((#.+byte-order-mark-code+ #.+swapped-byte-order-mark-code-32+) t))) (incf start 4)) (multiple-value-bind (count rem) (floor (- end start) 4) (cond ((and (plusp max) (> count max)) (values max (the fixnum (+ start (* 4 max))))) (t ;; check for incomplete last character (unless (zerop rem) (let ((vector (make-array 4 :fill-pointer 0))) (dotimes (i rem) (vector-push (,getter seq (+ i (- end rem))) vector)) (decoding-error vector :utf-32 seq (the fixnum (- end rem)) nil 'end-of-input-in-character) (decf end rem))) (values count end)))))) (define-encoder :utf-32 (getter src-type setter dest-type) `(lambda (src start end dest d-start) (declare (type ,src-type src) (type ,dest-type dest) (fixnum start end d-start)) (loop for i fixnum from start below end for di fixnum from d-start by 4 do (,setter (,getter src i) dest di 4) finally (return (the fixnum (- di d-start)))))) (define-decoder :utf-32 (getter src-type setter dest-type) `(lambda (src start end dest d-start) (declare (type ,src-type src) (type ,dest-type dest) (fixnum start end d-start)) (let ((reverse #+big-endian nil #+little-endian t)) (when (not (zerop (- end start))) (case (,getter src 0 4) (#.+byte-order-mark-code+ (incf start 4) #+little-endian (setq reverse nil)) (#.+swapped-byte-order-mark-code-32+ (incf start 4) #+big-endian (setq reverse t)))) (loop for i fixnum from start below end by 4 for di from d-start do (,setter (let ((unit (if reverse (,getter src i 4 :re) (,getter src i 4)))) (if (>= unit #x110000) (decoding-error (vector (,getter src i) (,getter src (+ i 1)) (,getter src (+ i 2)) (,getter src (+ i 3))) :utf-32 src i +repl+ 'character-out-of-range) unit)) dest di) finally (return (the fixnum (- di d-start)))))))
34,709
Common Lisp
.lisp
697
33.58967
80
0.480354
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ca5cce4c11b689537f76384493f08bc06a7ea443268e3bed8ced252b360ef7f4
21,681
[ 143428 ]
21,682
packages.lisp
rheaplex_minara/lib/babel/src/packages.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; package.lisp --- Package definition for Babel ;;; ;;; Copyright (C) 2007, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. (in-package #:cl-user) (defpackage #:babel-encodings (:use #:common-lisp #:alexandria) (:export ;; character encoding objects #:list-character-encodings #:character-encoding #:*default-character-encoding* #:get-character-encoding #:enc-name #:enc-aliases #:enc-code-unit-size #:enc-max-units-per-char #:enc-native-endianness #:enc-decode-literal-code-unit-limit #:enc-encode-literal-code-unit-limit #:enc-use-bom #:enc-bom-encoding #:enc-nul-encoding #:enc-default-replacement ;; concrete mappings #:instantiate-concrete-mappings #:encoder #:decoder #:octet-counter #:code-point-counter #:lookup-mapping #:with-simple-vector #:with-checked-simple-vector #:*suppress-character-coding-errors* ;; errors #:character-coding-error #:character-coding-error-encoding ; accessor #:character-coding-error-buffer ; accessor #:character-coding-error-position ; accessor #:character-decoding-error #:character-decoding-error-octets ; accessor #:character-encoding-error #:character-encoding-error-code ; accessor #:end-of-input-in-character #:character-out-of-range #:invalid-utf8-starter-byte #:invalid-utf8-continuation-byte #:overlong-utf8-sequence)) (defpackage #:babel (:use #:common-lisp #:babel-encodings #:alexandria) (:import-from #:babel-encodings) (:export ;; types #:unicode-char #:unicode-char-code-limit #:unicode-string #:simple-unicode-string ;; fixed sharp-backslash reader #:enable-sharp-backslash-syntax #:set-sharp-backslash-syntax-in-readtable ;; external formats #:external-format #:make-external-format #:ensure-external-format #:external-format-encoding #:external-format-eol-style #:external-format-equal #:*default-eol-style* ;; general user API #:*default-character-encoding* #:list-character-encodings #:string-to-octets #:octets-to-string #:concatenate-strings-to-octets #:string-size-in-octets #:vector-size-in-chars ;; errors #:character-coding-error #:character-coding-error-encoding ; accessor #:character-coding-error-buffer ; accessor #:character-coding-error-position ; accessor #:character-decoding-error #:character-decoding-error-octets ; accessor #:character-encoding-error #:character-encoding-error-code ; accessor #:end-of-input-in-character #:character-out-of-range #:invalid-utf8-starter-byte #:invalid-utf8-continuation-byte #:overlong-utf8-sequence))
3,845
Common Lisp
.lisp
111
31.414414
70
0.723667
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
8a6dd2e6a99bfc750c5bb022b92eb26b09373a20263596fd0f5b015292d54579
21,682
[ 400372 ]
21,683
tests.lisp
rheaplex_minara/lib/babel/tests/tests.lisp
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; tests.lisp --- Unit and regression tests for Babel. ;;; ;;; Copyright (C) 2007-2008, Luis Oliveira <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. (in-package #:cl-user) (defpackage #:babel-tests (:use #:common-lisp #:babel #:babel-encodings #:stefil)) (in-package #:babel-tests) (defun run-tests () (funcall-test-with-feedback-message 'babel-tests)) (in-root-suite) (defsuite* babel-tests) (defun ub8v (&rest contents) (make-array (length contents) :element-type '(unsigned-byte 8) :initial-contents contents)) (defun make-ub8-vector (size) (make-array size :element-type '(unsigned-byte 8) :initial-element 0)) (defmacro returns (form &rest values) "Asserts, through EQUALP, that FORM returns VALUES." `(is (equalp (multiple-value-list ,form) (list ,@values)))) (defmacro defstest (name form &body return-values) "Similar to RT's DEFTEST." `(deftest ,name () (returns ,form ,@(mapcar (lambda (x) `',x) return-values)))) (defun fail (control-string &rest arguments) (stefil::record-failure 'stefil::failed-assertion :format-control control-string :format-arguments arguments)) (defun expected (expected &key got) (fail "expected ~A, got ~A instead" expected got)) (enable-sharp-backslash-syntax) ;;;; Simple tests using ASCII (defstest enc.ascii.1 (string-to-octets "abc" :encoding :ascii) #(97 98 99)) (defstest enc.ascii.2 (string-to-octets (string #\uED) :encoding :ascii :errorp nil) #(#x1a)) (deftest enc.ascii.3 () (handler-case (string-to-octets (string #\uED) :encoding :ascii :errorp t) (character-encoding-error (c) (is (eql 0 (character-coding-error-position c))) (is (eq :ascii (character-coding-error-encoding c))) (is (eql #xed (character-encoding-error-code c)))) (:no-error (result) (expected 'character-encoding-error :got result)))) (defstest dec.ascii.1 (octets-to-string (ub8v 97 98 99) :encoding :ascii) "abc") (deftest dec.ascii.2 () (handler-case (octets-to-string (ub8v 97 128 99) :encoding :ascii :errorp t) (character-decoding-error (c) (is (equalp #(128) (character-decoding-error-octets c))) (is (eql 1 (character-coding-error-position c))) (is (eq :ascii (character-coding-error-encoding c)))) (:no-error (result) (expected 'character-decoding-error :got result)))) (defstest dec.ascii.3 (octets-to-string (ub8v 97 255 98 99) :encoding :ascii :errorp nil) #(#\a #\Sub #\b #\c)) (defstest oct-count.ascii.1 (string-size-in-octets "abc" :encoding :ascii) 3 3) (defstest char-count.ascii.1 (vector-size-in-chars (ub8v 97 98 99) :encoding :ascii) 3 3) ;;;; UTF-8 (defstest char-count.utf-8.1 ;; "ni hao" in hanzi with the last octet missing (vector-size-in-chars (ub8v 228 189 160 229 165) :errorp nil) 2 5) (deftest char-count.utf-8.2 () ;; same as above with the last 2 octets missing (handler-case (vector-size-in-chars (ub8v 228 189 160 229) :errorp t) (end-of-input-in-character (c) (is (equalp #(229) (character-decoding-error-octets c))) (is (eql 3 (character-coding-error-position c))) (is (eq :utf-8 (character-coding-error-encoding c)))) (:no-error (result) (expected 'end-of-input-in-character :got result)))) ;;; Lispworks bug? ;; #+lispworks ;; (pushnew 'dec.utf-8.1 rtest::*expected-failures*) (defstest dec.utf-8.1 (octets-to-string (ub8v 228 189 160 229) :errorp nil) #(#\u4f60 #\ufffd)) (deftest dec.utf-8.2 () (handler-case (octets-to-string (ub8v 228 189 160 229) :errorp t) (end-of-input-in-character (c) (is (equalp #(229) (character-decoding-error-octets c))) (is (eql 3 (character-coding-error-position c))) (is (eq :utf-8 (character-coding-error-encoding c)))) (:no-error (result) (expected 'end-of-input-in-character :got result)))) ;;;; UTF-16 ;;; Test that the BOM is not being counted as a character. (deftest char-count.utf-16.bom () (is (eql (vector-size-in-chars (ub8v #xfe #xff #x00 #x55 #x00 #x54 #x00 #x46) :encoding :utf-16) 3)) (is (eql (vector-size-in-chars (ub8v #xff #xfe #x00 #x55 #x00 #x54 #x00 #x46) :encoding :utf-16) 3))) ;;;; UTF-32 ;;; RT: check that UTF-32 characters without a BOM are treated as ;;; little-endian. (deftest endianness.utf-32.no-bom () (is (string= "a" (octets-to-string (ub8v 0 0 0 97) :encoding :utf-32)))) ;;;; MORE TESTS (defparameter *standard-characters* "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!$\"'(),_-./:;?+<=>#%&*@[\\]{|}`^~") ;;; Testing consistency by encoding and decoding a simple string for ;;; all character encodings. (deftest rw-equiv.1 () (dolist (*default-character-encoding* (list-character-encodings)) (let ((octets (string-to-octets *standard-characters*))) (is (string= (octets-to-string octets) *standard-characters*))))) ;;; FIXME: assumes little-endianness. Easily fixable when we ;;; implement the BE and LE variants of :UTF-16. (deftest concatenate-strings-to-octets-equiv.1 () (let ((foo (octets-to-string (ub8v 102 195 186 195 186) :encoding :utf-8)) (bar (octets-to-string (ub8v 98 195 161 114) :encoding :utf-8))) ;; note: FOO and BAR are not ascii (is (equalp (concatenate-strings-to-octets :utf-8 foo bar) (ub8v 102 195 186 195 186 98 195 161 114))) (is (equalp (concatenate-strings-to-octets :utf-16 foo bar) (ub8v 102 0 250 0 250 0 98 0 225 0 114 0))))) ;;;; Testing against files generated by GNU iconv. (defun test-file (name type) (let ((sys-pn (truename (asdf:system-definition-pathname (asdf:find-system 'babel-tests))))) (make-pathname :name name :type type :directory (append (pathname-directory sys-pn) '("tests")) :defaults sys-pn))) (defun read-test-file (name type) (with-open-file (in (test-file name type) :element-type '(unsigned-byte 8)) (let* ((data (loop for byte = (read-byte in nil nil) until (null byte) collect byte))) (make-array (length data) :element-type '(unsigned-byte 8) :initial-contents data)))) (deftest test-encoding (enc &optional input-enc-name) (let* ((*default-character-encoding* enc) (enc-name (string-downcase (symbol-name enc))) (utf8-octets (read-test-file enc-name "txt-utf8")) (foo-octets (read-test-file (or input-enc-name enc-name) "txt")) (utf8-string (octets-to-string utf8-octets :encoding :utf-8 :errorp t)) (foo-string (octets-to-string foo-octets :errorp t))) (is (string= utf8-string foo-string)) (is (= (length foo-string) (vector-size-in-chars foo-octets :errorp t))) (unless (member enc '(:utf-16 :utf-32)) ;; FIXME: skipping UTF-16 and UTF-32 because of the BOMs and ;; because the input might not be in native-endian order so the ;; comparison will fail there. (let ((new-octets (string-to-octets foo-string :errorp t))) (is (equalp new-octets foo-octets)) (is (eql (length foo-octets) (string-size-in-octets foo-string :errorp t))))))) (deftest iconv-test () (dolist (enc '(:ascii :ebcdic-us :utf-8 :utf-16 :utf-32)) (case enc (:utf-16 (test-encoding :utf-16 "utf-16-with-le-bom")) (:utf-32 (test-encoding :utf-32 "utf-32-with-le-bom"))) (test-encoding enc))) ;;; RT: accept encoding objects in LOOKUP-MAPPING etc. (defstest encoding-objects.1 (string-to-octets "abc" :encoding (get-character-encoding :ascii)) #(97 98 99)) (defmacro with-sharp-backslash-syntax (&body body) `(let ((*readtable* (copy-readtable *readtable*))) (set-sharp-backslash-syntax-in-readtable) ,@body)) (defstest sharp-backslash.1 (with-sharp-backslash-syntax (loop for string in '("#\\a" "#\\u" "#\\ued") collect (char-code (read-from-string string)))) (97 117 #xed)) (deftest sharp-backslash.2 () (signals reader-error (with-sharp-backslash-syntax (read-from-string "#\\u12zz")))) ;;; RT: the slow implementation of with-simple-vector was buggy. (defstest string-to-octets.1 (code-char (aref (string-to-octets "abc" :start 1 :end 2) 0)) #\b) (defstest simple-base-string.1 (string-to-octets (coerce "abc" 'base-string) :encoding :ascii) #(97 98 99)) (defstest utf-8b.1 (string-to-octets (coerce #(#\a #\b #\udcf0) 'unicode-string) :encoding :utf-8b) #(97 98 #xf0)) (defstest utf-8b.2 (octets-to-string (ub8v 97 98 #xcd) :encoding :utf-8b) #(#\a #\b #\udccd)) (defstest utf-8b.3 (octets-to-string (ub8v 97 #xf0 #xf1 #xff #x01) :encoding :utf-8b) #(#\a #\udcf0 #\udcf1 #\udcff #\udc01)) (deftest utf-8b.4 () (let* ((octets (coerce (loop repeat 8192 collect (random (+ #x82))) '(array (unsigned-byte 8) (*)))) (string (octets-to-string octets :encoding :utf-8b))) (is (equalp octets (string-to-octets string :encoding :utf-8b))))) ;;; The following tests have been adapted from SBCL's ;;; tests/octets.pure.lisp file. (deftest ensure-roundtrip-ascii () (let ((octets (make-ub8-vector 128))) (dotimes (i 128) (setf (aref octets i) i)) (let* ((str (octets-to-string octets :encoding :ascii)) (oct2 (string-to-octets str :encoding :ascii))) (is (= (length octets) (length oct2))) (is (every #'= octets oct2))))) (deftest test-8bit-roundtrip (enc) (let ((octets (make-ub8-vector 256))) (dotimes (i 256) (setf (aref octets i) i)) (let* ((str (octets-to-string octets :encoding enc))) ;; remove the undefined code-points because they translate ;; to #xFFFD and string-to-octets raises an error when ;; encoding #xFFFD (multiple-value-bind (filtered-str filtered-octets) (let ((s (make-array 0 :element-type 'character :adjustable t :fill-pointer 0)) (o (make-array 0 :element-type '(unsigned-byte 16) :adjustable t :fill-pointer 0))) (loop for i below 256 for c = (aref str i) when (/= (char-code c) #xFFFD) do (vector-push-extend c s) (vector-push-extend (aref octets i) o)) (values s o)) (let ((oct2 (string-to-octets filtered-str :encoding enc))) (is (eql (length filtered-octets) (length oct2))) (is (every #'eql filtered-octets oct2))))))) (defparameter *iso-8859-charsets* '(:iso-8859-1 :iso-8859-2 :iso-8859-3 :iso-8859-4 :iso-8859-5 :iso-8859-6 :iso-8859-7 :iso-8859-8 :iso-8859-9 :iso-8859-10 :iso-8859-11 :iso-8859-13 :iso-8859-14 :iso-8859-15 :iso-8859-16)) ;;; Don't actually see what comes out, but there shouldn't be any ;;; errors. (deftest iso-8859-roundtrip-no-checking () (loop for enc in *iso-8859-charsets* do (test-8bit-roundtrip enc))) (deftest ensure-roundtrip-latin () (loop for enc in '(:latin1 :latin9) do (test-8bit-roundtrip enc))) ;;; Latin-9 chars; the previous test checked roundtrip from ;;; octets->char and back, now test that the latin-9 characters did in ;;; fact appear during that trip. (deftest ensure-roundtrip-latin9 () (let ((l9c (map 'string #'code-char '(8364 352 353 381 382 338 339 376)))) (is (string= (octets-to-string (string-to-octets l9c :encoding :latin9) :encoding :latin9) l9c)))) (deftest test-unicode-roundtrip (enc) (let ((string (make-string unicode-char-code-limit))) (dotimes (i unicode-char-code-limit) (setf (char string i) (code-char i))) (let ((string2 (octets-to-string (string-to-octets string :encoding enc :errorp t) :encoding enc :errorp t))) (is (eql (length string2) (length string))) (is (string= string string2))))) (deftest ensure-roundtrip.utf8 () (test-unicode-roundtrip :utf-8)) (deftest ensure-roundtrip.utf32 () (test-unicode-roundtrip :utf-32)) #+sbcl (progn (deftest test-encode-against-sbcl (enc) (let ((string (make-string unicode-char-code-limit))) (dotimes (i unicode-char-code-limit) (setf (char string i) (code-char i))) (loop for ch across string for babel = (string-to-octets (string ch) :encoding enc) for sbcl = (sb-ext:string-to-octets (string ch) :external-format enc) do (is (equalp babel sbcl))))) ;; not run automatically because it's a bit slow (1114112 assertions) (deftest (test-encode-against-sbcl.utf-8 :auto-call nil) () (test-encode-against-sbcl :utf-8))) (deftest non-ascii-bytes () (let ((octets (make-array 128 :element-type '(unsigned-byte 8) :initial-contents (loop for i from 128 below 256 collect i)))) (is (string= (octets-to-string octets :encoding :ascii :errorp nil) (make-string 128 :initial-element #\Sub))))) (deftest non-ascii-chars () (let ((string (make-array 128 :element-type 'character :initial-contents (loop for i from 128 below 256 collect (code-char i))))) (is (equalp (string-to-octets string :encoding :ascii :errorp nil) (make-array 128 :initial-element (char-code #\Sub)))))) ;;; The following UTF-8 decoding tests are adapted from ;;; <http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt>. (deftest utf8-decode-test (octets expected-results expected-errors) (let ((string (octets-to-string (coerce octets '(vector (unsigned-byte 8) *)) :encoding :utf-8 :errorp nil))) (is (string= expected-results string)) (is (= (count #\ufffd string) expected-errors)))) (deftest utf8-decode-tests (octets expected-results) (let ((expected-errors (count #\? expected-results)) (expected-results (substitute #\ufffd #\? expected-results))) (utf8-decode-test octets expected-results expected-errors) (utf8-decode-test (concatenate 'vector '(34) octets '(34)) (format nil "\"~A\"" expected-results) expected-errors))) (deftest utf8-too-big-characters () (utf8-decode-tests #(#xf4 #x90 #x80 #x80) "?") ; #x110000 (utf8-decode-tests #(#xf7 #xbf #xbf #xbf) "?") ; #x1fffff (utf8-decode-tests #(#xf8 #x88 #x80 #x80 #x80) "?") ; #x200000 (utf8-decode-tests #(#xfb #xbf #xbf #xbf #xbf) "?") ; #x3ffffff (utf8-decode-tests #(#xfc #x84 #x80 #x80 #x80 #x80) "?") ; #x4000000e (utf8-decode-tests #(#xfd #xbf #xbf #xbf #xbf #xbf) "?")) ; #x7fffffff (deftest utf8-unexpected-continuation-bytes () (utf8-decode-tests #(#x80) "?") (utf8-decode-tests #(#xbf) "?") (utf8-decode-tests #(#x80 #xbf) "??") (utf8-decode-tests #(#x80 #xbf #x80) "???") (utf8-decode-tests #(#x80 #xbf #x80 #xbf) "????") (utf8-decode-tests #(#x80 #xbf #x80 #xbf #x80) "?????") (utf8-decode-tests #(#x80 #xbf #x80 #xbf #x80 #xbf) "??????") (utf8-decode-tests #(#x80 #xbf #x80 #xbf #x80 #xbf #x80) "???????")) ;;; All 64 continuation bytes in a row. (deftest utf8-continuation-bytes () (apply #'utf8-decode-tests (loop for i from #x80 to #xbf collect i into bytes collect #\? into chars finally (return (list bytes (coerce chars 'string)))))) (deftest utf8-lonely-start-characters () (flet ((lsc (first last) (apply #'utf8-decode-tests (loop for i from first to last nconc (list i 32) into bytes nconc (list #\? #\Space) into chars finally (return (list bytes (coerce chars 'string))))) (apply #'utf8-decode-tests (loop for i from first to last collect i into bytes collect #\? into chars finally (return (list bytes (coerce chars 'string))))))) (lsc #xc0 #xdf) ; 2-byte sequence start chars (lsc #xe0 #xef) ; 3-byte (lsc #xf0 #xf7) ; 4-byte (lsc #xf8 #xfb) ; 5-byte (lsc #xfc #xfd))) ; 6-byte ;;; Otherwise incomplete sequences (last continuation byte missing) (deftest utf8-incomplete-sequences () (utf8-decode-tests #0=#(#xc0) "?") (utf8-decode-tests #1=#(#xe0 #x80) "?") (utf8-decode-tests #2=#(#xf0 #x80 #x80) "?") (utf8-decode-tests #3=#(#xf8 #x80 #x80 #x80) "?") (utf8-decode-tests #4=#(#xfc #x80 #x80 #x80 #x80) "?") (utf8-decode-tests #5=#(#xdf) "?") (utf8-decode-tests #6=#(#xef #xbf) "?") (utf8-decode-tests #7=#(#xf7 #xbf #xbf) "?") (utf8-decode-tests #8=#(#xfb #xbf #xbf #xbf) "?") (utf8-decode-tests #9=#(#xfd #xbf #xbf #xbf #xbf) "?") ;; All ten previous tests concatenated (utf8-decode-tests (concatenate 'vector #0# #1# #2# #3# #4# #5# #6# #7# #8# #9#) "??????????")) (deftest utf8-random-impossible-bytes () (utf8-decode-tests #(#xfe) "?") (utf8-decode-tests #(#xff) "?") (utf8-decode-tests #(#xfe #xfe #xff #xff) "????")) (deftest utf8-overlong-sequences-/ () (utf8-decode-tests #(#xc0 #xaf) "?") (utf8-decode-tests #(#xe0 #x80 #xaf) "?") (utf8-decode-tests #(#xf0 #x80 #x80 #xaf) "?") (utf8-decode-tests #(#xf8 #x80 #x80 #x80 #xaf) "?") (utf8-decode-tests #(#xfc #x80 #x80 #x80 #x80 #xaf) "?")) (deftest utf8-overlong-sequences-rubout () (utf8-decode-tests #(#xc1 #xbf) "?") (utf8-decode-tests #(#xe0 #x9f #xbf) "?") (utf8-decode-tests #(#xf0 #x8f #xbf #xbf) "?") (utf8-decode-tests #(#xf8 #x87 #xbf #xbf #xbf) "?") (utf8-decode-tests #(#xfc #x83 #xbf #xbf #xbf #xbf) "?")) (deftest utf8-overlong-sequences-null () (utf8-decode-tests #(#xc0 #x80) "?") (utf8-decode-tests #(#xe0 #x80 #x80) "?") (utf8-decode-tests #(#xf0 #x80 #x80 #x80) "?") (utf8-decode-tests #(#xf8 #x80 #x80 #x80 #x80) "?") (utf8-decode-tests #(#xfc #x80 #x80 #x80 #x80 #x80) "?")) ;;; End of adapted SBCL tests. ;;; A list of the ISO-8859 encodings where each element is a cons with ;;; the car being a keyword denoting the encoding and the cdr being a ;;; vector enumerating the corresponding character codes. ;;; ;;; It was auto-generated from files which can be found at ;;; <ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/>. ;;; ;;; Taken from flexi-streams. (defparameter *iso-8859-tables* '((:iso-8859-1 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255)) (:iso-8859-2 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 260 728 321 164 317 346 167 168 352 350 356 377 173 381 379 176 261 731 322 180 318 347 711 184 353 351 357 378 733 382 380 340 193 194 258 196 313 262 199 268 201 280 203 282 205 206 270 272 323 327 211 212 336 214 215 344 366 218 368 220 221 354 223 341 225 226 259 228 314 263 231 269 233 281 235 283 237 238 271 273 324 328 243 244 337 246 247 345 367 250 369 252 253 355 729)) (:iso-8859-3 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 294 728 163 164 65533 292 167 168 304 350 286 308 173 65533 379 176 295 178 179 180 181 293 183 184 305 351 287 309 189 65533 380 192 193 194 65533 196 266 264 199 200 201 202 203 204 205 206 207 65533 209 210 211 212 288 214 215 284 217 218 219 220 364 348 223 224 225 226 65533 228 267 265 231 232 233 234 235 236 237 238 239 65533 241 242 243 244 289 246 247 285 249 250 251 252 365 349 729)) (:iso-8859-4 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 260 312 342 164 296 315 167 168 352 274 290 358 173 381 175 176 261 731 343 180 297 316 711 184 353 275 291 359 330 382 331 256 193 194 195 196 197 198 302 268 201 280 203 278 205 206 298 272 325 332 310 212 213 214 215 216 370 218 219 220 360 362 223 257 225 226 227 228 229 230 303 269 233 281 235 279 237 238 299 273 326 333 311 244 245 246 247 248 371 250 251 252 361 363 729)) (:iso-8859-5 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 173 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 8470 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 167 1118 1119)) (:iso-8859-6 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 65533 65533 65533 164 65533 65533 65533 65533 65533 65533 65533 1548 173 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 1563 65533 65533 65533 1567 65533 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 65533 65533 65533 65533 65533 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533)) (:iso-8859-7 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 8216 8217 163 8364 8367 166 167 168 169 890 171 172 173 65533 8213 176 177 178 179 900 901 902 183 904 905 906 187 908 189 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 65533 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 65533)) (:iso-8859-8 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 65533 162 163 164 165 166 167 168 169 215 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 247 187 188 189 190 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 65533 8215 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 65533 65533 8206 8207 65533)) (:iso-8859-9 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 286 209 210 211 212 213 214 215 216 217 218 219 220 304 350 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 287 241 242 243 244 245 246 247 248 249 250 251 252 305 351 255)) (:iso-8859-10 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 260 274 290 298 296 310 167 315 272 352 358 381 173 362 330 176 261 275 291 299 297 311 183 316 273 353 359 382 8213 363 331 256 193 194 195 196 197 198 302 268 201 280 203 278 205 206 207 208 325 332 211 212 213 214 360 216 370 218 219 220 221 222 223 257 225 226 227 228 229 230 303 269 233 281 235 279 237 238 239 240 326 333 243 244 245 246 361 248 371 250 251 252 253 254 312)) (:iso-8859-11 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 65533 65533 65533 65533 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 65533 65533 65533 65533)) (:iso-8859-13 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 8221 162 163 164 8222 166 167 216 169 342 171 172 173 174 198 176 177 178 179 8220 181 182 183 248 185 343 187 188 189 190 230 260 302 256 262 196 197 280 274 268 201 377 278 290 310 298 315 352 323 325 211 332 213 214 215 370 321 346 362 220 379 381 223 261 303 257 263 228 229 281 275 269 233 378 279 291 311 299 316 353 324 326 243 333 245 246 247 371 322 347 363 252 380 382 8217)) (:iso-8859-14 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 7682 7683 163 266 267 7690 167 7808 169 7810 7691 7922 173 174 376 7710 7711 288 289 7744 7745 182 7766 7809 7767 7811 7776 7923 7812 7813 7777 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 372 209 210 211 212 213 214 7786 216 217 218 219 220 221 374 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 373 241 242 243 244 245 246 7787 248 249 250 251 252 253 375 255)) (:iso-8859-15 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 8364 165 352 167 353 169 170 171 172 173 174 175 176 177 178 179 381 181 182 183 382 185 186 187 338 339 376 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255)) (:iso-8859-16 . #(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 260 261 321 8364 8222 352 167 353 169 536 171 377 173 378 379 176 177 268 322 381 8221 182 183 382 269 537 187 338 339 376 380 192 193 194 258 196 262 198 199 200 201 202 203 204 205 206 207 272 323 210 211 212 336 214 346 368 217 218 219 220 280 538 223 224 225 226 259 228 263 230 231 232 233 234 235 236 237 238 239 273 324 242 243 244 337 246 347 369 249 250 251 252 281 539 255)))) (deftest iso-8859-decode-check () (loop for enc in *iso-8859-charsets* for octets = (let ((octets (make-ub8-vector 256))) (dotimes (i 256 octets) (setf (aref octets i) i))) for string = (octets-to-string octets :encoding enc) do (is (equalp (map 'vector #'char-code string) (cdr (assoc enc *iso-8859-tables*)))))) (deftest character-out-of-range.utf-32 () (signals character-out-of-range (octets-to-string (ub8v 0 0 #xfe #xff 0 #x11 0 0) :encoding :utf-32 :errorp t)))
36,737
Common Lisp
.lisp
658
48.50304
101
0.636341
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
cf17e2a7dd70c1bc9cba310273289dedd1c864a4408a01c24b1958af6fbf256d
21,683
[ 295604 ]
21,686
flexichain-package.lisp
rheaplex_minara/lib/flexichain/flexichain-package.lisp
;;; Flexichain ;;; Package definition ;;; ;;; Copyright (C) 2003-2004 Robert Strandh ([email protected]) ;;; Copyright (C) 2003-2004 Matthieu Villeneuve ([email protected]) ;;; ;;; THIS LIBRARY IS FREE software; you can redistribute it and/or ;;; modify it under the terms of the GNU Lesser General Public ;;; License as published by the Free Software Foundation; either ;;; version 2.1 of the License, or (at your option) any later version. ;;; ;;; This library is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Lesser General Public License for more details. ;;; ;;; You should have received a copy of the GNU Lesser General Public ;;; License along with this library; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (defpackage :flexichain (:use :common-lisp) (:export #:flexichain #:standard-flexichain #:flexi-error #:flexi-initialization-error #:flexi-position-error #:flexi-incompatible-type-error #:nb-elements #:flexi-empty-p #:insert* #:insert-vector* #:element* #:delete* #:push-start #:pop-start #:push-end #:pop-end #:rotate #:cursorchain #:standard-cursorchain #:flexicursor #:standard-flexicursor #:left-sticky-flexicursor #:right-sticky-flexicursor #:chain #:clone-cursor #:cursor-pos #:at-beginning-error #:at-end-error #:at-beginning-p #:at-end-p #:move> #:move< #:insert #:insert-sequence #:element< #:element> #:delete< #:delete> #:flexirank-mixin #:element-rank-mixin #:rank #:flexi-first-p #:flexi-last-p #:flexi-next #:flexi-prev))
1,772
Common Lisp
.lisp
40
40.775
78
0.706189
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
5605b38cd93b57924354f083674d2d404b30c5e482c40db2e4477a70b6215b48
21,686
[ -1 ]
21,687
flexichain.lisp
rheaplex_minara/lib/flexichain/flexichain.lisp
;;; Flexichain ;;; Flexichain data structure definition ;;; ;;; Copyright (C) 2003-2004 Robert Strandh ([email protected]) ;;; Copyright (C) 2003-2004 Matthieu Villeneuve ([email protected]) ;;; ;;; This library is free software; you can redistribute it and/or ;;; modify it under the terms of the GNU Lesser General Public ;;; License as published by the Free Software Foundation; either ;;; version 2.1 of the License, or (at your option) any later version. ;;; ;;; This library is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Lesser General Public License for more details. ;;; ;;; You should have received a copy of the GNU Lesser General Public ;;; License along with this library; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (in-package :flexichain) (defclass flexichain () ((element-type :initarg :element-type :initform t) (fill-element :initarg :fill-element) (expand-factor :initarg :expand-factor :initform 1.5) (min-size :initarg :min-size :initform 5)) (:documentation "The protocol class for flexichains.")) (defmethod initialize-instance :after ((chain flexichain) &rest initargs &key initial-contents) (declare (ignore initargs initial-contents)) (with-slots (expand-factor min-size) chain (assert (> expand-factor 1) () 'flexichain-initialization-error :cause "EXPAND-FACTOR should be greater than 1.") (assert (> min-size 0) () 'flexichain-initialization-error :cause "MIN-SIZE should be greater than 0.")) (if (slot-boundp chain 'fill-element) (with-slots (element-type fill-element) chain (assert (typep fill-element element-type) () 'flexichain-initialization-error :cause (format nil "FILL-ELEMENT ~A not of type ~S." fill-element element-type))) (multiple-value-bind (element foundp) (find-if-2 (lambda (x) (typep x (slot-value chain 'element-type))) '(nil 0 #\a)) (if foundp (setf (slot-value chain 'fill-element) element) (error 'flexichain-initialization-error :cause "FILL-ELEMENT not provided, no default applicable."))))) (define-condition flexi-error (simple-error) ()) (define-condition flexi-initialization-error (flexi-error) ((cause :reader flexi-initialization-error-cause :initarg :cause :initform "")) (:report (lambda (condition stream) (format stream "Error initializing FLEXICHAIN (~S)" (flexi-initialization-error-cause condition))))) (define-condition flexi-position-error (flexi-error) ((chain :reader flexi-position-error-chain :initarg :chain :initform nil) (position :reader flexi-position-error-position :initarg :position :initform nil)) (:report (lambda (condition stream) (format stream "Position ~D out of bounds in ~A" (flexi-position-error-position condition) (flexi-position-error-chain condition))))) (define-condition flexi-incompatible-type-error (flexi-error) ((chain :reader flexi-incompatible-type-error-chain :initarg :chain :initform nil) (element :reader flexi-incompatible-type-error-element :initarg :element :initform nil)) (:report (lambda (condition stream) (let ((element (flexi-incompatible-type-error-element condition))) (format stream "Element ~A of type ~A cannot be inserted in ~A" element (type-of element) (flexi-incompatible-type-error-chain condition)))))) (defgeneric nb-elements (chain) (:documentation "Returns the number of elements in the flexichain.")) (defgeneric flexi-empty-p (chain) (:documentation "Checks whether CHAIN is empty or not.")) (defgeneric insert* (chain position object) (:documentation "Inserts an object before the element at POSITION in the chain. If POSITION is out of range (less than 0 or greater than the length of CHAIN, the FLEXI-POSITION-ERROR condition will be signaled.")) (defgeneric insert-vector* (chain position vector) (:documentation "Inserts the elements of VECTOR before the element at POSITION in the chain. If POSITION is out of range (less than 0 or greater than the length of CHAIN, the FLEXI-POSITION-ERROR condition will be signaled.")) (defgeneric delete* (chain position) (:documentation "Deletes an element at POSITION of the chain. If POSITION is out of range (less than 0 or greater than or equal to the length of CHAIN, the FLEXI-POSITION-ERROR condition will be signaled.")) (defgeneric element* (chain position) (:documentation "Returns the element at POSITION of the chain. If POSITION is out of range (less than 0 or greater than or equal to the length of CHAIN, the FLEXI-POSITION-ERROR condition will be signaled.")) (defgeneric (setf element*) (object chain position) (:documentation "Replaces the element at POSITION of CHAIN by OBJECT. If POSITION if out of range (less than 0 or greater than or equal to the length of CHAIN, the FLEXI-POSITION-ERROR condition will be signaled.")) (defgeneric push-start (chain object) (:documentation "Inserts an object at the beginning of CHAIN.")) (defgeneric push-end (chain object) (:documentation "Inserts an object at the end of CHAIN.")) (defgeneric pop-start (chain) (:documentation "Pops and returns the element at the beginning of CHAIN.")) (defgeneric pop-end (chain) (:documentation "Pops and returns the element at the end of CHAIN.")) (defgeneric rotate (chain &optional n) (:documentation "Rotates the elements of CHAIN so that the element that used to be at position N is now at position 0. With a negative value of N, rotates the elements so that the element that used to be at position 0 is now at position N.")) (defclass standard-flexichain (flexichain) ((buffer) (gap-start) (gap-end) (data-start)) (:documentation "The standard instantiable subclass of FLEXICHAIN.")) (defun required-space (chain nb-elements) (with-slots (min-size expand-factor) chain (+ 2 (max (ceiling (* nb-elements expand-factor)) min-size)))) (defmethod initialize-instance :after ((chain standard-flexichain) &rest initargs &key initial-contents (initial-nb-elements 0) (initial-element nil)) (declare (ignore initargs)) ;; Check initial-contents if provided (unless (null initial-contents) (with-slots (element-type) chain (multiple-value-bind (offending-element foundp) (find-if-2 (lambda (x) (not (typep x element-type))) initial-contents) (assert (not foundp) () 'flexi-initialization-error :cause (format nil "Initial element ~A not of type ~S." offending-element element-type))))) ;; Initialize slots (with-slots (element-type fill-element buffer) chain (let* ((data-length (if (> (length initial-contents) initial-nb-elements) (length initial-contents) initial-nb-elements)) (size (required-space chain data-length)) (fill-size (- size data-length 2)) (sentinel-list (make-list 2 :initial-element fill-element)) (fill-list (make-list fill-size :initial-element fill-element))) (setf buffer (if initial-contents (make-array size :element-type element-type :initial-contents (concatenate 'list sentinel-list initial-contents fill-list)) (let ((arr (make-array size :element-type element-type :initial-element initial-element))) (fill arr fill-element :end (length sentinel-list)) (fill arr fill-element :start (+ (length sentinel-list) initial-nb-elements) :end size)))) (with-slots (gap-start gap-end data-start) chain (setf gap-start (+ 2 data-length) gap-end 0 data-start 1))))) (defmacro with-virtual-gap ((bl ds gs ge) chain &body body) (let ((c (gensym))) `(let* ((,c ,chain) (,bl (length (slot-value ,c 'buffer))) (,ds (slot-value ,c 'data-start)) (,gs (slot-value ,c 'gap-start)) (,ge (slot-value ,c 'gap-end))) (declare (ignorable ,bl ,ds ,gs ,ge)) (when (< ,gs ,ds) (incf ,gs ,bl)) (when (< ,ge ,ds) (incf ,ge ,bl)) ,@body))) (defmethod nb-elements ((chain standard-flexichain)) (with-virtual-gap (bl ds gs ge) chain (- bl (- ge gs) 2))) (defmethod flexi-empty-p ((chain standard-flexichain)) (zerop (nb-elements chain))) (defun position-index (chain position) "Returns the (0 indexed) index of the POSITION-th element of the CHAIN in the buffer." (with-virtual-gap (bl ds gs ge) chain (let ((index (+ ds position 1))) (when (>= index gs) (incf index (- ge gs))) (when (>= index bl) (decf index bl)) index))) (defun index-position (chain index) "Returns the position corresponding to the INDEX in the CHAIN. Note: the result is undefined if INDEX is not the index of a valid element of the CHAIN." (with-virtual-gap (bl ds gs ge) chain (when (< index ds) (incf index bl)) (when (>= index ge) (decf index (- ge gs))) (- index ds 1))) (defun ensure-gap-position (chain position) (move-gap chain (position-index chain position))) (defun ensure-room (chain nb-elements) (with-slots (buffer) chain (when (> nb-elements (- (length buffer) 2)) (increase-buffer-size chain nb-elements)))) (defmethod insert* ((chain standard-flexichain) position object) (with-slots (element-type buffer gap-start) chain (assert (<= 0 position (nb-elements chain)) () 'flexi-position-error :chain chain :position position) (assert (typep object element-type) () 'flexi-incompatible-type-error :element object :chain chain) (ensure-gap-position chain position) (ensure-room chain (1+ (nb-elements chain))) (setf (aref buffer gap-start) object) (incf gap-start) (when (= gap-start (length buffer)) (setf gap-start 0)))) (defmethod insert-vector* ((chain standard-flexichain) position vector) (with-slots (element-type buffer gap-start) chain (assert (<= 0 position (nb-elements chain)) () 'flexi-position-error :chain chain :position position) (assert (subtypep (array-element-type vector) element-type) () 'flexi-incompatible-type-error :element vector :chain chain) (ensure-gap-position chain position) (ensure-room chain (+ (nb-elements chain) (length vector))) (loop for elem across vector do (setf (aref buffer gap-start) elem) (incf gap-start) (when (= gap-start (length buffer)) (setf gap-start 0))))) (defmethod delete* ((chain standard-flexichain) position) (with-slots (buffer expand-factor min-size fill-element gap-end) chain (assert (< -1 position (nb-elements chain)) () 'flexi-position-error :chain chain :position position) (ensure-gap-position chain position) (setf (aref buffer gap-end) fill-element) (incf gap-end) (when (= gap-end (length buffer)) (setf gap-end 0)) (when (and (> (length buffer) (+ min-size 2)) (< (+ (nb-elements chain) 2) (/ (length buffer) (square expand-factor)))) (decrease-buffer-size chain)))) (defmethod element* ((chain standard-flexichain) position) (with-slots (buffer) chain (assert (< -1 position (nb-elements chain)) () 'flexi-position-error :chain chain :position position) (aref buffer (position-index chain position)))) (defmethod (setf element*) (object (chain standard-flexichain) position) (with-slots (buffer element-type) chain (assert (< -1 position (nb-elements chain)) () 'flexi-position-error :chain chain :position position) (assert (typep object element-type) () 'flexi-incompatible-type-error :chain chain :element object) (setf (aref buffer (position-index chain position)) object))) (defmethod push-start ((chain standard-flexichain) object) (insert* chain 0 object)) (defmethod push-end ((chain standard-flexichain) object) (insert* chain (nb-elements chain) object)) (defmethod pop-start ((chain standard-flexichain)) (prog1 (element* chain 0) (delete* chain 0))) (defmethod pop-end ((chain standard-flexichain)) (let ((position (1- (nb-elements chain)))) (prog1 (element* chain position) (delete* chain position)))) (defmethod rotate ((chain standard-flexichain) &optional (n 1)) (when (> (nb-elements chain) 1) (cond ((plusp n) (loop repeat n do (push-start chain (pop-end chain)))) ((minusp n) (loop repeat (- n) do (push-end chain (pop-start chain)))) (t nil)))) (defun move-gap (chain hot-spot) "Moves the elements and gap inside the buffer so that the element currently at HOT-SPOT becomes the first element following the gap, or does nothing if there are no elements." (with-slots (gap-start gap-end) chain (unless (= hot-spot gap-end) (case (gap-location chain) (:gap-empty (move-empty-gap chain hot-spot)) (:gap-left (move-left-gap chain hot-spot)) (:gap-right (move-right-gap chain hot-spot)) (:gap-middle (move-middle-gap chain hot-spot)) (:gap-non-contiguous (move-non-contiguous-gap chain hot-spot)))) (values gap-start gap-end))) (defun move-empty-gap (chain hot-spot) "Moves the gap. Handles the case where the gap is empty." (with-slots (gap-start gap-end) chain (setf gap-start hot-spot gap-end hot-spot))) (defun move-left-gap (chain hot-spot) "Moves the gap. Handles the case where the gap is on the left of the buffer." (with-slots (buffer gap-start gap-end data-start) chain (let ((buffer-size (length buffer))) (cond ((< (- hot-spot gap-end) (- buffer-size hot-spot)) (push-elements-left chain (- hot-spot gap-end))) ((<= (- buffer-size hot-spot) gap-end) (hop-elements-left chain (- buffer-size hot-spot))) (t (hop-elements-left chain (- gap-end gap-start)) (push-elements-right chain (- gap-start hot-spot))))))) (defun move-right-gap (chain hot-spot) "Moves the gap. Handles the case where the gap is on the right of the buffer." (with-slots (buffer gap-start gap-end) chain (let ((buffer-size (length buffer))) (cond ((< (- gap-start hot-spot) hot-spot) (push-elements-right chain (- gap-start hot-spot))) ((<= hot-spot (- buffer-size gap-start)) (hop-elements-right chain hot-spot)) (t (hop-elements-right chain (- buffer-size gap-start)) (push-elements-left chain (- hot-spot gap-end))))))) (defun move-middle-gap (chain hot-spot) "Moves the gap. Handles the case where the gap is in the middle of the buffer." (with-slots (buffer gap-start gap-end) chain (let ((buffer-size (length buffer))) (cond ((< hot-spot gap-start) (cond ((<= (- gap-start hot-spot) (+ (- buffer-size gap-end) hot-spot)) (push-elements-right chain (- gap-start hot-spot))) (t (push-elements-left chain (- buffer-size gap-end)) (move-right-gap chain hot-spot)))) (t (cond ((< (- hot-spot gap-end) (+ (- buffer-size hot-spot) gap-start)) (push-elements-left chain (- hot-spot gap-end))) (t (push-elements-right chain gap-start) (move-left-gap chain hot-spot)))))))) (defun move-non-contiguous-gap (chain hot-spot) "Moves the gap. Handles the case where the gap is in 2 parts, on both ends of the buffer." (with-slots (buffer gap-start gap-end) chain (let ((buffer-size (length buffer))) (cond ((< (- hot-spot gap-end) (- gap-start hot-spot)) (hop-elements-right chain (min (- buffer-size gap-start) (- hot-spot gap-end))) (let ((nb-left (- hot-spot gap-end))) (unless (zerop nb-left) (push-elements-left chain nb-left)))) (t (hop-elements-left chain (min gap-end (- gap-start hot-spot))) (let ((nb-right (- gap-start hot-spot))) (unless (zerop nb-right) (push-elements-right chain nb-right)))))))) (defgeneric move-elements (standard-flexichain to from start1 start2 end2) (:documentation "move elements of a flexichain and adjust data-start")) (defmethod move-elements ((fc standard-flexichain) to from start1 start2 end2) (replace to from :start1 start1 :start2 start2 :end2 end2) (with-slots (data-start) fc (when (and (<= start2 data-start) (< data-start end2)) (incf data-start (- start1 start2))))) (defgeneric fill-gap (standard-flexichain start end) (:documentation "fill part of gap with the fill element")) (defmethod fill-gap ((fc standard-flexichain) start end) (with-slots (buffer fill-element) fc (fill buffer fill-element :start start :end end))) (defun push-elements-left (chain count) "Pushes the COUNT elements of CHAIN at the right of the gap, to the beginning of the gap. The gap must be continuous. Example: PUSH-ELEMENTS-LEFT abcd-----efghijklm 2 => abcdef-----ghijklm" (with-slots (buffer gap-start gap-end) chain (move-elements chain buffer buffer gap-start gap-end (+ gap-end count)) (fill-gap chain (max gap-end (+ gap-start count)) (+ gap-end count)) (incf gap-start count) (incf gap-end count) (normalize-indices chain))) (defun push-elements-right (chain count) "Pushes the COUNT elements of CHAIN at the left of the gap, to the end of the gap. The gap must be continuous. Example: PUSH-ELEMENTS-RIGHT abcd-----efghijklm 2 => ab-----cdefghijklm" (with-slots (buffer gap-start gap-end) chain (let* ((buffer-size (length buffer)) (rotated-gap-end (if (zerop gap-end) buffer-size gap-end))) (move-elements chain buffer buffer (- rotated-gap-end count) (- gap-start count) gap-start) (fill-gap chain (- gap-start count) (min gap-start (- rotated-gap-end count))) (decf gap-start count) (setf gap-end (- rotated-gap-end count)) (normalize-indices chain)))) (defun hop-elements-left (chain count) "Moves the COUNT rightmost elements to the end of the gap, on the left of the data. Example: HOP-ELEMENTS-LEFT ---abcdefghijklm--- 2 => -lmabcdefghijk-----" (with-slots (buffer gap-start gap-end) chain (let* ((buffer-size (length buffer)) (rotated-gap-start (if (zerop gap-start) buffer-size gap-start))) (move-elements chain buffer buffer (- gap-end count) (- rotated-gap-start count) rotated-gap-start) (fill-gap chain (- rotated-gap-start count) rotated-gap-start) (setf gap-start (- rotated-gap-start count)) (decf gap-end count) (normalize-indices chain)))) (defun hop-elements-right (chain count) "Moves the COUNT leftmost elements to the beginning of the gap, on the right of the data. Example: HOP-ELEMENTS-RIGHT ---abcdefghijklm--- 2 => -----cdefghijklmab-" (with-slots (buffer gap-start gap-end) chain (move-elements chain buffer buffer gap-start gap-end (+ gap-end count)) (fill-gap chain gap-end (+ gap-end count)) (incf gap-start count) (incf gap-end count) (normalize-indices chain))) (defun increase-buffer-size (chain nb-elements) (resize-buffer chain (required-space chain nb-elements))) (defun decrease-buffer-size (chain) (resize-buffer chain (required-space chain (nb-elements chain)))) (defgeneric resize-buffer (standard-flexichain new-buffer-size) (:documentation "allocate a new buffer with the size indicated")) (defmethod resize-buffer ((fc standard-flexichain) new-buffer-size) (with-slots (buffer gap-start gap-end fill-element element-type expand-factor) fc (let ((buffer-size (length buffer)) (buffer-after (make-array new-buffer-size :element-type element-type :initial-element fill-element))) (case (gap-location fc) ((:gap-empty :gap-middle) (move-elements fc buffer-after buffer 0 0 gap-start) (let ((gap-end-after (- new-buffer-size (- buffer-size gap-end)))) (move-elements fc buffer-after buffer gap-end-after gap-end buffer-size) (setf gap-end gap-end-after))) (:gap-right (move-elements fc buffer-after buffer 0 0 gap-start)) (:gap-left (let ((gap-end-after (- new-buffer-size (+ 2 (nb-elements fc))))) (move-elements fc buffer-after buffer gap-end-after gap-end buffer-size) (setf gap-end gap-end-after))) (:gap-non-contiguous (move-elements fc buffer-after buffer 0 gap-end gap-start) (decf gap-start gap-end) (setf gap-end 0))) (setf buffer buffer-after))) (normalize-indices fc)) (defun normalize-indices (chain) "Sets gap limits to 0 if they are at the end of the buffer." (with-slots (buffer gap-start gap-end data-start) chain (let ((buffer-size (length buffer))) (when (>= data-start buffer-size) (setf data-start 0)) (when (>= gap-start buffer-size) (setf gap-start 0)) (when (>= gap-end buffer-size) (setf gap-end 0))))) (defun gap-location (chain) "Returns a keyword indicating the general location of the gap." (with-slots (buffer gap-start gap-end) chain (cond ((= gap-start gap-end) :gap-empty) ((and (zerop gap-start) (>= gap-end 0)) :gap-left) ((and (zerop gap-end) (> gap-start 0)) :gap-right) ((> gap-end gap-start) :gap-middle) (t :gap-non-contiguous))))
22,789
Common Lisp
.lisp
468
40.65812
84
0.642254
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ea5012bf2cac38de0f7f39dcc5837cee564dff21f40be385bc3cb24e3c0b3f5d
21,687
[ -1 ]
21,688
tester.lisp
rheaplex_minara/lib/flexichain/tester.lisp
(in-package :tester) (define-application-frame tester () ((chain :initform (make-instance 'standard-cursorchain :element-type 'character :fill-element #\_) :reader chain) (cursors :initform (make-array 2) :reader cursors)) (:panes (app :application :width 800 :height 300 :display-function 'display-app) (int :interactor :width 800 :height 500)) (:layouts (default (vertically () app int)))) (defmethod initialize-instance :after ((frame tester) &rest args) (declare (ignore args)) (with-slots (chain cursors) frame (setf (aref cursors 0) (make-instance 'left-sticky-flexicursor :chain chain)) (setf (aref cursors 1) (make-instance 'right-sticky-flexicursor :chain chain)))) (defun run-tester () (loop for port in climi::*all-ports* do (destroy-port port)) (setq climi::*all-ports* nil) (run-frame-top-level (make-application-frame 'tester))) (defun display-app (frame pane) (let* ((chain (chain frame)) (buffer (slot-value chain 'flexichain::buffer)) (length (length buffer)) (cursors (cursors frame))) (format pane "nb elments: ~a~%~%" (nb-elements chain)) (loop for i from 0 below (nb-elements chain) do (format pane " ~a" (element* chain i))) (format pane "~%") (loop for i from 0 below 2 do (format pane (if (minusp (cursor-pos (aref cursors i))) (make-string (* -2 (cursor-pos (aref cursors i))) :initial-element #\?) (make-string (* 2 (cursor-pos (aref cursors i))) :initial-element #\space))) (format pane "~a~%" i)) (format pane "~%~%") (format pane (if (minusp (slot-value chain 'flexichain::gap-start)) (make-string (* -2 (slot-value chain 'flexichain::gap-start)) :initial-element #\?) (make-string (* 2 (slot-value chain 'flexichain::gap-start)) :initial-element #\space))) (format pane ">~%") (format pane (if (minusp (slot-value chain 'flexichain::gap-end)) (make-string (* -2 (slot-value chain 'flexichain::gap-end)) :initial-element #\?) (make-string (* 2 (slot-value chain 'flexichain::gap-end)) :initial-element #\space))) (format pane "<~%") (loop for i from 0 below length do (format pane "~a~a" (if (= i (slot-value chain 'flexichain::data-start)) #\* #\Space) (aref buffer i))) (format pane "~%") (loop for i from 0 below 2 do (format pane (make-string (1+ (* 2 (slot-value (aref cursors i) 'flexichain::index))) :initial-element #\space)) (format pane "~a~a~%" i (at-end-p (aref cursors i)))) (format pane "~%~%"))) (defmethod execute-frame-command :around ((frame tester) command) (declare (ignore command)) (handler-case (call-next-method) (flexi-error (condition) (format (frame-standard-input *application-frame*) "~a~%" condition)))) (define-tester-command (com-empty :name t) () (format (frame-standard-input *application-frame*) "~a~%" (flexi-empty-p (chain *application-frame*)))) (defun to-char (symbol) (char-downcase (aref (symbol-name symbol) 0))) (define-tester-command (com-is :name t) ((pos 'integer) (object 'symbol)) (insert* (chain *application-frame*) pos (to-char object))) (define-tester-command (com-element* :name t) ((pos 'integer)) (format (frame-standard-input *application-frame*) "~a~%" (element* (chain *application-frame*) pos))) (define-tester-command (com-set-element* :name t) ((pos 'integer) (object 'symbol)) (setf (element* (chain *application-frame*) pos) (to-char object))) (define-tester-command (com-ds :name t) ((pos 'integer)) (delete* (chain *application-frame*) pos)) (define-tester-command (com-push-start :name t) ((object 'symbol)) (push-start (chain *application-frame*) (to-char object))) (define-tester-command (com-push-end :name t) ((object 'symbol)) (push-end (chain *application-frame*) (to-char object))) (define-tester-command (com-pop-start :name t) () (format (frame-standard-input *application-frame*) "~a~%" (pop-start (chain *application-frame*)))) (define-tester-command (com-pop-end :name t) () (format (frame-standard-input *application-frame*) "~a~%" (pop-end (chain *application-frame*)))) (define-tester-command (com-rotate :name t) ((amount 'integer)) (rotate (chain *application-frame*) amount)) (define-tester-command (com-move> :name t) ((cursor 'integer)) (move> (aref (cursors *application-frame*) cursor))) (define-tester-command (com-move< :name t) ((cursor 'integer)) (move< (aref (cursors *application-frame*) cursor))) (define-tester-command (com-ii :name t) ((cursor 'integer) (object 'symbol)) (insert (aref (cursors *application-frame*) cursor) (to-char object))) (define-tester-command (com-d< :name t) ((cursor 'integer)) (delete< (aref (cursors *application-frame*) cursor))) (define-tester-command (com-d> :name t) ((cursor 'integer)) (delete> (aref (cursors *application-frame*) cursor))) (define-tester-command (com-clear :name t) () (with-slots (chain cursors) *application-frame* (setf chain (make-instance 'standard-cursorchain :element-type 'character :fill-element #\_)) (setf (aref cursors 0) (make-instance 'left-sticky-flexicursor :chain chain)) (setf (aref cursors 1) (make-instance 'right-sticky-flexicursor :chain chain)))) (define-tester-command (com-quit :name t) () (frame-exit *application-frame*))
5,420
Common Lisp
.lisp
115
42.721739
83
0.665846
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
537bd92b56be1f25918227b3ca0601dafd9ae03f480d13c9e917a546617033c4
21,688
[ 8381 ]
21,689
flexirank.lisp
rheaplex_minara/lib/flexichain/flexirank.lisp
;;; Ranked flexichain ;;; ;;; Copyright (C) 2005 Robert Strandh ([email protected]) ;;; ;;; This library is free software; you can redistribute it and/or ;;; modify it under the terms of the GNU Lesser General Public ;;; License as published by the Free Software Foundation; either ;;; version 2.1 of the License, or (at your option) any later version. ;;; ;;; This library is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Lesser General Public License for more details. ;;; ;;; You should have received a copy of the GNU Lesser General Public ;;; License along with this library; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (in-package :flexichain) ;;; A ranked flexichain is a flexichain (or a cursorchain) in which ;;; the elements know their position. To make that work, client code ;;; must use mix in the flexirank-mixin class into whatever flexichain ;;; class they are using, and mix in the element-rank-mixin class into ;;; elements of that chain. ;;; The element-rank-mixin supplies a method on the client-visible ;;; generic function rank. (defgeneric rank (element)) (defgeneric flexi-first-p (element)) (defgeneric flexi-last-p (element)) (defgeneric flexi-next (element)) (defgeneric flexi-prev (element)) (defclass element-rank-mixin () ((index :accessor index) (chain :accessor chain))) (defmethod rank ((element element-rank-mixin)) (index-position (chain element) (index element))) (defmethod flexi-first-p ((element element-rank-mixin)) (zerop (rank element))) (defmethod flexi-last-p ((element element-rank-mixin)) (= (rank element) (1- (nb-elements (chain element))))) (defmethod flexi-next ((element element-rank-mixin)) (assert (not (flexi-last-p element))) (element* (chain element) (1+ (rank element)))) (defmethod flexi-prev ((element element-rank-mixin)) (assert (not (flexi-first-p element))) (element* (chain element) (1- (rank element)))) ;;; this class must be mixed into a flexichain that contains ranked elements (defclass flexirank-mixin () ()) (defmethod move-elements :before ((chain flexirank-mixin) to from start1 start2 end2) (declare (ignore to)) (loop for old from start2 below end2 for new from start1 do (let ((element (aref from old))) (when (typep element 'element-rank-mixin) (setf (index element) new))))) (defmethod insert* :after ((chain flexirank-mixin) position (object element-rank-mixin)) (setf (index object) (position-index chain position) (chain object) chain)) (defmethod (setf element*) :after ((object element-rank-mixin) (chain flexirank-mixin) position) (setf (index object) (position-index chain position) (chain object) chain)) (defmethod insert-vector* :after ((chain flexirank-mixin) position vector) (loop for elem across vector for pos from position do (setf (index elem) (position-index chain pos) (chain elem) chain)))
3,068
Common Lisp
.lisp
65
45.138462
96
0.742972
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
976da63819fd381c1c5732beccb9815daf34dd01b00fbfe33b044e9af78b8e65
21,689
[ 340572 ]
21,690
stupid.lisp
rheaplex_minara/lib/flexichain/stupid.lisp
;;; this is a stupid implementation of the flexichain and flexicursor ;;; protocols. The idea is to use this as a reference implementation ;;; and test the other one by generating random operations issued to ;;; both implementations and compare the result. (defpackage :stupid (:use :common-lisp) (:export #:flexichain #:standard-flexichain #:flexi-error #:flexi-initialization-error #:flexi-position-error #:flexi-incompatible-type-error #:nb-elements #:flexi-empty-p #:insert* #:element* #:delete* #:push-start #:pop-start #:push-end #:pop-end #:rotate #:cursorchain #:standard-cursorchain #:flexicursor #:standard-flexicursor #:left-sticky-flexicursor #:right-sticky-flexicursor #:chain #:clone-cursor #:cursor-pos #:at-beginning-error #:at-end-error #:at-beginning-p #:at-end-p #:move> #:move< #:insert #:insert-sequence #:element< #:element> #:delete< #:delete>)) (in-package :stupid) (defclass flexichain () () (:documentation "The protocol class for flexichains.")) (define-condition flexi-error (simple-error) ()) (define-condition flexi-initialization-error (flexi-error) ((cause :reader flexi-initialization-error-cause :initarg :cause :initform "")) (:report (lambda (condition stream) (format stream "Error initializing FLEXICHAIN (~S)" (flexi-initialization-error-cause condition))))) (define-condition flexi-position-error (flexi-error) ((chain :reader flexi-position-error-chain :initarg :chain :initform nil) (position :reader flexi-position-error-position :initarg :position :initform nil)) (:report (lambda (condition stream) (format stream "Position ~D out of bounds in ~A" (flexi-position-error-position condition) (flexi-position-error-chain condition))))) (define-condition flexi-incompatible-type-error (flexi-error) ((chain :reader flexi-incompatible-type-error-chain :initarg :chain :initform nil) (element :reader flexi-incompatible-type-error-element :initarg :element :initform nil)) (:report (lambda (condition stream) (let ((element (flexi-incompatible-type-error-element condition))) (format stream "Element ~A of type ~A cannot be inserted in ~A" element (type-of element) (flexi-incompatible-type-error-chain condition)))))) (defgeneric nb-elements (chain) (:documentation "Returns the number of elements in the flexichain.")) (defgeneric flexi-empty-p (chain) (:documentation "Checks whether CHAIN is empty or not.")) (defgeneric insert* (chain position object) (:documentation "Inserts an object before the element at POSITION in the chain. If POSITION is out of range (less than 0 or greater than the length of CHAIN, the FLEXI-POSITION-ERROR condition will be signaled.")) (defgeneric delete* (chain position) (:documentation "Deletes an element at POSITION of the chain. If POSITION is out of range (less than 0 or greater than or equal to the length of CHAIN, the FLEXI-POSITION-ERROR condition will be signaled.")) (defgeneric element* (chain position) (:documentation "Returns the element at POSITION of the chain. If POSITION is out of range (less than 0 or greater than or equal to the length of CHAIN, the FLEXI-POSITION-ERROR condition will be signaled.")) (defgeneric (setf element*) (object chain position) (:documentation "Replaces the element at POSITION of CHAIN by OBJECT. If POSITION if out of range (less than 0 or greater than or equal to the length of CHAIN, the FLEXI-POSITION-ERROR condition will be signaled.")) (defgeneric push-start (chain object) (:documentation "Inserts an object at the beginning of CHAIN.")) (defgeneric push-end (chain object) (:documentation "Inserts an object at the end of CHAIN.")) (defgeneric pop-start (chain) (:documentation "Pops and returns the element at the beginning of CHAIN.")) (defgeneric pop-end (chain) (:documentation "Pops and returns the element at the end of CHAIN.")) (defgeneric rotate (chain &optional n) (:documentation "Rotates the elements of CHAIN so that the element that used to be at position N is now at position 0. With a negative value of N, rotates the elements so that the element that used to be at position 0 is now at position N.")) (defclass standard-flexichain (flexichain) ((elements :initform (list '()) :accessor elements))) (defmethod nb-elements ((chain standard-flexichain)) (/ (1- (length (elements chain))) 2)) (defmethod flexi-empty-p ((chain standard-flexichain)) (zerop (nb-elements chain))) (defmethod insert* ((chain standard-flexichain) position object) (assert (<= 0 position (nb-elements chain)) () 'flexi-position-error :chain chain :position position) (let* ((remainder (nthcdr (* 2 position) (elements chain)))) (push (remove-if-not (lambda (x) (typep x 'right-sticky-flexicursor)) (car remainder)) (cdr remainder)) (push object (cdr remainder)) (setf (car remainder) (remove-if (lambda (x) (typep x 'right-sticky-flexicursor)) (car remainder))))) (defmethod delete* ((chain standard-flexichain) position) (assert (< -1 position (nb-elements chain)) () 'flexi-position-error :chain chain :position position) (let* ((remainder (nthcdr (* 2 position) (elements chain)))) (pop (cdr remainder)) (setf (car remainder) (append (cadr remainder) (car remainder))) (pop (cdr remainder)))) (defmethod element* ((chain standard-flexichain) position) (assert (< -1 position (nb-elements chain)) () 'flexi-position-error :chain chain :position position) (nth (1+ (* 2 position)) (elements chain))) (defmethod (setf element*) (object (chain standard-flexichain) position) (assert (< -1 position (nb-elements chain)) () 'flexi-position-error :chain chain :position position) (setf (nth (1+ (* 2 position)) (elements chain)) object)) (defmethod push-start ((chain standard-flexichain) object) (insert* chain 0 object)) (defmethod push-end ((chain standard-flexichain) object) (insert* chain (nb-elements chain) object)) (defmethod pop-start ((chain standard-flexichain)) (prog1 (element* chain 0) (delete* chain 0))) (defmethod pop-end ((chain standard-flexichain)) (let ((position (1- (nb-elements chain)))) (prog1 (element* chain position) (delete* chain position)))) (defmethod rotate ((chain standard-flexichain) &optional (n 1)) (when (> (nb-elements chain) 1) (cond ((plusp n) (loop repeat n do (push-start chain (pop-end chain)))) ((minusp n) (loop repeat (- n) do (push-end chain (pop-start chain)))) (t nil)))) (defclass cursorchain (flexichain) () (:documentation "The protocol class for cursor chains.")) (defclass flexicursor () () (:documentation "The protocol class for flexicursors.")) (define-condition at-beginning-error (flexi-error) ((cursor :reader at-beginning-error-cursor :initarg :cursor :initform nil)) (:report (lambda (condition stream) (let ((cursor (at-beginning-error-cursor condition))) (format stream "Cursor ~A already at the beginning of ~A" cursor (chain cursor)))))) (define-condition at-end-error (flexi-error) ((cursor :reader at-end-error-cursor :initarg :cursor :initform nil)) (:report (lambda (condition stream) (let ((cursor (at-end-error-cursor condition))) (format stream "Cursor ~A already at the end of ~A" cursor (chain cursor)))))) (defgeneric clone-cursor (cursor) (:documentation "Creates a cursor that is initially at the same location as the one given as argument.")) (defgeneric cursor-pos (cursor) (:documentation "Returns the position of the cursor.")) (defgeneric (setf cursor-pos) (posistion cursor) (:documentation "Set the position of the cursor.")) (defgeneric at-beginning-p (cursor) (:documentation "Returns true if the cursor is at the beginning of the chain.")) (defgeneric at-end-p (cursor) (:documentation "Returns true if the cursor is at the beginning of the chain.")) (defgeneric move> (cursor &optional n) (:documentation "Moves the cursor forward N positions.")) (defgeneric move< (cursor &optional n) (:documentation "Moves the cursor backward N positions.")) (defgeneric insert (cursor object) (:documentation "Inserts an object at the cursor.")) (defgeneric insert-sequence (cursor sequence) (:documentation "The effect is the same as if each element of the sequence was inserted using INSERT.")) (defgeneric delete< (cursor &optional n) (:documentation "Deletes N objects before the cursor.")) (defgeneric delete> (cursor &optional n) (:documentation "Deletes N objects after the cursor.")) (defgeneric element< (cursor) (:documentation "Returns the element immediately before the cursor.")) (defgeneric (setf element<) (object cursor) (:documentation "Replaces the element immediately before the cursor.")) (defgeneric element> (cursor) (:documentation "Returns the element immediately after the cursor.")) (defgeneric (setf element>) (object cursor) (:documentation "Replaces the element immediately after the cursor.")) (defclass standard-cursorchain (cursorchain standard-flexichain) () (:documentation "The standard instantiable subclass of CURSORCHAIN")) (defclass standard-flexicursor (flexicursor) ((chain :reader chain :initarg :chain)) (:documentation "The standard instantiable subclass of FLEXICURSOR")) (defmethod initialize-instance :after ((cursor standard-flexicursor) &rest args &key (position 0)) (declare (ignore args)) (push cursor (car (nthcdr (* 2 position) (elements (chain cursor)))))) (defclass left-sticky-flexicursor (standard-flexicursor) ()) (defclass right-sticky-flexicursor (standard-flexicursor) ()) (defmethod cursor-pos ((cursor standard-flexicursor)) (loop for sublist on (elements (chain cursor)) by #'cddr for pos from 0 when (member cursor (car sublist) :test #'eq) do (return pos))) (defun sublist-of-cursor (cursor) (nthcdr (* 2 (cursor-pos cursor)) (elements (chain cursor)))) (defmethod clone-cursor ((cursor standard-flexicursor)) (make-instance (class-of cursor) :chain (chain cursor) :position (cursor-pos cursor))) (defmethod (setf cursor-pos) (position (cursor standard-flexicursor)) (assert (<= 0 position (nb-elements (chain cursor))) () 'flexi-position-error :chain (chain cursor) :position position) (let ((sublist1 (sublist-of-cursor cursor)) (sublist2 (nthcdr (* 2 position) (elements (chain cursor))))) (setf (car sublist1) (remove cursor (car sublist1) :test #'eq)) (push cursor (car sublist2)))) (defmethod at-beginning-p ((cursor standard-flexicursor)) (zerop (cursor-pos cursor))) (defmethod at-end-p ((cursor standard-flexicursor)) (= (cursor-pos cursor) (nb-elements (chain cursor)))) (defmethod move> ((cursor standard-flexicursor) &optional (n 1)) (incf (cursor-pos cursor) n)) (defmethod move< ((cursor standard-flexicursor) &optional (n 1)) (decf (cursor-pos cursor) n)) (defmethod insert ((cursor standard-flexicursor) object) (insert* (chain cursor) (cursor-pos cursor) object)) (defmethod insert-sequence ((cursor standard-flexicursor) sequence) (map nil (lambda (object) (insert cursor object)) sequence)) (defmethod delete> ((cursor standard-flexicursor) &optional (n 1)) (let ((chain (chain cursor)) (position (cursor-pos cursor))) (assert (plusp n) () 'flexi-position-error :chain chain :position n) (loop repeat n do (delete* chain position)))) (defmethod delete< ((cursor standard-flexicursor) &optional (n 1)) (let ((chain (chain cursor)) (position (cursor-pos cursor))) (assert (plusp n) () 'flexi-position-error :chain chain :position n) (loop repeat n do (delete* chain (- position n))))) (defmethod element> ((cursor standard-flexicursor)) (assert (not (at-end-p cursor)) () 'at-end-error :cursor cursor) (element* (chain cursor) (cursor-pos cursor))) (defmethod (setf element>) (object (cursor standard-flexicursor)) (assert (not (at-end-p cursor)) () 'at-end-error :cursor cursor) (setf (element* (chain cursor) (cursor-pos cursor)) object)) (defmethod element< ((cursor standard-flexicursor)) (assert (not (at-beginning-p cursor)) () 'at-beginning-error :cursor cursor) (element* (chain cursor) (1- (cursor-pos cursor)))) (defmethod (setf element<) (object (cursor standard-flexicursor)) (assert (not (at-beginning-p cursor)) () 'at-beginning-error :cursor cursor) (setf (element* (chain cursor) (1- (cursor-pos cursor))) object))
12,911
Common Lisp
.lisp
269
43.297398
90
0.706729
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
2384c19b2051ba87d930a7093e1ade5d9f9405e2c5b4cffbf8ca831a3b36f0ef
21,690
[ 343945 ]
21,691
utilities.lisp
rheaplex_minara/lib/flexichain/utilities.lisp
;;; Flexichain ;;; Utility functions ;;; ;;; Copyright (C) 2003-2004 Robert Strandh ([email protected]) ;;; Copyright (C) 2003-2004 Matthieu Villeneuve ([email protected]) ;;; ;;; This library is free software; you can redistribute it and/or ;;; modify it under the terms of the GNU Lesser General Public ;;; License as published by the Free Software Foundation; either ;;; version 2.1 of the License, or (at your option) any later version. ;;; ;;; This library is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Lesser General Public License for more details. ;;; ;;; You should have received a copy of the GNU Lesser General Public ;;; License along with this library; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (in-package :flexichain) (defun square (x) "Returns the square of the number X." (* x x)) (defun find-if-2 (predicate sequence) "Searches the sequence for an element that satisfies PREDICATE. Returns the element found or NIL of none was found, and a boolean indicating whether an element was found or not." (let ((position (position-if predicate sequence))) (if (null position) (values nil nil) (values (elt sequence position) t)))) ;;;; Weak pointers #+:openmcl (defvar *weak-pointers* (make-hash-table :test 'eq :weak :value) "Weak value hash-table mapping between pseudo weak pointers and its values.") #+:openmcl (defstruct (weak-pointer (:constructor %make-weak-pointer))) (defun make-weak-pointer (object) "Creates a new weak pointer which points to OBJECT. For portability reasons, OBJECT most not be NIL." (assert (not (null object))) #+:sbcl (sb-ext:make-weak-pointer object) #+:cmu (ext:make-weak-pointer object) #+:clisp (ext:make-weak-pointer object) #+:allegro (let ((wv (excl:weak-vector 1))) (setf (svref wv 0) object) wv) #+:openmcl (let ((wp (%make-weak-pointer))) (setf (gethash wp *weak-pointers*) object) wp) #+:corman (ccl:make-weak-pointer object) #+:lispworks (let ((array (make-array 1))) (hcl:set-array-weak array t) (setf (svref array 0) object) array) #-(or :sbcl :cmu :clisp :allegro :openmcl :corman :lispworks) object) (defun weak-pointer-value (weak-pointer) "If WEAK-POINTER is valid, returns its value. Otherwise, returns NIL." #+:sbcl (prog1 (sb-ext:weak-pointer-value weak-pointer)) #+:cmu (prog1 (ext:weak-pointer-value weak-pointer)) #+:clisp (prog1 (ext:weak-pointer-value weak-pointer)) #+:allegro (svref weak-pointer 0) #+:openmcl (prog1 (gethash weak-pointer *weak-pointers*)) #+:corman (ccl:weak-pointer-obj weak-pointer) #+:lispworks (svref weak-pointer 0) #-(or :sbcl :cmu :clisp :allegro :openmcl :corman :lispworks) weak-pointer) #-(or :sbcl :cmu :clisp :allegro :openmcl :corman :lispworks) (eval-when (:compile-toplevel :load-toplevel :execute) (warn "No support for weak pointers in this implementation. ~ Things may get big and slow."))
3,151
Common Lisp
.lisp
75
39.28
79
0.718526
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
4108285c8025d128c3e69619b2b9cb31dc073158513315cad7c5adb7c25b9148
21,691
[ 110869 ]
21,692
skiplist-package.lisp
rheaplex_minara/lib/flexichain/skiplist-package.lisp
;;; Skiplist ;;; Package definition ;;; ;;; Copyright (C) 2004 Robert Strandh ([email protected]) ;;; ;;; THIS LIBRARY IS FREE software; you can redistribute it and/or ;;; modify it under the terms of the GNU Lesser General Public ;;; License as published by the Free Software Foundation; either ;;; version 2.1 of the License, or (at your option) any later version. ;;; ;;; This library is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Lesser General Public License for more details. ;;; ;;; You should have received a copy of the GNU Lesser General Public ;;; License along with this library; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (defpackage :skiplist (:use :common-lisp) (:export #:skiplist #:skiplist-find #:skiplist-find-first #:skiplist-delete #:skiplist-slide-keys #:skiplist-rotate-prefix #:skiplist-rotate-suffix))
1,071
Common Lisp
.lisp
27
37.555556
75
0.737044
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
4e9b5161ff3880eadfd28fb8c88f7d2d40bac14d250eb1ea029b3ba3e3c694ff
21,692
[ 433576 ]
21,693
flexicursor.lisp
rheaplex_minara/lib/flexichain/flexicursor.lisp
;;; Flexichain ;;; Flexicursor data structure definition ;;; ;;; Copyright (C) 2003-2004 Robert Strandh ([email protected]) ;;; Copyright (C) 2003-2004 Matthieu Villeneuve ([email protected]) ;;; ;;; This library is free software; you can redistribute it and/or ;;; modify it under the terms of the GNU Lesser General Public ;;; License as published by the Free Software Foundation; either ;;; version 2.1 of the License, or (at your option) any later version. ;;; ;;; This library is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Lesser General Public License for more details. ;;; ;;; You should have received a copy of the GNU Lesser General Public ;;; License along with this library; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (in-package :flexichain) (defclass cursorchain (flexichain) () (:documentation "The protocol class for cursor chains.")) (defclass flexicursor () () (:documentation "The protocol class for flexicursors.")) (define-condition at-beginning-error (flexi-error) ((cursor :reader at-beginning-error-cursor :initarg :cursor :initform nil)) (:report (lambda (condition stream) (let ((cursor (at-beginning-error-cursor condition))) (format stream "Cursor ~A already at the beginning of ~A" cursor (chain cursor)))))) (define-condition at-end-error (flexi-error) ((cursor :reader at-end-error-cursor :initarg :cursor :initform nil)) (:report (lambda (condition stream) (let ((cursor (at-end-error-cursor condition))) (format stream "Cursor ~A already at the end of ~A" cursor (chain cursor)))))) (defgeneric clone-cursor (cursor) (:documentation "Creates a cursor that is initially at the same location as the one given as argument.")) (defgeneric cursor-pos (cursor) (:documentation "Returns the position of the cursor.")) (defgeneric (setf cursor-pos) (posistion cursor) (:documentation "Set the position of the cursor.")) (defgeneric at-beginning-p (cursor) (:documentation "Returns true if the cursor is at the beginning of the chain.")) (defgeneric at-end-p (cursor) (:documentation "Returns true if the cursor is at the beginning of the chain.")) (defgeneric move> (cursor &optional n) (:documentation "Moves the cursor forward N positions.")) (defgeneric move< (cursor &optional n) (:documentation "Moves the cursor backward N positions.")) (defgeneric insert (cursor object) (:documentation "Inserts an object at the cursor.")) (defgeneric insert-sequence (cursor sequence) (:documentation "The effect is the same as if each element of the sequence was inserted using INSERT.")) (defgeneric delete< (cursor &optional n) (:documentation "Deletes N objects before the cursor.")) (defgeneric delete> (cursor &optional n) (:documentation "Deletes N objects after the cursor.")) (defgeneric element< (cursor) (:documentation "Returns the element immediately before the cursor.")) (defgeneric (setf element<) (object cursor) (:documentation "Replaces the element immediately before the cursor.")) (defgeneric element> (cursor) (:documentation "Returns the element immediately after the cursor.")) (defgeneric (setf element>) (object cursor) (:documentation "Replaces the element immediately after the cursor.")) (defclass standard-cursorchain (cursorchain standard-flexichain) ((cursors :initform '())) (:documentation "The standard instantiable subclass of CURSORCHAIN")) (defclass standard-flexicursor (flexicursor) ((chain :reader chain :initarg :chain) (index :accessor flexicursor-index)) (:documentation "The standard instantiable subclass of FLEXICURSOR")) (defclass left-sticky-flexicursor (standard-flexicursor) ()) (defclass right-sticky-flexicursor (standard-flexicursor) ()) (defmethod initialize-instance :after ((cursor left-sticky-flexicursor) &rest initargs &key (position 0)) (declare (ignore initargs)) (with-slots (index chain) cursor (setf index (position-index chain (1- position))) (with-slots (cursors) chain (push (make-weak-pointer cursor) cursors)))) (defmethod initialize-instance :after ((cursor right-sticky-flexicursor) &rest initargs &key (position 0)) (declare (ignore initargs)) (with-slots (index chain) cursor (setf index (position-index chain position)) (with-slots (cursors) chain (push (make-weak-pointer cursor) cursors)))) (defun adjust-cursors (cursors start end increment) (let ((acc '())) (loop for cursor = (and cursors (weak-pointer-value (car cursors))) while cursors do (cond ((null cursor) (pop cursors)) ((<= start (flexicursor-index cursor) end) (incf (flexicursor-index cursor) increment) (let ((rest (cdr cursors))) (setf (cdr cursors) acc acc cursors cursors rest))) (t (let ((rest (cdr cursors))) (setf (cdr cursors) acc acc cursors cursors rest))))) acc)) (defmethod move-elements :after ((cc standard-cursorchain) to from start1 start2 end2) (declare (ignore to from)) (with-slots (cursors) cc (setf cursors (adjust-cursors cursors start2 (1- end2) (- start1 start2))))) (defmethod clone-cursor ((cursor standard-flexicursor)) (make-instance (class-of cursor) :chain (chain cursor) :position (cursor-pos cursor))) (defmethod cursor-pos ((cursor left-sticky-flexicursor)) (1+ (index-position (chain cursor) (slot-value cursor 'index)))) (defmethod (setf cursor-pos) (position (cursor left-sticky-flexicursor)) (assert (<= 0 position (nb-elements (chain cursor))) () 'flexi-position-error :chain (chain cursor) :position position) (with-slots (chain index) cursor (with-slots (cursors) chain (setf index (position-index chain (1- position)))))) (defmethod cursor-pos ((cursor right-sticky-flexicursor)) (index-position (chain cursor) (slot-value cursor 'index))) (defmethod (setf cursor-pos) (position (cursor right-sticky-flexicursor)) (assert (<= 0 position (nb-elements (chain cursor))) () 'flexi-position-error :chain (chain cursor) :position position) (with-slots (chain index) cursor (with-slots (cursors) chain (setf index (position-index chain position))))) (defmethod at-beginning-p ((cursor standard-flexicursor)) (zerop (cursor-pos cursor))) (defmethod at-end-p ((cursor standard-flexicursor)) (= (cursor-pos cursor) (nb-elements (chain cursor)))) (defmethod insert ((cursor standard-flexicursor) object) (insert* (chain cursor) (cursor-pos cursor) object)) (defmethod insert-sequence ((cursor standard-flexicursor) sequence) (map nil (lambda (object) (insert cursor object)) sequence)) (defmethod delete* :before ((chain standard-cursorchain) position) (with-slots (cursors) chain (let* ((old-index (position-index chain position))) (loop for cursor-wp in cursors as cursor = (weak-pointer-value cursor-wp) when (and cursor (= old-index (flexicursor-index cursor))) do (typecase cursor (right-sticky-flexicursor (incf (cursor-pos cursor))) (left-sticky-flexicursor (decf (cursor-pos cursor)))))))) (defmethod delete> ((cursor standard-flexicursor) &optional (n 1)) (let ((chain (chain cursor)) (position (cursor-pos cursor))) (assert (plusp n) () 'flexi-position-error :chain chain :position n) (loop repeat n do (delete* chain position)))) (defmethod delete< ((cursor standard-flexicursor) &optional (n 1)) (let ((chain (chain cursor)) (position (cursor-pos cursor))) (assert (plusp n) () 'flexi-position-error :chain chain :position n) (loop repeat n do (delete* chain (- position n))))) (defmethod element> ((cursor standard-flexicursor)) (assert (not (at-end-p cursor)) () 'at-end-error :cursor cursor) (element* (chain cursor) (cursor-pos cursor))) (defmethod (setf element>) (object (cursor standard-flexicursor)) (assert (not (at-end-p cursor)) () 'at-end-error :cursor cursor) (setf (element* (chain cursor) (cursor-pos cursor)) object)) (defmethod element< ((cursor standard-flexicursor)) (assert (not (at-beginning-p cursor)) () 'at-beginning-error :cursor cursor) (element* (chain cursor) (1- (cursor-pos cursor)))) (defmethod (setf element<) (object (cursor standard-flexicursor)) (assert (not (at-beginning-p cursor)) () 'at-beginning-error :cursor cursor) (setf (element* (chain cursor) (1- (cursor-pos cursor))) object))
8,806
Common Lisp
.lisp
194
41
86
0.708499
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
50346a06a64df827e70933f644f96631060f7ef3652a6750f2913edd95afb642
21,693
[ -1 ]
21,694
rtester.lisp
rheaplex_minara/lib/flexichain/rtester.lisp
(defparameter *instructions* '()) (defparameter *ins-del-state* t) (defparameter *cursors-real* '()) (defparameter *cursors-fake* '()) (defparameter *fc-real* (make-instance 'flexichain:standard-cursorchain)) (defparameter *fc-fake* (make-instance 'stupid:standard-cursorchain)) ;; nb-elements fch ;; element* fch pos ;; cursor-pos fcu ;; element< fcu ;; element> fcu ;; insert* fch pos obj ;; delete* fch pos ;; (setf element*) ;; clone-cursor fcu ;; (setf cursor-pos) ;; insert fcu obj ;; delete< fcu ;; delete> fcu ;; (setf element<) ;; (setf element>) ;; [flexi-empty-p fch] ;; [push-start fch obj] ;; [push-end fch obj] ;; [pop-start fch obj] ;; [pop-end fch obj] ;; [rotate fch &optional (n 1)] ;; [at-beginning-p fcu] ;; [at-end-p fcu] ;; [insert-sequence fcu sequence] (defun compare () ;; check that they are the same length (assert (= (flexichain:nb-elements *fc-real*) (stupid:nb-elements *fc-fake*))) ;; check that they have the same elements in the same places (loop for pos from 0 below (flexichain:nb-elements *fc-real*) do (assert (= (flexichain:element* *fc-real* pos) (stupid:element* *fc-fake* pos)))) ;; check all the cursors (loop for x in *cursors-real* for y in *cursors-fake* do (assert (= (flexichain:cursor-pos x) (stupid:cursor-pos y))) (unless (zerop (flexichain:cursor-pos x)) (assert (= (flexichain:element< x) (stupid:element< y)))) (unless (= (flexichain:cursor-pos x) (flexichain:nb-elements *fc-real*)) (assert (= (flexichain:element> x) (stupid:element> y)))))) (defun add-inst (inst) (push inst *instructions*)) (defun i* (&optional (pos (random (1+ (stupid:nb-elements *fc-fake*)))) (elem (random 1000000))) (add-inst `(i* ,pos ,elem)) (flexichain:insert* *fc-real* pos elem) (stupid:insert* *fc-fake* pos elem)) (defun d* (&optional pos) (unless (zerop (stupid:nb-elements *fc-fake*)) (unless pos (setf pos (random (stupid:nb-elements *fc-fake*)))) (add-inst `(d* ,pos)) (flexichain:delete* *fc-real* pos) (stupid:delete* *fc-fake* pos))) (defun se* (&optional pos elem) (unless (zerop (stupid:nb-elements *fc-fake*)) (unless pos (setf pos (random (stupid:nb-elements *fc-fake*)) elem (random 1000000))) (add-inst `(se* ,pos ,elem)) (setf (flexichain:element* *fc-real* pos) elem) (setf (stupid:element* *fc-fake* pos) elem))) (defun mlc () (add-inst `(mlc)) (push (make-instance 'flexichain:left-sticky-flexicursor :chain *fc-real*) *cursors-real*) (push (make-instance 'stupid:left-sticky-flexicursor :chain *fc-fake*) *cursors-fake*)) (defun mrc () (add-inst `(mrc)) (push (make-instance 'flexichain:right-sticky-flexicursor :chain *fc-real*) *cursors-real*) (push (make-instance 'stupid:right-sticky-flexicursor :chain *fc-fake*) *cursors-fake*)) (defun cc (&optional (elt (random (length *cursors-real*)))) (add-inst `(cc ,elt)) (push (flexichain:clone-cursor (elt *cursors-real* elt)) *cursors-real*) (push (stupid:clone-cursor (elt *cursors-fake* elt)) *cursors-fake*)) (defun scp (&optional (elt (random (length *cursors-real*))) (pos (random (1+ (flexichain:nb-elements *fc-real*))))) (add-inst `(scp ,elt ,pos)) (setf (flexichain:cursor-pos (elt *cursors-real* elt)) pos) (setf (stupid:cursor-pos (elt *cursors-fake* elt)) pos)) (defun ii (&optional (elt (random (length *cursors-fake*))) (elem (random 1000000))) (add-inst `(ii ,elt ,elem)) (flexichain:insert (elt *cursors-real* elt) elem) (stupid:insert (elt *cursors-fake* elt) elem)) (defun d< (&optional (elt (random (length *cursors-real*)))) (unless (zerop (stupid:cursor-pos (elt *cursors-fake* elt))) (add-inst `(d< ,elt)) (flexichain:delete< (elt *cursors-real* elt)) (stupid:delete< (elt *cursors-fake* elt)))) (defun d> (&optional (elt (random (length *cursors-fake*)))) (unless (= (stupid:cursor-pos (elt *cursors-fake* elt)) (stupid:nb-elements (stupid:chain (elt *cursors-fake* elt)))) (add-inst `(d> ,elt)) (flexichain:delete> (elt *cursors-real* elt)) (stupid:delete> (elt *cursors-fake* elt)))) (defun s< (&optional (elt (random (length *cursors-real*))) (elem (random 1000000))) (unless (zerop (stupid:cursor-pos (elt *cursors-fake* elt))) (add-inst `(s< ,elt ,elem)) (setf (flexichain:element< (elt *cursors-real* elt)) elem) (setf (stupid:element< (elt *cursors-fake* elt)) elem))) (defun s> (&optional (elt (random (length *cursors-real*))) (elem (random 1000000))) (unless (= (stupid:cursor-pos (elt *cursors-fake* elt)) (stupid:nb-elements (stupid:chain (elt *cursors-fake* elt)))) (add-inst `(s> ,elt ,elem)) (setf (flexichain:element> (elt *cursors-real* elt)) elem) (setf (stupid:element> (elt *cursors-fake* elt)) elem))) (defmacro randomcase (&body clauses) `(ecase (random ,(length clauses)) ,@(loop for clause in clauses for i from 0 collect `(,i ,clause)))) (defun i-or-d () (if *ins-del-state* (randomcase (i*) (ii)) (randomcase (d*) (d<) (d>)))) (defun setel () (randomcase (se*) (s<) (s>))) (defun mc () (randomcase (mlc) (mrc))) (defun test-step () (when (zerop (random 200)) (setf *ins-del-state* (not *ins-del-state*))) (randomcase (i-or-d) (setel) (mc) (cc) (scp)) (compare)) (defun reset-all () (setf *instructions* '()) (setf *ins-del-state* t) (setf *cursors-real* '()) (setf *cursors-fake* '()) (setf *fc-real* (make-instance 'flexichain:standard-cursorchain)) (setf *fc-fake* (make-instance 'stupid:standard-cursorchain))) (defun tester (&optional (n 1)) (reset-all) (mlc) (mrc) (loop repeat n do (test-step))) (defun replay (instructions) (let ((*instructions* '())) (reset-all) (loop for inst in (reverse instructions) do (apply (car inst) (cdr inst)) (compare))))
5,925
Common Lisp
.lisp
164
32.597561
77
0.651085
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
c20b3fd72e7cce798cad2592030639b54ed248a05bcc0cf21b6e36f587e7046a
21,694
[ 343604 ]
21,695
skiplist.lisp
rheaplex_minara/lib/flexichain/skiplist.lisp
;;; Skiplist ;;; Skiplist data structure definition ;;; ;;; Copyright (C) 2004 Robert Strandh ([email protected]) ;;; ;;; This library is free software; you can redistribute it and/or ;;; modify it under the terms of the GNU Lesser General Public ;;; License as published by the Free Software Foundation; either ;;; version 2.1 of the License, or (at your option) any later version. ;;; ;;; This library is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Lesser General Public License for more details. ;;; ;;; You should have received a copy of the GNU Lesser General Public ;;; License along with this library; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (in-package :skiplist) (defclass skiplist () ((maxlevel :initarg :maxlevel :initform 25 :reader maxlevel) (start :reader start) (lessfun :initarg :lessfun :initform #'< :reader lessfun) (current-maxlevel :initform -1 :accessor current-maxlevel))) (defmethod initialize-instance :after ((s skiplist) &rest args) (declare (ignore args)) (with-slots (maxlevel start) s (assert (plusp maxlevel)) (setf start (make-array (+ maxlevel 3) :initial-element nil)))) (defmethod print-object ((s skiplist) stream) (print-unreadable-object (s stream :type t) (with-slots (start) s (when (entry-next start 0) (loop for entry = (entry-next start 0) then (entry-next entry 0) do (format stream "(~W ~W) " (entry-key entry) (entry-obj entry)) until (last-entry-p start entry 0)))))) (defun entry-obj (entry) (aref entry 0)) (defun (setf entry-obj) (obj entry) (setf (aref entry 0) obj)) (defun entry-key (entry) (aref entry 1)) (defun (setf entry-key) (key entry) (setf (aref entry 1) key)) (defun entry-next (entry level) (aref entry (+ level 2))) (defun (setf entry-next) (next entry level) (setf (aref entry (+ level 2)) next)) (defun key-< (skiplist key1 key2) (funcall (lessfun skiplist) key1 key2)) (defun key-<= (skiplist key1 key2) (not (funcall (lessfun skiplist) key2 key1))) (defun key-= (skiplist key1 key2) (and (not (funcall (lessfun skiplist) key1 key2)) (not (funcall (lessfun skiplist) key2 key1)))) (defun key-> (skiplist key1 key2) (funcall (lessfun skiplist) key2 key1)) (defun key->= (skiplist key1 key2) (not (funcall (lessfun skiplist) key1 key2))) (defun last-entry-p (start entry level) (eq (entry-next entry level) (entry-next start level))) (defun skiplist-empty-p (skiplist) (= (slot-value skiplist 'current-maxlevel) -1)) ;;; From a given entry return an entry such that the key of the ;;; following one is the smallest one greater than or equal to the key ;;; given; or the last element if no such element exists. (defun find-entry-level (skiplist entry level key) (with-slots (start) skiplist (loop until (or (key-= skiplist (entry-key (entry-next entry level)) key) (and (key-< skiplist (entry-key entry) key) (key-> skiplist (entry-key (entry-next entry level)) key)) (and (key-< skiplist (entry-key entry) key) (key-< skiplist (entry-key (entry-next entry level)) key) (last-entry-p start entry level) (eq (entry-next entry level) (entry-next start level))) (and (key-> skiplist (entry-key entry) key) (key-> skiplist (entry-key (entry-next entry level)) key) (last-entry-p start entry level))) do (setf entry (entry-next entry level)))) entry) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Find (defun skiplist-find (skiplist key) (when (skiplist-empty-p skiplist) (return-from skiplist-find (values nil nil))) (with-slots (current-maxlevel start) skiplist (let ((entry (entry-next start current-maxlevel))) (loop for l downfrom current-maxlevel to 0 do (setf entry (find-entry-level skiplist entry l key))) (if (key-= skiplist (entry-key (entry-next entry 0)) key) (values (entry-obj (entry-next entry 0)) t) (values nil nil))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Find first (defun skiplist-find-first (skiplist) (assert (not (skiplist-empty-p skiplist))) (with-slots (start) skiplist (values (entry-obj (entry-next start 0)) (entry-key (entry-next start 0))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Insert (defun pick-a-level (maxlevel) (loop for level from 0 to maxlevel while (zerop (random 2)) finally (return level))) (defun make-entry (level key obj) (let ((entry (make-array (+ level 3) :initial-element nil))) (setf (aref entry 0) obj (aref entry 1) key) entry)) (defun (setf skiplist-find) (obj skiplist key) (with-slots (current-maxlevel start) skiplist (if (second (multiple-value-list (skiplist-find skiplist key))) (let ((entry (entry-next start current-maxlevel))) (loop for l downfrom current-maxlevel to 0 do (setf entry (find-entry-level skiplist entry l key))) (setf (entry-obj (entry-next entry 0)) obj)) (let* ((level (pick-a-level (maxlevel skiplist))) (new-entry (make-entry level key obj))) (loop for l downfrom level above current-maxlevel do (setf (entry-next start l) new-entry (entry-next new-entry l) new-entry)) (let ((entry (entry-next start current-maxlevel))) (loop for l downfrom current-maxlevel above level do (setf entry (find-entry-level skiplist entry l key))) (loop for l downfrom (min level current-maxlevel) to 0 do (setf entry (find-entry-level skiplist entry l key)) (setf (entry-next new-entry l) (entry-next entry l) (entry-next entry l) new-entry) (when (key-< skiplist key (entry-key entry)) (setf (entry-next start l) new-entry)))) (setf current-maxlevel (max current-maxlevel level))))) skiplist) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Delete (defun skiplist-delete (skiplist key) (assert (second (multiple-value-list (skiplist-find skiplist key)))) (with-slots (current-maxlevel start) skiplist (let ((entry (entry-next start current-maxlevel))) (loop for l downfrom current-maxlevel to 0 do (setf entry (find-entry-level skiplist entry l key)) when (key-= skiplist (entry-key (entry-next entry l)) key) do (cond ((key-= skiplist (entry-key entry) key) (setf (entry-next start l) nil)) ((key-< skiplist (entry-key entry) key) (setf (entry-next entry l) (entry-next (entry-next entry l) l))) (t (setf (entry-next entry l) (entry-next (entry-next entry l) l)) (setf (entry-next start l) (entry-next entry l))))) (loop while (and (null (entry-next start current-maxlevel)) (>= current-maxlevel 0)) do (decf current-maxlevel)))) skiplist) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Slide keys (defun update-interval (skiplist entry to update-key) (with-slots (start) skiplist (flet ((update-entry (entry) (setf (entry-key entry) (funcall update-key (entry-key entry) (entry-obj entry))))) (loop while (key-<= skiplist (entry-key entry) to) do (update-entry entry) until (last-entry-p start entry 0) do (setf entry (entry-next entry 0)))))) (defun skiplist-slide-keys (skiplist from to update-key) (unless (skiplist-empty-p skiplist) (with-slots (current-maxlevel start) skiplist (let ((entry (entry-next start current-maxlevel))) (loop for l downfrom current-maxlevel to 0 do (setf entry (find-entry-level skiplist entry l from))) (when (key->= skiplist (entry-key (entry-next entry 0)) from) (update-interval skiplist (entry-next entry 0) to update-key))))) skiplist) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Rotate prefix (defun skiplist-rotate-prefix (skiplist to update-key) (unless (skiplist-empty-p skiplist) (with-slots (current-maxlevel start) skiplist (let ((entry (entry-next start current-maxlevel))) (loop for l downfrom current-maxlevel to 0 do (setf entry (find-entry-level skiplist entry l to))) (when (key-= skiplist (entry-key (entry-next entry 0)) to) (setf entry (entry-next entry 0))) (cond ((and (key-> skiplist (entry-key entry) to) (key-> skiplist (entry-key (entry-next entry 0)) to)) nil) ((and (key-<= skiplist (entry-key entry) to) (key-<= skiplist (entry-key (entry-next entry 0)) to)) (update-interval skiplist (entry-next entry 0) to update-key)) (t (update-interval skiplist (entry-next start 0) to update-key) (loop with entry = (entry-next entry 0) for level from 0 to current-maxlevel do (loop until (>= (length entry) (+ 3 level)) do (setf entry (entry-next entry (1- level)))) (setf (entry-next start level) entry))))))) skiplist) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Rotate suffix (defun update-interval-to-end (skiplist entry update-key) (with-slots (start) skiplist (flet ((update-entry (entry) (setf (entry-key entry) (funcall update-key (entry-key entry) (entry-obj entry))))) (loop do (update-entry entry) until (last-entry-p start entry 0) do (setf entry (entry-next entry 0)))))) (defun skiplist-rotate-suffix (skiplist from update-key) (unless (skiplist-empty-p skiplist) (with-slots (current-maxlevel start) skiplist (let ((entry (entry-next start current-maxlevel))) (loop for l downfrom current-maxlevel to 0 do (setf entry (find-entry-level skiplist entry l from))) (cond ((and (key-< skiplist (entry-key entry) from) (key-< skiplist (entry-key (entry-next entry 0)) from)) nil) ((and (key->= skiplist (entry-key entry) from) (key->= skiplist (entry-key (entry-next entry 0)) from)) (update-interval-to-end skiplist (entry-next entry 0) update-key)) (t (update-interval-to-end skiplist (entry-next entry 0) update-key) (loop with entry = (entry-next entry 0) for level from 0 to current-maxlevel do (loop until (>= (length entry) (+ 3 level)) do (setf entry (entry-next entry (1- level)))) (setf (entry-next start level) entry))))))) skiplist)
10,500
Common Lisp
.lisp
236
40.300847
78
0.646903
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
d960b98dd622b7ea211080eadd2e29a60151470fda2ab40bb2d62be0e86250db
21,695
[ 156377 ]
21,696
win32.lisp
rheaplex_minara/lib/cl-cairo2/win32.lisp
(in-package :cl-cairo2) (load-foreign-library '(:default "user32")) ;;; ;;; win32 surfaces ;;; (cffi:defcstruct RECT (left :long) (top :long) (right :long) (bottom :long)) (cffi:defcfun ("GetClientRect" get-client-rect) :int (arg0 :pointer) (arg1 :pointer)) (defun win32-create-surface (hwnd hdc) (let ((width 0) (height 0) (surface (make-instance 'surface :width 0 :height 0 :pixel-based-p t))) ;; (setf (slot-value surface 'pointer) (cairo_win32_surface_create hdc)) ;; (with-foreign-object (r 'rect) (if (eql (get-client-rect hwnd r) 1) (let ((w (foreign-slot-value r 'rect 'right)) (h (foreign-slot-value r 'rect 'bottom))) (setf (slot-value surface 'width) w (slot-value surface 'height) h width w height h)) (warn "failed to get window size"))) ;; (values surface width height))) (defun win32-get-surface-dc (surface) (let ((hdc (cairo_win32_surface_get_dc (slot-value surface 'pointer)))) (if (null-pointer-p hdc) nil hdc))) (defun win32-get-surface-image (surface) (let ((image-surface (cairo_win32_surface_get_image (slot-value surface 'pointer)))) (if (null-pointer-p image-surface) nil image-surface))) (defmacro with-win32-context ((hwnd hdc width height &optional (surface-name (gensym))) &body body) `(multiple-value-bind (,surface-name ,width ,height) (win32-create-surface ,hwnd ,hdc) (let ((*context* (create-context ,surface-name))) (unwind-protect (progn ,@body) (progn (destroy *context*) (destroy ,surface-name)))))) ;;; ;;; win32 fonts ;;; (cffi:defcstruct LOGFONTW (lfHeight :long) (lfWidth :long) (lfEscapement :long) (lfOrientation :long) (lfWeight :long) (lfItalic :unsigned-char) (lfUnderline :unsigned-char) (lfStrikeOut :unsigned-char) (lfCharSet :unsigned-char) (lfOutPrecision :unsigned-char) (lfClipPrecision :unsigned-char) (lfQuality :unsigned-char) (lfPitchAndFamily :unsigned-char) (lfFaceName :pointer)) (defun win32-create-font-face-for-logfontw (logfontw) (cairo_win32_font_face_create_for_logfontw logfontw)) (defun win32-create-font-face-for-hfont (hfont) (cairo_win32_font_face_create_for_hfont hfont)) #|(defun win32-create-font-face-for-logfontw-hfont (logfontw hfont) (cairo_win32_font_face_create_for_logfontw_hfont logfontw hfont))|# (defun win32-select-font-scaled-font (scaled-font hdc) (let ((status (cairo_win32_scaled_font_select_font scaled-font hdc))) (if (eq status :success) t (warn "function returned with status ~A." status)))) (defun win32-done-font-scaled-font (scaled-font) (cairo_win32_scaled_font_done_font scaled-font)) (defun win32-get-metrics-facotor-scaled-font (scaled-font) (cairo_win32_scaled_font_get_metrics_factor scaled-font)) (defun win32-get-device-to-logical-scaled-font (scaled-font device-to-logical) (cairo_win32_scaled_font_get_device_to_logical scaled-font device-to-logical)) ;; export manually (export '(win32-create-surface win32-get-surface-dc win32-get-surface-image with-win32-context win32-create-font-face-for-logfontw win32-create-font-face-for-hfont #|win32-create-font-face-for-logfontw-hfont|# win32-select-font-scaled-font win32-done-font-scaled-font win32-get-metrics-factor-scaled-font win32-get-device-to-logical-scaled-font))
3,323
Common Lisp
.lisp
91
33.340659
99
0.722775
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
a6fd792c018dcfdeb2b0e291cc8b9f96bf91b49e439862a8880fd17f0801d129
21,696
[ -1 ]
21,697
libraries-x11.lisp
rheaplex_minara/lib/cl-cairo2/libraries-x11.lisp
(in-package :cl-cairo2) ;; is this really needed? OS should set this up properly #+darwin (pushnew "/usr/X11/lib/" *foreign-library-directories*) (define-foreign-library :libX11 (:darwin "libX11.dylib") (:unix "libX11.so")) (load-foreign-library :libX11) (define-foreign-library :gdk ;; 'darwin' comes before 'unix' because Mac OS X defines them both. (:darwin "libgdk-x11-2.0.dylib") (:unix (:or "libgdk-x11-2.0.so" "libgdk-x11-2.0.so.0")) (:windows "libgdk-win32-2.0-0.dll")) (load-foreign-library :gdk)
524
Common Lisp
.lisp
13
38
69
0.70751
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
8ca1dc9db75a8d675caf181db3b3e8b7a77c3d24c4abd19af55186bf9461680f
21,697
[ -1 ]
21,698
package.lisp
rheaplex_minara/lib/cl-cairo2/package.lisp
(in-package #:cl-cairo2-asd) (defpackage cl-cairo2 (:use :common-lisp :cffi :cl-colors :cl-utilities) (:export ;; cairo destroy deg-to-rad ;; surface surface pointer width height get-width get-height pixel-based-p destroy create-ps-surface create-pdf-surface create-svg-surface create-image-surface create-image-surface-for-data image-surface-get-format image-surface-get-width image-surface-get-height image-surface-get-data image-surface-get-stride image-surface-create-from-png surface-write-to-png with-png-surface ;; context context with-png-file create-context sync sync-lock sync sync-unlock sync-reset with-sync-lock *context* save restore push-group pop-group pop-group-to-source set-source-rgb set-source-rgba clip clip-preserve reset-clip copy-page show-page fill-preserve paint paint-with-alpha stroke stroke-preserve set-source-color get-line-width set-line-width get-miter-limit set-miter-limit get-antialias set-antialias get-fill-rule set-fill-rule get-line-cap set-line-cap get-line-join set-line-join get-operator set-operator fill-path set-dash get-dash clip-extents fill-extents in-fill in-stoke create-ps-context create-pdf-context create-svg-context get-target set-source-surface ;;pattern pattern create-rgb-pattern create-rgba-pattern create-linear-pattern create-radial-pattern create-pattern-for-surface pattern-add-color-stop-rgb pattern-add-color-stop-rgba pattern-add-color-stop pattern-get-type pattern-set-matrix pattern-get-matrix pattern-set-extend pattern-get-extend pattern-set-filet pattern-get-filter set-source mask create-color-pattern with-linear-pattern with-radial-pattern with-patterns ;; path new-path new-sub-path close-path arc arc-negative curve-to line-to move-to rectangle rel-move-to rel-curve-to rel-line-to text-path get-current-point ;; text select-font-face set-font-size text-extents show-text text-x-bearing text-y-bearing text-width text-height text-x-advance text-y-advance get-text-extents font-ascent font-descent font-height font-max-x-advance font-max-y-advance get-font-extents ;; transformations translate scale rotate reset-trans-matrix make-trans-matrix trans-matrix-xx trans-matrix-yx trans-matrix-xy trans-matrix-yy trans-matrix-x0 trans-matrix-y0 trans-matrix-p transform set-trans-matrix get-trans-matrix user-to-device user-to-device-distance device-to-user device-to-user-distance trans-matrix-init-translate trans-matrix-init-scale trans-matrix-init-rotate trans-matrix-rotate trans-matrix-scale trans-matrix-rotate trans-matrix-invert trans-matrix-multiply trans-matrix-distance transform-point) (:nicknames :cairo))
2,794
Common Lisp
.lisp
58
43.672414
76
0.782142
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
d370c09d1d5c98b799531a9ad9cafcb8a5cc38e116e00d5abb3dde2927ee56ec
21,698
[ -1 ]
21,699
transformations.lisp
rheaplex_minara/lib/cl-cairo2/transformations.lisp
(in-package :cl-cairo2) ;;;; Notes ;;;; ;;;; cairo-matrix-init is not defined, as we have a structure in lisp ;;;; with an appropriate constructor ;;;; ;;;; cairo_identity_matrix is reset-trans-matrix ;;;; ;;;; functions that manipulate transformation matrices have ;;;; trans-matrix instead of matrix in their name ;;;; ;;;; cairo_matrix_transform_distance and cairo_matrix_transform_point ;;;; are simply transform-distance and transform-point ;;;; ;;;; cairo_matrix_init is not defined, make-trans-matrix will give ;;;; you an identity matrix ;;;; ;;;; simple functions ;;;; (define-many-with-default-context (translate tx ty) (scale sx sy) (rotate angle)) (define-flexible (reset-trans-matrix pointer) (cairo_identity_matrix pointer)) ;;;; ;;;; transition matrix structure and helper functions/macros ;;;; (defstruct trans-matrix (xx 1d0 :type double-float) (yx 0d0 :type double-float) (xy 0d0 :type double-float) (yy 1d0 :type double-float) (x0 0d0 :type double-float) (y0 0d0 :type double-float)) (defun trans-matrix-copy-in (pointer matrix) "Copy matrix to a memory location." (with-foreign-slots ((xx yx xy yy x0 y0) pointer cairo_matrix_t) (setf xx (trans-matrix-xx matrix) yx (trans-matrix-yx matrix) xy (trans-matrix-xy matrix) yy (trans-matrix-yy matrix) x0 (trans-matrix-x0 matrix) y0 (trans-matrix-y0 matrix)))) (defun trans-matrix-copy-out (pointer matrix) "Copy contents of a memory location to a transition matrix." (with-foreign-slots ((xx yx xy yy x0 y0) pointer cairo_matrix_t) (setf (trans-matrix-xx matrix) xx (trans-matrix-yx matrix) yx (trans-matrix-xy matrix) xy (trans-matrix-yy matrix) yy (trans-matrix-x0 matrix) x0 (trans-matrix-y0 matrix) y0))) (defmacro with-trans-matrix-in (matrix pointer &body body) "Execute body with pointer pointing to a memory location with matrix." `(with-foreign-pointer (,pointer (foreign-type-size 'cairo_matrix_t)) (trans-matrix-copy-in ,pointer ,matrix) ,@body)) (defmacro with-trans-matrix-out (pointer &body body) "Execute body with pointer pointing to an uninitialized location, then copy this to matrix and return the matrix." (let ((matrix-name (gensym))) `(with-foreign-pointer (,pointer (foreign-type-size 'cairo_matrix_t)) (let ((,matrix-name (make-trans-matrix))) ,@body (trans-matrix-copy-out ,pointer ,matrix-name) ,matrix-name)))) (defmacro with-trans-matrix-in-out (matrix pointer &body body) (let ((matrix-name (gensym))) `(with-foreign-pointer (,pointer (foreign-type-size 'cairo_matrix_t)) (let ((,matrix-name (make-trans-matrix))) (trans-matrix-copy-in ,pointer ,matrix) ,@body (trans-matrix-copy-out ,pointer ,matrix-name) ,matrix-name)))) (defmacro with-x-y (&body body) "Creates temporary variables on the stack with pointers xp and yp, and copies x and y in/out before/after (respectively) the execution of body." `(with-foreign-objects ((xp :double) (yp :double)) (setf (mem-ref xp :double) (coerce x 'double-float) (mem-ref yp :double) (coerce y 'double-float)) ,@body (values (mem-ref xp :double) (mem-ref yp :double)))) (defmacro define-with-x-y (name) "Defines a function that is called with context, x and y, and returns the latter two." `(define-flexible (,name pointer x y) (with-x-y (,(prepend-intern "cairo_" name) pointer xp yp)))) ;;;; ;;;; transformation and conversion functions ;;;; (define-flexible (transform pointer matrix) (with-trans-matrix-in matrix matrix-pointer (cairo_transform pointer matrix-pointer))) (define-flexible (set-trans-matrix pointer matrix) (with-trans-matrix-in matrix matrix-pointer (cairo_set_matrix pointer matrix-pointer))) (define-flexible (get-trans-matrix pointer) (with-trans-matrix-out matrix-pointer (cairo_get_matrix pointer matrix-pointer))) (define-with-x-y user-to-device) (define-with-x-y user-to-device-distance) (define-with-x-y device-to-user) (define-with-x-y device-to-user-distance) ;;;; ;;;; transformations ;;;; (defmacro define-matrix-init (name &rest args) "Define a matrix initializer function with args, which returns the new matrix." `(defun ,(prepend-intern "trans-matrix-init-" name :replace-dash nil) ,args (with-trans-matrix-out matrix-pointer (,(prepend-intern "cairo_matrix_init_" name) matrix-pointer ,@args)))) (define-matrix-init translate tx ty) (define-matrix-init scale sx sy) (define-matrix-init rotate radians) (defmacro define-matrix-transformation (name &rest args) "Define a matrix transformation function with matrix and args, which returns the new matrix." `(export (defun ,(prepend-intern "trans-matrix-" name :replace-dash nil) (matrix ,@args) (with-trans-matrix-in-out matrix matrix-pointer (,(prepend-intern "cairo_matrix_" name) matrix-pointer ,@args))))) (define-matrix-transformation translate tx ty) (define-matrix-transformation scale sx sy) (define-matrix-transformation rotate radians) (define-matrix-transformation invert) (defun trans-matrix-multiply (a b) (with-trans-matrix-in a a-pointer (with-trans-matrix-in b b-pointer (with-trans-matrix-out result-pointer (cairo_matrix_multiply result-pointer a-pointer b-pointer))))) (defun transform-distance (matrix x y) (with-trans-matrix-in matrix matrix-pointer (with-x-y (cairo_matrix_transform_distance matrix-pointer xp yp)))) (defun transform-point (matrix x y) (with-trans-matrix-in matrix matrix-pointer (with-x-y (cairo_matrix_transform_point matrix-pointer xp yp))))
5,654
Common Lisp
.lisp
148
34.986486
83
0.72065
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
533ca1852ae892a0f9ee20c07f909a9dcd80ece856ddcbe58ffe14966586c663
21,699
[ -1 ]
21,700
tables.lisp
rheaplex_minara/lib/cl-cairo2/tables.lisp
(in-package :cl-cairo2) (defmacro exporting-table (name definition) `(progn (defparameter ,name ,definition) (export ',name))) ; (dolist (i ,name) ; (export (car i)) ;(export (cdr i))))) (exporting-table table-format '((:CAIRO_FORMAT_ARGB32 . :argb32) (:CAIRO_FORMAT_RGB24 . :rgb24) (:CAIRO_FORMAT_A8 . :a8) (:CAIRO_FORMAT_A1 . :a1))) (exporting-table table-antialias '((:CAIRO_ANTIALIAS_DEFAULT . :default) (:CAIRO_ANTIALIAS_NONE . :none) (:CAIRO_ANTIALIAS_GRAY . :gray) (:CAIRO_ANTIALIAS_SUBPIXEL . :subpixel))) (exporting-table table-fill-rule '((:CAIRO_FILL_RULE_WINDING . :winding) (:CAIRO_FILL_RULE_EVEN_ODD . :odd))) (exporting-table table-line-cap '((:CAIRO_LINE_CAP_BUTT . :butt) (:CAIRO_LINE_CAP_ROUND . :round) (:CAIRO_LINE_CAP_SQUARE . :square))) (exporting-table table-line-join '((:CAIRO_LINE_JOIN_MITER . :miter) (:CAIRO_LINE_JOIN_ROUND . :round) (:CAIRO_LINE_JOIN_BEVEL . :bevel))) (exporting-table table-operator '((:CAIRO_OPERATOR_CLEAR . :clear) (:CAIRO_OPERATOR_SOURCE . :source) (:CAIRO_OPERATOR_OVER . :over) (:CAIRO_OPERATOR_IN . :in) (:CAIRO_OPERATOR_OUT . :out) (:CAIRO_OPERATOR_ATOP . :atop) (:CAIRO_OPERATOR_DEST . :dest) (:CAIRO_OPERATOR_DEST_OVER . :dest-over) (:CAIRO_OPERATOR_DEST_IN . :dest-in) (:CAIRO_OPERATOR_DEST_OUT . :dest-out) (:CAIRO_OPERATOR_DEST_ATOP . :dest-atop) (:CAIRO_OPERATOR_XOR . :xor) (:CAIRO_OPERATOR_ADD . :add) (:CAIRO_OPERATOR_SATURATE . :saturate))) (exporting-table table-font-slant '((:CAIRO_FONT_SLANT_NORMAL . :normal) (:CAIRO_FONT_SLANT_ITALIC . :italic) (:CAIRO_FONT_SLANT_OBLIQUE . :oblique))) (exporting-table table-font-weight '((:CAIRO_FONT_WEIGHT_NORMAL . :normal) (:CAIRO_FONT_WEIGHT_BOLD . :bold))) (exporting-table table-subpixel-order '((:CAIRO_SUBPIXEL_ORDER_DEFAULT . :default) (:CAIRO_SUBPIXEL_ORDER_RGB . :rgb) (:CAIRO_SUBPIXEL_ORDER_BGR . :bgr) (:CAIRO_SUBPIXEL_ORDER_VRGB . :vrgb) (:CAIRO_SUBPIXEL_ORDER_VBGR . :vbgr))) (exporting-table table-hint-style '((:CAIRO_HINT_STYLE_DEFAULT . :default) (:CAIRO_HINT_STYLE_NONE . :none) (:CAIRO_HINT_STYLE_SLIGHT . :slight) (:CAIRO_HINT_STYLE_MEDIUM . :medium) (:CAIRO_HINT_STYLE_FULL . :full))) (exporting-table table-hint-metrics '((:CAIRO_HINT_METRICS_DEFAULT . :default) (:CAIRO_HINT_METRICS_OFF . :off) (:CAIRO_HINT_METRICS_ON . :on))) (exporting-table table-status '((:CAIRO_STATUS_SUCCESS . :success) (:CAIRO_STATUS_NO_MEMORY . :no-memory) (:CAIRO_STATUS_INVALID_RESTORE . :invalid-restore) (:CAIRO_STATUS_INVALID_POP_GROUP . :invalid-pop-group) (:CAIRO_STATUS_NO_CURRENT_POINT . :no-current-point) (:CAIRO_STATUS_INVALID_MATRIX . :invalid-matrix) (:CAIRO_STATUS_INVALID_STATUS . :invalid-status) (:CAIRO_STATUS_NULL_POINTER . :null-pointer) (:CAIRO_STATUS_INVALID_STRING . :invalid-string) (:CAIRO_STATUS_INVALID_PATH_DATA . :invalid-path-data) (:CAIRO_STATUS_READ_ERROR . :read-error) (:CAIRO_STATUS_WRITE_ERROR . :write-error) (:CAIRO_STATUS_SURFACE_FINISHED . :surface-finished) (:CAIRO_STATUS_SURFACE_TYPE_MISMATCH . :surface-type-mismatch) (:CAIRO_STATUS_PATTERN_TYPE_MISMATCH . :pattern-type-mismatch) (:CAIRO_STATUS_INVALID_CONTENT . :invalid-content) (:CAIRO_STATUS_INVALID_FORMAT . :invalid-format) (:CAIRO_STATUS_INVALID_VISUAL . :invalid-visual) (:CAIRO_STATUS_FILE_NOT_FOUND . :file-not-found) (:CAIRO_STATUS_INVALID_DASH . :invalid-dash) (:CAIRO_STATUS_INVALID_DSC_COMMENT . :invalid-dsc-comment) (:CAIRO_STATUS_INVALID_INDEX . :invalid-index) (:CAIRO_STATUS_CLIP_NOT_REPRESENTABLE . :clip-not-representable))) (exporting-table table-pattern-type '((:CAIRO_PATTERN_TYPE_SOLID . :solid) (:CAIRO_PATTERN_TYPE_SURFACE . :surface) (:CAIRO_PATTERN_TYPE_LINEAR . :linear) (:CAIRO_PATTERN_TYPE_RADIAL . :radial))) (exporting-table table-extend '((:CAIRO_EXTEND_NONE . :none) (:CAIRO_EXTEND_REPEAT . :repeat) (:CAIRO_EXTEND_REFLECT . :reflect) (:CAIRO_EXTEND_PAD . :pad))) (exporting-table table-filter '((:CAIRO_FILTER_FAST . :fast) (:CAIRO_FILTER_GOOD . :good) (:CAIRO_FILTER_BEST . :best) (:CAIRO_FILTER_NEAREST . :nearest) (:CAIRO_FILTER_BILINEAR . :bilinear) (:CAIRO_FILTER_GAUSSIAN . :gaussian))) (defun lookup-cairo-enum (cairo-enum table) (let ((enum (cdr (assoc cairo-enum table)))) (unless enum (error "Could not find cairo-enum ~a in ~a." cairo-enum table)) enum)) (defun lookup-enum (enum table) (let ((cairo-enum (car (rassoc enum table)))) (unless cairo-enum (error "Could not find enum ~a in ~a." enum table)) cairo-enum))
4,782
Common Lisp
.lisp
118
36.050847
70
0.669824
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ac22888012068b997697119d335b2ae197ea9b581b74854f600b1d20d5423655
21,700
[ -1 ]
21,701
xlib.lisp
rheaplex_minara/lib/cl-cairo2/xlib.lisp
(in-package :cl-cairo2) ;;;; ;;;; a limited interface to certain Xlib functions ;;;; ;;;; types (defctype display :pointer) (defctype xid :unsigned-long) ; X Id type (defctype drawable xid) (defctype window xid) (defctype pixmap xid) (defctype cursor xid) (defctype colormap xid) (defctype graphics-context xid) (defctype visual :pointer) (defctype xatom :unsigned-long) (defctype bool :int) ;; constants (defmacro define-bitmask-constants (&body name-power-pairs) "Define a list of constants from name-value pairs, raising 2 to the power value." (labels ((dbc (pairs) (case (length pairs) (0 nil) (1 (error "no power after ~a" (car name-power-pairs))) (t (destructuring-bind (name power &rest rest) pairs `((defconstant ,name (expt 2 ,power)) ,@(dbc rest))))))) `(progn ,@(dbc name-power-pairs)))) (defconstant noeventmask 0) (define-bitmask-constants keypressmask 0 keyreleasemask 1 buttonpressmask 2 buttonreleasemask 3 enterwindowmask 4 leavewindowmask 5 pointermotionmask 6 pointermotionhintmask 7 button1motionmask 8 button2motionmask 9 button3motionmask 10 button4motionmask 11 button5motionmask 12 buttonmotionmask 13 keymapstatemask 14 exposuremask 15 visibilitychangemask 16 structurenotifymask 17 resizeredirectmask 18 substructurenotifymask 19 substructureredirectmask 20 focuschangemask 21 propertychangemask 23 colormapchangemask 23 ownergrabbuttonmask 24) ;;;; error code handling (defmacro check-status (call) "Check the return calue of call, if nonzero, display an error message." (with-unique-names (status) `(let ((,status ,call)) (if (zerop ,status) (values) (error "operations ~a returned status (error) ~a" ',call ,status))))) ;;;; display operations (defcfun ("XOpenDisplay" xopendisplay) display (display-name :string)) (defcfun ("XCloseDisplay" xclosedisplay) :int (display display)) ;;;; defaults for the X11 display & screen (defcfun ("XDefaultDepth" xdefaultdepth) :int (display display) (screen-number :int)) (defcfun ("XDefaultRootWindow" xdefaultrootwindow) window (display display)) (defcfun ("XDefaultScreen" xdefaultscreen) :int (display display)) (defcfun ("XDefaultVisual" xdefaultvisual) visual (display display) (screen-number :int)) (defcfun ("XBlackPixel" xblackpixel) :unsigned-long (display display) (screen-number :int)) (defcfun ("XWhitePixel" xwhitepixel) :unsigned-long (display display) (screen-number :int)) ;;;; graphics contexts (defcfun ("XDefaultGC" xdefaultgc) graphics-context (display display) (screen-number :int)) (defcfun ("XCreateGC" xcreategc) graphics-context (display display) (drawable drawable) (valuemask :unsigned-long) (xgcvalues :pointer)) (defcfun ("XFreeGC" xfreegc) :int (display display) (graphics-context graphics-context)) ;;;; window and pixmap management (defcfun ("XMapWindow" xmapwindow) :int (display display) (window window)) (defcfun ("XCreateSimpleWindow" xcreatesimplewindow) window (display display) (parent window) (x :int) (y :int) (width :unsigned-int) (height :unsigned-int) (border-width :unsigned-int) (border :unsigned-long) (background :unsigned-long)) (defcfun ("XCreateWindow" xcreatewindow) window (display display) (parent window) (x :int) (y :int) (width :unsigned-int) (height :unsigned-int) (border-width :unsigned-int) (depth :int) (class :unsigned-int) (visual visual) (valuemask :unsigned-long) (attributes :pointer)) (defcstruct xsetwindowattributes (background-pixmap pixmap) (background-pixel :unsigned-long) (border-pixmap pixmap) (border-pixel :unsigned-long) (bit-gravity :int) (win-gravity :int) (backing-store :int) (backing-planes :unsigned-long) (backing-pixel :unsigned-long) (save-under bool) (event-mask :long) (do-not-propagate_mask :long) (override-redirect bool) (colormap colormap) (cursor cursor)) (define-bitmask-constants CWBackPixmap 0 CWBackPixel 1 CWBorderPixmap 2 CWBorderPixel 3 CWBitGravity 4 CWWinGravity 5 CWBackingStore 6 CWBackingPlanes 7 CWBackingPixel 8 CWOverrideRedirect 9 CWSaveUnder 10 CWEventMask 11 CWDontPropagate 12 CWColormap 13 CWCursor 14) (defcfun ("XChangeWindowAttributes" xchangewindowattributes) :int (display display) (window window) (valuemask :unsigned-long) (attributes :pointer)) (defcfun ("XDestroyWindow" xdestroywindow) :int (display display) (window window)) (defcfun ("XCreatePixmap" xcreatepixmap) pixmap (display display) (drawable drawable) (width :unsigned-int) (height :unsigned-int) (depth :unsigned-int)) (defcfun ("XFreePixmap" xfreepixmap) :int (display display) (pixmap pixmap)) (defcfun ("XSelectInput" xselectinput) :int (display display) (window window) (event-mask :long)) (defcfun ("XCopyArea" xcopyarea) :int (display display) (source drawable) (destination drawable) (graphics-context graphics-context) (source-x :int) (source-y :int) (width :unsigned-int) (height :unsigned-int) (destination-x :int) (destination-y :int)) (defcfun ("XSetGraphicsExposures" xsetgraphicsexposures) :int (display display) (graphics-context graphics-context) (graphics-exposures bool)) ;; synchronization & threads (defcfun ("XInitThreads" xinitthreads) :int) (defcfun ("XLockDisplay" xlockdisplay) :int (display display)) (defcfun ("XUnlockDisplay" xunlockdisplay) :int (display display)) (defcfun ("XSynchronize" xsynchronize) :int (display display) (onoff :int)) (defcfun ("XFlush" xflush) :int (display display)) (defcfun ("XSync" xsync) :int (display display) (discard :int)) ;; atoms & protocols (defcfun ("XInternAtom" xinternatom) xatom (display display) (atom-name :string) (only-if-exists :int)) (defcfun ("XSetWMProtocols" xsetwmprotocols) :int (display display) (window window) (protocols :pointer) (count :int)) ;; events (defcstruct xanyevent (type :int) (serial :unsigned-long) (send-event bool) (display display) (window window)) (defcstruct xexposeevent (type :int) (serial :unsigned-long) (send-event bool) (display display) (drawable drawable) (x :int) (y :int) (width :int) (height :int) (count :int) (major-code :int) (minor-code :int)) (defcstruct xdestroywindowevent (type :int) (serial :unsigned-long) (send-event bool) (display display) (event window) (window window)) (defcstruct xclientmessageevent (type :int) (serial :unsigned-long) (send-event bool) (display display) (window window) (message-type xatom) (format :int) ;; we only use first field, union of message data is not included (data0 :unsigned-long)) (defcstruct xvisibilityevent (type :int) (serial :unsigned-long) (send-event bool) (display display) (window window) (state :int)) (defcfun ("XNextEvent" xnextevent) :int (display display) (event-return :pointer)) (defcfun ("XSendEvent" xsendevent) :int (display display) (window window) (propagate bool) (event-mask :long) (xevent :pointer)) ;; hints & misc (defcstruct xsizehints (flags :long) ; marks which fields in this structure are defined (x :int) ; Obsolete (y :int) ; Obsolete (width :int) ; Obsolete (height :int) ; Obsolete (min-width :int) (min-height :int) (max-width :int) (max-height :int) (min-aspect-x :int) ; numerator (min-aspect-y :int) ; denominator (max-aspect-x :int) ; numerator (max-aspect-y :int) ; denominator (base-width :int) (base_height :int) (win_gravity :int)) (define-bitmask-constants USPosition 0 USSize 1 PPosition 2 PSize 3 PMinSize 4 PMaxSize 5 PResizeInc 6 PAspect 7 PBaseSize 8 PWinGravity 9) (defcfun ("XAllocSizeHints" xallocsizehints) :pointer) (defcfun ("XSetWMNormalHints" xsetwmnormalhints) :void (display display) (window window) (hints :pointer)) (defcfun ("XStoreName" xstorename) :int (display display) (window window) (window-name :string)) (defcfun ("XFree" xfree) :int (data :pointer)) ;; extensions (defcfun ("XAddExtension" xaddextension) :pointer (display display)) (defcstruct xextcodes (extensions :int) (major-opcode :int) (first-event :int) (first-error :int)) ;; image manipulation (cffi:defcstruct XImage (width :int) (height :int) (xoffset :int) (format :int) (data :pointer) (byte-order :int) (bitmap-unit :int) (bitmap-bit-order :int) (bitmap-pad :int) (depth :int) (bytes-per-line :int) (bits-per-pixel :int) (red-mask :unsigned-long) (green-mask :unsigned-long) (blue-mask :unsigned-long) (obdata :pointer) ;; funcs (create-image :pointer) (destroy-image :pointer) (get-pixel :pointer) (put-pixel :pointer) (sub-image :pointer) (add-pixel :pointer)) (defcfun ("XInitImage" xinitimage) :int (ximage :pointer)) (defcfun ("XPutImage" xputimage) :int (display display) (drawable drawable) (graphics-context graphics-context) (ximage :pointer) (src-x :int) (src-y :int) (dest-x :int) (dest-y :int) (width :unsigned-int) (height :unsigned-int)) ;; call xinitthreads (xinitthreads) ;; various higher level functions (defun set-window-size-hints (display window min-window-width max-window-width min-window-height max-window-height) ;; set size hints on window (most window managers will respect this) (let ((hints (xallocsizehints))) (with-foreign-slots ((flags x y min-width min-height max-width max-height) hints xsizehints) ;; we only set the first four values because old WM's might ;; get confused if we don't, they should be ignored (setf flags (logior pminsize pmaxsize) x 0 y 0 ;; we don't need to set the following, but some WMs go ;; crazy if we don't (foreign-slot-value hints 'xsizehints 'width) max-window-width (foreign-slot-value hints 'xsizehints 'height) max-window-height ;; set desired min/max width/height min-width min-window-width max-width max-window-width min-height min-window-height max-height max-window-height) (xsetwmnormalhints display window hints) (xfree hints)))) (defun create-window (display parent width height class visual background-pixel event-mask &optional (backing-store t)) "Create an x11 window, placed at 0 0, with the given attributes. For internal use in the cl-cairo2 package." ;; call xcreatewindow with attributes (with-foreign-object (attributes 'xsetwindowattributes) (setf (foreign-slot-value attributes 'xsetwindowattributes 'event-mask) event-mask (foreign-slot-value attributes 'xsetwindowattributes 'background-pixel) background-pixel (foreign-slot-value attributes 'xsetwindowattributes 'backing-store) (if backing-store 1 0)) (xcreatewindow display parent 0 0 width height 0 ; zero border width 0 ; depth - copy from parent (ecase class (copyfromparent 0) (inputoutput 1) (inputonly 2)) ; class visual (if (eq class 'inputonly) cweventmask (logior cwbackpixel cwbackingstore cweventmask)) attributes)))
11,652
Common Lisp
.lisp
408
24.563725
79
0.703478
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
26999a2bddc280ae9fd6880a2f2b25d96370b776fb43e608ba69deb69b5ec7e8
21,701
[ -1 ]
21,702
path.lisp
rheaplex_minara/lib/cl-cairo2/path.lisp
(in-package :cl-cairo2) (define-many-with-default-context (new-path) (new-sub-path) (close-path) (arc xc yc radius angle1 angle2) (arc-negative xc yc radius angle1 angle2) (curve-to x1 y1 x2 y2 x3 y3) (line-to x y) (move-to x y) (rectangle x y width height) (rel-move-to dx dy) (rel-curve-to dx1 dy1 dx2 dy2 dx3 dy3) (rel-line-to dx dy) (text-path text)) (define-flexible (get-current-point pointer) (with-foreign-objects ((xp :double) (yp :double)) (cairo_get_current_point pointer xp yp) (values (mem-ref xp :double) (mem-ref yp :double)))) ;; !!! not done yet: glyph-path ;; !!! need to write: path data type iterators, copy-path, ;; !!! copy-path-flat, path-destroy, append-path
723
Common Lisp
.lisp
22
30.045455
58
0.687231
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
3f54114593991511d9d731312f424c4c5afe5f2944cccee31ae5213a43d60aad
21,702
[ -1 ]
21,703
my-double.lisp
rheaplex_minara/lib/cl-cairo2/my-double.lisp
(in-package :cl-cairo2) ;; define our own alias for double float, so we can automatically ;; convert other numerical types in the arguments (define-foreign-type my-double-type () () (:actual-type :double) (:simple-parser my-double)) (defmethod translate-to-foreign (value (type my-double-type)) (coerce value 'double-float))
413
Common Lisp
.lisp
9
35.111111
65
0.75
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
07fd4e947a4f4f8381d4cc9718ffebf4ee6fcb2dba47556f45586387565195c9
21,703
[ -1 ]
21,704
xlib-image-context.lisp
rheaplex_minara/lib/cl-cairo2/xlib-image-context.lisp
(in-package :cl-cairo2) ;; constants for communicating with the signal window (defconstant +destroy-message+ 4072) ; just some random constant (defconstant +refresh-message+ 2495) ; ditto (defvar *xlib-image-context-count* 0 "window counter for autogenerating names") (defun next-xlib-image-context-name () "Return an autogenerated window name using *xlib-context-count*." (format nil "cl-cairo2 ~a" (incf *xlib-image-context-count*))) ;; code to make threads, please extend with your own Lisp if needed ;; testing is welcome, I only tested cmucl and sbcl (defun start-thread (function name) #+allegro (mp:process-run-function name function) #+armedbear (ext:make-thread function :name name) #+cmu (mp:make-process function :name name) #+lispworks (mp:process-run-function name nil function) #+openmcl (ccl:process-run-function name function) #+sbcl (sb-thread:make-thread function :name name)) ;; we create this definition manually, SWIG just messes things up (defcfun ("cairo_xlib_surface_create" cairo_xlib_surface_create) cairo_surface_t (display display) (drawable drawable) (visual visual) (width :int) (height :int)) (defclass xlib-image-context (context) ((display :initarg :display) window graphics-context signal-window (xlib-context :accessor xlib-context) wm-delete-window (width :initarg :width) (height :initarg :height) thread (sync-counter :initform 0 :accessor sync-counter))) ;; synchronization after drawing (defun send-message-to-signal-window (xlib-image-context message) "Send the desired message to the context window." (with-slots (pointer (display-pointer display) signal-window) xlib-image-context (unless pointer (warn "context is not active, can't send message to window") (return-from send-message-to-signal-window)) (with-foreign-object (xev :long 24) (with-foreign-slots ((type display window message-type format data0) xev xclientmessageevent) (setf type 33) ; clientnotify (setf display display-pointer) (setf window signal-window) (setf message-type 0) (setf format 32) (setf data0 message) (xsendevent display-pointer signal-window 0 0 xev)) #| (xflush display-pointer) |# (xsync display-pointer 0)))) (defmethod sync ((object xlib-image-context)) (when (zerop (sync-counter object)) (send-message-to-signal-window object +refresh-message+))) (defmethod sync-lock ((object xlib-image-context)) (incf (sync-counter object))) (defmethod sync-unlock ((object xlib-image-context)) (with-slots (sync-counter) object (when (plusp sync-counter) (decf sync-counter))) (sync object)) (defmethod sync-reset ((object xlib-image-context)) (setf (sync-counter object) 0) (sync object)) (defun create-xlib-image-context (width height &key (display-name nil) (window-name (next-xlib-image-context-name)) (background-color +white+)) "Create a window mapped to an xlib-image-context, with given width, height (non-resizable) and window-name on display-name. If background-color is not nil, the window will be painted with it." (let ((display (xopendisplay (if display-name display-name (null-pointer))))) (when (null-pointer-p display) (error "couldn't open display ~a" display-name)) (let ((xlib-image-context (make-instance 'xlib-image-context :display display :width width :height height :pixel-based-p t))) (labels (;; Repaint the xlib context with the image surface ;; (previously set as source during initialization. (refresh () (cairo_paint (xlib-context xlib-image-context))) ;; The main event loop, started as a separate thread ;; when initialization is complete. The main thread is ;; supposed to communicate with this one via X signals ;; using an unmapped InputOnly window (see ;; send-message-to-signal-window). (event-loop () (with-slots (display (this-window window) signal-window wm-delete-window graphics-context) xlib-image-context (let ((wm-protocols (xinternatom display "WM_PROTOCOLS" 1))) (with-foreign-object (xev :long 24) (do ((got-close-signal nil)) (got-close-signal) ;; get next event (xnextevent display xev) ;; decipher structure, at least partially (with-foreign-slots ((type window serial) xev xanyevent) ;; action based on event type (cond ;; expose events ((and (= type 12) (= window this-window)) (refresh)) ;; clientnotify event ((= type 33) (with-foreign-slots ((message-type data0) xev xclientmessageevent) (cond ((or (and (= window signal-window) (= data0 +destroy-message+)) (and (= window this-window) (= message-type wm-protocols) (= data0 wm-delete-window))) (setf got-close-signal t)) ((and (= window signal-window) (= data0 +refresh-message+)) (refresh))))))))))) ;; close down everything (with-slots (display pixmap window signal-window pointer xlib-context) xlib-image-context (xsynchronize display 1) (let ((saved-pointer pointer)) (setf pointer nil) ; invalidate first so it can't be used (cairo_destroy saved-pointer)) (cairo_destroy xlib-context) ;; !! free xlib-context, surface (xdestroywindow display window) (xdestroywindow display signal-window) (xclosedisplay display)))) ;; initialize (xsynchronize display 1) (let* ((screen (xdefaultscreen display)) (root (xdefaultrootwindow display)) (visual (xdefaultvisual display screen)) (whitepixel (xwhitepixel display screen))) (with-slots (window signal-window thread wm-delete-window pointer graphics-context xlib-context) xlib-image-context ;; create signal window and window (setf window (create-window display root width height 'inputoutput visual whitepixel (logior exposuremask structurenotifymask) t)) (setf signal-window (create-window display root 1 1 'inputonly visual whitepixel 0 nil)) ;; create graphics-context (setf graphics-context (xcreategc display window 0 (null-pointer))) ;; set size hints on window (most window managers will respect this) (set-window-size-hints display window width width height height) ;; intern atom for window closing, set protocol on window (setf wm-delete-window (xinternatom display "WM_DELETE_WINDOW" 1)) (with-foreign-object (prot 'xatom) (setf (mem-aref prot 'xatom) wm-delete-window) (xsetwmprotocols display window prot 1)) ;; store name (xstorename display window window-name) ;; first we create an X11 surface and context on the window (let ((xlib-surface (cairo_xlib_surface_create display window visual width height))) (setf xlib-context (cairo_create xlib-surface)) (cairo_surface_destroy xlib-surface)) ;; create cairo surface, then context, then set the ;; surface as the source of the xlib-context (let ((surface (cairo_image_surface_create :CAIRO_FORMAT_RGB24 width height))) (setf pointer (cairo_create surface)) (cairo_set_source_surface xlib-context surface 0 0) (cairo_surface_destroy surface)) ;; map window (xmapwindow display window) ;; end of synchronizing (xsynchronize display 0) ;; start thread (setf thread (start-thread #'event-loop (format nil "thread for display ~a" display-name)))))) ;; paint it if we are given a background color (when background-color (set-source-color background-color xlib-image-context) (paint xlib-image-context) (sync xlib-image-context)) ;; return context xlib-image-context))) (defmethod destroy ((object xlib-image-context)) (send-message-to-signal-window object +destroy-message+)) ;; export manually (export '(xlib-image-context create-xlib-image-context))
8,091
Common Lisp
.lisp
198
35.29798
82
0.69431
rheaplex/minara
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
08454433580126c62e9fd2ff49dfb63c1b7b5ee147f92e74106c586a036ecc2e
21,704
[ -1 ]