Shinichiro Hamaji | 1d545aa | 2015-06-23 15:29:13 +0900 | [diff] [blame] | 1 | // Copyright 2015 Google Inc. All rights reserved |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 15 | #ifndef FUNC_H_ |
| 16 | #define FUNC_H_ |
| 17 | |
Shinichiro Hamaji | c9b0aca | 2015-07-31 16:47:56 +0900 | [diff] [blame] | 18 | #include <memory> |
| 19 | #include <string> |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 20 | #include <vector> |
| 21 | |
Shinichiro Hamaji | 645cca7 | 2015-09-24 17:04:21 +0900 | [diff] [blame] | 22 | #include "expr.h" |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 23 | |
| 24 | using namespace std; |
| 25 | |
| 26 | struct FuncInfo { |
| 27 | const char* name; |
| 28 | void (*func)(const vector<Value*>& args, Evaluator* ev, string* s); |
| 29 | int arity; |
Shinichiro Hamaji | fead3b7 | 2015-06-18 15:31:15 +0900 | [diff] [blame] | 30 | int min_arity; |
| 31 | // For all parameters. |
| 32 | bool trim_space; |
| 33 | // Only for the first parameter. |
| 34 | bool trim_right_space_1st; |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | void InitFuncTable(); |
| 38 | void QuitFuncTable(); |
| 39 | |
| 40 | FuncInfo* GetFuncInfo(StringPiece name); |
| 41 | |
Shinichiro Hamaji | c9b0aca | 2015-07-31 16:47:56 +0900 | [diff] [blame] | 42 | struct FindCommand; |
| 43 | |
Dan Willemsen | f06d801 | 2016-10-03 00:16:07 -0700 | [diff] [blame] | 44 | enum struct CommandOp { |
| 45 | SHELL, |
| 46 | FIND, |
| 47 | READ, |
| 48 | READ_MISSING, |
| 49 | WRITE, |
| 50 | APPEND, |
| 51 | }; |
| 52 | |
Shinichiro Hamaji | 4db9edc | 2015-08-13 16:43:02 +0900 | [diff] [blame] | 53 | struct CommandResult { |
Dan Willemsen | f06d801 | 2016-10-03 00:16:07 -0700 | [diff] [blame] | 54 | CommandOp op; |
Stefan Becker | d4f2871 | 2016-04-07 13:29:36 +0300 | [diff] [blame] | 55 | string shell; |
Dan Willemsen | 064be22 | 2016-09-30 20:17:14 -0700 | [diff] [blame] | 56 | string shellflag; |
Shinichiro Hamaji | c9b0aca | 2015-07-31 16:47:56 +0900 | [diff] [blame] | 57 | string cmd; |
| 58 | unique_ptr<FindCommand> find; |
| 59 | string result; |
| 60 | }; |
| 61 | |
Shinichiro Hamaji | 4db9edc | 2015-08-13 16:43:02 +0900 | [diff] [blame] | 62 | const vector<CommandResult*>& GetShellCommandResults(); |
Shinichiro Hamaji | c9b0aca | 2015-07-31 16:47:56 +0900 | [diff] [blame] | 63 | |
Shinichiro Hamaji | 776ca30 | 2015-06-06 03:52:48 +0900 | [diff] [blame] | 64 | #endif // FUNC_H_ |