summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2017-07-04 14:06:23 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-07-13 19:00:49 -0300
commitc966c3976ee6a3ae0ab5952663e1bcc6c1ba1d94 (patch)
tree4fdc59a2792572452025ec95a5aeedc5fcd2e9f0
parent44edb8e0698a0965907b2e4f7de0fc9022a76007 (diff)
eolian_mono eolian_cxx: remove reduntant c_type field from parameter_def
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_type.hh6
-rw-r--r--src/bin/eolian_mono/eolian/mono/type.hh2
-rw-r--r--src/lib/eolian_cxx/grammar/c_type.hpp4
-rw-r--r--src/lib/eolian_cxx/grammar/function_definition.hpp2
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp13
-rw-r--r--src/lib/eolian_cxx/grammar/type.hpp2
6 files changed, 13 insertions, 16 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_type.hh b/src/bin/eolian_mono/eolian/mono/marshall_type.hh
index b3df7c3308..006d09c696 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_type.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_type.hh
@@ -29,7 +29,7 @@ struct marshall_type_generator
29 template <typename OutputIterator, typename Context> 29 template <typename OutputIterator, typename Context>
30 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const 30 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
31 { 31 {
32 return param.type.original_type.visit(detail::marshall_type_visitor_generate<OutputIterator, Context>{sink, &context, param.c_type 32 return param.type.original_type.visit(detail::marshall_type_visitor_generate<OutputIterator, Context>{sink, &context, param.type.c_type
33 , param.direction != attributes::parameter_direction::in, false}); 33 , param.direction != attributes::parameter_direction::in, false});
34 } 34 }
35 35
@@ -49,7 +49,7 @@ struct marshall_annotation_generator
49 template <typename OutputIterator, typename Context> 49 template <typename OutputIterator, typename Context>
50 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const 50 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
51 { 51 {
52 return param.type.original_type.visit(detail::marshall_annotation_visitor_generate<OutputIterator, Context>{sink, &context, param.c_type 52 return param.type.original_type.visit(detail::marshall_annotation_visitor_generate<OutputIterator, Context>{sink, &context, param.type.c_type
53 , param.direction != attributes::parameter_direction::in, false}); 53 , param.direction != attributes::parameter_direction::in, false});
54 } 54 }
55 55
@@ -69,7 +69,7 @@ struct marshall_native_annotation_generator
69 template <typename OutputIterator, typename Context> 69 template <typename OutputIterator, typename Context>
70 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const 70 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
71 { 71 {
72 return param.type.original_type.visit(detail::marshall_native_annotation_visitor_generate<OutputIterator, Context>{sink, &context, param.c_type 72 return param.type.original_type.visit(detail::marshall_native_annotation_visitor_generate<OutputIterator, Context>{sink, &context, param.type.c_type
73 , param.direction != attributes::parameter_direction::in, false}); 73 , param.direction != attributes::parameter_direction::in, false});
74 } 74 }
75 75
diff --git a/src/bin/eolian_mono/eolian/mono/type.hh b/src/bin/eolian_mono/eolian/mono/type.hh
index f2503ff56a..b0e14516ce 100644
--- a/src/bin/eolian_mono/eolian/mono/type.hh
+++ b/src/bin/eolian_mono/eolian/mono/type.hh
@@ -25,7 +25,7 @@ struct type_generator
25 template <typename OutputIterator, typename Context> 25 template <typename OutputIterator, typename Context>
26 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const 26 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
27 { 27 {
28 return param.type.original_type.visit(visitor_generate<OutputIterator, Context>{sink, &context, param.c_type 28 return param.type.original_type.visit(visitor_generate<OutputIterator, Context>{sink, &context, param.type.c_type
29 , param.direction != attributes::parameter_direction::in, false}); 29 , param.direction != attributes::parameter_direction::in, false});
30 } 30 }
31 31
diff --git a/src/lib/eolian_cxx/grammar/c_type.hpp b/src/lib/eolian_cxx/grammar/c_type.hpp
index 1a163538d7..e680b38835 100644
--- a/src/lib/eolian_cxx/grammar/c_type.hpp
+++ b/src/lib/eolian_cxx/grammar/c_type.hpp
@@ -35,10 +35,10 @@ inline std::string c_type(parameter_def const& param)
35 switch(param.direction) 35 switch(param.direction)
36 { 36 {
37 case parameter_direction::in: 37 case parameter_direction::in:
38 return param.type.original_type.visit(c_type_visitor{&param.c_type}); 38 return param.type.original_type.visit(c_type_visitor{&param.type.c_type});
39 case parameter_direction::out: 39 case parameter_direction::out:
40 case parameter_direction::inout: 40 case parameter_direction::inout:
41 return param.type.original_type.visit(c_type_visitor{&param.c_type}) + "*"; 41 return param.type.original_type.visit(c_type_visitor{&param.type.c_type}) + "*";
42 default: 42 default:
43 throw std::runtime_error("Unknown parameter direction"); 43 throw std::runtime_error("Unknown parameter direction");
44 }; 44 };
diff --git a/src/lib/eolian_cxx/grammar/function_definition.hpp b/src/lib/eolian_cxx/grammar/function_definition.hpp
index d85c6f02a1..5dbfccc44f 100644
--- a/src/lib/eolian_cxx/grammar/function_definition.hpp
+++ b/src/lib/eolian_cxx/grammar/function_definition.hpp
@@ -88,7 +88,7 @@ struct function_definition_generator
88 if(!as_generator(scope_tab).generate(sink, attributes::unused, ctx)) return false; 88 if(!as_generator(scope_tab).generate(sink, attributes::unused, ctx)) return false;
89 89
90 if(f.return_type != attributes::void_ 90 if(f.return_type != attributes::void_
91 && !as_generator(attributes::c_type({attributes::parameter_direction::in, f.return_type, "", f.return_type.c_type}) 91 && !as_generator(attributes::c_type({attributes::parameter_direction::in, f.return_type, ""})
92 << " __return_value = " 92 << " __return_value = "
93 ).generate(sink, attributes::unused, ctx)) return false; 93 ).generate(sink, attributes::unused, ctx)) return false;
94 94
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index e81f3da6f2..f4d1a70140 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -335,26 +335,23 @@ struct parameter_def
335 parameter_direction direction; 335 parameter_direction direction;
336 type_def type; 336 type_def type;
337 std::string param_name; 337 std::string param_name;
338 std::string c_type; // TODO: Remove this. Use 'c_type' inside 'type' instead.
339 338
340 friend inline bool operator==(parameter_def const& lhs, parameter_def const& rhs) 339 friend inline bool operator==(parameter_def const& lhs, parameter_def const& rhs)
341 { 340 {
342 return lhs.direction == rhs.direction 341 return lhs.direction == rhs.direction
343 && lhs.type == rhs.type 342 && lhs.type == rhs.type
344 && lhs.param_name == rhs.param_name 343 && lhs.param_name == rhs.param_name;
345 && lhs.c_type == rhs.c_type;
346 } 344 }
347 friend inline bool operator!=(parameter_def const& lhs, parameter_def const& rhs) 345 friend inline bool operator!=(parameter_def const& lhs, parameter_def const& rhs)
348 { 346 {
349 return !(lhs == rhs); 347 return !(lhs == rhs);
350 } 348 }
351 349
352 parameter_def(parameter_direction direction, type_def type, std::string param_name, std::string c_type) 350 parameter_def(parameter_direction direction, type_def type, std::string param_name)
353 : direction(std::move(direction)), type(std::move(type)), param_name(std::move(param_name)), c_type(std::move(c_type)) {} 351 : direction(std::move(direction)), type(std::move(type)), param_name(std::move(param_name)) {}
354 parameter_def(Eolian_Function_Parameter const* param, Eolian_Unit const* unit) 352 parameter_def(Eolian_Function_Parameter const* param, Eolian_Unit const* unit)
355 : type( ::eolian_parameter_type_get(param), unit) 353 : type( ::eolian_parameter_type_get(param), unit)
356 , param_name( ::eolian_parameter_name_get(param)) 354 , param_name( ::eolian_parameter_name_get(param))
357 , c_type( ::eolian_type_c_type_get(::eolian_parameter_type_get(param)))
358 { 355 {
359 Eolian_Parameter_Dir direction = ::eolian_parameter_direction_get(param); 356 Eolian_Parameter_Dir direction = ::eolian_parameter_direction_get(param);
360 switch(direction) 357 switch(direction)
@@ -400,8 +397,8 @@ template <>
400struct tuple_element<3ul, parameter_def> 397struct tuple_element<3ul, parameter_def>
401{ 398{
402 typedef std::string type; 399 typedef std::string type;
403 static type const& get(parameter_def const& p) { return p.c_type; } 400 static type const& get(parameter_def const& p) { return p.type.c_type; }
404 static type& get(parameter_def& p) { return p.c_type; } 401 static type& get(parameter_def& p) { return p.type.c_type; }
405}; 402};
406template <int I> 403template <int I>
407typename tuple_element<I, parameter_def>::type const& get(parameter_def const& p) 404typename tuple_element<I, parameter_def>::type const& get(parameter_def const& p)
diff --git a/src/lib/eolian_cxx/grammar/type.hpp b/src/lib/eolian_cxx/grammar/type.hpp
index 4eb08ac55e..61e0e55fba 100644
--- a/src/lib/eolian_cxx/grammar/type.hpp
+++ b/src/lib/eolian_cxx/grammar/type.hpp
@@ -23,7 +23,7 @@ struct type_generator
23 template <typename OutputIterator, typename Context> 23 template <typename OutputIterator, typename Context>
24 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const 24 bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
25 { 25 {
26 return param.type.original_type.visit(visitor_generate<OutputIterator, Context>{sink, &context, param.c_type 26 return param.type.original_type.visit(visitor_generate<OutputIterator, Context>{sink, &context, param.type.c_type
27 , param.direction != attributes::parameter_direction::in, false}); 27 , param.direction != attributes::parameter_direction::in, false});
28 } 28 }
29 29