Skip to content

Commit

Permalink
Add runtime getters to python and lisp files
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Jun 29, 2024
1 parent 385cac6 commit 0b0ccdd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions compile.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,23 @@ public static class PromptFont {~%")
(format stream "~
# PromptFont by Yukari \"Shinmera\" Hafner, accessible at https://shinmera.com/promptfont~%")
(format stream "~&~a = ~s~%" (to-c-name code-name) character)
())
(format stream "~&
def get(name){
return globals()[name]
}"))

(define-processor lisp (stream code-name character)
(format stream "~
;;;; PromptFont by Yukari \"Shinmera\" Hafner, accessible at https://shinmera.com/promptfont
\(defpackage #:org.shirakumo.fraf.promptfont (:use))
\(in-package #:org.shirakumo.fraf.promptfont)~%~%")
(format stream "~&(cl:define-symbol-macro ~a ~s)~%" code-name character)
(format stream "~&~%~
(format stream "~&(cl:setf (cl:symbol-value '~a) ~s)~%" code-name character)
(format stream "~&
(cl:defun get (get)
(cl:etypecase get
(cl:symbol (get (cl:symbol-name get)))
(cl:string (cl:symbol-value (cl:find-symbol get #.cl:*package*)))))
(cl:do-symbols (cl:symbol cl:*package*)
(cl:export cl:symbol))~%"))

Expand Down

2 comments on commit 0b0ccdd

@domdfcoding
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python syntax is wrong. Instead of the curley braces there should be a colon, like this:

def get(name): 
  return globals()[name]

@Shinmera
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What an embarrassing mistake. Thanks!

Please sign in to comment.