1 /*
2  * Copyright 2019 by its authors. See AUTHORS.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifdef HAVE_CONFIG_H
17 # include <config.h>
18 #endif
19 
20 #include <iostream>
21 #include <cassert>
22 #include <iterator>
23 
24 #include "eolian_cxx_suite.h"
25 
26 #include <grammar/header.hpp>
27 
EFL_START_TEST(eolian_cxx_test_generate_complex_types)28 EFL_START_TEST(eolian_cxx_test_generate_complex_types)
29 {
30    using efl::eolian::grammar::class_header;
31    using efl::eolian::grammar::attributes::unused_type;
32    using efl::eolian::grammar::attributes::regular_type_def;
33    using efl::eolian::grammar::attributes::klass_name;
34    using efl::eolian::grammar::attributes::complex_type_def;
35    using efl::eolian::grammar::attributes::parameter_direction;
36    using efl::eolian::grammar::attributes::qualifier_info;
37    using efl::eolian::grammar::context_null;;
38 
39    // efl::eolian::grammar::attributes::klass_def my_class
40    // {
41    //      "Class_Name", "Class_Name", {"Namespace1", "Namesapce2"}
42    //    , {
43    //        {{regular_type_def{"int", {qualifier_info::is_none, {}}, {}}}
44    //        , "function_name"
45    //        , {
46    //            {parameter_direction::in,    {regular_type_def{"unsigned", {qualifier_info::is_none, {}}, {}}}, "param1", ""}
47    //          , {parameter_direction::out,   {klass_name{{"Namespace1","Namesapce2"}, "Class_Name",
48    //                                                                                    {qualifier_info::is_none, {}}, {}, {}}}
49    //              , "param2", ""}
50    //          , {parameter_direction::inout, {complex_type_def
51    //                  {{
52    //                    {regular_type_def{"list", {qualifier_info::is_none, {}}, {}}}
53    //                  , {regular_type_def{"int",  {qualifier_info::is_none, {}}, {}}}
54    //                  }}}
55    //              , "param3", ""}
56    //          }
57    //        }
58    //      }
59    //    , {}
60    //    , {}
61    // };
62 
63    // std::tuple<std::string, std::vector<std::string>
64    //            , std::vector<std::string>, std::vector<efl::eolian::grammar::attributes::klass_def>
65    //            , std::vector<efl::eolian::grammar::attributes::klass_def>
66    //            , std::vector<efl::eolian::grammar::attributes::klass_def>> attributes
67    //   {"GUARD_HEADER_HH", {"abc.h", "def.h"}, {"abc.hh", "def.hh"}, {my_class}, {my_class}, {my_class}};
68    // std::vector<char> buffer;
69    // class_header.generate(std::back_inserter<std::vector<char>>(buffer), attributes, context_null());
70 
71    // const char result[] =
72    //   "#ifndef GUARD_HEADER_HH\n"
73    //   "#define GUARD_HEADER_HH\n"
74    //   "#endif\n"
75    //   ;
76 
77    // std::cout << "Beginning of generated file" << std::endl;
78    // std::copy(buffer.begin(), buffer.end(), std::ostream_iterator<char>(std::cout));
79    // std::cout << "\n End of generated file" << std::endl;
80 
81    // ck_assert(buffer.size() == (sizeof(result) - 1));
82    // ck_assert(std::equal(buffer.begin(), buffer.end(), result));
83 }
84 EFL_END_TEST
85 
86 void
eolian_cxx_test_generate(TCase * tc)87 eolian_cxx_test_generate(TCase* tc)
88 {
89    tcase_add_test(tc, eolian_cxx_test_generate_complex_types);
90 }
91