summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-11-28 14:17:51 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-11-28 17:47:12 +0900
commitc2a190bd82ffacc3206e58d46aa589d78ab98f09 (patch)
tree599272f06758bd5ca7c92d69d91bcf62e8f733e6
parent486b6b700a752ef5fc4a86872b97c1b6d6c56cf3 (diff)
cxx: Implement support for @class static functions
-rw-r--r--src/lib/eolian_cxx/grammar/function_declaration.hpp8
-rw-r--r--src/lib/eolian_cxx/grammar/function_definition.hpp20
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp5
3 files changed, 24 insertions, 9 deletions
diff --git a/src/lib/eolian_cxx/grammar/function_declaration.hpp b/src/lib/eolian_cxx/grammar/function_declaration.hpp
index 106cf9bc4b..7a9c36ef4d 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 d6c61558e3..3843cdf1ee 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, "", f.return_type.c_type}) 109 && !as_generator(attributes::c_type({attributes::parameter_direction::in, f.return_type, "", f.return_type.c_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 21ebca1cb3..6cb76d8ff6 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -420,6 +420,7 @@ struct function_def
420 bool is_beta; 420 bool is_beta;
421 bool is_protected; 421 bool is_protected;
422 bool is_function_pointer; 422 bool is_function_pointer;
423 bool is_static;
423 424
424 friend inline bool operator==(function_def const& lhs, function_def const& rhs) 425 friend inline bool operator==(function_def const& lhs, function_def const& rhs)
425 { 426 {
@@ -429,7 +430,8 @@ struct function_def
429 && lhs.c_name == rhs.c_name 430 && lhs.c_name == rhs.c_name
430 && lhs.is_beta == rhs.is_beta 431 && lhs.is_beta == rhs.is_beta
431 && lhs.is_protected == rhs.is_protected 432 && lhs.is_protected == rhs.is_protected
432 && lhs.is_function_pointer == rhs.is_function_pointer; 433 && lhs.is_function_pointer == rhs.is_function_pointer
434 && lhs.is_static == rhs.is_static;
433 } 435 }
434 friend inline bool operator!=(function_def const& lhs, function_def const& rhs) 436 friend inline bool operator!=(function_def const& lhs, function_def const& rhs)
435 { 437 {
@@ -500,6 +502,7 @@ struct function_def
500 c_name = eolian_function_full_c_name_get(function, type, EINA_FALSE); 502 c_name = eolian_function_full_c_name_get(function, type, EINA_FALSE);
501 is_beta = eolian_function_is_beta(function); 503 is_beta = eolian_function_is_beta(function);
502 is_protected = eolian_function_scope_get(function, type) == EOLIAN_SCOPE_PROTECTED; 504 is_protected = eolian_function_scope_get(function, type) == EOLIAN_SCOPE_PROTECTED;
505 is_static = eolian_function_is_class(function);
503 } 506 }
504 507
505 std::string template_statement() const 508 std::string template_statement() const