summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/function_declaration.hpp
blob: aabf8a2dba3c141680c38afedc5767732b810bf7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef EOLIAN_CXX_FUNCTION_DECLARATION_HH
#define EOLIAN_CXX_FUNCTION_DECLARATION_HH

#include "grammar/generator.hpp"
#include "grammar/klass_def.hpp"

#include "grammar/indentation.hpp"
#include "grammar/list.hpp"
#include "grammar/alternative.hpp"
#include "grammar/type.hpp"
#include "grammar/parameter.hpp"
#include "grammar/keyword.hpp"

namespace efl { namespace eolian { namespace grammar {

struct function_declaration_generator
{
  template <typename OutputIterator, typename Context>
  bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
  {
    return as_generator
      (grammar::type << " " << string << "(" << (parameter % ", ") << ") const;\n")
      .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), context);
  }
};

template <>
struct is_eager_generator<function_declaration_generator> : std::true_type {};

namespace type_traits {
template <>
struct attributes_needed<function_declaration_generator> : std::integral_constant<int, 1> {};
}
      
function_declaration_generator const function_declaration;
      
} } }

#endif