Permalink
Browse files

c++ add make_from_tuple

	modified:   src/cl-stl-base.lisp
	modified:   src/cl-stl-tuple.lisp
	modified:   src/user-package.lisp
  • Loading branch information...
show-matz committed Jan 15, 2019
1 parent 76a21aa commit 232991a0c3f9b48247088d229c4b1100906c478d
Showing with 52 additions and 0 deletions.
  1. +4 −0 src/cl-stl-base.lisp
  2. +44 −0 src/cl-stl-tuple.lisp
  3. +4 −0 src/user-package.lisp
@@ -198,6 +198,10 @@
#-cl-stl-0x98 :tuple_cat
#-cl-stl-0x98 :tie
#-(or cl-stl-noextra cl-stl-0x98) :with_tie
#-(or
cl-stl-0x98
cl-stl-0x11
cl-stl-0x14) :make_from_tuple
;----------------------------------
;utility
:pair
@@ -385,6 +385,50 @@
(<= 0 (tuple-compare (__inner-array tpl1) (__inner-array tpl2)))))))


#-(or cl-stl-0x98 cl-stl-0x11 cl-stl-0x14)
(locally (declare (optimize speed))
(defun __make_from_tuple-imp (ctor tpl)
(let ((arr (__inner-array tpl)))
(declare (type simple-vector arr))
(let ((cnt (length arr)))
(declare (type fixnum cnt))
(case cnt
(2 (locally (declare (type (simple-vector 2) arr))
(cl:funcall ctor (svref arr 0) (svref arr 1))))
(3 (locally (declare (type (simple-vector 3) arr))
(cl:funcall ctor (svref arr 0)
(svref arr 1) (svref arr 2))))
(4 (locally (declare (type (simple-vector 4) arr))
(cl:funcall ctor (svref arr 0) (svref arr 1)
(svref arr 2) (svref arr 3))))
(5 (locally (declare (type (simple-vector 5) arr))
(cl:funcall ctor (svref arr 0) (svref arr 1)
(svref arr 2) (svref arr 3) (svref arr 4))))
(6 (locally (declare (type (simple-vector 6) arr))
(cl:funcall ctor (svref arr 0) (svref arr 1)
(svref arr 2) (svref arr 3)
(svref arr 4) (svref arr 5))))
(7 (locally (declare (type (simple-vector 7) arr))
(cl:funcall ctor (svref arr 0) (svref arr 1)
(svref arr 2) (svref arr 3)
(svref arr 4) (svref arr 5) (svref arr 6))))
(8 (locally (declare (type (simple-vector 8) arr))
(cl:funcall ctor (svref arr 0) (svref arr 1)
(svref arr 2) (svref arr 3)
(svref arr 4) (svref arr 5)
(svref arr 6) (svref arr 7))))
(9 (locally (declare (type (simple-vector 9) arr))
(cl:funcall ctor (svref arr 0) (svref arr 1)
(svref arr 2) (svref arr 3)
(svref arr 4) (svref arr 5)
(svref arr 6) (svref arr 7) (svref arr 8))))
(t (cl:apply ctor (coerce arr 'cl:list))))))))

#-(or cl-stl-0x98 cl-stl-0x11 cl-stl-0x14)
(defmacro make_from_tuple (type tpl)
(let ((ctor-name (cl-overload::make-constructor-name type)))
`(__make_from_tuple-imp #',ctor-name ,tpl)))


;;------------------------------------------------------------------------------
;;
@@ -195,6 +195,10 @@
#-cl-stl-0x98 :tuple_cat
#-cl-stl-0x98 :tie
#-(or cl-stl-noextra cl-stl-0x98) :with_tie
#-(or
cl-stl-0x98
cl-stl-0x11
cl-stl-0x14) :make_from_tuple
;----------------------------------
;utility
:pair

0 comments on commit 232991a

Please sign in to comment.