@ -353,6 +353,20 @@ It's time to create a compile-time function which will create our runtime comman
Each hook has a pre-defined signature, which is what the ~environment~ and other arguments are. If you use the wrong signature, you will get a helpful error saying what the expected signature was.
From our previous note on ~post-references-resolved~ we learned that our hook can be invoked multiple times. Let's store a comptime var to prevent it from being called more than once:
We have to make the decision to do this ourselves because we might actually want a hook to respond to many iterations of ~post-references-resolved~. In this case however, we want it to run only once.
Our compile-time function is now hooked up and running when all references are resolved, but it's doing nothing.
Let's get our command table and make a loop to iterate over it, printing each command:
@ -360,6 +374,11 @@ Let's get our command table and make a loop to iterate over it, printing each co
(get-or-create-comptime-var command-table (<> (in std vector) (* (const Token))))
(var command-data (* (<> std::vector Token)) (new (<> std::vector Token)))
@ -511,9 +535,10 @@ We use a /splice point/ to save a spot to insert code later. Define a splice poi
(splice-point command-lookup-table)
#+END_SRC
Finally, let's evaluate our generated code, outputting it to the splice point. We'll change ~create-command-lookup-table~ to return the result of the evaluation:
Finally, let's evaluate our generated code, outputting it to the splice point. We'll change ~create-command-lookup-table~ to return the result of the evaluation. We set ~was-code-modified~ to tell Cakelisp that we actually made changes that may need more processing.