(ffi:clines "
#include <SDL2/SDL.h>
")

(defun atof (a) (* 1.0 (with-input-from-string (in a) (read in))))

(defun c-add (a b) "arguments are ennumerated."
(ffi:c-inline (a b) (:float :float) :float
 "@(return) = #0 + #1;"))

(defun c-powf (a b)
(ffi:c-inline (a b) (:float :float) :float
 "@(return) = powf(#0,#1);"))

(defun sdl2-atan2 (x y) "returns radians"
(ffi:c-inline
 (y x) (:double :double) :double "SDL_atan2(#0,#1)" :one-liner t))

(defvar *math-form* (list '+ 0 0))

(defvar *ops* (pairlis '("add" "powf" "atan2") `(,#'c-add ,#'c-powf ,#'sdl2-atan2)))

(defvar *help-message*
`("--op" (key from ,*ops*)
  "-a" number-1 "-b" number-2
  press return))

(defconstant +command-args+
'(("--op" 1 (setq *math-form*
             (list (cdr (assoc 1 *ops* :test 'equal)) 0 0)))
  ("-a" 1 (setf (second *math-form*) (atof 1)))
  ("-b" 1 (setf (third *math-form*) (atof 1)))
  ("-?" 0 (print *help-message*) :stop)
  ("*DEFAULT*" 0 (print *help-message*) :stop)))

(ext:process-command-args :rules +command-args+)

(print `(*math-form* ,*math-form*))

(When (car *math-form*) (print (apply (car *math-form*) (cdr *math-form*))))

(terpri)

(si:quit)