@animech-public/playcanvas
Version:
PlayCanvas WebGL game engine
47 lines (46 loc) • 2.08 kB
TypeScript
/**
* Pure static class implementing subset of C-style preprocessor.
* inspired by: https://github.com/dcodeIO/Preprocessor.js
*
* @ignore
*/
export class Preprocessor {
/**
* Run c-like preprocessor on the source code, and resolves the code based on the defines and ifdefs
*
* @param {string} source - The source code to work on.
* @param {Map<string, string>} [includes] - A map containing key-value pairs of include names
* and their content. These are used for resolving #include directives in the source.
* @param {boolean} [stripUnusedColorAttachments] - If true, strips unused color attachments.
* @returns {string|null} Returns preprocessed source code, or null in case of error.
*/
static run(source: string, includes?: Map<string, string>, stripUnusedColorAttachments?: boolean): string | null;
static processArraySize(source: any, intDefines: any): any;
static RemoveEmptyLines(source: any): any;
/**
* Process source code, and resolves the code based on the defines and ifdefs.
*
* @param {string} source - The source code to work on.
* @param {Map<string, string>} defines - Supplied defines which are used in addition to those
* defined in the source code. Maps a define name to its value. Note that the map is modified
* by the function.
* @param {Map<string, string>} [includes] - An object containing key-value pairs of include names and their
* content.
* @returns {string} Returns preprocessed source code.
*/
static _preprocess(source: string, defines?: Map<string, string>, includes?: Map<string, string>): string;
static _keep(stack: any): boolean;
/**
* Very simple expression evaluation, handles cases:
* expression
* defined(expression)
* !defined(expression)
*
* But does not handle more complex cases, which would require more complex system:
* defined(A) || defined(B)
*/
static evaluate(expression: any, defines: any): {
result: any;
error: boolean;
};
}