source download embed.lsp
Module: embed
Author: Ralph Ronnquist, Real Thing Entertainment Pty. Ltd.
Location: http://www.realthing.com.au/files/newlisp/embed.lsp
Version: 1.0
Utility for embedding
This is a utility module for producing an embedded newlisp program, including all loaded source. It instruments the "load" function to use an embedded source if such exists, or else to capture the external file for embedding. Embedding is a three-stage procedure:
- Place a clause:
(Embed:embed-save main-file)in the main program file at the point where the program is fully loaded, but before its main activity starts.
- Generate an embedding base by running newlisp with embed.lsp as its first module:
% newlisp embed.lsp main-file.lspThis generates the file embed-main-file.lsp; i.e., the prefix "embed-" to the main file name given to embed-save above. Note that only files loaded via the load function are included in the embedding, and not those given on the command line.
- Run newlisp embedding with the embedding base:
% newlisp -x embed-main-file.lsp program
§
embed-save
syntax: (embed-save main-file)
parameter: main-file - is the name of the main file to append.
When invoked for creating the embedding base, the embed-save function writes this as an embeddable source file for the application and exits.
The embedding base constists of a preamble that is a snapshot of the Embed context, which in particular includes the embedded variable as set up with all loaded files, and its initial variable set to false. This is followed by action clauses to redirect the load function to embed-load, which uses the embedded sources rather than loading external files. Finally the given main file is appended.
When invoked in the embedded appliation, embed-save just returns without ado.§
embed-load
syntax: (embed-load filename)
The embed-load function replicates the standard load function, but taking its input from pre-loaded files from the embedded alist, if possible, and otherwise capturing those that are read in into the embedded ailst.- ∂ -
generated with newLISP and newLISPdoc