Skip to content

Commit

Permalink
add defxstar, fix map-g-into
Browse files Browse the repository at this point in the history
map-g-into it used to listify the fbo beofre handing to
with-fbo-bound. This was so we could use all the args from
with-fbo-bound
..this didnt work as then you can pass (some-fbo x) as the fbo

ugh..need a better approach
  • Loading branch information
cbaggers committed Apr 10, 2016
1 parent 77403f3 commit 3013461
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/pipelines/map-g.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
%current-fbo)))

(defmacro map-g-into (fbo pipeline-func stream &rest uniforms)
`(with-fbo-bound ,(listify fbo)
`(with-fbo-bound (,fbo)
(map-g ,pipeline-func ,stream ,@uniforms)))
42 changes: 41 additions & 1 deletion core/utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@
(values (intern (apply #'mkstr args))))

(defun symb-package (package &rest args)
(values (intern (apply #'cepl-utils:mkstr args) package)))
(values (intern (apply #'cepl-utils:mkstr args)
(if (packagep package)
package
(find-package package)))))

(defun make-keyword (&rest args)
"This takes a list of symbols (or strings) and outputs one
Expand Down Expand Up @@ -509,3 +512,40 @@ source: ~s~%list-to-match: ~s" list list-to-match)
(defun just-ignore (&rest args)
(declare (ignore args))
nil)

(defpackage :defxstar-hidden)

(defstruct (defxstar-hidden::boop6
(:constructor defxstar-hidden::make-boop6)
(:conc-name nil)
(:predicate defxstar-hidden::boop-p))
defxstar-hidden::boop-x defxstar-hidden::boop-y)

(defun defx* (defname name slots)
(labels ((extract-slot-def (x)
(dbind (slot-name _ &key type) x
(declare (ignore _))
(list (symb name :- slot-name) nil :type (or type t))))
(extract-let (x)
(dbind (name val &key type) x
(declare (ignore type))
(list name val)))
(extract-init (x)
(let ((slot-name (first x)))
(list (kwd name :- slot-name) slot-name))))
(let* ((data-name (symb-package :defxstar-hidden name :-data))
(cname (symb-package :defxstar-hidden :%make- data-name)))
`(progn
(defstruct (,data-name (:constructor ,cname)
(:predicate nil)
(:conc-name nil))
,@(mapcar #'extract-slot-def slots))
(,defname ,name
(let* ,(mapcar #'extract-let slots)
(,cname ,@(mapcan #'extract-init slots))))))))

(defmacro defvar* (name &body slots)
(defx* 'defvar name slots))

(defmacro defparameter* (name &body slots)
(defx* 'defparameter name slots))
12 changes: 9 additions & 3 deletions package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
:ni-val
:n-of
:n-of*
:just-ignore))
:just-ignore
:defvar*
:defparameter*))

(defpackage :cepl.errors
(:use :cl :cffi :cepl-utils :varjo :varjo-lang :rtg-math)
Expand Down Expand Up @@ -834,15 +836,19 @@
:shadow (:quit)
:import-from ((:cepl-utils :deferror
:print-mem
:p->))
:p->
:defvar*
:defparameter*))
:export (:make-project
:quit
:repl
:step-host
:continuable
:cls
:swap
:print-mem)
:print-mem
:defvar*
:defparameter*)
:re-export (:cepl.render-state
:cepl.viewports
:cepl.types
Expand Down

0 comments on commit 3013461

Please sign in to comment.