diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-11-28 14:17:51 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-12-05 10:17:02 +0900 |
commit | 6653b9e2b1196f6d22ad8733bb67bf94b17e0d12 (patch) | |
tree | 14eba8d58634ef786d5906c8ac7a20eb4a69e91a /src/lib/eolian_cxx | |
parent | 0f812f15847e9127b19e9711f9cb1dd26d938f0a (diff) |
cxx: Implement support for @class static functions
Diffstat (limited to 'src/lib/eolian_cxx')
-rw-r--r-- | src/lib/eolian_cxx/grammar/function_declaration.hpp | 8 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/function_definition.hpp | 20 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/klass_def.hpp | 6 |
3 files changed, 24 insertions, 10 deletions
diff --git a/src/lib/eolian_cxx/grammar/function_declaration.hpp b/src/lib/eolian_cxx/grammar/function_declaration.hpp index 04694fa1fb..fe3ad732f1 100644 --- a/src/lib/eolian_cxx/grammar/function_declaration.hpp +++ b/src/lib/eolian_cxx/grammar/function_declaration.hpp | |||
@@ -24,7 +24,7 @@ struct function_declaration_generator | |||
24 | template <typename OutputIterator, typename Context> | 24 | template <typename OutputIterator, typename Context> |
25 | bool generate(OutputIterator sink, attributes::function_def const& f, Context const& ctx) const | 25 | bool generate(OutputIterator sink, attributes::function_def const& f, Context const& ctx) const |
26 | { | 26 | { |
27 | std::string suffix; | 27 | std::string suffix, static_flag, const_flag; |
28 | switch(_klass_name.type) | 28 | switch(_klass_name.type) |
29 | { | 29 | { |
30 | case attributes::class_type::regular: | 30 | case attributes::class_type::regular: |
@@ -50,8 +50,12 @@ struct function_declaration_generator | |||
50 | .generate(sink, attributes::unused, ctx)) | 50 | .generate(sink, attributes::unused, ctx)) |
51 | return false; | 51 | return false; |
52 | 52 | ||
53 | if (f.is_static) static_flag = "static "; | ||
54 | else const_flag = " const"; | ||
55 | |||
53 | if(!as_generator | 56 | if(!as_generator |
54 | (scope_tab << "::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "(" << (parameter % ", ") << ") const;\n") | 57 | (scope_tab << static_flag << "::efl::eolian::return_traits<" << grammar::type(true) << ">::type " |
58 | << string << "(" << (parameter % ", ") << ")" << const_flag << ";\n") | ||
55 | .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), ctx)) | 59 | .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), ctx)) |
56 | return false; | 60 | return false; |
57 | if(f.is_beta && | 61 | if(f.is_beta && |
diff --git a/src/lib/eolian_cxx/grammar/function_definition.hpp b/src/lib/eolian_cxx/grammar/function_definition.hpp index 55f56216fd..1ffbed4bb3 100644 --- a/src/lib/eolian_cxx/grammar/function_definition.hpp +++ b/src/lib/eolian_cxx/grammar/function_definition.hpp | |||
@@ -60,9 +60,14 @@ struct function_definition_generator | |||
60 | .generate(sink, attributes::unused, ctx)) | 60 | .generate(sink, attributes::unused, ctx)) |
61 | return false; | 61 | return false; |
62 | 62 | ||
63 | std::string const_flag; | ||
64 | if (!f.is_static) const_flag = " const"; | ||
65 | |||
63 | if(!as_generator | 66 | if(!as_generator |
64 | ("inline ::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "::" << string << "(" << (parameter % ", ") << ") const\n{\n") | 67 | ("inline ::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "::" |
65 | .generate(sink, std::make_tuple(f.return_type, _klass_name.eolian_name, escape_keyword(f.name), f.parameters), ctx)) | 68 | << string << "(" << (parameter % ", ") << ")" << string << "\n{\n") |
69 | .generate(sink, std::make_tuple(f.return_type, _klass_name.eolian_name, | ||
70 | escape_keyword(f.name), f.parameters, const_flag), ctx)) | ||
66 | return false; | 71 | return false; |
67 | 72 | ||
68 | std::vector<std::string> opening_statements(f.opening_statements()); | 73 | std::vector<std::string> opening_statements(f.opening_statements()); |
@@ -104,10 +109,13 @@ struct function_definition_generator | |||
104 | && !as_generator(attributes::c_type({attributes::parameter_direction::in, f.return_type, ""}) | 109 | && !as_generator(attributes::c_type({attributes::parameter_direction::in, f.return_type, ""}) |
105 | << " __return_value = " | 110 | << " __return_value = " |
106 | ).generate(sink, attributes::unused, ctx)) return false; | 111 | ).generate(sink, attributes::unused, ctx)) return false; |
107 | 112 | ||
113 | std::string object_flag; | ||
114 | if (f.is_static) object_flag = "_eo_class()"; | ||
115 | else object_flag = "_eo_ptr()"; | ||
116 | |||
108 | if(!as_generator | 117 | if(!as_generator |
109 | (" ::" << string << "(this->_eo_ptr()" | 118 | (" ::" << string << "(" << string << |
110 | << | ||
111 | *( | 119 | *( |
112 | "\n" << scope_tab << scope_tab << ", " | 120 | "\n" << scope_tab << scope_tab << ", " |
113 | << | 121 | << |
@@ -119,7 +127,7 @@ struct function_definition_generator | |||
119 | ) | 127 | ) |
120 | ) | 128 | ) |
121 | << ");\n" | 129 | << ");\n" |
122 | ).generate(sink, std::make_tuple(f.c_name, f.parameters), ctx)) | 130 | ).generate(sink, std::make_tuple(f.c_name, object_flag, f.parameters), ctx)) |
123 | return false; | 131 | return false; |
124 | 132 | ||
125 | auto out_assignments = | 133 | auto out_assignments = |
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp index fc6d62d5b8..b2aae1bbef 100644 --- a/src/lib/eolian_cxx/grammar/klass_def.hpp +++ b/src/lib/eolian_cxx/grammar/klass_def.hpp | |||
@@ -439,6 +439,7 @@ struct function_def | |||
439 | bool is_beta; | 439 | bool is_beta; |
440 | bool is_protected; | 440 | bool is_protected; |
441 | bool is_function_pointer; | 441 | bool is_function_pointer; |
442 | bool is_static; | ||
442 | 443 | ||
443 | friend inline bool operator==(function_def const& lhs, function_def const& rhs) | 444 | friend inline bool operator==(function_def const& lhs, function_def const& rhs) |
444 | { | 445 | { |
@@ -449,7 +450,8 @@ struct function_def | |||
449 | && lhs.filename == rhs.filename | 450 | && lhs.filename == rhs.filename |
450 | && lhs.is_beta == rhs.is_beta | 451 | && lhs.is_beta == rhs.is_beta |
451 | && lhs.is_protected == rhs.is_protected | 452 | && lhs.is_protected == rhs.is_protected |
452 | && lhs.is_function_pointer == rhs.is_function_pointer; | 453 | && lhs.is_function_pointer == rhs.is_function_pointer |
454 | && lhs.is_static == rhs.is_static; | ||
453 | } | 455 | } |
454 | friend inline bool operator!=(function_def const& lhs, function_def const& rhs) | 456 | friend inline bool operator!=(function_def const& lhs, function_def const& rhs) |
455 | { | 457 | { |
@@ -531,7 +533,7 @@ struct function_def | |||
531 | } | 533 | } |
532 | is_beta = eolian_function_is_beta(function); | 534 | is_beta = eolian_function_is_beta(function); |
533 | is_protected = eolian_function_scope_get(function, type) == EOLIAN_SCOPE_PROTECTED; | 535 | is_protected = eolian_function_scope_get(function, type) == EOLIAN_SCOPE_PROTECTED; |
534 | is_protected = eolian_function_scope_get(function, type) == EOLIAN_SCOPE_PROTECTED; | 536 | is_static = eolian_function_is_class(function); |
535 | } | 537 | } |
536 | 538 | ||
537 | std::string template_statement() const | 539 | std::string template_statement() const |