================================================================================ Extended Code Generation Notes ================================================================================ The inspect module looks like a goldmine of code manipulation and analysis functions. There are functions to access + change the values of function parameters, access the source code of functions and classes, and get maniupte aforementioned data in various ways. Right now, I think that the best way forward will be to create a dedicated code manipulation module inside of the scheme->utils directory. The module will function as a code generator that takes in raw functions from the widget's core code and manipulates them to create statically executable output. There will be distinct phases of code generation, each one moving a bit lower down from simply getting the source code of the function(s) and inserting it into the output script. For example, a likely second step could be generating a list of variable declarations for the code header or to generate/modify a self variable to be injected or copied into the output. Once as much as possible is done to the actual code objects, the final step is to do manual replacements and analysis of the generated code as strings. This should be kept to as much of a minimum as possible, as it can lead to messy and difficult to understand code. I think it will be a good idea to not go far out of the way to work with abstract python classes/functions/objects in a difficult way when I could much more easily do a simple string replace on the generated output and spare the whole effort. However, at the same time, forwards compatibility should be kept in mind and code generation functions should attempt to avoid methods of code generation such as counting characters, lines, or other arbitrary methods that can easily break as a result of future code changes to the widgets themselves. It's a bit like parsing HTML. You can convert the HTML strings to DOM nodes and convert the DOM nodes to objects in a programming language, or you can search the document text-wise and manually pull out text. The method proposed above is a bit of a mix between the two, as it starts out mainly relying on the function's original source code to be copied directly into the output but also entails some higher-level edits made programatically to the functions before they even hit the source code generator.
Password: Filename:
Secret