diff options
Diffstat (limited to 'tools/gn/functions.h')
-rw-r--r-- | tools/gn/functions.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/tools/gn/functions.h b/tools/gn/functions.h index b55ff3a..351861b 100644 --- a/tools/gn/functions.h +++ b/tools/gn/functions.h @@ -18,7 +18,6 @@ class Label; class ListNode; class ParseNode; class Scope; -class SourceDir; class Token; class Value; @@ -26,6 +25,14 @@ class Value; namespace functions { +// This type of function invocation has no block and evaluates its arguments +// itself rather than taking a pre-executed list. This allows us to implement +// certain built-in functions. +typedef Value (*SelfEvaluatingArgsFunction)(Scope* scope, + const FunctionCallNode* function, + const ListNode* args_list, + Err* err); + // This type of function invocation takes a block node that it will execute. typedef Value (*GenericBlockFunction)(Scope* scope, const FunctionCallNode* function, @@ -92,6 +99,13 @@ Value RunDeclareArgs(Scope* scope, BlockNode* block, Err* err); +extern const char kDefined[]; +extern const char kDefined_Help[]; +Value RunDefined(Scope* scope, + const FunctionCallNode* function, + const ListNode* args_list, + Err* err); + extern const char kExecScript[]; extern const char kExecScript_Help[]; Value RunExecScript(Scope* scope, @@ -234,10 +248,12 @@ Value RunWriteFile(Scope* scope, // which indicates the type of function it is. struct FunctionInfo { FunctionInfo(); + FunctionInfo(SelfEvaluatingArgsFunction seaf, const char* in_help); FunctionInfo(GenericBlockFunction gbf, const char* in_help); FunctionInfo(ExecutedBlockFunction ebf, const char* in_help); FunctionInfo(NoBlockFunction nbf, const char* in_help); + SelfEvaluatingArgsFunction self_evaluating_args_runner; GenericBlockFunction generic_block_runner; ExecutedBlockFunction executed_block_runner; NoBlockFunction no_block_runner; @@ -253,7 +269,7 @@ const FunctionInfoMap& GetFunctions(); // Runs the given function. Value RunFunction(Scope* scope, const FunctionCallNode* function, - const std::vector<Value>& args, + const ListNode* args_list, BlockNode* block, // Optional. Err* err); @@ -300,10 +316,6 @@ bool EnsureSingleStringArg(const FunctionCallNode* function, const std::vector<Value>& args, Err* err); -// Returns the source directory for the file comtaining the given function -// invocation. -const SourceDir& SourceDirForFunctionCall(const FunctionCallNode* function); - // Returns the name of the toolchain for the given scope. const Label& ToolchainLabelForScope(const Scope* scope); |