Skip to content

Commit

Permalink
lispworks conditionalization
Browse files Browse the repository at this point in the history
  • Loading branch information
lisp committed Apr 22, 2011
1 parent fea0ec5 commit 5ecfb67
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 14 deletions.
30 changes: 26 additions & 4 deletions classes.lisp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -224,15 +224,18 @@
(:method ((identifier string)) (:method ((identifier string))
identifier)) identifier))



;;; 20110402 : lw does not allow for standard argument keys, thus the &allow-other-keys here
(defmethod c2mop:direct-slot-definition-class ((class thrift-class) &key identifier (identifier-name identifier)) (defmethod c2mop:direct-slot-definition-class ((class thrift-class) &key
identifier (identifier-name identifier)
&allow-other-keys)
"If an id is present in the definition, the slot is included to pr included when de/serializing" "If an id is present in the definition, the slot is included to pr included when de/serializing"
(cond (identifier-name (cond (identifier-name
(find-class 'direct-field-definition)) (find-class 'direct-field-definition))
(t (t
(call-next-method)))) (call-next-method))))


(defmethod c2mop:effective-slot-definition-class ((class thrift-class) &key name) (defmethod c2mop:effective-slot-definition-class ((class thrift-class) &key name
&allow-other-keys)
"If some direct lost definition indicates thrift support, them carry that over to the effective definition" "If some direct lost definition indicates thrift support, them carry that over to the effective definition"
(if (some #'(lambda (class) (if (some #'(lambda (class)
(typep (find name (c2mop:class-direct-slots class) :key #'field-definition-name) (typep (find name (c2mop:class-direct-slots class) :key #'field-definition-name)
Expand Down Expand Up @@ -313,7 +316,26 @@
;; for use in macros ;; for use in macros
(getf (cddr fd) :type)) (getf (cddr fd) :type))
(:method ((sd c2mop:slot-definition)) (:method ((sd c2mop:slot-definition))
(c2mop:slot-definition-type sd))) (let ((literal-type (c2mop:slot-definition-type sd)))
;; clozure rewrites the types specified in a slot definition
(etypecase literal-type
(symbol (case literal-type
(boolean 'bool)
(double-float 'thrift:double)
(single-float 'thrift:float)
(base-string 'string)
(t literal-type)))
(cons (case (first literal-type)
(member (if (or (equal '(member nil t) literal-type) (equal '(member t nil) literal-type))
'bool
literal-type))
(signed-byte (ecase (second literal-type)
(8 'i08)
(16 'i16)
(32 'i32)
(64 'i64)))
((array vector) 'binary)
(t literal-type)))))))




(defgeneric class-field-definitions (class) (defgeneric class-field-definitions (class)
Expand Down
21 changes: 14 additions & 7 deletions package.lisp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
#+sbcl #+sbcl
(:import-from :sb-gray (:import-from :sb-gray
:stream-write-string) :stream-write-string)

#+lispworks
(:import-from :stream
:stream-write-string)
(:export (:export
:*binary-transport-element-type* :*binary-transport-element-type*
:application-error :application-error
Expand Down Expand Up @@ -195,28 +197,33 @@
stream operators.") stream operators.")


(:shadowing-import-from :common-lisp :byte :set :list :map :type-of :float) (:shadowing-import-from :common-lisp :byte :set :list :map :type-of :float)


(:import-from :de.setf.utility
:stream-reader
:stream-writer
)
#+ccl #+ccl
(:import-from :ccl (:import-from :ccl
:stream-write-byte :stream-read-byte :stream-write-byte :stream-read-byte
:stream-close :stream-direction :stream-direction
:stream-position :stream-position
:stream-read-sequence :stream-write-sequence
:stream-force-output :stream-finish-output) :stream-force-output :stream-finish-output)

#+mcl
(:import-from :ccl
:stream-close
:stream-read-sequence :stream-write-sequence
:stream-tyi :stream-tyo :stream-untyi)
#+clozure #+clozure
(:import-from :ccl (:import-from :ccl
:double-float-positive-infinity :double-float-positive-infinity
:double-float-negative-infinity :double-float-negative-infinity
#+ccl-1.4 :double-float-nan) #+ccl-1.4 :double-float-nan)

#+sbcl #+sbcl
(:import-from :sb-ext (:import-from :sb-ext
:double-float-positive-infinity :double-float-positive-infinity
:double-float-negative-infinity :double-float-negative-infinity
:single-float-positive-infinity :single-float-positive-infinity
:single-float-negative-infinity) :single-float-negative-infinity)

#+sbcl #+sbcl
(:import-from :sb-gray (:import-from :sb-gray
:stream-write-byte :stream-read-byte :stream-write-byte :stream-read-byte
Expand Down
11 changes: 11 additions & 0 deletions parameters.lisp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -185,3 +185,14 @@
(eval '(+ single-float-positive-infinity single-float-negative-infinity))) (eval '(+ single-float-positive-infinity single-float-negative-infinity)))
(defconstant double-float-nan (defconstant double-float-nan
(eval '(+ double-float-positive-infinity double-float-negative-infinity))))) (eval '(+ double-float-positive-infinity double-float-negative-infinity)))))

#+lispworks
(progn
(defconstant double-float-positive-infinity system::*plus-infinity-double*)
(defconstant double-float-negative-infinity system::*minus-infinity-double*)
(defconstant single-float-positive-infinity (coerce system::*plus-infinity-double* 'single-float))
(defconstant single-float-negative-infinity (coerce system::*minus-infinity-double* 'single-float))

(defconstant single-float-nan (+ single-float-positive-infinity single-float-negative-infinity))
(defconstant double-float-nan (+ double-float-positive-infinity double-float-negative-infinity))
)
4 changes: 3 additions & 1 deletion types.lisp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
'list) 'list)




(deftype base-type () '(member bool thrift:byte i08 i16 i32 i64 double thrift:float string binary)) (deftype base-type ()
"Indicates the union of thrift base (atomic) types."
'(member bool thrift:byte i08 i16 i32 i64 double thrift:float string binary))


(defun base-type-p (type) (defun base-type-p (type)
(typep type 'base-type)) (typep type 'base-type))
Expand Down
4 changes: 2 additions & 2 deletions vector-protocol.lisp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
(incf position) (incf position)
byte)))) byte))))


#+ccl #+mcl
(defmethod ccl:stream-tyi ((stream vector-input-stream)) (defmethod ccl:stream-tyi ((stream vector-input-stream))
(stream-read-byte stream)) (stream-read-byte stream))


Expand Down Expand Up @@ -198,7 +198,7 @@
(setf position next))) (setf position next)))




#+ccl #+mcl
(defmethod ccl:stream-tyo ((stream vector-output-stream) byte) (defmethod ccl:stream-tyo ((stream vector-output-stream) byte)
(stream-write-byte stream byte)) (stream-write-byte stream byte))


Expand Down

0 comments on commit 5ecfb67

Please sign in to comment.