Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 1 | #ifndef T_FUNCTION_H |
| 2 | #define T_FUNCTION_H |
| 3 | |
| 4 | #include <string> |
| 5 | #include "t_type.h" |
| 6 | #include "t_struct.h" |
| 7 | |
| 8 | /** |
| 9 | * Representation of a function. Key parst are return type, function name, |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 10 | * optional modifiers, and an argument list. |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 11 | * |
| 12 | * @author Mark Slee <mcslee@facebook.com> |
| 13 | */ |
| 14 | class t_function { |
| 15 | public: |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 16 | t_function(t_type* returntype, |
| 17 | std::string name, |
| 18 | t_struct* arglist, |
| 19 | bool async=false) : |
| 20 | returntype_(returntype), |
| 21 | name_(name), |
| 22 | arglist_(arglist), |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame^] | 23 | async_(async) { |
| 24 | xceptions_ = new t_struct; |
| 25 | } |
| 26 | |
| 27 | |
| 28 | t_function(t_type* returntype, |
| 29 | std::string name, |
| 30 | t_struct* arglist, |
| 31 | t_struct* xceptions, |
| 32 | bool async=false) : |
| 33 | returntype_(returntype), |
| 34 | name_(name), |
| 35 | arglist_(arglist), |
| 36 | xceptions_(xceptions), |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 37 | async_(async) {} |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 38 | |
| 39 | ~t_function() {} |
| 40 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 41 | t_type* get_returntype() const { return returntype_; } |
| 42 | const std::string& get_name() const { return name_; } |
| 43 | t_struct* get_arglist() const { return arglist_; } |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame^] | 44 | t_struct* get_xceptions() const { return xceptions_; } |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 45 | bool is_async() const { return async_; } |
Mark Slee | b15a68b | 2006-06-07 06:46:24 +0000 | [diff] [blame] | 46 | |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 47 | private: |
| 48 | t_type* returntype_; |
| 49 | std::string name_; |
| 50 | t_struct* arglist_; |
Mark Slee | 9cb7c61 | 2006-09-01 22:17:45 +0000 | [diff] [blame^] | 51 | t_struct* xceptions_; |
Mark Slee | 52f643d | 2006-08-09 00:03:43 +0000 | [diff] [blame] | 52 | bool async_; |
Mark Slee | 3198572 | 2006-05-24 21:45:31 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | #endif |