Impelment C++ Generator 58/295558/33
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 13 Jul 2023 06:49:11 +0000 (15:49 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 28 Jul 2023 01:31:45 +0000 (10:31 +0900)
Type marsharling info is included to the parcel data.
To save the information to the parcel, Unit and UnitMap classes are added.

Change-Id: I8eb2b6e1d924702b2b84b1f20bc798bb2b6c5c1d
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
32 files changed:
idlc/CMakeLists.txt
idlc/ast/location.hh
idlc/ast/position.hh
idlc/ast/tidlc.yy
idlc/ast/tidlc_y.cpp
idlc/ast/tidlc_y.hpp
idlc/ast/type.cc
idlc/ast/type.h
idlc/gen/generator.cc
idlc/gen/generator.h
idlc/gen/replace_all.cc
idlc/gen/replace_all.h
idlc/gen/version2/c_body_generator_base.cc
idlc/gen/version2/cpp_generator_base.cc [new file with mode: 0644]
idlc/gen/version2/cpp_generator_base.hh [new file with mode: 0644]
idlc/gen/version2/cpp_generator_base_cb.hh [new file with mode: 0644]
idlc/gen/version2/cpp_proxy_body_generator.cc [new file with mode: 0644]
idlc/gen/version2/cpp_proxy_body_generator.hh [new file with mode: 0644]
idlc/gen/version2/cpp_proxy_body_generator_cb.hh [new file with mode: 0644]
idlc/gen/version2/cpp_proxy_header_generator.cc [new file with mode: 0644]
idlc/gen/version2/cpp_proxy_header_generator.hh [new file with mode: 0644]
idlc/gen/version2/cpp_proxy_header_generator_cb.hh [new file with mode: 0644]
idlc/gen/version2/cpp_stub_body_generator.cc [new file with mode: 0644]
idlc/gen/version2/cpp_stub_body_generator.hh [new file with mode: 0644]
idlc/gen/version2/cpp_stub_body_generator_cb.hh [new file with mode: 0644]
idlc/gen/version2/cpp_stub_header_generator.cc [new file with mode: 0644]
idlc/gen/version2/cpp_stub_header_generator.hh [new file with mode: 0644]
idlc/gen/version2/cpp_stub_header_generator_cb.hh [new file with mode: 0644]
idlc/main.cc
tests/build_tests/CMakeLists.txt
tests/build_tests/prebuild.sh
tests/build_tests/tidl/Message_v2test.tidl [new file with mode: 0644]

index 00a5178..00c4ca8 100644 (file)
@@ -18,6 +18,7 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wno-unused-function -Wno-sign-compare")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++11")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g")
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
 SET(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static-libgcc")
 SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
index 5839186..c045e77 100644 (file)
@@ -1,8 +1,8 @@
-// A Bison parser, made by GNU Bison 3.0.4.
+// A Bison parser, made by GNU Bison 3.5.1.
 
 // Locations for Bison parsers in C++
 
-// Copyright (C) 2002-2015 Free Software Foundation, Inc.
+// Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
 
 // This program is free software: you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 #ifndef YY_YY_OPT_DATA_TIZEN_PUBLIC_PLATFORM_CORE_APPFW_TIDL_IDLC_AST_LOCATION_HH_INCLUDED
 # define YY_YY_OPT_DATA_TIZEN_PUBLIC_PLATFORM_CORE_APPFW_TIDL_IDLC_AST_LOCATION_HH_INCLUDED
 
-# include "position.hh"
+# include <iostream>
+# include <string>
 
+# ifndef YY_NULLPTR
+#  if defined __cplusplus
+#   if 201103L <= __cplusplus
+#    define YY_NULLPTR nullptr
+#   else
+#    define YY_NULLPTR 0
+#   endif
+#  else
+#   define YY_NULLPTR ((void*)0)
+#  endif
+# endif
 
 namespace yy {
-#line 46 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/location.hh" // location.cc:296
-  /// Abstract a location.
+#line 58 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/location.hh"
+
+  /// A point in a source file.
+  class position
+  {
+  public:
+    /// Type for line and column numbers.
+    typedef int counter_type;
+
+    /// Initialization.
+    void initialize (std::string* fn = YY_NULLPTR,
+                     counter_type l = 1,
+                     counter_type c = 1)
+    {
+      filename = fn;
+      line = l;
+      column = c;
+    }
+
+    /** \name Line and Column related manipulators
+     ** \{ */
+    /// (line related) Advance to the COUNT next lines.
+    void lines (counter_type count = 1)
+    {
+      if (count)
+        {
+          column = 1;
+          line = add_ (line, count, 1);
+        }
+    }
+
+    /// (column related) Advance to the COUNT next columns.
+    void columns (counter_type count = 1)
+    {
+      column = add_ (column, count, 1);
+    }
+    /** \} */
+
+    /// File name to which this position refers.
+    std::string* filename;
+    /// Current line number.
+    counter_type line;
+    /// Current column number.
+    counter_type column;
+
+  private:
+    /// Compute max (min, lhs+rhs).
+    static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min)
+    {
+      return lhs + rhs < min ? min : lhs + rhs;
+    }
+  };
+
+  /// Add \a width columns, in place.
+  inline position&
+  operator+= (position& res, position::counter_type width)
+  {
+    res.columns (width);
+    return res;
+  }
+
+  /// Add \a width columns.
+  inline position
+  operator+ (position res, position::counter_type width)
+  {
+    return res += width;
+  }
+
+  /// Subtract \a width columns, in place.
+  inline position&
+  operator-= (position& res, position::counter_type width)
+  {
+    return res += -width;
+  }
+
+  /// Subtract \a width columns.
+  inline position
+  operator- (position res, position::counter_type width)
+  {
+    return res -= width;
+  }
+
+  /// Compare two position objects.
+  inline bool
+  operator== (const position& pos1, const position& pos2)
+  {
+    return (pos1.line == pos2.line
+            && pos1.column == pos2.column
+            && (pos1.filename == pos2.filename
+                || (pos1.filename && pos2.filename
+                    && *pos1.filename == *pos2.filename)));
+  }
+
+  /// Compare two position objects.
+  inline bool
+  operator!= (const position& pos1, const position& pos2)
+  {
+    return !(pos1 == pos2);
+  }
+
+  /** \brief Intercept output stream redirection.
+   ** \param ostr the destination output stream
+   ** \param pos a reference to the position to redirect
+   */
+  template <typename YYChar>
+  std::basic_ostream<YYChar>&
+  operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
+  {
+    if (pos.filename)
+      ostr << *pos.filename << ':';
+    return ostr << pos.line << '.' << pos.column;
+  }
+
+  /// Two points in a source file.
   class location
   {
   public:
+    /// Type for line and column numbers.
+    typedef position::counter_type counter_type;
 
     /// Initialization.
     void initialize (std::string* f = YY_NULLPTR,
-                     unsigned int l = 1u,
-                     unsigned int c = 1u)
+                     counter_type l = 1,
+                     counter_type c = 1)
     {
       begin.initialize (f, l, c);
       end = begin;
@@ -67,13 +193,13 @@ namespace yy {
     }
 
     /// Extend the current location to the COUNT next columns.
-    void columns (int count = 1)
+    void columns (counter_type count = 1)
     {
       end += count;
     }
 
     /// Extend the current location to the COUNT next lines.
-    void lines (int count = 1)
+    void lines (counter_type count = 1)
     {
       end.lines (count);
     }
@@ -88,39 +214,45 @@ namespace yy {
   };
 
   /// Join two locations, in place.
-  inline location& operator+= (location& res, const location& end)
+  inline location&
+  operator+= (location& res, const location& end)
   {
     res.end = end.end;
     return res;
   }
 
   /// Join two locations.
-  inline location operator+ (location res, const location& end)
+  inline location
+  operator+ (location res, const location& end)
   {
     return res += end;
   }
 
   /// Add \a width columns to the end position, in place.
-  inline location& operator+= (location& res, int width)
+  inline location&
+  operator+= (location& res, location::counter_type width)
   {
     res.columns (width);
     return res;
   }
 
   /// Add \a width columns to the end position.
-  inline location operator+ (location res, int width)
+  inline location
+  operator+ (location res, location::counter_type width)
   {
     return res += width;
   }
 
   /// Subtract \a width columns to the end position, in place.
-  inline location& operator-= (location& res, int width)
+  inline location&
+  operator-= (location& res, location::counter_type width)
   {
     return res += -width;
   }
 
   /// Subtract \a width columns to the end position.
-  inline location operator- (location res, int width)
+  inline location
+  operator- (location res, location::counter_type width)
   {
     return res -= width;
   }
@@ -146,10 +278,11 @@ namespace yy {
    ** Avoid duplicate information.
    */
   template <typename YYChar>
-  inline std::basic_ostream<YYChar>&
+  std::basic_ostream<YYChar>&
   operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
   {
-    unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
+    location::counter_type end_col
+      = 0 < loc.end.column ? loc.end.column - 1 : 0;
     ostr << loc.begin;
     if (loc.end.filename
         && (!loc.begin.filename
@@ -162,7 +295,7 @@ namespace yy {
     return ostr;
   }
 
-
 } // yy
-#line 168 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/location.hh" // location.cc:296
+#line 300 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/location.hh"
+
 #endif // !YY_YY_OPT_DATA_TIZEN_PUBLIC_PLATFORM_CORE_APPFW_TIDL_IDLC_AST_LOCATION_HH_INCLUDED
index 4d0f698..bf34c1c 100644 (file)
-// A Bison parser, made by GNU Bison 3.0.4.
+// A Bison parser, made by GNU Bison 3.5.1.
 
-// Positions for Bison parsers in C++
+// Starting with Bison 3.2, this file is useless: the structure it
+// used to define is now defined in "location.hh".
+//
+// To get rid of this file:
+// 1. add '%require "3.2"' (or newer) to your grammar file
+// 2. remove references to this file from your build system
+// 3. if you used to include it, include "location.hh" instead.
 
-// Copyright (C) 2002-2015 Free Software Foundation, Inc.
-
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-// As a special exception, you may create a larger work that contains
-// part or all of the Bison parser skeleton and distribute that work
-// under terms of your choice, so long as that work isn't itself a
-// parser generator using the skeleton or a modified version thereof
-// as a parser skeleton.  Alternatively, if you modify or redistribute
-// the parser skeleton itself, you may (at your option) remove this
-// special exception, which will cause the skeleton and the resulting
-// Bison output files to be licensed under the GNU General Public
-// License without this special exception.
-
-// This special exception was added by the Free Software Foundation in
-// version 2.2 of Bison.
-
-/**
- ** \file /opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/position.hh
- ** Define the yy::position class.
- */
-
-#ifndef YY_YY_OPT_DATA_TIZEN_PUBLIC_PLATFORM_CORE_APPFW_TIDL_IDLC_AST_POSITION_HH_INCLUDED
-# define YY_YY_OPT_DATA_TIZEN_PUBLIC_PLATFORM_CORE_APPFW_TIDL_IDLC_AST_POSITION_HH_INCLUDED
-
-# include <algorithm> // std::max
-# include <iostream>
-# include <string>
-
-# ifndef YY_NULLPTR
-#  if defined __cplusplus && 201103L <= __cplusplus
-#   define YY_NULLPTR nullptr
-#  else
-#   define YY_NULLPTR 0
-#  endif
-# endif
-
-
-namespace yy {
-#line 56 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/position.hh" // location.cc:296
-  /// Abstract a position.
-  class position
-  {
-  public:
-    /// Initialization.
-    void initialize (std::string* fn = YY_NULLPTR,
-                     unsigned int l = 1u,
-                     unsigned int c = 1u)
-    {
-      filename = fn;
-      line = l;
-      column = c;
-    }
-
-    /** \name Line and Column related manipulators
-     ** \{ */
-    /// (line related) Advance to the COUNT next lines.
-    void lines (int count = 1)
-    {
-      if (count)
-        {
-          column = 1u;
-          line = add_ (line, count, 1);
-        }
-    }
-
-    /// (column related) Advance to the COUNT next columns.
-    void columns (int count = 1)
-    {
-      column = add_ (column, count, 1);
-    }
-    /** \} */
-
-    /// File name to which this position refers.
-    std::string* filename;
-    /// Current line number.
-    unsigned int line;
-    /// Current column number.
-    unsigned int column;
-
-  private:
-    /// Compute max(min, lhs+rhs) (provided min <= lhs).
-    static unsigned int add_ (unsigned int lhs, int rhs, unsigned int min)
-    {
-      return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs
-              ? rhs + lhs
-              : min);
-    }
-  };
-
-  /// Add \a width columns, in place.
-  inline position&
-  operator+= (position& res, int width)
-  {
-    res.columns (width);
-    return res;
-  }
-
-  /// Add \a width columns.
-  inline position
-  operator+ (position res, int width)
-  {
-    return res += width;
-  }
-
-  /// Subtract \a width columns, in place.
-  inline position&
-  operator-= (position& res, int width)
-  {
-    return res += -width;
-  }
-
-  /// Subtract \a width columns.
-  inline position
-  operator- (position res, int width)
-  {
-    return res -= width;
-  }
-
-  /// Compare two position objects.
-  inline bool
-  operator== (const position& pos1, const position& pos2)
-  {
-    return (pos1.line == pos2.line
-            && pos1.column == pos2.column
-            && (pos1.filename == pos2.filename
-                || (pos1.filename && pos2.filename
-                    && *pos1.filename == *pos2.filename)));
-  }
-
-  /// Compare two position objects.
-  inline bool
-  operator!= (const position& pos1, const position& pos2)
-  {
-    return !(pos1 == pos2);
-  }
-
-  /** \brief Intercept output stream redirection.
-   ** \param ostr the destination output stream
-   ** \param pos a reference to the position to redirect
-   */
-  template <typename YYChar>
-  inline std::basic_ostream<YYChar>&
-  operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
-  {
-    if (pos.filename)
-      ostr << *pos.filename << ':';
-    return ostr << pos.line << '.' << pos.column;
-  }
-
-
-} // yy
-#line 169 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/position.hh" // location.cc:296
-#endif // !YY_YY_OPT_DATA_TIZEN_PUBLIC_PLATFORM_CORE_APPFW_TIDL_IDLC_AST_POSITION_HH_INCLUDED
+#include "location.hh"
index 68e2a6d..2ab2894 100644 (file)
@@ -417,9 +417,14 @@ elements: element {
 ;
 
 element: raw_type T_ID T_SEMICOLON {
-    $$ = new tidl::Element($2->ToString(), $1, $1->GetComments(),
-        @1.begin.line);
-    delete $2;
+    if (tidl::BaseType::IsFile($1)) {
+      ps->ReportError("syntax error. \"The file cannot be included in the struct.\"", @2.begin.line);
+      $$ = NULL;
+    } else {
+      $$ = new tidl::Element($2->ToString(), $1, $1->GetComments(),
+          @1.begin.line);
+      delete $2;
+    }
   }
   | raw_type T_SEMICOLON {
     ps->ReportError("syntax error. \"No identifier\".", @2.begin.line);
@@ -875,6 +880,10 @@ container_type: container_type_name T_META_OPEN base_type T_META_CLOSE {
         ps->ReportError("syntax error. The value must be existed.", @1.begin.line);
         delete $1;
       } else {
+        if ($3->GetMetaType() != nullptr && tidl::BaseType::IsFile($3)) {
+          ps->ReportError("syntax error. The file should be included in only one container.", @1.begin.line);
+        }
+
         $$ = new tidl::BaseType($1->ToString(), $1->GetComments());
         $$->SetMetaType($3);
         delete $1;
index 0ba12ab..9cffa0c 100644 (file)
@@ -1,8 +1,8 @@
-// A Bison parser, made by GNU Bison 3.0.4.
+// A Bison parser, made by GNU Bison 3.5.1.
 
 // Skeleton implementation for Bison GLR parsers in C
 
-// Copyright (C) 2002-2015 Free Software Foundation, Inc.
+// Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
 
 // This program is free software: you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 
 /* C GLR parser skeleton written by Paul Hilfinger.  */
 
+// Undocumented macros, especially those whose name start with YY_,
+// are private implementation details.  Do not rely on them.
+
 /* Identify Bison output.  */
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "3.0.4"
+#define YYBISON_VERSION "3.5.1"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "glr.cc"
@@ -49,8 +52,8 @@
 
 
 
-/* First part of user declarations.  */
-#line 1 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:240
+// First part of user prologue.
+#line 1 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -77,13 +80,26 @@ tidl::Enums* currentInterfaceEnums;
 tidl::Declarations* currentDeclarations = nullptr;
 tidl::Document* document = nullptr;
 
-#line 81 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:240
+#line 84 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
 
+# ifndef YY_CAST
+#  ifdef __cplusplus
+#   define YY_CAST(Type, Val) static_cast<Type> (Val)
+#   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
+#  else
+#   define YY_CAST(Type, Val) ((Type) (Val))
+#   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
+#  endif
+# endif
 # ifndef YY_NULLPTR
-#  if defined __cplusplus && 201103L <= __cplusplus
-#   define YY_NULLPTR nullptr
+#  if defined __cplusplus
+#   if 201103L <= __cplusplus
+#    define YY_NULLPTR nullptr
+#   else
+#    define YY_NULLPTR 0
+#   endif
 #  else
-#   define YY_NULLPTR 0
+#   define YY_NULLPTR ((void*)0)
 #  endif
 # endif
 
@@ -108,35 +124,73 @@ static YYLTYPE yyloc_default
 # endif
 ;
 
-/* Copy the second part of user declarations.  */
-#line 113 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:263
-/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
-   If N is 0, then set CURRENT to the empty location which ends
-   the previous symbol: RHS[0] (always defined).  */
-
-# ifndef YYLLOC_DEFAULT
-#  define YYLLOC_DEFAULT(Current, Rhs, N)                               \
-    do                                                                  \
-      if (N)                                                            \
-        {                                                               \
-          (Current).begin  = YYRHSLOC (Rhs, 1).begin;                   \
-          (Current).end    = YYRHSLOC (Rhs, N).end;                     \
-        }                                                               \
-      else                                                              \
-        {                                                               \
-          (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end;      \
-        }                                                               \
-    while (/*CONSTCOND*/ false)
-# endif
-
-#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
+// Second part of user prologue.
+#line 129 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
 static void yyerror (const yy::parser::location_type *yylocationp, yy::parser& yyparser, tidl::Parser* ps, const char* msg);
-#line 135 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:263
+#line 131 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+
 
+#include <stddef.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
+   <limits.h> and (if available) <stdint.h> are included
+   so that the code can choose integer types of a good width.  */
+
+#ifndef __PTRDIFF_MAX__
+# include <limits.h> /* INFRINGES ON USER NAME SPACE */
+# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
+#  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
+#  define YY_STDINT_H
+# endif
+#endif
+
+/* Narrow types that promote to a signed type and that can represent a
+   signed or unsigned integer of at least N bits.  In tables they can
+   save space and decrease cache pressure.  Promoting to a signed type
+   helps avoid bugs in integer arithmetic.  */
+
+#ifdef __INT_LEAST8_MAX__
+typedef __INT_LEAST8_TYPE__ yytype_int8;
+#elif defined YY_STDINT_H
+typedef int_least8_t yytype_int8;
+#else
+typedef signed char yytype_int8;
+#endif
+
+#ifdef __INT_LEAST16_MAX__
+typedef __INT_LEAST16_TYPE__ yytype_int16;
+#elif defined YY_STDINT_H
+typedef int_least16_t yytype_int16;
+#else
+typedef short yytype_int16;
+#endif
+
+#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
+typedef __UINT_LEAST8_TYPE__ yytype_uint8;
+#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
+       && UINT_LEAST8_MAX <= INT_MAX)
+typedef uint_least8_t yytype_uint8;
+#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
+typedef unsigned char yytype_uint8;
+#else
+typedef short yytype_uint8;
+#endif
+
+#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
+typedef __UINT_LEAST16_TYPE__ yytype_uint16;
+#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
+       && UINT_LEAST16_MAX <= INT_MAX)
+typedef uint_least16_t yytype_uint16;
+#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
+typedef unsigned short yytype_uint16;
+#else
+typedef int yytype_uint16;
+#endif
+
 #ifndef YY_
 # if defined YYENABLE_NLS && YYENABLE_NLS
 #  if ENABLE_NLS
@@ -159,48 +213,64 @@ static void yyerror (const yy::parser::location_type *yylocationp, yy::parser& y
 # define YYREALLOC realloc
 #endif
 
-#define YYSIZEMAX ((size_t) -1)
+#define YYSIZEMAX \
+  (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : YY_CAST (ptrdiff_t, SIZE_MAX))
 
 #ifdef __cplusplus
-   typedef bool yybool;
+  typedef bool yybool;
+# define yytrue true
+# define yyfalse false
 #else
-   typedef unsigned char yybool;
+  /* When we move to stdbool, get rid of the various casts to yybool.  */
+  typedef signed char yybool;
+# define yytrue 1
+# define yyfalse 0
 #endif
-#define yytrue 1
-#define yyfalse 0
 
 #ifndef YYSETJMP
 # include <setjmp.h>
 # define YYJMP_BUF jmp_buf
 # define YYSETJMP(Env) setjmp (Env)
-/* Pacify clang.  */
-# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
+/* Pacify Clang and ICC.  */
+# define YYLONGJMP(Env, Val)                    \
+ do {                                           \
+   longjmp (Env, Val);                          \
+   YY_ASSERT (0);                               \
+ } while (yyfalse)
 #endif
 
-#ifndef YY_ATTRIBUTE
-# if (defined __GNUC__                                               \
-      && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
-     || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
-#  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
+#ifndef YY_ATTRIBUTE_PURE
+# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
+#  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
 # else
-#  define YY_ATTRIBUTE(Spec) /* empty */
+#  define YY_ATTRIBUTE_PURE
 # endif
 #endif
 
-#ifndef YY_ATTRIBUTE_PURE
-# define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
-#endif
-
 #ifndef YY_ATTRIBUTE_UNUSED
-# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
+# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
+#  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+# else
+#  define YY_ATTRIBUTE_UNUSED
+# endif
 #endif
 
-#if !defined _Noreturn \
-     && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
+/* The _Noreturn keyword of C11.  */
+#ifndef _Noreturn
+# if (defined __cplusplus \
+      && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
+          || (defined _MSC_VER && 1900 <= _MSC_VER)))
+#  define _Noreturn [[noreturn]]
+# elif ((!defined __cplusplus || defined __clang__) \
+        && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)  \
+            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
+   /* _Noreturn works as-is.  */
+# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
+#  define _Noreturn __attribute__ ((__noreturn__))
+# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
 #  define _Noreturn __declspec (noreturn)
 # else
-#  define _Noreturn YY_ATTRIBUTE ((__noreturn__))
+#  define _Noreturn
 # endif
 #endif
 
@@ -211,13 +281,13 @@ static void yyerror (const yy::parser::location_type *yylocationp, yy::parser& y
 # define YYUSE(E) /* empty */
 #endif
 
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
-    _Pragma ("GCC diagnostic push") \
-    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                            \
+    _Pragma ("GCC diagnostic push")                                     \
+    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
     _Pragma ("GCC diagnostic pop")
 #else
 # define YY_INITIAL_VALUE(Value) Value
@@ -230,10 +300,20 @@ static void yyerror (const yy::parser::location_type *yylocationp, yy::parser& y
 # define YY_INITIAL_VALUE(Value) /* Nothing. */
 #endif
 
-
-#ifndef YYASSERT
-# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
+#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
+# define YY_IGNORE_USELESS_CAST_BEGIN                          \
+    _Pragma ("GCC diagnostic push")                            \
+    _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
+# define YY_IGNORE_USELESS_CAST_END            \
+    _Pragma ("GCC diagnostic pop")
 #endif
+#ifndef YY_IGNORE_USELESS_CAST_BEGIN
+# define YY_IGNORE_USELESS_CAST_BEGIN
+# define YY_IGNORE_USELESS_CAST_END
+#endif
+
+
+#define YY_ASSERT(E) ((void) (0 && (E)))
 
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  23
@@ -246,7 +326,7 @@ static void yyerror (const yy::parser::location_type *yylocationp, yy::parser& y
 #define YYNNTS  25
 /* YYNRULES -- Number of rules.  */
 #define YYNRULES  97
-/* YYNRULES -- Number of states.  */
+/* YYNSTATES -- Number of states.  */
 #define YYNSTATES  197
 /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule.  */
 #define YYMAXRHS 10
@@ -254,15 +334,23 @@ static void yyerror (const yy::parser::location_type *yylocationp, yy::parser& y
    accessed by $0, $-1, etc., in any rule.  */
 #define YYMAXLEFT 0
 
-/* YYTRANSLATE(X) -- Bison symbol number corresponding to X.  */
-#define YYUNDEFTOK  2
+/* YYMAXUTOK -- Last valid token number (for yychar).  */
 #define YYMAXUTOK   298
+/* YYFAULTYTOK -- Token number (for yychar) that denotes a
+   syntax_error thrown from the scanner.  */
+#define YYFAULTYTOK (YYMAXUTOK + 1)
+/* YYUNDEFTOK -- Symbol number (for yytoken) that denotes an unknown
+   token.  */
+#define YYUNDEFTOK  2
 
-#define YYTRANSLATE(YYX)                                                \
-  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
+   as returned by yylex, with out-of-bounds checking.  */
+#define YYTRANSLATE(YYX)                         \
+  (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
 
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
-static const unsigned char yytranslate[] =
+/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
+   as returned by yylex.  */
+static const yytype_int8 yytranslate[] =
 {
        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -298,18 +386,18 @@ static const unsigned char yytranslate[] =
 
 #if YYDEBUG
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
-static const unsigned short int yyrline[] =
+static const yytype_int16 yyrline[] =
 {
        0,   116,   116,   121,   127,   141,   145,   149,   154,   167,
      176,   188,   200,   212,   239,   268,   295,   300,   306,   313,
      322,   335,   347,   355,   368,   372,   376,   380,   384,   388,
-     394,   402,   413,   419,   424,   428,   432,   438,   446,   457,
-     463,   468,   474,   481,   487,   495,   501,   509,   514,   519,
-     526,   535,   546,   552,   565,   584,   592,   605,   620,   625,
-     630,   635,   639,   643,   647,   651,   657,   665,   676,   682,
-     685,   688,   693,   696,   700,   706,   709,   715,   718,   735,
-     738,   742,   746,   750,   754,   758,   762,   766,   776,   780,
-     784,   846,   873,   883,   896,   900,   904,   912
+     394,   402,   413,   419,   429,   433,   437,   443,   451,   462,
+     468,   473,   479,   486,   492,   500,   506,   514,   519,   524,
+     531,   540,   551,   557,   570,   589,   597,   610,   625,   630,
+     635,   640,   644,   648,   652,   656,   662,   670,   681,   687,
+     690,   693,   698,   701,   705,   711,   714,   720,   723,   740,
+     743,   747,   751,   755,   759,   763,   767,   771,   781,   785,
+     789,   851,   878,   892,   905,   909,   913,   921
 };
 #endif
 
@@ -334,12 +422,12 @@ static const char *const yytname[] =
 };
 #endif
 
-#define YYPACT_NINF -83
-#define YYTABLE_NINF -81
+#define YYPACT_NINF (-83)
+#define YYTABLE_NINF (-81)
 
   // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
   // STATE-NUM.
-static const short int yypact[] =
+static const yytype_int16 yypact[] =
 {
       28,     7,    15,    21,    10,    49,    28,   -83,   -83,   -83,
      -83,    53,   672,    71,    87,   740,    46,   -83,    55,    -1,
@@ -366,7 +454,7 @@ static const short int yypact[] =
   // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
   // Performed when YYTABLE does not specify something else to do.  Zero
   // means the default is an error.
-static const unsigned char yydefact[] =
+static const yytype_int8 yydefact[] =
 {
        0,     0,     0,     0,     0,     0,     2,     3,     7,     6,
        5,     0,     0,     0,     0,     0,     0,    39,     0,     0,
@@ -391,7 +479,7 @@ static const unsigned char yydefact[] =
 };
 
   // YYPGOTO[NTERM-NUM].
-static const short int yypgoto[] =
+static const yytype_int16 yypgoto[] =
 {
      -83,   -83,   -83,   218,   -83,   -83,   -45,   -57,   -83,    67,
      -22,   -31,   173,   163,   -83,   -48,   -54,   -82,   -83,    91,
@@ -399,7 +487,7 @@ static const short int yypgoto[] =
 };
 
   // YYDEFGOTO[NTERM-NUM].
-static const short int yydefgoto[] =
+static const yytype_int16 yydefgoto[] =
 {
       -1,     5,     6,     7,     8,     9,    75,    76,   151,   152,
       43,    44,    19,    20,    10,    55,    56,   115,   116,   117,
@@ -409,7 +497,7 @@ static const short int yydefgoto[] =
   // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
   // positive, shift that token.  If negative, reduce the rule whose
   // number is the opposite.  If YYTABLE_NINF, syntax error.
-static const short int yytable[] =
+static const yytype_int16 yytable[] =
 {
       45,    85,    78,    64,    62,   124,   165,    92,    11,   129,
       62,    90,    68,    45,    89,    12,    14,   166,   105,   130,
@@ -495,7 +583,7 @@ static const short int yytable[] =
       37,    38,    39,    40,    41,    42,     0,     0,     0,    54
 };
 
-static const short int yycheck[] =
+static const yytype_int16 yycheck[] =
 {
       12,    55,    50,    25,     5,    87,     5,     1,     1,     5,
        5,    59,    43,    25,    59,     8,     1,    16,    75,    15,
@@ -583,7 +671,7 @@ static const short int yycheck[] =
 
   // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
   // symbol of state STATE-NUM.
-static const unsigned char yystos[] =
+static const yytype_int8 yystos[] =
 {
        0,    22,    23,    39,    42,    45,    46,    47,    48,    49,
       58,     1,     8,    19,     1,     8,    19,     1,    19,    56,
@@ -608,7 +696,7 @@ static const unsigned char yystos[] =
 };
 
   // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
-static const unsigned char yyr1[] =
+static const yytype_int8 yyr1[] =
 {
        0,    44,    45,    46,    46,    47,    47,    47,    48,    48,
       49,    49,    49,    49,    49,    49,    49,    49,    49,    50,
@@ -623,7 +711,7 @@ static const unsigned char yyr1[] =
 };
 
   // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
-static const unsigned char yyr2[] =
+static const yytype_int8 yyr2[] =
 {
        0,     2,     1,     1,     2,     1,     1,     1,     2,     2,
        5,     6,     5,     7,     8,     7,     4,     5,     3,     1,
@@ -639,7 +727,7 @@ static const unsigned char yyr2[] =
 
 
 /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none).  */
-static const unsigned char yydprec[] =
+static const yytype_int8 yydprec[] =
 {
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
@@ -654,7 +742,7 @@ static const unsigned char yydprec[] =
 };
 
 /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM.  */
-static const unsigned char yymerger[] =
+static const yytype_int8 yymerger[] =
 {
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
@@ -688,7 +776,7 @@ static const yybool yyimmediate[] =
    list of conflicting reductions corresponding to action entry for
    state STATE-NUM in yytable.  0 means no conflicts.  The list in
    yyconfl is terminated by a rule number of 0.  */
-static const unsigned char yyconflp[] =
+static const yytype_int8 yyconflp[] =
 {
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
@@ -776,7 +864,7 @@ static const unsigned char yyconflp[] =
 
 /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
    0, pointed into by YYCONFLP.  */
-static const short int yyconfl[] =
+static const short yyconfl[] =
 {
        0
 };
@@ -801,7 +889,7 @@ static const short int yyconfl[] =
         {                                                               \
           (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end;      \
         }                                                               \
-    while (/*CONSTCOND*/ false)
+    while (false)
 # endif
 
 # define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
@@ -836,6 +924,25 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
 #  define YYFPRINTF fprintf
 # endif
 
+# define YY_FPRINTF                             \
+  YY_IGNORE_USELESS_CAST_BEGIN YY_FPRINTF_
+
+# define YY_FPRINTF_(Args)                      \
+  do {                                          \
+    YYFPRINTF Args;                             \
+    YY_IGNORE_USELESS_CAST_END                  \
+  } while (0)
+
+# define YY_DPRINTF                             \
+  YY_IGNORE_USELESS_CAST_BEGIN YY_DPRINTF_
+
+# define YY_DPRINTF_(Args)                      \
+  do {                                          \
+    if (yydebug)                                \
+      YYFPRINTF Args;                           \
+    YY_IGNORE_USELESS_CAST_END                  \
+  } while (0)
+
 
 /* YY_LOCATION_PRINT -- Print the location on the stream.
    This macro was not mandated originally: define only if we know
@@ -847,10 +954,10 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
 /* Print *YYLOCP on YYO.  Private, do not rely on its existence. */
 
 YY_ATTRIBUTE_UNUSED
-static unsigned
+static int
 yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
 {
-  unsigned res = 0;
+  int res = 0;
   int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
   if (0 <= yylocp->first_line)
     {
@@ -881,12 +988,6 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
 #endif
 
 
-# define YYDPRINTF(Args)                        \
-  do {                                          \
-    if (yydebug)                                \
-      YYFPRINTF Args;                           \
-  } while (0)
-
 
 /*--------------------.
 | Print this symbol.  |
@@ -905,9 +1006,9 @@ yy_symbol_print (FILE *, int yytype, const yy::parser::semantic_type *yyvaluep,
   do {                                                                  \
     if (yydebug)                                                        \
       {                                                                 \
-        YYFPRINTF (stderr, "%s ", Title);                               \
+        YY_FPRINTF ((stderr, "%s ", Title));                            \
         yy_symbol_print (stderr, Type, Value, Location, yyparser, ps);        \
-        YYFPRINTF (stderr, "\n");                                       \
+        YY_FPRINTF ((stderr, "\n"));                                    \
       }                                                                 \
   } while (0)
 
@@ -916,14 +1017,14 @@ yy_symbol_print (FILE *, int yytype, const yy::parser::semantic_type *yyvaluep,
 int yydebug;
 
 struct yyGLRStack;
-static void yypstack (struct yyGLRStack* yystackp, size_t yyk)
+static void yypstack (struct yyGLRStack* yystackp, ptrdiff_t yyk)
   YY_ATTRIBUTE_UNUSED;
 static void yypdumpstack (struct yyGLRStack* yystackp)
   YY_ATTRIBUTE_UNUSED;
 
 #else /* !YYDEBUG */
 
-# define YYDPRINTF(Args)
+# define YY_DPRINTF(Args) do {} while (yyfalse)
 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
 
 #endif /* !YYDEBUG */
@@ -1000,12 +1101,12 @@ yystpcpy (char *yydest, const char *yysrc)
    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
    null, do not copy; instead, return the length of what the result
    would have been.  */
-static size_t
+static ptrdiff_t
 yytnamerr (char *yyres, const char *yystr)
 {
   if (*yystr == '"')
     {
-      size_t yyn = 0;
+      ptrdiff_t yyn = 0;
       char const *yyp = yystr;
 
       for (;;)
@@ -1018,7 +1119,10 @@ yytnamerr (char *yyres, const char *yystr)
           case '\\':
             if (*++yyp != '\\')
               goto do_not_strip_quotes;
-            /* Fall through.  */
+            else
+              goto append;
+
+          append:
           default:
             if (yyres)
               yyres[yyn] = *yyp;
@@ -1033,26 +1137,26 @@ yytnamerr (char *yyres, const char *yystr)
     do_not_strip_quotes: ;
     }
 
-  if (yyres)
-    return strlen (yystr);
-
-  return yystpcpy (yyres, yystr) - yyres;
+  if (yyres)
+    return yystpcpy (yyres, yystr) - yyres;
+  else
+    return YY_CAST (ptrdiff_t, strlen (yystr));
 }
 # endif
 
 #endif /* !YYERROR_VERBOSE */
 
-/** State numbers, as in LALR(1) machine */
+/** State numbers. */
 typedef int yyStateNum;
 
-/** Rule numbers, as in LALR(1) machine */
+/** Rule numbers. */
 typedef int yyRuleNum;
 
-/** Grammar symbol */
+/** Grammar symbol. */
 typedef int yySymbol;
 
-/** Item references, as in LALR(1) machine */
-typedef short int yyItemNum;
+/** Item references. */
+typedef short yyItemNum;
 
 typedef struct yyGLRState yyGLRState;
 typedef struct yyGLRStateSet yyGLRStateSet;
@@ -1071,10 +1175,10 @@ struct yyGLRState {
   /** Preceding state in this stack */
   yyGLRState* yypred;
   /** Source position of the last token produced by my symbol */
-  size_t yyposn;
+  ptrdiff_t yyposn;
   union {
     /** First in a chain of alternative reductions producing the
-     *  non-terminal corresponding to this state, threaded through
+     *  nonterminal corresponding to this state, threaded through
      *  yynext.  */
     yySemanticOption* yyfirstVal;
     /** Semantic value for this state.  */
@@ -1091,7 +1195,8 @@ struct yyGLRStateSet {
    *  operation, yylookaheadNeeds[0] is not maintained since it would merely
    *  duplicate yychar != YYEMPTY.  */
   yybool* yylookaheadNeeds;
-  size_t yysize, yycapacity;
+  ptrdiff_t yysize;
+  ptrdiff_t yycapacity;
 };
 
 struct yySemanticOption {
@@ -1130,7 +1235,7 @@ struct yyGLRStack {
   YYJMP_BUF yyexception_buffer;
   yyGLRStackItem* yyitems;
   yyGLRStackItem* yynextFree;
-  size_t yyspaceLeft;
+  ptrdiff_t yyspaceLeft;
   yyGLRState* yysplitPoint;
   yyGLRState* yylastDeleted;
   yyGLRStateSet yytops;
@@ -1140,7 +1245,7 @@ struct yyGLRStack {
 static void yyexpandGLRStack (yyGLRStack* yystackp);
 #endif
 
-static _Noreturn void
+_Noreturn static void
 yyFail (yyGLRStack* yystackp, YYLTYPE *yylocp, yy::parser& yyparser, tidl::Parser* ps, const char* yymsg)
 {
   if (yymsg != YY_NULLPTR)
@@ -1148,7 +1253,7 @@ yyFail (yyGLRStack* yystackp, YYLTYPE *yylocp, yy::parser& yyparser, tidl::Parse
   YYLONGJMP (yystackp->yyexception_buffer, 1);
 }
 
-static _Noreturn void
+_Noreturn static void
 yyMemoryExhausted (yyGLRStack* yystackp)
 {
   YYLONGJMP (yystackp->yyexception_buffer, 2);
@@ -1159,10 +1264,7 @@ yyMemoryExhausted (yyGLRStack* yystackp)
 static inline const char*
 yytokenName (yySymbol yytoken)
 {
-  if (yytoken == YYEMPTY)
-    return "";
-
-  return yytname[yytoken];
+  return yytoken == YYEMPTY ? "" : yytname[yytoken];
 }
 #endif
 
@@ -1192,6 +1294,49 @@ yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
     }
 }
 
+
+/** If yychar is empty, fetch the next token.  */
+static inline yySymbol
+yygetToken (int *yycharp, yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser* ps)
+{
+  yySymbol yytoken;
+  YYUSE (yyparser);
+  YYUSE (ps);
+  if (*yycharp == YYEMPTY)
+    {
+      YY_DPRINTF ((stderr, "Reading a token: "));
+#if YY_EXCEPTIONS
+      try
+        {
+#endif // YY_EXCEPTIONS
+          *yycharp = yylex (&yylval, &yylloc, lex_scanner);
+#if YY_EXCEPTIONS
+        }
+      catch (const yy::parser::syntax_error& yyexc)
+        {
+          YY_DPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));
+          yylloc = yyexc.location;
+          yyerror (&yylloc, yyparser, ps, yyexc.what ());
+          // Map errors caught in the scanner to the undefined token
+          // (YYUNDEFTOK), so that error handling is started.
+          // However, record this with this special value of yychar.
+          *yycharp = YYFAULTYTOK;
+        }
+#endif // YY_EXCEPTIONS
+    }
+  if (*yycharp <= YYEOF)
+    {
+      *yycharp = yytoken = YYEOF;
+      YY_DPRINTF ((stderr, "Now at end of input.\n"));
+    }
+  else
+    {
+      yytoken = YYTRANSLATE (*yycharp);
+      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+    }
+  return yytoken;
+}
+
 /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1.  Otherwise, fill in
  * YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
  * For convenience, always return YYLOW1.  */
@@ -1214,11 +1359,11 @@ yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
  *  (@$).  Returns yyok for normal return, yyaccept for YYACCEPT,
  *  yyerr for YYERROR, yyabort for YYABORT.  */
 static YYRESULTTAG
-yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
+yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
               yyGLRStack* yystackp,
               YYSTYPE* yyvalp, YYLTYPE *yylocp, yy::parser& yyparser, tidl::Parser* ps)
 {
-  yybool yynormal YY_ATTRIBUTE_UNUSED = (yystackp->yysplitPoint == YY_NULLPTR);
+  yybool yynormal YY_ATTRIBUTE_UNUSED = yystackp->yysplitPoint == YY_NULLPTR;
   int yylow;
   YYUSE (yyvalp);
   YYUSE (yylocp);
@@ -1238,7 +1383,7 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
 # undef yyclearin
 # define yyclearin (yychar = YYEMPTY)
 # undef YYFILL
-# define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
+# define YYFILL(N) yyfill (yyvsp, &yylow, (N), yynormal)
 # undef YYBACKUP
 # define YYBACKUP(Token, Value)                                              \
   return yyerror (yylocp, yyparser, ps, YY_("syntax error: cannot back up")),     \
@@ -1249,1084 +1394,1095 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
     *yyvalp = yyval_default;
   else
     *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;
+  /* Default location. */
   YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen);
   yystackp->yyerror_range[1].yystate.yyloc = *yylocp;
 
+#if YY_EXCEPTIONS
+  typedef yy::parser::syntax_error syntax_error;
+  try
+  {
+#endif // YY_EXCEPTIONS
   switch (yyn)
     {
-        case 2:
-#line 116 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-     ps->SetDoc((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.doc));
+  case 2:
+#line 116 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+              {
+     ps->SetDoc((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.doc));
   }
-#line 1263 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1414 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 3:
-#line 121 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 121 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+              {
     ((*yyvalp).doc) = new tidl::Document();
     document = ((*yyvalp).doc);
-    if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk) != NULL)
-      ((*yyvalp).doc)->AddBlock((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk));
+    if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk) != NULL)
+      ((*yyvalp).doc)->AddBlock((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk));
   }
-#line 1274 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1425 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 4:
-#line 127 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).doc) = (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.doc);
-
-    if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk) != NULL) {
-      if (((*yyvalp).doc)->ExistBlock((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk))) {
-        ps->ReportError("syntax error. \"Already Exists\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk)->GetLine());
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk);
+#line 127 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                 {
+    ((*yyvalp).doc) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.doc);
+
+    if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk) != NULL) {
+      if (((*yyvalp).doc)->ExistBlock((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk))) {
+        ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk)->GetLine());
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk);
       } else {
-        ((*yyvalp).doc)->AddBlock((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk));
+        ((*yyvalp).doc)->AddBlock((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk));
       }
     }
   }
-#line 1291 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1442 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 5:
-#line 141 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).blk) = (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.interf);
+#line 141 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                       {
+    ((*yyvalp).blk) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.interf);
     currentInterfaceEnums = nullptr;
   }
-#line 1300 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1451 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 6:
-#line 145 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).blk) = (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.structure);
+#line 145 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                    {
+    ((*yyvalp).blk) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.structure);
     currentInterfaceEnums = nullptr;
   }
-#line 1309 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1460 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 7:
-#line 149 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).blk) = (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk);
+#line 149 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                   {
+    ((*yyvalp).blk) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.blk);
   }
-#line 1317 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1468 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 8:
-#line 154 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    int ver = atoi((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString().c_str());
+#line 154 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                    {
+    int ver = atoi((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString().c_str());
 
     if (ver < 1) {
-      ps->ReportError("syntax error in protocol version : " + (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(),
-        (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+      ps->ReportError("syntax error in protocol version : " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(),
+        (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
     } else {
       ps->SetVersion(ver);
     }
     ((*yyvalp).blk) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
   }
-#line 1335 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1486 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 9:
-#line 167 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in protocol version : " + (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(),
-        (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+#line 167 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                    {
+    ps->ReportError("syntax error in protocol version : " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(),
+        (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
     ((*yyvalp).blk) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
   }
-#line 1347 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1498 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 10:
-#line 176 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).structure) = new tidl::Structure((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms), new tidl::Enums(),
-        (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->GetComments(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
+#line 176 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                      {
+    ((*yyvalp).structure) = new tidl::Structure((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms), new tidl::Enums(),
+        (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->GetComments(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
     if (!((*yyvalp).structure)->FindAndValidateElements()) {
-      ps->ReportError("syntax error. invalid element : " + (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
+      ps->ReportError("syntax error. invalid element : " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
       ((*yyvalp).structure) = NULL;
       delete ((*yyvalp).structure);
     }
 
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
   }
-#line 1364 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1515 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 11:
-#line 188 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).structure) = new tidl::Structure((((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms), (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations), (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->GetComments(),
-        (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
+#line 188 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                               {
+    ((*yyvalp).structure) = new tidl::Structure((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->GetComments(),
+        (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
     if (!((*yyvalp).structure)->FindAndValidateElements()) {
-      ps->ReportError("syntax error. invalid element : " + (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
+      ps->ReportError("syntax error. invalid element : " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
       ((*yyvalp).structure) = NULL;
       delete ((*yyvalp).structure);
     }
 
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
   }
-#line 1381 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1532 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 12:
-#line 200 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).structure) = new tidl::Structure((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), new tidl::Elements(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enumerations), (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->GetComments(),
-        (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
+#line 200 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                      {
+    ((*yyvalp).structure) = new tidl::Structure((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), new tidl::Elements(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enumerations), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->GetComments(),
+        (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
     if (!((*yyvalp).structure)->FindAndValidateElements()) {
-      ps->ReportError("syntax error. invalid element : " + (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
+      ps->ReportError("syntax error. invalid element : " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
       ((*yyvalp).structure) = NULL;
       delete ((*yyvalp).structure);
     }
 
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
   }
-#line 1398 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1549 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 13:
-#line 212 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 212 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                      {
     if (ps->GetVersion() < 2) {
-      ps->ReportError("syntax error. Please try to use protocol 2.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
+      ps->ReportError("syntax error. Please try to use protocol 2.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
     } else {
       std::shared_ptr<tidl::Block> block = nullptr;
       if (document != nullptr)
-        block = document->FindBlock((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString());
+        block = document->FindBlock((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString());
 
       if (block == nullptr || block->GetType() != tidl::Block::Type::TYPE_STRUCTURE) {
-        ps->ReportError("syntax error. " + (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString() + " does not exist.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
+        ps->ReportError("syntax error. " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString() + " does not exist.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
       } else {
-        ((*yyvalp).structure) = new tidl::Structure((((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms), new tidl::Enums(),
-            (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
+        ((*yyvalp).structure) = new tidl::Structure((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms), new tidl::Enums(),
+            (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
         ((*yyvalp).structure)->SetBase(std::dynamic_pointer_cast<tidl::Structure>(block));
         if (!((*yyvalp).structure)->FindAndValidateElements()) {
-          ps->ReportError("syntax error. invalid element : " + (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
+          ps->ReportError("syntax error. invalid element : " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
           ((*yyvalp).structure) = NULL;
           delete ((*yyvalp).structure);
         }
       }
     }
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
   }
-#line 1430 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1581 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 14:
-#line 239 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 239 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                            {
     if (ps->GetVersion() < 2) {
-      ps->ReportError("syntax error. Please try to use protocol 2.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yyloc).begin.line);
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations);
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
+      ps->ReportError("syntax error. Please try to use protocol 2.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-7)].yystate.yyloc).begin.line);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
     } else {
       std::shared_ptr<tidl::Block> block = nullptr;
       if (document != nullptr)
-        block = document->FindBlock((((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString());
+        block = document->FindBlock((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString());
 
       if (block == nullptr || block->GetType() != tidl::Block::Type::TYPE_STRUCTURE) {
-        ps->ReportError("syntax error. " + (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString() + " does not exist.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yyloc).begin.line);
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations);
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
+        ps->ReportError("syntax error. " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString() + " does not exist.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-7)].yystate.yyloc).begin.line);
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations);
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
       } else {
-        ((*yyvalp).structure) = new tidl::Structure((((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms), (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations), (((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.token)->GetComments(),
-          (((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yyloc).begin.line);
+        ((*yyvalp).structure) = new tidl::Structure((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.token)->GetComments(),
+          (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-7)].yystate.yyloc).begin.line);
         ((*yyvalp).structure)->SetBase(std::dynamic_pointer_cast<tidl::Structure>(block));
         if (!((*yyvalp).structure)->FindAndValidateElements()) {
-          ps->ReportError("syntax error. invalid element : " + (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yyloc).begin.line);
+          ps->ReportError("syntax error. invalid element : " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-7)].yystate.yyloc).begin.line);
           ((*yyvalp).structure) = NULL;
           delete ((*yyvalp).structure);
         }
       }
     }
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
   }
-#line 1464 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1615 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 15:
-#line 268 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 268 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                   {
     if (ps->GetVersion() < 2) {
-      ps->ReportError("syntax error. Please try to use protocol 2.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enumerations);
+      ps->ReportError("syntax error. Please try to use protocol 2.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enumerations);
     } else {
       std::shared_ptr<tidl::Block> block = nullptr;
       if (document != nullptr)
-        block = document->FindBlock((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString());
+        block = document->FindBlock((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString());
 
       if (block == nullptr || block->GetType() != tidl::Block::Type::TYPE_STRUCTURE) {
-        ps->ReportError("syntax error. " + (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString() + " does not exist.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enumerations);
+        ps->ReportError("syntax error. " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString() + " does not exist.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enumerations);
       } else {
-        ((*yyvalp).structure) = new tidl::Structure((((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(), new tidl::Elements(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enumerations), (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments(),
-            (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
+        ((*yyvalp).structure) = new tidl::Structure((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(), new tidl::Elements(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enumerations), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments(),
+            (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
         ((*yyvalp).structure)->SetBase(std::dynamic_pointer_cast<tidl::Structure>(block));
         if (!((*yyvalp).structure)->FindAndValidateElements()) {
-          ps->ReportError("syntax error. invalid element : " + (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
+          ps->ReportError("syntax error. invalid element : " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
           delete ((*yyvalp).structure);
           ((*yyvalp).structure) = NULL;
         }
       }
     }
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
   }
-#line 1496 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1647 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 16:
-#line 295 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error. \"No identifier\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
+#line 295 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                    {
+    ps->ReportError("syntax error. \"No identifier\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
     ((*yyvalp).structure) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
   }
-#line 1506 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1657 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 17:
-#line 300 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 300 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                          {
     ps->ReportError("syntax error. \"Please check it before an open brace.\"",
-        (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
+        (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
     ((*yyvalp).structure) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
   }
-#line 1517 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1668 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 18:
-#line 306 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in structure declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+#line 306 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                    {
+    ps->ReportError("syntax error in structure declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
     ((*yyvalp).structure) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
   }
-#line 1527 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1678 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 19:
-#line 313 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 313 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+            {
   ((*yyvalp).enumerations) = new (std::nothrow) tidl::Enums();
   currentInterfaceEnums = ((*yyvalp).enumerations);
     if (((*yyvalp).enumerations) != nullptr) {
-      if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration) != nullptr) {
-        ((*yyvalp).enumerations)->Add(std::unique_ptr<tidl::Enum>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration)));
+      if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration) != nullptr) {
+        ((*yyvalp).enumerations)->Add(std::unique_ptr<tidl::Enum>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration)));
       }
     }
   }
-#line 1541 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1692 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 20:
-#line 322 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).enumerations) = (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enumerations);
-    if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration) != nullptr) {
-      if (((*yyvalp).enumerations)->Exist(*(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration))) {
-        ps->ReportError("syntax error. \"Already Exists\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration)->GetLine());
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration);
+#line 322 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+               {
+    ((*yyvalp).enumerations) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enumerations);
+    if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration) != nullptr) {
+      if (((*yyvalp).enumerations)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration))) {
+        ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration)->GetLine());
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration);
       } else {
-        ((*yyvalp).enumerations)->Add(std::unique_ptr<tidl::Enum>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration)));
+        ((*yyvalp).enumerations)->Add(std::unique_ptr<tidl::Enum>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enumeration)));
       }
     }
   }
-#line 1557 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1708 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 21:
-#line 335 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 335 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                    {
     if (ps->GetVersion() < 2) {
-      ps->ReportError("syntax error. \"enum is supported from protocol version 2\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
-      ps->ReportError("try to use protocol version 2.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
+      ps->ReportError("syntax error. \"enum is supported from protocol version 2\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
+      ps->ReportError("try to use protocol version 2.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
     } else {
-      ((*yyvalp).enumeration) = new tidl::Enum((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enum_fields), (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->GetComments(),
-          (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
+      ((*yyvalp).enumeration) = new tidl::Enum((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enum_fields), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->GetComments(),
+          (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
     }
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
   }
-#line 1572 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1723 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 22:
-#line 347 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 347 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+              {
    ((*yyvalp).enum_fields) = new (std::nothrow) tidl::Fields();
      if (((*yyvalp).enum_fields) != nullptr) {
-      if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field) != nullptr) {
-        ((*yyvalp).enum_fields)->Add(std::unique_ptr<tidl::Field>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field)));
+      if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field) != nullptr) {
+        ((*yyvalp).enum_fields)->Add(std::unique_ptr<tidl::Field>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field)));
       }
     }
    }
-#line 1585 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1736 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 23:
-#line 355 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).enum_fields) = (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enum_fields);
-    if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field) != nullptr) {
-      if (((*yyvalp).enum_fields)->Exist(*(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field))) {
-        ps->ReportError("syntax error. \"Already Exists\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field)->GetLine());
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field);
+#line 355 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                 {
+    ((*yyvalp).enum_fields) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.enum_fields);
+    if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field) != nullptr) {
+      if (((*yyvalp).enum_fields)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field))) {
+        ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field)->GetLine());
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field);
       } else {
-        ((*yyvalp).enum_fields)->Add(std::unique_ptr<tidl::Field>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field)));
+        ((*yyvalp).enum_fields)->Add(std::unique_ptr<tidl::Field>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.enum_field)));
       }
     }
   }
-#line 1601 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1752 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 24:
-#line 368 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-  ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token)->ToString(), "",  (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token)->GetComments(),
-    (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+#line 368 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                    {
+  ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token)->ToString(), "",  (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token)->GetComments(),
+    (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
   }
-#line 1610 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1761 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 25:
-#line 372 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token)->ToString(),
-      (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->GetComments(),  (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
+#line 372 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                  {
+    ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token)->ToString(),
+      (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->GetComments(),  (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
   }
-#line 1619 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1770 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 26:
-#line 376 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token)->ToString(),
-      (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->GetComments(),  (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
+#line 376 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                      {
+    ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token)->ToString(),
+      (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->GetComments(),  (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
   }
-#line 1628 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1779 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 27:
-#line 380 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-  ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(), "",  (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments(),
-    (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+#line 380 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+          {
+  ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(), "",  (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments(),
+    (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
   }
-#line 1637 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1788 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 28:
-#line 384 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(),
-      (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->GetComments(),  (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
+#line 384 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                          {
+    ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(),
+      (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->GetComments(),  (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
   }
-#line 1646 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1797 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 29:
-#line 388 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(),
-      (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->GetComments(),  (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
+#line 388 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                              {
+    ((*yyvalp).enum_field) = new (std::nothrow) tidl::Field((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(),
+      (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->GetComments(),  (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
   }
-#line 1655 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1806 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 30:
-#line 394 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 394 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                  {
     ((*yyvalp).elms) = new (std::nothrow) tidl::Elements();
     if (((*yyvalp).elms) != nullptr) {
-      if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm) != nullptr) {
-        ((*yyvalp).elms)->Add(std::unique_ptr<tidl::Element>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)));
+      if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm) != nullptr) {
+        ((*yyvalp).elms)->Add(std::unique_ptr<tidl::Element>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)));
       }
     }
   }
-#line 1668 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1819 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 31:
-#line 402 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).elms) = (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
-    if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm) != nullptr) {
-      if (((*yyvalp).elms)->Exist(*(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm))) {
-        ps->ReportError("syntax error. \"Already Exists\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)->GetLine());
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm);
+#line 402 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                     {
+    ((*yyvalp).elms) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.elms);
+    if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm) != nullptr) {
+      if (((*yyvalp).elms)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm))) {
+        ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)->GetLine());
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm);
       } else {
-        ((*yyvalp).elms)->Add(std::unique_ptr<tidl::Element>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)));
+        ((*yyvalp).elms)->Add(std::unique_ptr<tidl::Element>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.elm)));
       }
     }
   }
-#line 1684 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1835 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 32:
-#line 413 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in elements declarations.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
-    ((*yyvalp).elms) = (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.elms);
+#line 413 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                               {
+    ps->ReportError("syntax error in elements declarations.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
+    ((*yyvalp).elms) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.elms);
   }
-#line 1693 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1844 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 33:
-#line 419 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).elm) = new tidl::Element((((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.b_type), (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.b_type)->GetComments(),
-        (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token);
+#line 419 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                   {
+    if (tidl::BaseType::IsFile((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.b_type))) {
+      ps->ReportError("syntax error. \"The file cannot be included in the struct.\"", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+      ((*yyvalp).elm) = NULL;
+    } else {
+      ((*yyvalp).elm) = new tidl::Element((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.b_type), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.b_type)->GetComments(),
+          (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.token);
+    }
   }
-#line 1703 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1859 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 34:
-#line 424 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error. \"No identifier\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+#line 429 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                         {
+    ps->ReportError("syntax error. \"No identifier\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
     ((*yyvalp).elm) = NULL;
   }
-#line 1712 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1868 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 35:
-#line 428 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in element declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+#line 433 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                               {
+    ps->ReportError("syntax error in element declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
     ((*yyvalp).elm) = NULL;
   }
-#line 1721 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1877 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 36:
-#line 432 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in element declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+#line 437 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+          {
+    ps->ReportError("syntax error in element declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
     ((*yyvalp).elm) = NULL;
   }
-#line 1730 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1886 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 37:
-#line 438 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 443 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                      {
     ((*yyvalp).attrs) = new (std::nothrow) tidl::Attributes();
     if (((*yyvalp).attrs) != nullptr) {
-      if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr) != nullptr) {
-        ((*yyvalp).attrs)->Add(std::unique_ptr<tidl::Attribute>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)));
+      if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr) != nullptr) {
+        ((*yyvalp).attrs)->Add(std::unique_ptr<tidl::Attribute>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)));
       }
     }
   }
-#line 1743 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1899 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 38:
-#line 446 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).attrs) = (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.attrs);
-    if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr) != nullptr) {
-      if (((*yyvalp).attrs)->Exist(*(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr))) {
-        ps->ReportError("syntax error. \"Already Exist\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)->GetLine());
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr);
+#line 451 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                 {
+    ((*yyvalp).attrs) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.attrs);
+    if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr) != nullptr) {
+      if (((*yyvalp).attrs)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr))) {
+        ps->ReportError("syntax error. \"Already Exist\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)->GetLine());
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr);
       } else {
-        ((*yyvalp).attrs)->Add(std::unique_ptr<tidl::Attribute>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)));
+        ((*yyvalp).attrs)->Add(std::unique_ptr<tidl::Attribute>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.attr)));
       }
     }
   }
-#line 1759 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1915 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 39:
-#line 457 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in attributes", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+#line 462 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+          {
+    ps->ReportError("syntax error in attributes", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
     ((*yyvalp).attrs) = new tidl::Attributes();
   }
-#line 1768 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1924 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 40:
-#line 463 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).attr) = new tidl::Attribute((((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 468 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                {
+    ((*yyvalp).attr) = new tidl::Attribute((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
   }
-#line 1778 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1934 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 41:
-#line 468 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in attribute declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+#line 473 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                        {
+    ps->ReportError("syntax error in attribute declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
     ((*yyvalp).attr) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
   }
-#line 1789 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1945 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 42:
-#line 474 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in attribute declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+#line 479 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                       {
+    ps->ReportError("syntax error in attribute declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
     ((*yyvalp).attr) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
   }
-#line 1799 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1955 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 43:
-#line 481 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).interf) = new tidl::Interface((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls), new tidl::Enums(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->GetComments(),
-        new tidl::Attributes(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
+#line 486 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                          {
+    ((*yyvalp).interf) = new tidl::Interface((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls), new tidl::Enums(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->GetComments(),
+        new tidl::Attributes(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
   }
-#line 1810 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1966 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 44:
-#line 487 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).interf) = new tidl::Interface((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls), new tidl::Enums(),
-        (((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.token)->GetComments(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.attrs), (((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yyloc).begin.line);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
+#line 492 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                                             {
+    ((*yyvalp).interf) = new tidl::Interface((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls), new tidl::Enums(),
+        (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.token)->GetComments(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.attrs), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-7)].yystate.yyloc).begin.line);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
   }
-#line 1823 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1979 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 45:
-#line 495 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).interf) = new tidl::Interface((((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls), (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations), (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->GetComments(),
-        new tidl::Attributes(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+#line 500 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                   {
+    ((*yyvalp).interf) = new tidl::Interface((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->GetComments(),
+        new tidl::Attributes(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
   }
-#line 1834 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 1990 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 46:
-#line 501 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).interf) = new tidl::Interface((((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls), (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations), (((yyGLRStackItem const *)yyvsp)[YYFILL (-8)].yystate.yysemantics.yysval.token)->GetComments(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.attrs),
-        (((yyGLRStackItem const *)yyvsp)[YYFILL (-8)].yystate.yyloc).begin.line);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-8)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+#line 506 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                                                   {
+    ((*yyvalp).interf) = new tidl::Interface((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.enumerations), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-8)].yystate.yysemantics.yysval.token)->GetComments(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.attrs),
+        (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-8)].yystate.yyloc).begin.line);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-8)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
   }
-#line 1847 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2003 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 47:
-#line 509 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error. \"No identifier\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
+#line 514 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                        {
+    ps->ReportError("syntax error. \"No identifier\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
     ((*yyvalp).interf) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
   }
-#line 1857 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2013 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 48:
-#line 514 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in interface declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
+#line 519 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                              {
+    ps->ReportError("syntax error in interface declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
     ((*yyvalp).interf) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
   }
-#line 1867 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2023 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 49:
-#line 519 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in interface declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+#line 524 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                    {
+    ps->ReportError("syntax error in interface declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
     ((*yyvalp).interf) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
   }
-#line 1877 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2033 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 50:
-#line 526 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 531 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                          {
     ((*yyvalp).decls) = new (std::nothrow) tidl::Declarations();
     currentDeclarations = ((*yyvalp).decls);
     if (((*yyvalp).decls) != nullptr) {
-      if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl) != nullptr) {
-        ((*yyvalp).decls)->Add(std::unique_ptr<tidl::Declaration>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)));
+      if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl) != nullptr) {
+        ((*yyvalp).decls)->Add(std::unique_ptr<tidl::Declaration>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)));
       }
     }
   }
-#line 1891 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2047 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 51:
-#line 535 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).decls) = (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls);
-    if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl) != nullptr) {
-      if (((*yyvalp).decls)->Exist(*(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl))) {
-        ps->ReportError("syntax error. \"Already Exists\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)->GetLine());
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl);
+#line 540 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                             {
+    ((*yyvalp).decls) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.decls);
+    if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl) != nullptr) {
+      if (((*yyvalp).decls)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl))) {
+        ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)->GetLine());
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl);
       } else {
-        ((*yyvalp).decls)->Add(std::unique_ptr<tidl::Declaration>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)));
+        ((*yyvalp).decls)->Add(std::unique_ptr<tidl::Declaration>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.decl)));
       }
     }
   }
-#line 1907 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2063 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 52:
-#line 546 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in methods declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
-    ((*yyvalp).decls) = (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.decls);
+#line 551 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                   {
+    ps->ReportError("syntax error in methods declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+    ((*yyvalp).decls) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.decls);
   }
-#line 1916 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2072 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 53:
-#line 552 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 557 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                      {
     if (ps->IsGroupEnabled()) {
-      ps->ReportError("Group does not support 'sync' method type", (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
+      ps->ReportError("Group does not support 'sync' method type", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
       ((*yyvalp).decl) = NULL;
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
     } else {
-      ((*yyvalp).decl) = new tidl::Declaration((((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(),
-          std::unique_ptr<tidl::BaseType>((((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.b_type)),
-          std::unique_ptr<tidl::Parameters>((((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.params)), (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.b_type)->GetComments(),
-          (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line, tidl::Declaration::MethodType::SYNC);
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+      ((*yyvalp).decl) = new tidl::Declaration((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(),
+          std::unique_ptr<tidl::BaseType>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.b_type)),
+          std::unique_ptr<tidl::Parameters>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.params)), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.b_type)->GetComments(),
+          (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line, tidl::Declaration::MethodType::SYNC);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
     }
   }
-#line 1934 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2090 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 54:
-#line 565 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 570 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                                             {
     if (ps->GetVersion() < 2) {
-      ps->ReportError("syntax error. \"method attributes is supported from protocol version 2\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (-8)].yystate.yyloc).begin.line);
-      ps->ReportError("try to use protocol version 2.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-8)].yystate.yyloc).begin.line);
+      ps->ReportError("syntax error. \"method attributes is supported from protocol version 2\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-8)].yystate.yyloc).begin.line);
+      ps->ReportError("try to use protocol version 2.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-8)].yystate.yyloc).begin.line);
     }
 
   if (ps->IsGroupEnabled()) {
-      ps->ReportError("Group does not support 'sync' method type", (((yyGLRStackItem const *)yyvsp)[YYFILL (-8)].yystate.yyloc).begin.line);
+      ps->ReportError("Group does not support 'sync' method type", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-8)].yystate.yyloc).begin.line);
       ((*yyvalp).decl) = NULL;
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
     } else {
-      ((*yyvalp).decl) = new tidl::Declaration((((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(),
-          std::unique_ptr<tidl::BaseType>((((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.b_type)),
-          std::unique_ptr<tidl::Parameters>((((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.params)), (((yyGLRStackItem const *)yyvsp)[YYFILL (-8)].yystate.yysemantics.yysval.token)->GetComments(),
-          (((yyGLRStackItem const *)yyvsp)[YYFILL (-8)].yystate.yyloc).begin.line, tidl::Declaration::MethodType::SYNC,
-          (((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.attrs));
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+      ((*yyvalp).decl) = new tidl::Declaration((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token)->ToString(),
+          std::unique_ptr<tidl::BaseType>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.b_type)),
+          std::unique_ptr<tidl::Parameters>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.params)), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-8)].yystate.yysemantics.yysval.token)->GetComments(),
+          (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-8)].yystate.yyloc).begin.line, tidl::Declaration::MethodType::SYNC,
+          (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval.attrs));
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
     }
   }
-#line 1958 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2114 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 55:
-#line 584 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).decl) = new tidl::Declaration((((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(),
-        std::unique_ptr<tidl::BaseType>(new tidl::BaseType("void", (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments())),
-        std::unique_ptr<tidl::Parameters>((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.params)), (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments(),
-        (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line, tidl::Declaration::MethodType::ASYNC);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+#line 589 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                  {
+    ((*yyvalp).decl) = new tidl::Declaration((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(),
+        std::unique_ptr<tidl::BaseType>(new tidl::BaseType("void", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments())),
+        std::unique_ptr<tidl::Parameters>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.params)), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments(),
+        (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line, tidl::Declaration::MethodType::ASYNC);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
   }
-#line 1971 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2127 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 56:
-#line 592 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 597 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                                                  {
     if (ps->GetVersion() < 2) {
-      ps->ReportError("syntax error. \"method attributes is supported from protocol version 2\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (-9)].yystate.yyloc).begin.line);
-      ps->ReportError("try to use protocol version 2.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-9)].yystate.yyloc).begin.line);
+      ps->ReportError("syntax error. \"method attributes is supported from protocol version 2\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-9)].yystate.yyloc).begin.line);
+      ps->ReportError("try to use protocol version 2.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-9)].yystate.yyloc).begin.line);
     }
 
-    ((*yyvalp).decl) = new tidl::Declaration((((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(),
-        std::unique_ptr<tidl::BaseType>(new tidl::BaseType("void", (((yyGLRStackItem const *)yyvsp)[YYFILL (-9)].yystate.yysemantics.yysval.token)->GetComments())),
-        std::unique_ptr<tidl::Parameters>((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.params)), (((yyGLRStackItem const *)yyvsp)[YYFILL (-9)].yystate.yysemantics.yysval.token)->GetComments(),
-        (((yyGLRStackItem const *)yyvsp)[YYFILL (-9)].yystate.yyloc).begin.line, tidl::Declaration::MethodType::ASYNC, (((yyGLRStackItem const *)yyvsp)[YYFILL (-8)].yystate.yysemantics.yysval.attrs));
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+    ((*yyvalp).decl) = new tidl::Declaration((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(),
+        std::unique_ptr<tidl::BaseType>(new tidl::BaseType("void", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-9)].yystate.yysemantics.yysval.token)->GetComments())),
+        std::unique_ptr<tidl::Parameters>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.params)), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-9)].yystate.yysemantics.yysval.token)->GetComments(),
+        (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-9)].yystate.yyloc).begin.line, tidl::Declaration::MethodType::ASYNC, (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-8)].yystate.yysemantics.yysval.attrs));
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
   }
-#line 1989 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2145 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 57:
-#line 605 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 610 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                     {
     if (ps->IsGroupEnabled()) {
-      ps->ReportError("Group does not support 'delegate' method type", (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
+      ps->ReportError("Group does not support 'delegate' method type", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line);
       ((*yyvalp).decl) = NULL;
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
     } else {
-      ((*yyvalp).decl) = new tidl::Declaration((((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(),
-          std::unique_ptr<tidl::BaseType>(new tidl::BaseType("void", (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments())),
-          std::unique_ptr<tidl::Parameters>((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.params)), (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments(),
-          (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line, tidl::Declaration::MethodType::DELEGATE);
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+      ((*yyvalp).decl) = new tidl::Declaration((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(),
+          std::unique_ptr<tidl::BaseType>(new tidl::BaseType("void", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments())),
+          std::unique_ptr<tidl::Parameters>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.params)), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token)->GetComments(),
+          (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yyloc).begin.line, tidl::Declaration::MethodType::DELEGATE);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-6)].yystate.yysemantics.yysval.token);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
     }
   }
-#line 2009 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2165 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 58:
-#line 620 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in method declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
+#line 625 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                     {
+    ps->ReportError("syntax error in method declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
     ((*yyvalp).decl) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
   }
-#line 2019 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2175 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 59:
-#line 625 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in method declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
+#line 630 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                        {
+    ps->ReportError("syntax error in method declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
     ((*yyvalp).decl) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
   }
-#line 2029 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2185 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 60:
-#line 630 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error. \"No async\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+#line 635 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                          {
+    ps->ReportError("syntax error. \"No async\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
     ((*yyvalp).decl) = NULL;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.token);
   }
-#line 2039 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2195 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 61:
-#line 635 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error. \"No identifier\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
+#line 640 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                        {
+    ps->ReportError("syntax error. \"No identifier\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
     ((*yyvalp).decl) = NULL;
   }
-#line 2048 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2204 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 62:
-#line 639 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error. \"No identifier\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
+#line 644 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                             {
+    ps->ReportError("syntax error. \"No identifier\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
     ((*yyvalp).decl) = NULL;
   }
-#line 2057 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2213 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 63:
-#line 643 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error. \"No identifier\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
+#line 648 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                {
+    ps->ReportError("syntax error. \"No identifier\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-4)].yystate.yyloc).begin.line);
     ((*yyvalp).decl) = NULL;
   }
-#line 2066 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2222 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 64:
-#line 647 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in method declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+#line 652 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                {
+    ps->ReportError("syntax error in method declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
     ((*yyvalp).decl) = NULL;
   }
-#line 2075 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2231 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 65:
-#line 651 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in method declaration.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+#line 656 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                             {
+    ps->ReportError("syntax error in method declaration.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
     ((*yyvalp).decl) = NULL;
   }
-#line 2084 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2240 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 66:
-#line 657 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 662 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                          {
     ((*yyvalp).params) = new tidl::Parameters();
     if (((*yyvalp).params) != nullptr) {
-      if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param) != nullptr) {
-        ((*yyvalp).params)->Add(std::unique_ptr<tidl::Parameter>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)));
+      if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param) != nullptr) {
+        ((*yyvalp).params)->Add(std::unique_ptr<tidl::Parameter>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)));
       }
     }
   }
-#line 2097 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2253 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 67:
-#line 665 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).params) = (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.params);
-    if ((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param) != nullptr) {
-      if (((*yyvalp).params)->Exist(*(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param))) {
-        ps->ReportError("syntax error. \"Already Exists\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)->GetLine());
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param);
+#line 670 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                     {
+    ((*yyvalp).params) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.params);
+    if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param) != nullptr) {
+      if (((*yyvalp).params)->Exist(*(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param))) {
+        ps->ReportError("syntax error. \"Already Exists\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)->GetLine());
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param);
       } else {
-        ((*yyvalp).params)->Add(std::unique_ptr<tidl::Parameter>((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)));
+        ((*yyvalp).params)->Add(std::unique_ptr<tidl::Parameter>((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.param)));
       }
     }
   }
-#line 2113 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2269 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 68:
-#line 676 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ps->ReportError("syntax error in parameter list", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+#line 681 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+          {
+    ps->ReportError("syntax error in parameter list", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
     ((*yyvalp).params) = new tidl::Parameters();
   }
-#line 2122 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2278 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 69:
-#line 682 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 687 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                          {
     ((*yyvalp).direction) = new tidl::Token("in", "");
   }
-#line 2130 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2286 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 70:
-#line 685 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 690 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+          {
     ((*yyvalp).direction) = new tidl::Token("out", "");
   }
-#line 2138 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2294 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 71:
-#line 688 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 693 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+          {
     ((*yyvalp).direction) = new tidl::Token("ref", "");
   }
-#line 2146 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2302 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 72:
-#line 693 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 698 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+           {
     ((*yyvalp).param) = nullptr;
   }
-#line 2154 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2310 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 73:
-#line 696 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 701 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+           {
     ((*yyvalp).param) = nullptr;
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
   }
-#line 2163 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2319 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 74:
-#line 700 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-    ((*yyvalp).param) = new tidl::Parameter((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.p_type), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
-    delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 705 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                        {
+    ((*yyvalp).param) = new tidl::Parameter((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.p_type), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yyloc).begin.line);
+    delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
   }
-#line 2172 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2328 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 75:
-#line 706 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).p_type) = new tidl::ParameterType((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.b_type));
+#line 711 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                          {
+      ((*yyvalp).p_type) = new tidl::ParameterType((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.b_type));
     }
-#line 2180 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2336 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 76:
-#line 709 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).p_type) = new tidl::ParameterType((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.b_type), (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.direction)->ToString());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.direction);
+#line 714 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                    {
+      ((*yyvalp).p_type) = new tidl::ParameterType((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.b_type), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.direction)->ToString());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.direction);
     }
-#line 2189 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2345 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 77:
-#line 715 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).b_type) = (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.b_type);
+#line 720 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                    {
+      ((*yyvalp).b_type) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.b_type);
     }
-#line 2197 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2353 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 78:
-#line 718 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 723 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+             {
       if (ps->IsGroupEnabled()) {
-        ps->ReportError("Group does not support 'file' type", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+        ps->ReportError("Group does not support 'file' type", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
         ((*yyvalp).b_type) = NULL;
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
       } else if (!ps->IsBetaEnabled() && ps->GetVersion() < 2) {
-        ps->ReportError("syntax error. \"No identifier\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
-        ps->ReportError("try to use beta version (-b option).", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+        ps->ReportError("syntax error. \"No identifier\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+        ps->ReportError("try to use beta version (-b option).", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
         ((*yyvalp).b_type) = NULL;
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
       } else {
-        ((*yyvalp).b_type) = new tidl::BaseType("file", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+        ((*yyvalp).b_type) = new tidl::BaseType("file", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
       }
     }
-#line 2217 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2373 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 79:
-#line 735 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).b_type) = (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.b_type);
+#line 740 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                         {
+      ((*yyvalp).b_type) = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.b_type);
     }
-#line 2225 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2381 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 80:
-#line 738 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).b_type) = new tidl::BaseType("void", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 743 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+             {
+      ((*yyvalp).b_type) = new tidl::BaseType("void", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2234 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2390 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 81:
-#line 742 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).b_type) = new tidl::BaseType("char", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 747 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+             {
+      ((*yyvalp).b_type) = new tidl::BaseType("char", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2243 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2399 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 82:
-#line 746 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).b_type) = new tidl::BaseType("short", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 751 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+              {
+      ((*yyvalp).b_type) = new tidl::BaseType("short", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2252 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2408 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 83:
-#line 750 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).b_type) = new tidl::BaseType("int", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 755 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+            {
+      ((*yyvalp).b_type) = new tidl::BaseType("int", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2261 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2417 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 84:
-#line 754 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).b_type) = new tidl::BaseType("long", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 759 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+             {
+      ((*yyvalp).b_type) = new tidl::BaseType("long", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2270 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2426 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 85:
-#line 758 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).b_type) = new tidl::BaseType("float", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 763 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+              {
+      ((*yyvalp).b_type) = new tidl::BaseType("float", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2279 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2435 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 86:
-#line 762 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).b_type) = new tidl::BaseType("double", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 767 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+               {
+      ((*yyvalp).b_type) = new tidl::BaseType("double", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2288 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2444 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 87:
-#line 766 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 771 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+               {
       if (ps->IsCionEnabled()) {
-        ps->ReportError("Cion does not support 'bundle' type", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+        ps->ReportError("Cion does not support 'bundle' type", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
         ((*yyvalp).b_type) = NULL;
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
       } else {
-        ((*yyvalp).b_type) = new tidl::BaseType("bundle", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+        ((*yyvalp).b_type) = new tidl::BaseType("bundle", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
       }
     }
-#line 2303 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2459 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 88:
-#line 776 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).b_type) = new tidl::BaseType("string", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 781 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+               {
+      ((*yyvalp).b_type) = new tidl::BaseType("string", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2312 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2468 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 89:
-#line 780 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).b_type) = new tidl::BaseType("bool", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 785 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+             {
+      ((*yyvalp).b_type) = new tidl::BaseType("bool", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2321 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2477 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 90:
-#line 784 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 789 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+           {
       if (ps->GetVersion() < 2) {
-        ((*yyvalp).b_type) = new tidl::BaseType((((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments(), true);
+        ((*yyvalp).b_type) = new tidl::BaseType((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments(), true);
       } else {
-        std::string name = (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString();
+        std::string name = (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString();
         bool found = false;
         tidl::BaseType::UserType type;
         if (currentInterfaceEnums) {
@@ -2376,27 +2532,27 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
         }
 
         if (found) {
-          ((*yyvalp).b_type) = new tidl::BaseType(name, (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments(), type);
+          ((*yyvalp).b_type) = new tidl::BaseType(name, (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments(), type);
         } else {
-          ps->ReportError("Unknown type : " + (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+          ps->ReportError("Unknown type : " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
           ((*yyvalp).b_type) = NULL;
         }
       }
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2388 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2544 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 91:
-#line 846 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 851 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                      {
       bool found = false;
       if (document) {
         for (auto& b : document->GetBlocks()) {
           if (b->GetType() == tidl::Block::TYPE_STRUCTURE
-              && b->GetID() == (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString()) {
+              && b->GetID() == (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString()) {
             for (auto& e : b->GetEnums()) {
-              if (e->GetID() == (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString()) {
+              if (e->GetID() == (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString()) {
                 found = true;
                 break;
               }
@@ -2406,96 +2562,111 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
       }
 
       if (found) {
-        ((*yyvalp).b_type) = new tidl::BaseType((((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString() + "." + (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString() , (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->GetComments(), tidl::BaseType::UserType::ENUM);
+        ((*yyvalp).b_type) = new tidl::BaseType((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString() + "." + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString() , (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->GetComments(), tidl::BaseType::UserType::ENUM);
       } else {
-        ps->ReportError("Unknown type : " + (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString() + "." + (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(),
-          (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
+        ps->ReportError("Unknown type : " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token)->ToString() + "." + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(),
+          (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yyloc).begin.line);
         ((*yyvalp).b_type) = NULL;
       }
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
     }
-#line 2418 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2574 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 92:
-#line 873 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      if ((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString() == "map") {
-        ps->ReportError("syntax error. The value must be existed.", (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
+#line 878 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                       {
+      if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString() == "map") {
+        ps->ReportError("syntax error. The value must be existed.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
       } else {
-        ((*yyvalp).b_type) = new tidl::BaseType((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->GetComments());
-        ((*yyvalp).b_type)->SetMetaType((((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.b_type));
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
+        if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.b_type)->GetMetaType() != nullptr && tidl::BaseType::IsFile((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.b_type))) {
+          ps->ReportError("syntax error. The file should be included in only one container.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
+        }
+
+        ((*yyvalp).b_type) = new tidl::BaseType((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->GetComments());
+        ((*yyvalp).b_type)->SetMetaType((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.b_type));
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
       }
     }
-#line 2433 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2593 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 93:
-#line 883 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      if ((((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString() != "map") {
-        ps->ReportError("syntax error. The container type must be \"map\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+#line 892 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                                                                               {
+      if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString() != "map") {
+        ps->ReportError("syntax error. The container type must be \"map\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
       } else {
-        ((*yyvalp).b_type) = new tidl::BaseType((((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(), (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->GetComments());
-        ((*yyvalp).b_type)->SetKeyType((((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.b_type));
-        ((*yyvalp).b_type)->SetValueType((((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.b_type));
-        delete (((yyGLRStackItem const *)yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
+        ((*yyvalp).b_type) = new tidl::BaseType((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->GetComments());
+        ((*yyvalp).b_type)->SetKeyType((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.b_type));
+        ((*yyvalp).b_type)->SetValueType((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.b_type));
+        delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
       }
     }
-#line 2449 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2609 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 94:
-#line 896 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).token) = new tidl::Token("list", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 905 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+                            {
+      ((*yyvalp).token) = new tidl::Token("list", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2458 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2618 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 95:
-#line 900 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
-      ((*yyvalp).token) = new tidl::Token("array", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+#line 909 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+              {
+      ((*yyvalp).token) = new tidl::Token("array", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2467 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2627 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 96:
-#line 904 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 913 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+            {
       if (ps->GetVersion() < 2) {
-        ps->ReportError("syntax error. \"No identifier\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
-        ps->ReportError("try to use protocol version 2.", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+        ps->ReportError("syntax error. \"No identifier\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+        ps->ReportError("try to use protocol version 2.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
       }
-      ((*yyvalp).token) = new tidl::Token("map", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+      ((*yyvalp).token) = new tidl::Token("map", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2480 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2640 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 97:
-#line 912 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:816
-    {
+#line 921 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+            {
       if (ps->GetVersion() < 2) {
-        ps->ReportError("syntax error. \"No identifier\".", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
-        ps->ReportError("try to use protocol version 2.", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+        ps->ReportError("syntax error. \"No identifier\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
+        ps->ReportError("try to use protocol version 2.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
       }
-      ((*yyvalp).token) = new tidl::Token("set", (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
-      delete (((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
+      ((*yyvalp).token) = new tidl::Token("set", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
+      delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2493 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2653 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
 
-#line 2497 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:816
+#line 2657 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+
       default: break;
     }
+#if YY_EXCEPTIONS
+  }
+  catch (const syntax_error& yyexc)
+    {
+      YY_DPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));
+      *yylocp = yyexc.location;
+      yyerror (yylocp, yyparser, ps, yyexc.what ());
+      YYERROR;
+    }
+#endif // YY_EXCEPTIONS
 
   return yyok;
 # undef yyerrok
@@ -2562,9 +2733,9 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys, yy::parser& yyparser, tid
       if (yydebug)
         {
           if (yys->yysemantics.yyfirstVal)
-            YYFPRINTF (stderr, "%s unresolved", yymsg);
+            YY_FPRINTF ((stderr, "%s unresolved", yymsg));
           else
-            YYFPRINTF (stderr, "%s incomplete", yymsg);
+            YY_FPRINTF ((stderr, "%s incomplete", yymsg));
           YY_SYMBOL_PRINT ("", yystos[yys->yylrState], YY_NULLPTR, &yys->yyloc);
         }
 #endif
@@ -2589,8 +2760,8 @@ yylhsNonterm (yyRuleNum yyrule)
   return yyr1[yyrule];
 }
 
-#define yypact_value_is_default(Yystate) \
-  (!!((Yystate) == (-83)))
+#define yypact_value_is_default(Yyn) \
+  ((Yyn) == YYPACT_NINF)
 
 /** True iff LR state YYSTATE has only a default reduction (regardless
  *  of token).  */
@@ -2607,10 +2778,10 @@ yydefaultAction (yyStateNum yystate)
   return yydefact[yystate];
 }
 
-#define yytable_value_is_error(Yytable_value) \
+#define yytable_value_is_error(Yyn) \
   0
 
-/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
+/** The action to take in YYSTATE on seeing YYTOKEN.
  *  Result R means
  *    R < 0:  Reduce on rule -R.
  *    R = 0:  Error.
@@ -2618,26 +2789,25 @@ yydefaultAction (yyStateNum yystate)
  *  Set *YYCONFLICTS to a pointer into yyconfl to a 0-terminated list
  *  of conflicting reductions.
  */
-static inline void
-yygetLRActions (yyStateNum yystate, int yytoken,
-                int* yyaction, const short int** yyconflicts)
+static inline int
+yygetLRActions (yyStateNum yystate, yySymbol yytoken, const short** yyconflicts)
 {
   int yyindex = yypact[yystate] + yytoken;
-  if (yypact_value_is_default (yypact[yystate])
+  if (yyisDefaultedState (yystate)
       || yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
     {
-      *yyaction = -yydefact[yystate];
       *yyconflicts = yyconfl;
+      return -yydefact[yystate];
     }
   else if (! yytable_value_is_error (yytable[yyindex]))
     {
-      *yyaction = yytable[yyindex];
       *yyconflicts = yyconfl + yyconflp[yyindex];
+      return yytable[yyindex];
     }
   else
     {
-      *yyaction = 0;
       *yyconflicts = yyconfl + yyconflp[yyindex];
+      return 0;
     }
 }
 
@@ -2689,12 +2859,12 @@ yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
  *  alternative actions for YYSTATE.  Assumes that YYRHS comes from
  *  stack #YYK of *YYSTACKP. */
 static void
-yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
+yyaddDeferredAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyGLRState* yystate,
                      yyGLRState* yyrhs, yyRuleNum yyrule)
 {
   yySemanticOption* yynewOption =
     &yynewGLRStackItem (yystackp, yyfalse)->yyoption;
-  YYASSERT (!yynewOption->yyisState);
+  YY_ASSERT (!yynewOption->yyisState);
   yynewOption->yystate = yyrhs;
   yynewOption->yyrule = yyrule;
   if (yystackp->yytops.yylookaheadNeeds[yyk])
@@ -2719,17 +2889,25 @@ yyinitStateSet (yyGLRStateSet* yyset)
 {
   yyset->yysize = 1;
   yyset->yycapacity = 16;
-  yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
+  yyset->yystates
+    = YY_CAST (yyGLRState**,
+               YYMALLOC (YY_CAST (size_t, yyset->yycapacity)
+                         * sizeof yyset->yystates[0]));
   if (! yyset->yystates)
     return yyfalse;
   yyset->yystates[0] = YY_NULLPTR;
-  yyset->yylookaheadNeeds =
-    (yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]);
+  yyset->yylookaheadNeeds
+    = YY_CAST (yybool*,
+               YYMALLOC (YY_CAST (size_t, yyset->yycapacity)
+                         * sizeof yyset->yylookaheadNeeds[0]));
   if (! yyset->yylookaheadNeeds)
     {
       YYFREE (yyset->yystates);
       return yyfalse;
     }
+  memset (yyset->yylookaheadNeeds,
+          0,
+          YY_CAST (size_t, yyset->yycapacity) * sizeof yyset->yylookaheadNeeds[0]);
   return yytrue;
 }
 
@@ -2742,13 +2920,15 @@ static void yyfreeStateSet (yyGLRStateSet* yyset)
 /** Initialize *YYSTACKP to a single empty stack, with total maximum
  *  capacity for all stacks of YYSIZE.  */
 static yybool
-yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
+yyinitGLRStack (yyGLRStack* yystackp, ptrdiff_t yysize)
 {
   yystackp->yyerrState = 0;
   yynerrs = 0;
   yystackp->yyspaceLeft = yysize;
-  yystackp->yyitems =
-    (yyGLRStackItem*) YYMALLOC (yysize * sizeof yystackp->yynextFree[0]);
+  yystackp->yyitems
+    = YY_CAST (yyGLRStackItem*,
+               YYMALLOC (YY_CAST (size_t, yysize)
+                         * sizeof yystackp->yynextFree[0]));
   if (!yystackp->yyitems)
     return yyfalse;
   yystackp->yynextFree = yystackp->yyitems;
@@ -2759,8 +2939,9 @@ yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
 
 
 #if YYSTACKEXPANDABLE
-# define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
-  &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
+# define YYRELOC(YYFROMITEMS, YYTOITEMS, YYX, YYTYPE)                   \
+  &((YYTOITEMS)                                                         \
+    - ((YYFROMITEMS) - YY_REINTERPRET_CAST (yyGLRStackItem*, (YYX))))->YYTYPE
 
 /** If *YYSTACKP is expandable, extend it.  WARNING: Pointers into the
     stack from outside should be considered invalid after this call.
@@ -2772,15 +2953,18 @@ yyexpandGLRStack (yyGLRStack* yystackp)
 {
   yyGLRStackItem* yynewItems;
   yyGLRStackItem* yyp0, *yyp1;
-  size_t yynewSize;
-  size_t yyn;
-  size_t yysize = yystackp->yynextFree - yystackp->yyitems;
+  ptrdiff_t yynewSize;
+  ptrdiff_t yyn;
+  ptrdiff_t yysize = yystackp->yynextFree - yystackp->yyitems;
   if (YYMAXDEPTH - YYHEADROOM < yysize)
     yyMemoryExhausted (yystackp);
   yynewSize = 2*yysize;
   if (YYMAXDEPTH < yynewSize)
     yynewSize = YYMAXDEPTH;
-  yynewItems = (yyGLRStackItem*) YYMALLOC (yynewSize * sizeof yynewItems[0]);
+  yynewItems
+    = YY_CAST (yyGLRStackItem*,
+               YYMALLOC (YY_CAST (size_t, yynewSize)
+                         * sizeof yynewItems[0]));
   if (! yynewItems)
     yyMemoryExhausted (yystackp);
   for (yyp0 = yystackp->yyitems, yyp1 = yynewItems, yyn = yysize;
@@ -2788,7 +2972,7 @@ yyexpandGLRStack (yyGLRStack* yystackp)
        yyn -= 1, yyp0 += 1, yyp1 += 1)
     {
       *yyp1 = *yyp0;
-      if (*(yybool *) yyp0)
+      if (*YY_REINTERPRET_CAST (yybool *, yyp0))
         {
           yyGLRState* yys0 = &yyp0->yystate;
           yyGLRState* yys1 = &yyp1->yystate;
@@ -2844,7 +3028,7 @@ yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
 
 /** Invalidate stack #YYK in *YYSTACKP.  */
 static inline void
-yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
+yymarkStackDeleted (yyGLRStack* yystackp, ptrdiff_t yyk)
 {
   if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
     yystackp->yylastDeleted = yystackp->yytops.yystates[yyk];
@@ -2861,23 +3045,21 @@ yyundeleteLastStack (yyGLRStack* yystackp)
     return;
   yystackp->yytops.yystates[0] = yystackp->yylastDeleted;
   yystackp->yytops.yysize = 1;
-  YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
+  YY_DPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
   yystackp->yylastDeleted = YY_NULLPTR;
 }
 
 static inline void
 yyremoveDeletes (yyGLRStack* yystackp)
 {
-  size_t yyi, yyj;
+  ptrdiff_t yyi, yyj;
   yyi = yyj = 0;
   while (yyj < yystackp->yytops.yysize)
     {
       if (yystackp->yytops.yystates[yyi] == YY_NULLPTR)
         {
           if (yyi == yyj)
-            {
-              YYDPRINTF ((stderr, "Removing dead stacks.\n"));
-            }
+            YY_DPRINTF ((stderr, "Removing dead stacks.\n"));
           yystackp->yytops.yysize -= 1;
         }
       else
@@ -2891,10 +3073,8 @@ yyremoveDeletes (yyGLRStack* yystackp)
           yystackp->yytops.yylookaheadNeeds[yyj] =
             yystackp->yytops.yylookaheadNeeds[yyi];
           if (yyj != yyi)
-            {
-              YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
-                          (unsigned long int) yyi, (unsigned long int) yyj));
-            }
+            YY_DPRINTF ((stderr, "Rename stack %ld -> %ld.\n",
+                        YY_CAST (long, yyi), YY_CAST (long, yyj)));
           yyj += 1;
         }
       yyi += 1;
@@ -2905,8 +3085,8 @@ yyremoveDeletes (yyGLRStack* yystackp)
  * state YYLRSTATE, at input position YYPOSN, with (resolved) semantic
  * value *YYVALP and source location *YYLOCP.  */
 static inline void
-yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
-            size_t yyposn,
+yyglrShift (yyGLRStack* yystackp, ptrdiff_t yyk, yyStateNum yylrState,
+            ptrdiff_t yyposn,
             YYSTYPE* yyvalp, YYLTYPE* yylocp)
 {
   yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
@@ -2926,11 +3106,11 @@ yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
  *  state YYLRSTATE, at input position YYPOSN, with the (unresolved)
  *  semantic value of YYRHS under the action for YYRULE.  */
 static inline void
-yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
-                 size_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
+yyglrShiftDefer (yyGLRStack* yystackp, ptrdiff_t yyk, yyStateNum yylrState,
+                 ptrdiff_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
 {
   yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
-  YYASSERT (yynewState->yyisState);
+  YY_ASSERT (yynewState->yyisState);
 
   yynewState->yylrState = yylrState;
   yynewState->yyposn = yyposn;
@@ -2947,38 +3127,37 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
 # define YY_REDUCE_PRINT(Args)
 #else
 # define YY_REDUCE_PRINT(Args)          \
-do {                                    \
-  if (yydebug)                          \
-    yy_reduce_print Args;               \
-} while (0)
+  do {                                  \
+    if (yydebug)                        \
+      yy_reduce_print Args;             \
+  } while (0)
 
 /*----------------------------------------------------------------------.
 | Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. |
 `----------------------------------------------------------------------*/
 
 static inline void
-yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
+yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, ptrdiff_t yyk,
                  yyRuleNum yyrule, yy::parser& yyparser, tidl::Parser* ps)
 {
   int yynrhs = yyrhsLength (yyrule);
   int yylow = 1;
   int yyi;
-  YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
-             (unsigned long int) yyk, yyrule - 1,
-             (unsigned long int) yyrline[yyrule]);
+  YY_FPRINTF ((stderr, "Reducing stack %ld by rule %d (line %d):\n",
+               YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule]));
   if (! yynormal)
     yyfillin (yyvsp, 1, -yynrhs);
   /* The symbols being reduced.  */
   for (yyi = 0; yyi < yynrhs; yyi++)
     {
-      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
+      YY_FPRINTF ((stderr, "   $%d = ", yyi + 1));
       yy_symbol_print (stderr,
                        yystos[yyvsp[yyi - yynrhs + 1].yystate.yylrState],
-                       &yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval
-                       , &(((yyGLRStackItem const *)yyvsp)[YYFILL ((yyi + 1) - (yynrhs))].yystate.yyloc)                       , yyparser, ps);
+                       &yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval,
+                       &(YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL ((yyi + 1) - (yynrhs))].yystate.yyloc)                       , yyparser, ps);
       if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved)
-        YYFPRINTF (stderr, " (unresolved)");
-      YYFPRINTF (stderr, "\n");
+        YY_FPRINTF ((stderr, " (unresolved)"));
+      YY_FPRINTF ((stderr, "\n"));
     }
 }
 #endif
@@ -2990,7 +3169,7 @@ yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
  *  and *YYLOCP to the computed location (if any).  Return value is as
  *  for userAction.  */
 static inline YYRESULTTAG
-yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
+yydoAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
             YYSTYPE* yyvalp, YYLTYPE *yylocp, yy::parser& yyparser, tidl::Parser* ps)
 {
   int yynrhs = yyrhsLength (yyrule);
@@ -2998,33 +3177,33 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
   if (yystackp->yysplitPoint == YY_NULLPTR)
     {
       /* Standard special case: single stack.  */
-      yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
-      YYASSERT (yyk == 0);
+      yyGLRStackItem* yyrhs
+        = YY_REINTERPRET_CAST (yyGLRStackItem*, yystackp->yytops.yystates[yyk]);
+      YY_ASSERT (yyk == 0);
       yystackp->yynextFree -= yynrhs;
       yystackp->yyspaceLeft += yynrhs;
       yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
-      YY_REDUCE_PRINT ((1, yyrhs, yyk, yyrule, yyparser, ps));
+      YY_REDUCE_PRINT ((yytrue, yyrhs, yyk, yyrule, yyparser, ps));
       return yyuserAction (yyrule, yynrhs, yyrhs, yystackp,
                            yyvalp, yylocp, yyparser, ps);
     }
   else
     {
-      int yyi;
-      yyGLRState* yys;
       yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
-      yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
+      yyGLRState* yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
         = yystackp->yytops.yystates[yyk];
+      int yyi;
       if (yynrhs == 0)
         /* Set default location.  */
         yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;
       for (yyi = 0; yyi < yynrhs; yyi += 1)
         {
           yys = yys->yypred;
-          YYASSERT (yys);
+          YY_ASSERT (yys);
         }
       yyupdateSplit (yystackp, yys);
       yystackp->yytops.yystates[yyk] = yys;
-      YY_REDUCE_PRINT ((0, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule, yyparser, ps));
+      YY_REDUCE_PRINT ((yyfalse, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule, yyparser, ps));
       return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
                            yystackp, yyvalp, yylocp, yyparser, ps);
     }
@@ -3042,10 +3221,10 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
  *  added to the options for the existing state's semantic value.
  */
 static inline YYRESULTTAG
-yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
+yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
              yybool yyforceEval, yy::parser& yyparser, tidl::Parser* ps)
 {
-  size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
+  ptrdiff_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
 
   if (yyforceEval || yystackp->yysplitPoint == YY_NULLPTR)
     {
@@ -3054,10 +3233,9 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
 
       YYRESULTTAG yyflag = yydoAction (yystackp, yyk, yyrule, &yysval, &yyloc, yyparser, ps);
       if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULLPTR)
-        {
-          YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n",
-                     (unsigned long int) yyk, yyrule - 1));
-        }
+        YY_DPRINTF ((stderr,
+                     "Parse on stack %ld rejected by rule %d (line %d).\n",
+                     YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule - 1]));
       if (yyflag != yyok)
         return yyflag;
       YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
@@ -3068,7 +3246,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
     }
   else
     {
-      size_t yyi;
+      ptrdiff_t yyi;
       int yyn;
       yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk];
       yyStateNum yynewLRState;
@@ -3077,14 +3255,15 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
            0 < yyn; yyn -= 1)
         {
           yys = yys->yypred;
-          YYASSERT (yys);
+          YY_ASSERT (yys);
         }
       yyupdateSplit (yystackp, yys);
       yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
-      YYDPRINTF ((stderr,
-                  "Reduced stack %lu by rule #%d; action deferred.  "
-                  "Now in state %d.\n",
-                  (unsigned long int) yyk, yyrule - 1, yynewLRState));
+      YY_DPRINTF ((stderr,
+                   "Reduced stack %ld by rule %d (line %d); action deferred.  "
+                   "Now in state %d.\n",
+                   YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule - 1],
+                   yynewLRState));
       for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
         if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULLPTR)
           {
@@ -3096,9 +3275,8 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
                   {
                     yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule);
                     yymarkStackDeleted (yystackp, yyk);
-                    YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n",
-                                (unsigned long int) yyk,
-                                (unsigned long int) yyi));
+                    YY_DPRINTF ((stderr, "Merging stack %ld into stack %ld.\n",
+                                 YY_CAST (long, yyk), YY_CAST (long, yyi)));
                     return yyok;
                   }
                 yyp = yyp->yypred;
@@ -3110,48 +3288,50 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
   return yyok;
 }
 
-static size_t
-yysplitStack (yyGLRStack* yystackp, size_t yyk)
+static ptrdiff_t
+yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk)
 {
   if (yystackp->yysplitPoint == YY_NULLPTR)
     {
-      YYASSERT (yyk == 0);
+      YY_ASSERT (yyk == 0);
       yystackp->yysplitPoint = yystackp->yytops.yystates[yyk];
     }
-  if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity)
+  if (yystackp->yytops.yycapacity <= yystackp->yytops.yysize)
     {
-      yyGLRState** yynewStates;
-      yybool* yynewLookaheadNeeds;
-
-      yynewStates = YY_NULLPTR;
-
-      if (yystackp->yytops.yycapacity
-          > (YYSIZEMAX / (2 * sizeof yynewStates[0])))
+      ptrdiff_t state_size = sizeof yystackp->yytops.yystates[0];
+      ptrdiff_t half_max_capacity = YYSIZEMAX / 2 / state_size;
+      if (half_max_capacity < yystackp->yytops.yycapacity)
         yyMemoryExhausted (yystackp);
       yystackp->yytops.yycapacity *= 2;
 
-      yynewStates =
-        (yyGLRState**) YYREALLOC (yystackp->yytops.yystates,
-                                  (yystackp->yytops.yycapacity
-                                   * sizeof yynewStates[0]));
-      if (yynewStates == YY_NULLPTR)
-        yyMemoryExhausted (yystackp);
-      yystackp->yytops.yystates = yynewStates;
+      {
+        yyGLRState** yynewStates
+          = YY_CAST (yyGLRState**,
+                     YYREALLOC (yystackp->yytops.yystates,
+                                (YY_CAST (size_t, yystackp->yytops.yycapacity)
+                                 * sizeof yynewStates[0])));
+        if (yynewStates == YY_NULLPTR)
+          yyMemoryExhausted (yystackp);
+        yystackp->yytops.yystates = yynewStates;
+      }
 
-      yynewLookaheadNeeds =
-        (yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds,
-                             (yystackp->yytops.yycapacity
-                              * sizeof yynewLookaheadNeeds[0]));
-      if (yynewLookaheadNeeds == YY_NULLPTR)
-        yyMemoryExhausted (yystackp);
-      yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds;
+      {
+        yybool* yynewLookaheadNeeds
+          = YY_CAST (yybool*,
+                     YYREALLOC (yystackp->yytops.yylookaheadNeeds,
+                                (YY_CAST (size_t, yystackp->yytops.yycapacity)
+                                 * sizeof yynewLookaheadNeeds[0])));
+        if (yynewLookaheadNeeds == YY_NULLPTR)
+          yyMemoryExhausted (yystackp);
+        yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds;
+      }
     }
   yystackp->yytops.yystates[yystackp->yytops.yysize]
     = yystackp->yytops.yystates[yyk];
   yystackp->yytops.yylookaheadNeeds[yystackp->yytops.yysize]
     = yystackp->yytops.yylookaheadNeeds[yyk];
   yystackp->yytops.yysize += 1;
-  return yystackp->yytops.yysize-1;
+  return yystackp->yytops.yysize - 1;
 }
 
 /** True iff YYY0 and YYY1 represent identical options at the top level.
@@ -3185,7 +3365,7 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
   int yyn;
   for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
        yyn = yyrhsLength (yyy0->yyrule);
-       yyn > 0;
+       0 < yyn;
        yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
     {
       if (yys0 == yys1)
@@ -3267,7 +3447,7 @@ yyresolveStates (yyGLRState* yys, int yyn,
 {
   if (0 < yyn)
     {
-      YYASSERT (yys->yypred);
+      YY_ASSERT (yys->yypred);
       YYCHK (yyresolveStates (yys->yypred, yyn-1, yystackp, yyparser, ps));
       if (! yys->yyresolved)
         YYCHK (yyresolveValue (yys, yystackp, yyparser, ps));
@@ -3338,26 +3518,26 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
     yystates[0] = yys;
 
   if (yyx->yystate->yyposn < yys->yyposn + 1)
-    YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n",
-               yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
-               yyx->yyrule - 1);
+    YY_FPRINTF ((stderr, "%*s%s -> <Rule %d, empty>\n",
+                 yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
+                 yyx->yyrule - 1));
   else
-    YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
-               yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
-               yyx->yyrule - 1, (unsigned long int) (yys->yyposn + 1),
-               (unsigned long int) yyx->yystate->yyposn);
+    YY_FPRINTF ((stderr, "%*s%s -> <Rule %d, tokens %ld .. %ld>\n",
+                 yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
+                 yyx->yyrule - 1, YY_CAST (long, yys->yyposn + 1),
+                 YY_CAST (long, yyx->yystate->yyposn)));
   for (yyi = 1; yyi <= yynrhs; yyi += 1)
     {
       if (yystates[yyi]->yyresolved)
         {
           if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
-            YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
-                       yytokenName (yystos[yystates[yyi]->yylrState]));
+            YY_FPRINTF ((stderr, "%*s%s <empty>\n", yyindent+2, "",
+                         yytokenName (yystos[yystates[yyi]->yylrState])));
           else
-            YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
-                       yytokenName (yystos[yystates[yyi]->yylrState]),
-                       (unsigned long int) (yystates[yyi-1]->yyposn + 1),
-                       (unsigned long int) yystates[yyi]->yyposn);
+            YY_FPRINTF ((stderr, "%*s%s <tokens %ld .. %ld>\n", yyindent+2, "",
+                         yytokenName (yystos[yystates[yyi]->yylrState]),
+                         YY_CAST (long, yystates[yyi-1]->yyposn + 1),
+                         YY_CAST (long, yystates[yyi]->yyposn)));
         }
       else
         yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
@@ -3373,12 +3553,12 @@ yyreportAmbiguity (yySemanticOption* yyx0,
   YYUSE (yyx1);
 
 #if YYDEBUG
-  YYFPRINTF (stderr, "Ambiguity detected.\n");
-  YYFPRINTF (stderr, "Option 1,\n");
+  YY_FPRINTF ((stderr, "Ambiguity detected.\n"));
+  YY_FPRINTF ((stderr, "Option 1,\n"));
   yyreportTree (yyx0, 2);
-  YYFPRINTF (stderr, "\nOption 2,\n");
+  YY_FPRINTF ((stderr, "\nOption 2,\n"));
   yyreportTree (yyx1, 2);
-  YYFPRINTF (stderr, "\n");
+  YY_FPRINTF ((stderr, "\n"));
 #endif
 
   yyerror (yylocp, yyparser, ps, YY_("syntax is ambiguous"));
@@ -3389,7 +3569,7 @@ yyreportAmbiguity (yySemanticOption* yyx0,
  *  ending at YYS1.  Has no effect on previously resolved states.
  *  The first semantic option of a state is always chosen.  */
 static void
-yyresolveLocations (yyGLRStateyys1, int yyn1,
+yyresolveLocations (yyGLRState *yys1, int yyn1,
                     yyGLRStack *yystackp, yy::parser& yyparser, tidl::Parser* ps)
 {
   if (0 < yyn1)
@@ -3400,9 +3580,9 @@ yyresolveLocations (yyGLRState* yys1, int yyn1,
           yyGLRStackItem yyrhsloc[1 + YYMAXRHS];
           int yynrhs;
           yySemanticOption *yyoption = yys1->yysemantics.yyfirstVal;
-          YYASSERT (yyoption != YY_NULLPTR);
+          YY_ASSERT (yyoption);
           yynrhs = yyrhsLength (yyoption->yyrule);
-          if (yynrhs > 0)
+          if (0 < yynrhs)
             {
               yyGLRState *yys;
               int yyn;
@@ -3425,18 +3605,7 @@ yyresolveLocations (yyGLRState* yys1, int yyn1,
               yyGLRState *yyprevious = yyoption->yystate;
               yyrhsloc[0].yystate.yyloc = yyprevious->yyloc;
             }
-          {
-            int yychar_current = yychar;
-            YYSTYPE yylval_current = yylval;
-            YYLTYPE yylloc_current = yylloc;
-            yychar = yyoption->yyrawchar;
-            yylval = yyoption->yyval;
-            yylloc = yyoption->yyloc;
-            YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
-            yychar = yychar_current;
-            yylval = yylval_current;
-            yylloc = yylloc_current;
-          }
+          YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
         }
     }
 }
@@ -3486,7 +3655,7 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp, yy::parser& yyparser, tid
               yymerge = yyfalse;
               break;
             default:
-              /* This cannot happen so it is not worth a YYASSERT (yyfalse),
+              /* This cannot happen so it is not worth a YY_ASSERT (yyfalse),
                  but some compilers complain if the default case is
                  omitted.  */
               break;
@@ -3564,7 +3733,7 @@ yycompressStack (yyGLRStack* yystackp)
     yyp->yypred = yyr;
 
   yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
-  yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
+  yystackp->yynextFree = YY_REINTERPRET_CAST (yyGLRStackItem*, yystackp->yysplitPoint) + 1;
   yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
   yystackp->yysplitPoint = YY_NULLPTR;
   yystackp->yylastDeleted = YY_NULLPTR;
@@ -3581,16 +3750,16 @@ yycompressStack (yyGLRStack* yystackp)
 }
 
 static YYRESULTTAG
-yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
-                   size_t yyposn, YYLTYPE *yylocp, yy::parser& yyparser, tidl::Parser* ps)
+yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
+                   ptrdiff_t yyposn, YYLTYPE *yylocp, yy::parser& yyparser, tidl::Parser* ps)
 {
   while (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
     {
       yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
-      YYDPRINTF ((stderr, "Stack %lu Entering state %d\n",
-                  (unsigned long int) yyk, yystate));
+      YY_DPRINTF ((stderr, "Stack %ld Entering state %d\n",
+                   YY_CAST (long, yyk), yystate));
 
-      YYASSERT (yystate != YYFINAL);
+      YY_ASSERT (yystate != YYFINAL);
 
       if (yyisDefaultedState (yystate))
         {
@@ -3598,18 +3767,17 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
           yyRuleNum yyrule = yydefaultAction (yystate);
           if (yyrule == 0)
             {
-              YYDPRINTF ((stderr, "Stack %lu dies.\n",
-                          (unsigned long int) yyk));
+              YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yyk)));
               yymarkStackDeleted (yystackp, yyk);
               return yyok;
             }
           yyflag = yyglrReduce (yystackp, yyk, yyrule, yyimmediate[yyrule], yyparser, ps);
           if (yyflag == yyerr)
             {
-              YYDPRINTF ((stderr,
-                          "Stack %lu dies "
-                          "(predicate failure or explicit user error).\n",
-                          (unsigned long int) yyk));
+              YY_DPRINTF ((stderr,
+                           "Stack %ld dies "
+                           "(predicate failure or explicit user error).\n",
+                           YY_CAST (long, yyk)));
               yymarkStackDeleted (yystackp, yyk);
               return yyok;
             }
@@ -3618,37 +3786,17 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
         }
       else
         {
-          yySymbol yytoken;
-          int yyaction;
-          const short int* yyconflicts;
-
+          yySymbol yytoken = yygetToken (&yychar, yystackp, yyparser, ps);
+          const short* yyconflicts;
+          const int yyaction = yygetLRActions (yystate, yytoken, &yyconflicts);
           yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
-          if (yychar == YYEMPTY)
-            {
-              YYDPRINTF ((stderr, "Reading a token: "));
-              yychar = yylex (&yylval, &yylloc, lex_scanner);
-            }
-
-          if (yychar <= YYEOF)
-            {
-              yychar = yytoken = YYEOF;
-              YYDPRINTF ((stderr, "Now at end of input.\n"));
-            }
-          else
-            {
-              yytoken = YYTRANSLATE (yychar);
-              YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
-            }
-
-          yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
 
           while (*yyconflicts != 0)
             {
               YYRESULTTAG yyflag;
-              size_t yynewStack = yysplitStack (yystackp, yyk);
-              YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
-                          (unsigned long int) yynewStack,
-                          (unsigned long int) yyk));
+              ptrdiff_t yynewStack = yysplitStack (yystackp, yyk);
+              YY_DPRINTF ((stderr, "Splitting off stack %ld from %ld.\n",
+                           YY_CAST (long, yynewStack), YY_CAST (long, yyk)));
               yyflag = yyglrReduce (yystackp, yynewStack,
                                     *yyconflicts,
                                     yyimmediate[*yyconflicts], yyparser, ps);
@@ -3657,8 +3805,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
                                           yyposn, yylocp, yyparser, ps));
               else if (yyflag == yyerr)
                 {
-                  YYDPRINTF ((stderr, "Stack %lu dies.\n",
-                              (unsigned long int) yynewStack));
+                  YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yynewStack)));
                   yymarkStackDeleted (yystackp, yynewStack);
                 }
               else
@@ -3670,8 +3817,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
             break;
           else if (yyisErrorAction (yyaction))
             {
-              YYDPRINTF ((stderr, "Stack %lu dies.\n",
-                          (unsigned long int) yyk));
+              YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yyk)));
               yymarkStackDeleted (yystackp, yyk);
               break;
             }
@@ -3681,10 +3827,10 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
                                                 yyimmediate[-yyaction], yyparser, ps);
               if (yyflag == yyerr)
                 {
-                  YYDPRINTF ((stderr,
-                              "Stack %lu dies "
-                              "(predicate failure or explicit user error).\n",
-                              (unsigned long int) yyk));
+                  YY_DPRINTF ((stderr,
+                               "Stack %ld dies "
+                               "(predicate failure or explicit user error).\n",
+                               YY_CAST (long, yyk)));
                   yymarkStackDeleted (yystackp, yyk);
                   break;
                 }
@@ -3706,18 +3852,18 @@ yyreportSyntaxError (yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser* p
 #else
   {
   yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
-  size_t yysize0 = yytnamerr (YY_NULLPTR, yytokenName (yytoken));
-  size_t yysize = yysize0;
   yybool yysize_overflow = yyfalse;
   char* yymsg = YY_NULLPTR;
   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
   /* Internationalized format string. */
   const char *yyformat = YY_NULLPTR;
-  /* Arguments of yyformat. */
+  /* Arguments of yyformat: reported tokens (one for the "unexpected",
+     one per "expected"). */
   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
-  /* Number of reported tokens (one for the "unexpected", one per
-     "expected").  */
+  /* Actual size of YYARG. */
   int yycount = 0;
+  /* Cumulated lengths of YYARG.  */
+  ptrdiff_t yysize = 0;
 
   /* There are many possibilities here to consider:
      - If this state is a consistent state with a default action, then
@@ -3745,6 +3891,8 @@ yyreportSyntaxError (yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser* p
   if (yytoken != YYEMPTY)
     {
       int yyn = yypact[yystackp->yytops.yystates[0]->yylrState];
+      ptrdiff_t yysize0 = yytnamerr (YY_NULLPTR, yytokenName (yytoken));
+      yysize = yysize0;
       yyarg[yycount++] = yytokenName (yytoken);
       if (!yypact_value_is_default (yyn))
         {
@@ -3768,9 +3916,11 @@ yyreportSyntaxError (yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser* p
                   }
                 yyarg[yycount++] = yytokenName (yyx);
                 {
-                  size_t yysz = yysize + yytnamerr (YY_NULLPTR, yytokenName (yyx));
-                  yysize_overflow |= yysz < yysize;
-                  yysize = yysz;
+                  ptrdiff_t yysz = yytnamerr (YY_NULLPTR, yytokenName (yyx));
+                  if (YYSIZEMAX - yysize < yysz)
+                    yysize_overflow = yytrue;
+                  else
+                    yysize += yysz;
                 }
               }
         }
@@ -3782,6 +3932,7 @@ yyreportSyntaxError (yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser* p
       case N:                           \
         yyformat = S;                   \
       break
+    default: /* Avoid compiler warnings. */
       YYCASE_(0, YY_("syntax error"));
       YYCASE_(1, YY_("syntax error, unexpected %s"));
       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
@@ -3792,13 +3943,17 @@ yyreportSyntaxError (yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser* p
     }
 
   {
-    size_t yysz = yysize + strlen (yyformat);
-    yysize_overflow |= yysz < yysize;
-    yysize = yysz;
+    /* Don't count the "%s"s in the final size, but reserve room for
+       the terminator.  */
+    ptrdiff_t yysz = YY_CAST (ptrdiff_t, strlen (yyformat)) - 2 * yycount + 1;
+    if (YYSIZEMAX - yysize < yysz)
+      yysize_overflow = yytrue;
+    else
+      yysize += yysz;
   }
 
   if (!yysize_overflow)
-    yymsg = (char *) YYMALLOC (yysize);
+    yymsg = YY_CAST (char *, YYMALLOC (YY_CAST (size_t, yysize)));
 
   if (yymsg)
     {
@@ -3813,8 +3968,8 @@ yyreportSyntaxError (yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser* p
             }
           else
             {
-              yyp++;
-              yyformat++;
+              ++yyp;
+              ++yyformat;
             }
         }
       yyerror (&yylloc, yyparser, ps, yymsg);
@@ -3836,15 +3991,13 @@ yyreportSyntaxError (yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser* p
 static void
 yyrecoverSyntaxError (yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser* ps)
 {
-  size_t yyk;
-  int yyj;
-
   if (yystackp->yyerrState == 3)
     /* We just shifted the error token and (perhaps) took some
        reductions.  Skip tokens until we can proceed.  */
     while (yytrue)
       {
         yySymbol yytoken;
+        int yyj;
         if (yychar == YYEOF)
           yyFail (yystackp, &yylloc, yyparser, ps, YY_NULLPTR);
         if (yychar != YYEMPTY)
@@ -3859,19 +4012,9 @@ yyrecoverSyntaxError (yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser*
             yytoken = YYTRANSLATE (yychar);
             yydestruct ("Error: discarding",
                         yytoken, &yylval, &yylloc, yyparser, ps);
+            yychar = YYEMPTY;
           }
-        YYDPRINTF ((stderr, "Reading a token: "));
-        yychar = yylex (&yylval, &yylloc, lex_scanner);
-        if (yychar <= YYEOF)
-          {
-            yychar = yytoken = YYEOF;
-            YYDPRINTF ((stderr, "Now at end of input.\n"));
-          }
-        else
-          {
-            yytoken = YYTRANSLATE (yychar);
-            YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
-          }
+        yytoken = yygetToken (&yychar, yystackp, yyparser, ps);
         yyj = yypact[yystackp->yytops.yystates[0]->yylrState];
         if (yypact_value_is_default (yyj))
           return;
@@ -3886,22 +4029,25 @@ yyrecoverSyntaxError (yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser*
       }
 
   /* Reduce to one stack.  */
-  for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
-    if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
-      break;
-  if (yyk >= yystackp->yytops.yysize)
-    yyFail (yystackp, &yylloc, yyparser, ps, YY_NULLPTR);
-  for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1)
-    yymarkStackDeleted (yystackp, yyk);
-  yyremoveDeletes (yystackp);
-  yycompressStack (yystackp);
+  {
+    ptrdiff_t yyk;
+    for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
+      if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
+        break;
+    if (yyk >= yystackp->yytops.yysize)
+      yyFail (yystackp, &yylloc, yyparser, ps, YY_NULLPTR);
+    for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1)
+      yymarkStackDeleted (yystackp, yyk);
+    yyremoveDeletes (yystackp);
+    yycompressStack (yystackp);
+  }
 
   /* Now pop stack until we find a state that shifts the error token.  */
   yystackp->yyerrState = 3;
   while (yystackp->yytops.yystates[0] != YY_NULLPTR)
     {
       yyGLRState *yys = yystackp->yytops.yystates[0];
-      yyj = yypact[yys->yylrState];
+      int yyj = yypact[yys->yylrState];
       if (! yypact_value_is_default (yyj))
         {
           yyj += YYTERROR;
@@ -3909,13 +4055,14 @@ yyrecoverSyntaxError (yyGLRStack* yystackp, yy::parser& yyparser, tidl::Parser*
               && yyisShiftAction (yytable[yyj]))
             {
               /* Shift the error token.  */
+              int yyaction = yytable[yyj];
               /* First adjust its location.*/
               YYLTYPE yyerrloc;
               yystackp->yyerror_range[2].yystate.yyloc = yylloc;
               YYLLOC_DEFAULT (yyerrloc, (yystackp->yyerror_range), 2);
-              YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]],
+              YY_SYMBOL_PRINT ("Shifting", yystos[yyaction],
                                &yylval, &yyerrloc);
-              yyglrShift (yystackp, 0, yytable[yyj],
+              yyglrShift (yystackp, 0, yyaction,
                           yys->yyposn, &yylval, &yyerrloc);
               yys = yystackp->yytops.yystates[0];
               break;
@@ -3958,17 +4105,18 @@ yyparse (yy::parser& yyparser, tidl::Parser* ps)
   int yyresult;
   yyGLRStack yystack;
   yyGLRStack* const yystackp = &yystack;
-  size_t yyposn;
+  ptrdiff_t yyposn;
 
-  YYDPRINTF ((stderr, "Starting parse\n"));
+  YY_DPRINTF ((stderr, "Starting parse\n"));
 
   yychar = YYEMPTY;
   yylval = yyval_default;
   yylloc = yyloc_default;
 
-  /* User initialization code.  */
-  yylloc.initialize ();
-#line 3972 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:2270
+  // User initialization code.
+yylloc.initialize ();
+#line 4119 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+
 
   if (! yyinitGLRStack (yystackp, YYINITDEPTH))
     goto yyexhaustedlab;
@@ -3990,20 +4138,16 @@ yyparse (yy::parser& yyparser, tidl::Parser* ps)
       /* Standard mode */
       while (yytrue)
         {
-          yyRuleNum yyrule;
-          int yyaction;
-          const short int* yyconflicts;
-
           yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
-          YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+          YY_DPRINTF ((stderr, "Entering state %d\n", yystate));
           if (yystate == YYFINAL)
             goto yyacceptlab;
           if (yyisDefaultedState (yystate))
             {
-              yyrule = yydefaultAction (yystate);
+              yyRuleNum yyrule = yydefaultAction (yystate);
               if (yyrule == 0)
                 {
-               yystack.yyerror_range[1].yystate.yyloc = yylloc;
+                  yystack.yyerror_range[1].yystate.yyloc = yylloc;
                   yyreportSyntaxError (&yystack, yyparser, ps);
                   goto yyuser_error;
                 }
@@ -4011,25 +4155,9 @@ yyparse (yy::parser& yyparser, tidl::Parser* ps)
             }
           else
             {
-              yySymbol yytoken;
-              if (yychar == YYEMPTY)
-                {
-                  YYDPRINTF ((stderr, "Reading a token: "));
-                  yychar = yylex (&yylval, &yylloc, lex_scanner);
-                }
-
-              if (yychar <= YYEOF)
-                {
-                  yychar = yytoken = YYEOF;
-                  YYDPRINTF ((stderr, "Now at end of input.\n"));
-                }
-              else
-                {
-                  yytoken = YYTRANSLATE (yychar);
-                  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
-                }
-
-              yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
+              yySymbol yytoken = yygetToken (&yychar, yystackp, yyparser, ps);
+              const short* yyconflicts;
+              int yyaction = yygetLRActions (yystate, yytoken, &yyconflicts);
               if (*yyconflicts != 0)
                 break;
               if (yyisShiftAction (yyaction))
@@ -4043,8 +4171,11 @@ yyparse (yy::parser& yyparser, tidl::Parser* ps)
                 }
               else if (yyisErrorAction (yyaction))
                 {
-               yystack.yyerror_range[1].yystate.yyloc = yylloc;
-                  yyreportSyntaxError (&yystack, yyparser, ps);
+                  yystack.yyerror_range[1].yystate.yyloc = yylloc;
+                  /* Don't issue an error message again for exceptions
+                     thrown from the scanner.  */
+                  if (yychar != YYFAULTYTOK)
+                    yyreportSyntaxError (&yystack, yyparser, ps);
                   goto yyuser_error;
                 }
               else
@@ -4055,7 +4186,7 @@ yyparse (yy::parser& yyparser, tidl::Parser* ps)
       while (yytrue)
         {
           yySymbol yytoken_to_shift;
-          size_t yys;
+          ptrdiff_t yys;
 
           for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
             yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY;
@@ -4088,8 +4219,8 @@ yyparse (yy::parser& yyparser, tidl::Parser* ps)
               if (yystack.yytops.yysize == 0)
                 yyFail (&yystack, &yylloc, yyparser, ps, YY_("syntax error"));
               YYCHK1 (yyresolveStack (&yystack, yyparser, ps));
-              YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
-           yystack.yyerror_range[1].yystate.yyloc = yylloc;
+              YY_DPRINTF ((stderr, "Returning to deterministic operation.\n"));
+              yystack.yyerror_range[1].yystate.yyloc = yylloc;
               yyreportSyntaxError (&yystack, yyparser, ps);
               goto yyuser_error;
             }
@@ -4104,25 +4235,24 @@ yyparse (yy::parser& yyparser, tidl::Parser* ps)
           yyposn += 1;
           for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
             {
-              int yyaction;
-              const short int* yyconflicts;
               yyStateNum yystate = yystack.yytops.yystates[yys]->yylrState;
-              yygetLRActions (yystate, yytoken_to_shift, &yyaction,
+              const short* yyconflicts;
+              int yyaction = yygetLRActions (yystate, yytoken_to_shift,
                               &yyconflicts);
               /* Note that yyconflicts were handled by yyprocessOneStack.  */
-              YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long int) yys));
+              YY_DPRINTF ((stderr, "On stack %ld, ", YY_CAST (long, yys)));
               YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc);
               yyglrShift (&yystack, yys, yyaction, yyposn,
                           &yylval, &yylloc);
-              YYDPRINTF ((stderr, "Stack %lu now in state #%d\n",
-                          (unsigned long int) yys,
-                          yystack.yytops.yystates[yys]->yylrState));
+              YY_DPRINTF ((stderr, "Stack %ld now in state #%d\n",
+                           YY_CAST (long, yys),
+                           yystack.yytops.yystates[yys]->yylrState));
             }
 
           if (yystack.yytops.yysize == 1)
             {
               YYCHK1 (yyresolveStack (&yystack, yyparser, ps));
-              YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
+              YY_DPRINTF ((stderr, "Returning to deterministic operation.\n"));
               yycompressStack (&yystack);
               break;
             }
@@ -4138,7 +4268,7 @@ yyparse (yy::parser& yyparser, tidl::Parser* ps)
   goto yyreturn;
 
  yybuglab:
-  YYASSERT (yyfalse);
+  YY_ASSERT (yyfalse);
   goto yyabortlab;
 
  yyabortlab:
@@ -4163,16 +4293,16 @@ yyparse (yy::parser& yyparser, tidl::Parser* ps)
       yyGLRState** yystates = yystack.yytops.yystates;
       if (yystates)
         {
-          size_t yysize = yystack.yytops.yysize;
-          size_t yyk;
+          ptrdiff_t yysize = yystack.yytops.yysize;
+          ptrdiff_t yyk;
           for (yyk = 0; yyk < yysize; yyk += 1)
             if (yystates[yyk])
               {
                 while (yystates[yyk])
                   {
                     yyGLRState *yys = yystates[yyk];
-                 yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;
-                  if (yys->yypred != YY_NULLPTR)
+                    yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;
+                    if (yys->yypred != YY_NULLPTR)
                       yydestroyGLRState ("Cleanup: popping", yys, yyparser, ps);
                     yystates[yyk] = yys->yypred;
                     yystack.yynextFree -= 1;
@@ -4195,70 +4325,74 @@ yy_yypstack (yyGLRState* yys)
   if (yys->yypred)
     {
       yy_yypstack (yys->yypred);
-      YYFPRINTF (stderr, " -> ");
+      YY_FPRINTF ((stderr, " -> "));
     }
-  YYFPRINTF (stderr, "%d@%lu", yys->yylrState,
-             (unsigned long int) yys->yyposn);
+  YY_FPRINTF ((stderr, "%d@%ld", yys->yylrState, YY_CAST (long, yys->yyposn)));
 }
 
 static void
 yypstates (yyGLRState* yyst)
 {
   if (yyst == YY_NULLPTR)
-    YYFPRINTF (stderr, "<null>");
+    YY_FPRINTF ((stderr, "<null>"));
   else
     yy_yypstack (yyst);
-  YYFPRINTF (stderr, "\n");
+  YY_FPRINTF ((stderr, "\n"));
 }
 
 static void
-yypstack (yyGLRStack* yystackp, size_t yyk)
+yypstack (yyGLRStack* yystackp, ptrdiff_t yyk)
 {
   yypstates (yystackp->yytops.yystates[yyk]);
 }
 
-#define YYINDEX(YYX)                                                         \
-    ((YYX) == YY_NULLPTR ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems)
-
-
 static void
 yypdumpstack (yyGLRStack* yystackp)
 {
+#define YYINDEX(YYX)                                                    \
+  YY_CAST (long,                                                        \
+           ((YYX)                                                       \
+            ? YY_REINTERPRET_CAST (yyGLRStackItem*, (YYX)) - yystackp->yyitems \
+            : -1))
+
   yyGLRStackItem* yyp;
-  size_t yyi;
   for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1)
     {
-      YYFPRINTF (stderr, "%3lu. ",
-                 (unsigned long int) (yyp - yystackp->yyitems));
-      if (*(yybool *) yyp)
+      YY_FPRINTF ((stderr, "%3ld. ",
+                   YY_CAST (long, yyp - yystackp->yyitems)));
+      if (*YY_REINTERPRET_CAST (yybool *, yyp))
         {
-          YYASSERT (yyp->yystate.yyisState);
-          YYASSERT (yyp->yyoption.yyisState);
-          YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
-                     yyp->yystate.yyresolved, yyp->yystate.yylrState,
-                     (unsigned long int) yyp->yystate.yyposn,
-                     (long int) YYINDEX (yyp->yystate.yypred));
+          YY_ASSERT (yyp->yystate.yyisState);
+          YY_ASSERT (yyp->yyoption.yyisState);
+          YY_FPRINTF ((stderr, "Res: %d, LR State: %d, posn: %ld, pred: %ld",
+                       yyp->yystate.yyresolved, yyp->yystate.yylrState,
+                       YY_CAST (long, yyp->yystate.yyposn),
+                       YYINDEX (yyp->yystate.yypred)));
           if (! yyp->yystate.yyresolved)
-            YYFPRINTF (stderr, ", firstVal: %ld",
-                       (long int) YYINDEX (yyp->yystate
-                                             .yysemantics.yyfirstVal));
+            YY_FPRINTF ((stderr, ", firstVal: %ld",
+                         YYINDEX (yyp->yystate.yysemantics.yyfirstVal)));
         }
       else
         {
-          YYASSERT (!yyp->yystate.yyisState);
-          YYASSERT (!yyp->yyoption.yyisState);
-          YYFPRINTF (stderr, "Option. rule: %d, state: %ld, next: %ld",
-                     yyp->yyoption.yyrule - 1,
-                     (long int) YYINDEX (yyp->yyoption.yystate),
-                     (long int) YYINDEX (yyp->yyoption.yynext));
+          YY_ASSERT (!yyp->yystate.yyisState);
+          YY_ASSERT (!yyp->yyoption.yyisState);
+          YY_FPRINTF ((stderr, "Option. rule: %d, state: %ld, next: %ld",
+                       yyp->yyoption.yyrule - 1,
+                       YYINDEX (yyp->yyoption.yystate),
+                       YYINDEX (yyp->yyoption.yynext)));
         }
-      YYFPRINTF (stderr, "\n");
+      YY_FPRINTF ((stderr, "\n"));
     }
-  YYFPRINTF (stderr, "Tops:");
-  for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
-    YYFPRINTF (stderr, "%lu: %ld; ", (unsigned long int) yyi,
-               (long int) YYINDEX (yystackp->yytops.yystates[yyi]));
-  YYFPRINTF (stderr, "\n");
+
+  YY_FPRINTF ((stderr, "Tops:"));
+  {
+    ptrdiff_t yyi;
+    for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
+      YY_FPRINTF ((stderr, "%ld: %ld; ", YY_CAST (long, yyi),
+                   YYINDEX (yystackp->yytops.yystates[yyi])));
+    YY_FPRINTF ((stderr, "\n"));
+  }
+#undef YYINDEX
 }
 #endif
 
@@ -4269,7 +4403,7 @@ yypdumpstack (yyGLRStack* yystackp)
 
 
 
-#line 922 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.c:2584
+#line 931 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
 
 
 #include <ctype.h>
@@ -4281,7 +4415,7 @@ void yy::parser::error(const yy::parser::location_type& l,
 }
 
 
-#line 4285 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:2584
+#line 4419 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
 
 /*------------------.
 | Report an error.  |
@@ -4296,9 +4430,9 @@ yyerror (const yy::parser::location_type *yylocationp, yy::parser& yyparser, tid
 }
 
 
-
 namespace yy {
-#line 4302 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:2584
+#line 4435 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+
   /// Build a parser object.
   parser::parser (tidl::Parser* ps_yyarg)
     :
@@ -4306,11 +4440,18 @@ namespace yy {
       yycdebug_ (&std::cerr),
 #endif
       ps (ps_yyarg)
-  {
-  }
+  {}
 
   parser::~parser ()
+  {}
+
+  parser::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
+  {}
+
+  int
+  parser::operator() ()
   {
+    return parse ();
   }
 
   int
@@ -4324,16 +4465,16 @@ namespace yy {
   | Print this symbol.  |
   `--------------------*/
 
-  inline void
+  void
   parser::yy_symbol_value_print_ (int yytype,
                            const semantic_type* yyvaluep,
                            const location_type* yylocationp)
   {
     YYUSE (yylocationp);
     YYUSE (yyvaluep);
-    std::ostream& yyoutput = debug_stream ();
-    std::ostream& yyo = yyoutput;
-    YYUSE (yyo);
+    std::ostream& yyo = debug_stream ();
+    std::ostream& yyoutput = yyo;
+    YYUSE (yyoutput);
     YYUSE (yytype);
   }
 
@@ -4377,6 +4518,5 @@ namespace yy {
   }
 
 #endif
-
 } // yy
-#line 4383 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp" // glr.c:2584
+#line 4523 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
index ecc47e0..0ecc24e 100644 (file)
@@ -1,8 +1,8 @@
-// A Bison parser, made by GNU Bison 3.0.4.
+// A Bison parser, made by GNU Bison 3.5.1.
 
 // Skeleton interface for Bison GLR parsers in C++
 
-// Copyright (C) 2002-2015 Free Software Foundation, Inc.
+// Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
 
 // This program is free software: you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 
 // C++ GLR parser skeleton written by Akim Demaille.
 
+// Undocumented macros, especially those whose name start with YY_,
+// are private implementation details.  Do not rely on them.
+
 #ifndef YY_YY_OPT_DATA_TIZEN_PUBLIC_PLATFORM_CORE_APPFW_TIDL_IDLC_AST_TIDLC_Y_HPP_INCLUDED
 # define YY_YY_OPT_DATA_TIZEN_PUBLIC_PLATFORM_CORE_APPFW_TIDL_IDLC_AST_TIDLC_Y_HPP_INCLUDED
 
-
+#include <iostream>
 #include <stdexcept>
 #include <string>
-#include <iostream>
-#include "location.hh"
+
+#if defined __cplusplus
+# define YY_CPLUSPLUS __cplusplus
+#else
+# define YY_CPLUSPLUS 199711L
+#endif
+
+// Support move semantics when possible.
+#if 201103L <= YY_CPLUSPLUS
+# define YY_MOVE           std::move
+# define YY_MOVE_OR_COPY   move
+# define YY_MOVE_REF(Type) Type&&
+# define YY_RVREF(Type)    Type&&
+# define YY_COPY(Type)     Type
+#else
+# define YY_MOVE
+# define YY_MOVE_OR_COPY   copy
+# define YY_MOVE_REF(Type) Type&
+# define YY_RVREF(Type)    const Type&
+# define YY_COPY(Type)     const Type&
+#endif
+
+// Support noexcept when possible.
+#if 201103L <= YY_CPLUSPLUS
+# define YY_NOEXCEPT noexcept
+# define YY_NOTHROW
+#else
+# define YY_NOEXCEPT
+# define YY_NOTHROW throw ()
+#endif
+
+// Support constexpr when possible.
+#if 201703 <= YY_CPLUSPLUS
+# define YY_CONSTEXPR constexpr
+#else
+# define YY_CONSTEXPR
+#endif
+# include "location.hh"
+
+
+#ifndef YY_ATTRIBUTE_PURE
+# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
+#  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
+# else
+#  define YY_ATTRIBUTE_PURE
+# endif
+#endif
+
+#ifndef YY_ATTRIBUTE_UNUSED
+# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
+#  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+# else
+#  define YY_ATTRIBUTE_UNUSED
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E.  */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(E) ((void) (E))
+#else
+# define YYUSE(E) /* empty */
+#endif
+
+#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                            \
+    _Pragma ("GCC diagnostic push")                                     \
+    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
+    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
+    _Pragma ("GCC diagnostic pop")
+#else
+# define YY_INITIAL_VALUE(Value) Value
+#endif
+#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END
+#endif
+#ifndef YY_INITIAL_VALUE
+# define YY_INITIAL_VALUE(Value) /* Nothing. */
+#endif
+
+#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
+# define YY_IGNORE_USELESS_CAST_BEGIN                          \
+    _Pragma ("GCC diagnostic push")                            \
+    _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
+# define YY_IGNORE_USELESS_CAST_END            \
+    _Pragma ("GCC diagnostic pop")
+#endif
+#ifndef YY_IGNORE_USELESS_CAST_BEGIN
+# define YY_IGNORE_USELESS_CAST_BEGIN
+# define YY_IGNORE_USELESS_CAST_END
+#endif
+
+# ifndef YY_NULLPTR
+#  if defined __cplusplus
+#   if 201103L <= __cplusplus
+#    define YY_NULLPTR nullptr
+#   else
+#    define YY_NULLPTR 0
+#   endif
+#  else
+#   define YY_NULLPTR ((void*)0)
+#  endif
+# endif
+
+// This skeleton is based on C, yet compiles it as C++.
+// So expect warnings about C style casts.
+#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__
+# pragma clang diagnostic ignored "-Wold-style-cast"
+#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
+# pragma GCC diagnostic ignored "-Wold-style-cast"
+#endif
+
+// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's
+// -pedantic reports as being a C++11 extension.
+#if defined __APPLE__ && YY_CPLUSPLUS < 201103L \
+    && defined __clang__ && 4 <= __clang_major__
+# pragma clang diagnostic ignored "-Wc++11-long-long"
+#endif
+
+// Whether we are compiled with exception support.
+#ifndef YY_EXCEPTIONS
+# if defined __GNUC__ && !defined __EXCEPTIONS
+#  define YY_EXCEPTIONS 0
+# else
+#  define YY_EXCEPTIONS 1
+# endif
+#endif
 
 /* Debug traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG 0
 #endif
 
-
 namespace yy {
-#line 52 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.hpp" // glr.cc:329
+#line 181 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.hpp"
+
+
 
 
   /// A Bison parser.
@@ -59,7 +190,7 @@ namespace yy {
     /// Symbol semantic values.
     union semantic_type
     {
-    #line 41 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy" // glr.cc:329
+#line 41 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
 
   tidl::Document* doc;
   tidl::Interface* interf;
@@ -83,7 +214,8 @@ namespace yy {
   tidl::Field* enum_field;
   tidl::Fields* enum_fields;
 
-#line 87 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.hpp" // glr.cc:329
+#line 218 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.hpp"
+
     };
 #else
     typedef YYSTYPE semantic_type;
@@ -94,7 +226,18 @@ namespace yy {
     /// Syntax errors thrown from user actions.
     struct syntax_error : std::runtime_error
     {
-      syntax_error (const location_type& l, const std::string& m);
+      syntax_error (const location_type& l, const std::string& m)
+        : std::runtime_error (m)
+        , location (l)
+      {}
+
+      syntax_error (const syntax_error& s)
+        : std::runtime_error (s.what ())
+        , location (s.location)
+      {}
+
+      ~syntax_error () YY_NOEXCEPT YY_NOTHROW;
+
       location_type location;
     };
 
@@ -157,105 +300,22 @@ namespace yy {
     enum { empty_symbol = -2 };
 
     /// Internal symbol number for tokens (subsumed by symbol_number_type).
-    typedef unsigned char token_number_type;
-
-    /// A complete symbol.
-    ///
-    /// Expects its Base type to provide access to the symbol type
-    /// via type_get().
-    ///
-    /// Provide access to semantic value and location.
-    template <typename Base>
-    struct basic_symbol : Base
-    {
-      /// Alias to Base.
-      typedef Base super_type;
-
-      /// Default constructor.
-      basic_symbol ();
-
-      /// Copy constructor.
-      basic_symbol (const basic_symbol& other);
-
-      /// Constructor for valueless symbols.
-      basic_symbol (typename Base::kind_type t,
-                    const location_type& l);
-
-      /// Constructor for symbols with semantic value.
-      basic_symbol (typename Base::kind_type t,
-                    const semantic_type& v,
-                    const location_type& l);
-
-      /// Destroy the symbol.
-      ~basic_symbol ();
-
-      /// Destroy contents, and record that is empty.
-      void clear ();
-
-      /// Whether empty.
-      bool empty () const;
-
-      /// Destructive move, \a s is emptied into this.
-      void move (basic_symbol& s);
-
-      /// The semantic value.
-      semantic_type value;
-
-      /// The location.
-      location_type location;
-
-    private:
-      /// Assignment operator.
-      basic_symbol& operator= (const basic_symbol& other);
-    };
-
-    /// Type access provider for token (enum) based symbols.
-    struct by_type
-    {
-      /// Default constructor.
-      by_type ();
-
-      /// Copy constructor.
-      by_type (const by_type& other);
-
-      /// The symbol type as needed by the constructor.
-      typedef token_type kind_type;
-
-      /// Constructor from (external) token numbers.
-      by_type (kind_type t);
-
-      /// Record that this symbol is empty.
-      void clear ();
-
-      /// Steal the symbol type from \a that.
-      void move (by_type& that);
-
-      /// The (internal) type number (corresponding to \a type).
-      /// \a empty when empty.
-      symbol_number_type type_get () const;
-
-      /// The token.
-      token_type token () const;
-
-      /// The symbol type.
-      /// \a empty_symbol when empty.
-      /// An int, not token_number_type, to be able to store empty_symbol.
-      int type;
-    };
-
-    /// "External" symbols: returned by the scanner.
-    typedef basic_symbol<by_type> symbol_type;
-
+    typedef signed char token_number_type;
 
 
     /// Build a parser object.
     parser (tidl::Parser* ps_yyarg);
     virtual ~parser ();
 
+    /// Parse.  An alias for parse ().
+    /// \returns  0 iff parsing succeeded.
+    int operator() ();
+
     /// Parse.
     /// \returns  0 iff parsing succeeded.
     virtual int parse ();
 
+#if YYDEBUG
     /// The current debugging stream.
     std::ostream& debug_stream () const;
     /// Set the current debugging stream.
@@ -267,8 +327,8 @@ namespace yy {
     debug_level_type debug_level () const;
     /// Set the current debugging level.
     void set_debug_level (debug_level_type l);
+#endif
 
-  public:
     /// Report a syntax error.
     /// \param loc    where the syntax error is found.
     /// \param msg    a description of the syntax error.
@@ -309,9 +369,9 @@ namespace yy {
 # define YYLTYPE yy::parser::location_type
 #endif
 
-
 } // yy
-#line 315 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.hpp" // glr.cc:329
+#line 374 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.hpp"
+
 
 
 #endif // !YY_YY_OPT_DATA_TIZEN_PUBLIC_PLATFORM_CORE_APPFW_TIDL_IDLC_AST_TIDLC_Y_HPP_INCLUDED
index 788008a..7c61c36 100644 (file)
@@ -38,8 +38,9 @@ BaseType::BaseType(std::string name, std::string comments, UserType user_type)
       user_type_(user_type) {}
 
 BaseType::BaseType(const BaseType& type)
-  : Token(type.ToString(), type.GetComments()),
-    user_defined_(type.IsUserDefinedType()), user_type_(type.GetUserDefinedType()) {
+    : Token(type.ToString(), type.GetComments()),
+      user_defined_(type.IsUserDefinedType()),
+      user_type_(type.GetUserDefinedType()) {
   if (type.GetMetaType() != nullptr)
     SetMetaType(new BaseType(*type.GetMetaType()));
 
@@ -50,6 +51,49 @@ BaseType::BaseType(const BaseType& type)
     SetValueType(new BaseType(*type.GetValueType()));
 }
 
+BaseType& BaseType::operator = (const BaseType& type) {
+  if (this != &type) {
+    name_ = type.name_;
+    comments_ = type.comments_;
+    user_defined_ = type.user_defined_;
+    user_type_ = type.user_type_;
+    if (type.GetMetaType() != nullptr)
+      SetMetaType(new BaseType(*type.GetMetaType()));
+
+    if (type.GetKeyType() != nullptr)
+      SetKeyType(new BaseType(*type.GetKeyType()));
+
+    if (type.GetValueType() != nullptr)
+      SetValueType(new BaseType(*type.GetValueType()));
+  }
+
+  return *this;
+}
+
+BaseType::BaseType(BaseType&& type) noexcept {
+  name_ = std::move(type.name_);
+  comments_ = std::move(type.comments_);
+  user_defined_ = type.user_defined_;
+  user_type_ = type.user_type_;
+  meta_type_ = std::move(type.meta_type_);
+  key_type_ = std::move(type.key_type_);
+  value_type_ = std::move(type.value_type_);
+}
+
+BaseType& BaseType::operator = (BaseType&& type) noexcept {
+  if (this != &type) {
+    name_ = std::move(type.name_);
+    comments_ = std::move(type.comments_);
+    user_defined_ = type.user_defined_;
+    user_type_ = type.user_type_;
+    meta_type_ = std::move(type.meta_type_);
+    key_type_ = std::move(type.key_type_);
+    value_type_ = std::move(type.value_type_);
+  }
+
+  return *this;
+}
+
 void BaseType::SetMetaType(BaseType* type) {
   meta_type_.reset(type);
 }
@@ -100,6 +144,26 @@ bool BaseType::IsUserDefinedType() const {
   return user_defined_;
 }
 
+bool BaseType::IsFile(const BaseType* type) {
+  if (type == nullptr)
+    return false;
+
+  if (type->GetMetaType() != nullptr)
+    return IsFile(type->GetMetaType());
+
+  if (type->GetKeyType() != nullptr) {
+    if (IsFile(type->GetKeyType()))
+      return true;
+  }
+
+  if (type->GetValueType() != nullptr) {
+    if (IsFile(type->GetValueType()))
+      return true;
+  }
+
+  return type->ToString() == "file";
+}
+
 ParameterType::ParameterType(BaseType* type)
     : type_(type),
     dir_(Direction::IN) {
index 64c7a1f..fce01f2 100644 (file)
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef IDLC_TYPE_H_
-#define IDLC_TYPE_H_
+#ifndef IDLC_AST_TYPE_H_
+#define IDLC_AST_TYPE_H_
 
 #include <string>
 #include <memory>
@@ -24,13 +24,14 @@ namespace tidl {
 
 class Token {
  public:
+  Token() = default;
   Token(std::string name, std::string comments);
   virtual ~Token() = default;
 
   virtual std::string ToString() const { return name_; }
   virtual std::string GetComments() const { return comments_; }
 
- private:
+ protected:
   std::string name_;
   std::string comments_;
 };
@@ -43,11 +44,19 @@ class BaseType : public Token {
     DELEGATE,
     ENUM,
   };
+
+  BaseType() = default;
+  virtual ~BaseType() = default;
+
   BaseType(std::string name, std::string comments,
                     bool user_defined = false);
   BaseType(std::string name, std::string comments,
                     UserType user_type);
   BaseType(const BaseType& type);
+  BaseType& operator = (const BaseType& type);
+
+  BaseType(BaseType&& type) noexcept;
+  BaseType& operator = (BaseType&& type) noexcept;
 
   void SetMetaType(BaseType* type);
   const BaseType* GetMetaType() const;
@@ -65,12 +74,14 @@ class BaseType : public Token {
     return user_type_;
   }
 
+  static bool IsFile(const BaseType* type);
+
  private:
   std::unique_ptr<BaseType> meta_type_;
   std::unique_ptr<BaseType> key_type_;
   std::unique_ptr<BaseType> value_type_;
-  bool user_defined_;
-  UserType user_type_;
+  bool user_defined_ = false;
+  UserType user_type_ = UserType::DEFAULT;
 };
 
 class ParameterType {
@@ -96,4 +107,4 @@ class ParameterType {
 
 }  // namespace tidl
 
-#endif  // IDLC_TYPE_H_
+#endif  // IDLC_AST_TYPE_H_
index 896dbfc..d965ba9 100644 (file)
@@ -111,4 +111,17 @@ bool Generator::IsDelegateType(const Interface& inf,
   return false;
 }
 
+std::string Generator::GetInterfaceNameFromDelegate(const BaseType& type) {
+  for (auto& i : GetDocument().GetBlocks()) {
+    if (i->GetType() != Block::TYPE_INTERFACE)
+      continue;
+
+    auto& iface = static_cast<const Interface&>(*i);
+    if (IsDelegateType(iface, type))
+      return iface.GetID();
+  }
+
+  return {};
+}
+
 }  // namespace tidl
index e6ab5ec..9355de3 100644 (file)
@@ -46,6 +46,7 @@ class Generator {
   std::string GetFileNamespace() const;
   bool IsDelegateType(const Interface& inf, const BaseType& type);
   bool IsDelegateType(const BaseType& type);
+  std::string GetInterfaceNameFromDelegate(const BaseType& type);
 
   void EnableNamespace(bool enable) {
     hasNamespace_ = enable;
index 7561f03..b1f3a12 100644 (file)
@@ -79,6 +79,15 @@ ReplaceAll& ReplaceAll::ChangeToUpper(const std::string& from,
   });
 }
 
+ReplaceAll& ReplaceAll::ChangeToLower(const std::string& from,
+    const std::string& to) {
+  return Change(from, [to]() {
+    std::string t = to;
+    std::transform(t.begin(), t.end(), t.begin(), ::tolower);
+    return t;
+  });
+}
+
 ReplaceAll& ReplaceAll::Once(const std::string& from,
     const std::string& to) {
   std::size_t pos = 0;
index 5199cda..ce0fc05 100755 (executable)
@@ -87,6 +87,7 @@ class ReplaceAll {
   }
 
   ReplaceAll& ChangeToUpper(const std::string& from, const std::string& to);
+  ReplaceAll& ChangeToLower(const std::string& from, const std::string& to);
   ReplaceAll& Once(const std::string& from, const std::string& to);
 
   template <class T>
index 8c53c31..0869bb2 100644 (file)
@@ -123,7 +123,7 @@ void CBodyGeneratorBase::GenStructureDefinition(std::ofstream& stream) {
     }
   }
 
-  for (auto& i: GetStructures()) {
+  for (auto& i : GetStructures()) {
     auto& st = *i.second;
     if (st.GetID().compare(0, strlen("array"), "array") == 0)
       GenStructureArrayBaseDefinition(stream, st);
@@ -192,7 +192,8 @@ void CBodyGeneratorBase::GenStructureSetBaseDefinition(std::ofstream& stream,
       .Out(stream);
 }
 
-std::string CBodyGeneratorBase::GenBaseElements(const Elements& elms, const std::string& id) {
+std::string CBodyGeneratorBase::GenBaseElements(const Elements& elms,
+    const std::string& id) {
   std::string code;
   for (const auto& elm : elms) {
     auto& type = elm->GetType();
@@ -226,7 +227,7 @@ void CBodyGeneratorBase::GenStructure(std::ofstream& stream) {
     }
   }
 
-  for (auto& i: GetStructures()) {
+  for (auto& i : GetStructures()) {
     auto& st = *i.second;
     if (st.GetID().compare(0, strlen("array"), "array") == 0)
       GenStructureArrayBase(stream, st);
@@ -339,7 +340,7 @@ std::string CBodyGeneratorBase::GenListDataFree(
   auto& type = elm->GetType();
   if (type.GetUserDefinedType() == BaseType::UserType::ENUM) {
     code = CB_STRUCTURE_LIST_BASE_FREE;
-  } else  if (type.IsUserDefinedType() || type.GetMetaType() != nullptr ||
+  } else if (type.IsUserDefinedType() || type.GetMetaType() != nullptr ||
       type.GetKeyType() != nullptr) {
     code = ReplaceAll(CB_STRUCTURE_LIST_USER_DEFINED_FREE)
         .Change("<PREFIX>", GetHandlePrefix())
@@ -416,7 +417,7 @@ std::string CBodyGeneratorBase::GenListAdd(
             RemoveLastSpaces(
               GetParamTypeString(ParameterType::Direction::IN, type,
                   GetEnumBockString(type.ToString()))));
-  } else  if (type.IsUserDefinedType() || type.GetMetaType() != nullptr ||
+  } else if (type.IsUserDefinedType() || type.GetMetaType() != nullptr ||
       type.GetKeyType() != nullptr) {
     code = ReplaceAll(CB_STRUCTURE_LIST_USER_DEFINED_ADD)
         .Change("<PREFIX>", GetHandlePrefix())
diff --git a/idlc/gen/version2/cpp_generator_base.cc b/idlc/gen/version2/cpp_generator_base.cc
new file mode 100644 (file)
index 0000000..ca41e7a
--- /dev/null
@@ -0,0 +1,708 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "idlc/gen/version2/cpp_generator_base.hh"
+
+#include <sstream>
+#include <utility>
+
+#include "idlc/gen/version2/cpp_generator_base_cb.hh"
+
+namespace tidl {
+namespace version2 {
+namespace {
+
+bool IsObject(const BaseType& type) {
+  if (type.IsUserDefinedType() ||
+      type.GetMetaType() != nullptr ||
+      type.ToString() == "string" ||
+      type.ToString() == "bundle" ||
+      type.ToString() == "file")
+    return true;
+
+  return false;
+}
+
+}  // namespace
+
+CppGeneratorBase::CppGeneratorBase(std::shared_ptr<Document> doc,
+    bool thread_enabled)
+    : Generator(std::move(doc)),
+      thread_enabled_(thread_enabled) {
+  type_map_ = {
+    {"char", "char"},
+    {"int", "int"},
+    {"short", "short"},
+    {"long", "long long"},
+    {"string", "std::string"},
+    {"bool", "bool"},
+    {"list", "std::list"},
+    {"float", "float"},
+    {"double", "double"},
+    {"file", "File"},
+    {"bundle", "Bundle"},
+    {"void", "void"},
+    {"array", "std::vector"}
+  };
+
+  parcel_type_map_ = {
+    {"char", "byte"},
+    {"int", "int32"},
+    {"short", "int16"},
+    {"long", "int64"},
+    {"string", "string"},
+    {"bool", "bool"},
+    {"float", "float"},
+    {"double", "double"},
+    {"bundle", "bundle"},
+    {"file", "string"},
+  };
+
+  type_init_map_ = {
+    {"char", "0"},
+    {"int", "0"},
+    {"short", "0"},
+    {"long", "0"},
+    {"bool", "false"},
+    {"float", "0.0f"},
+    {"double", "0.0"},
+  };
+}
+
+void CppGeneratorBase::GenVersion(std::ofstream& stream) {
+  ReplaceAll(CB_VERSION)
+      .Change("<VERSION>", std::string(FULLVER))
+      .Transform([&](std::string code) { return RemoveLine(std::move(code)); })
+      .Out(stream);
+}
+
+void CppGeneratorBase::GenIncludeDefaultHeaders(std::ofstream& stream,
+    bool is_body) {
+  if (is_body)
+    stream << CB_BODY_HEADER;
+  else
+    stream << CB_HEADER;
+}
+
+void CppGeneratorBase::GenLogTag(std::ofstream& stream,
+    const std::string& log_tag) {
+  ReplaceAll(CB_LOG_TAG)
+      .Change("<LOG_TAG>", log_tag)
+      .Out(stream);
+}
+
+void CppGeneratorBase::GenLogDefinition(std::ofstream& stream) {
+  stream << CB_LOG_DEF;
+}
+
+void CppGeneratorBase::GenVersionDefinition(std::ofstream& stream) {
+  ReplaceAll(CB_TIDL_VERSION)
+      .Change("<VERSION>", std::string(FULLVER))
+      .Out(stream);
+  stream << NLine(1);
+}
+
+std::string CppGeneratorBase::GenExceptions() {
+  std::string code = CB_HEADER_UNIT_MAP_DEF;
+  code += std::string(CB_EXCEPTIONS);
+  return RemoveLine(code);
+}
+
+std::string CppGeneratorBase::GenParameters(const Elements& elms) {
+  bool first = true;
+  std::string code;
+  for (const auto& elm : elms) {
+    if (!first)
+      code += ", ";
+
+    code += ConvertTypeToString(elm->GetType()) + " " + elm->GetID();
+    first = false;
+  }
+
+  return code;
+}
+
+std::string CppGeneratorBase::GenMethodIds(const Interface& iface) {
+  int value = 2;
+  std::string code;
+  for (const auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() == Declaration::MethodType::DELEGATE)
+      continue;
+
+    code += ReplaceAll(CB_ENUM)
+        .Change("<NAME>", decl->GetID())
+        .Change("<VALUE>", std::to_string(value++));
+    code += NLine(1);
+  }
+
+  if (code.empty())
+    return code;
+
+  return RemoveLine(
+      std::string(ReplaceAll(CB_METHOD_IDS).Change("<IDS>", code)));
+}
+
+std::string CppGeneratorBase::GenDelegateIds(const Interface& iface) {
+  int value = 1;
+  std::string code;
+  for (const auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() != Declaration::MethodType::DELEGATE)
+      continue;
+
+    code += ReplaceAll(CB_ENUM)
+        .Change("<NAME>", decl->GetID())
+        .Change("<VALUE>", std::to_string(value++));
+    code += NLine(1);
+  }
+
+  if (code.empty())
+    return code;
+
+  return RemoveLine(
+      std::string(ReplaceAll(CB_DELEGATE_IDS).Change("<IDS>", code)));
+}
+
+std::string CppGeneratorBase::RemoveLine(std::string lines,
+    unsigned int line_num) {
+  std::stringstream ss(lines);
+  std::string result;
+  std::string line;
+  unsigned int line_count = 0;
+
+  while (std::getline(ss, line, '\n')) {
+    line_count++;
+    if (line_num == line_count)
+      continue;
+
+    result += Trim(line);
+    result += NLine(1);
+  }
+
+  return result;
+}
+
+std::string CppGeneratorBase::RemoveLastLine(std::string lines,
+    unsigned int line_num) {
+  std::stringstream ss(lines);
+  std::vector<std::string> tmp_lines;
+  std::string line;
+
+  while (std::getline(ss, line, '\n')) {
+    line = Trim(line);
+    line += NLine(1);
+    tmp_lines.push_back(line);
+  }
+
+  std::string result;
+  for (unsigned int i = 0; i < (tmp_lines.size() - line_num); ++i)
+    result += tmp_lines[i] + NLine(1);
+
+  return result;
+}
+
+std::string CppGeneratorBase::Tab(int cnt) {
+  return std::string(cnt * 2, ' ');
+}
+
+std::string CppGeneratorBase::NLine(int cnt) {
+  return std::string(cnt, '\n');
+}
+
+std::string CppGeneratorBase::ConvertTypeToString(const BaseType& type,
+    bool full_name) {
+  if (type.IsUserDefinedType()) {
+    if (IsDelegateType(type)) {
+      std::string name = type.ToString();
+      if (full_name)
+        name = GetInterfaceNameFromDelegate(type) + "::" + name;
+
+      return "std::unique_ptr<" + name + ">";
+    }
+
+    return type.ToString();
+  }
+
+  if (type.GetMetaType() != nullptr) {
+    return type_map_[type.ToString()] + "<" +
+        ConvertTypeToString(*(type.GetMetaType())) + ">";
+  }
+
+  return type_map_[type.ToString()];
+}
+
+std::string CppGeneratorBase::GetReturnType(const BaseType& type) {
+  if (IsObject(type))
+    return "const " + ConvertTypeToString(type) + "&";
+
+  return ConvertTypeToString(type);
+}
+
+std::string CppGeneratorBase::GetParameterType(const BaseType& type) {
+  return ConvertTypeToString(type);
+}
+
+std::string CppGeneratorBase::GetParameters(const Parameters& params) {
+  std::string code;
+  for (const auto& param : params) {
+    if (!code.empty())
+      code += ", ";
+
+    std::string ref;
+    auto direction = param->GetParameterType().GetDirection();
+    if (direction == ParameterType::Direction::OUT ||
+        direction == ParameterType::Direction::REF)
+      ref = "&";
+
+    code += ConvertTypeToString(param->GetParameterType().GetBaseType()) +
+        ref + " " + param->GetID();
+  }
+
+  return code;
+}
+
+std::string CppGeneratorBase::GenStructuresForHeader() {
+  std::string code(CB_HEADER_BUNDLE);
+  code += NLine(1);
+  code += CB_HEADER_FILE;
+  code += NLine(1);
+  for (auto& block : GetDocument().GetBlocks()) {
+    if (block->GetType() != Block::TYPE_STRUCTURE)
+      continue;
+
+    auto& st = static_cast<Structure&>(*block);
+    code += GenStructureForHeader(st) + NLine(1);
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppGeneratorBase::GenStructureForHeader(const Structure& st) {
+  return std::string(
+      ReplaceAll(CB_HEADER_STRUCTURE_BASE)
+          .Change("<CLS_NAME>", st.GetID())
+          .Change("<PARAMS>", GenParameters(st.GetElements()))
+          .Change("<GETTER_SETTER>",
+              GenStructureGetterSetterForHeader(st.GetElements()))
+          .Change("<MEMBERS>", GenStructureMembersForHeader(st.GetElements())));
+}
+
+std::string CppGeneratorBase::GenStructureGetterSetterForHeader(
+    const Elements& elms) {
+  std::string code;
+  for (auto& elm : elms) {
+    code += Tab(1);
+    code += ReplaceAll(CB_HEADER_STRUCTURE_GETTER_SETTER)
+                .Change("<RETURN_TYPE>", GetReturnType(elm->GetType()))
+                .Change("<NAME>", elm->GetID())
+                .Change("<PARAM_TYPE>", GetParameterType(elm->GetType()))
+                .Change("<PARAM_NAME>", elm->GetID());
+  }
+
+  return code;
+}
+
+std::string CppGeneratorBase::GenStructureMembersForHeader(
+    const Elements& elms) {
+  std::string code;
+  for (auto& elm : elms) {
+    code += Tab(1);
+    code += ReplaceAll(CB_HEADER_STRUCTURE_MEMBER)
+                .Change("<TYPE>", ConvertTypeToString(elm->GetType()))
+                .Change("<NAME>", elm->GetID());
+    code += NLine(1);
+  }
+
+  return code;
+}
+
+std::string CppGeneratorBase::SmartIndent(const std::string& str) {
+  unsigned int inside_class = 0;
+  std::string indentation;
+  std::string code;
+  std::istringstream iss(str);
+  std::string line;
+  std::string previous_line;
+  bool is_access_modifier = false;
+  bool control_flow_statement_with_single_line = false;
+
+  while (std::getline(iss, line)) {
+    std::string trimmed_line = Trim(line);
+    if (trimmed_line.empty()) {
+      if (previous_line.empty() ||
+          (previous_line.find(',') != std::string::npos &&
+           previous_line.back() == ','))
+        continue;
+
+      code += trimmed_line + NLine(1);
+      previous_line = std::move(trimmed_line);
+      continue;
+    }
+
+    if (trimmed_line.find("class") != std::string::npos)
+      inside_class++;
+
+    if (previous_line.find("if (") != std::string::npos ||
+        previous_line.find("for (") != std::string::npos ||
+        previous_line.find("while (") != std::string::npos ||
+        previous_line.find("else") != std::string::npos) {
+      if (previous_line.find('{') == std::string::npos &&
+          previous_line.back() != ';')
+        control_flow_statement_with_single_line = true;
+    }
+
+    if (trimmed_line.find('{') != std::string::npos) {
+      control_flow_statement_with_single_line = false;
+      code += indentation + trimmed_line + NLine(1);
+      if (trimmed_line.find("namespace ") == std::string::npos &&
+          trimmed_line.find('}') == std::string::npos)
+        indentation += Tab(1);
+
+      previous_line = std::move(trimmed_line);
+      continue;
+    }
+
+    if (control_flow_statement_with_single_line)
+      indentation += Tab(1);
+
+    if (trimmed_line.find('}') != std::string::npos)
+      indentation = indentation.substr(0, indentation.length() - 2);
+
+    if (trimmed_line.find("};") != std::string::npos)
+      inside_class--;
+
+    if (inside_class != 0 &&
+        (trimmed_line.find("public:") != std::string::npos ||
+         trimmed_line.find("private:") != std::string::npos ||
+         trimmed_line.find("protected:") != std::string::npos))
+      is_access_modifier = true;
+
+    code += (is_access_modifier ?
+        indentation.substr(0, indentation.length() - 1) : indentation) +
+        trimmed_line + NLine(1);
+    is_access_modifier  = false;
+    if (control_flow_statement_with_single_line) {
+      indentation = indentation.substr(0, indentation.length() - 2);
+      control_flow_statement_with_single_line = false;
+    }
+
+    previous_line = std::move(trimmed_line);
+  }
+
+  return code;
+}
+
+std::string CppGeneratorBase::Trim(std::string str) {
+  if (str.compare(0, 3, "/**") == 0 || str.compare(0, 2, " *") == 0 ||
+      str.compare(0, 3, " */") == 0 || str.compare(0, 3, "///") == 0)
+    return str;
+
+  auto first = str.find_first_not_of(" \t\r\n");
+  if (first == std::string::npos)
+    return "";
+
+  auto last = str.find_last_not_of(" \t\r\n");
+  return str.substr(first, (last - first + 1));
+}
+
+std::string CppGeneratorBase::GenStructures() {
+  std::string code(CB_BODY_BUNDLE);
+  code += CB_BODY_FILE;
+  for (auto& block : GetDocument().GetBlocks()) {
+    if (block->GetType() == Block::Type::TYPE_STRUCTURE) {
+      auto& st = static_cast<const Structure&>(*block);
+      code += GenStructure(st);
+    }
+  }
+
+  return code;
+}
+
+std::string CppGeneratorBase::GenStructure(const Structure& st) {
+  return std::string(
+      ReplaceAll(CB_BODY_STRUCTURE_BASE)
+          .Change("<CLS_NAME>", st.GetID())
+          .Change("<PARAMS>", GenParameters(st.GetElements()))
+          .Change("<MEMBER_INIT>", GenStructureMemberInit(st.GetElements()))
+          .Change("<GETTER_SETTER>", GenStructureGetterSetter(st)));
+}
+
+std::string CppGeneratorBase::GenStructureMemberInit(const Elements& elms) {
+  std::string code;
+  for (auto& elm : elms) {
+    if (!code.empty())
+      code += ", ";
+
+    code += ReplaceAll(CB_BODY_STRUCTURE_MEMBER_INIT)
+        .Change("<NAME>", elm->GetID())
+        .Change("<VALUE>", GetSetterValue(elm->GetType(), elm->GetID()));
+  }
+
+  return code;
+}
+
+std::string CppGeneratorBase::GenStructureGetterSetter(const Structure& st) {
+  std::string code;
+  for (auto& elm : st.GetElements()) {
+    code += ReplaceAll(CB_BODY_STRUCTURE_GETTER_SETTER)
+        .Change("<RETURN_TYPE>", GetReturnType(elm->GetType()))
+        .Change("<CLS_NAME>", st.GetID())
+        .Change("<NAME>", elm->GetID())
+        .Change("<PARAM_TYPE>", GetParameterType(elm->GetType()))
+        .Change("<PARAM_NAME>", elm->GetID())
+        .Change("<VALUE>", GetSetterValue(elm->GetType(), elm->GetID()));
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppGeneratorBase::GetSetterValue(const BaseType& type,
+    const std::string& value) {
+  return IsObject(type) ? "std::move(" + value + ")" : value;
+}
+
+void CppGeneratorBase::InitUnitTypes() {
+  AddUnitType("int", BaseType("int", ""));
+  AddUnitType("bool", BaseType("bool", ""));
+  AddUnitType("string", BaseType("string", ""));
+  AddUnitType("bundle", BaseType("bundle", ""));
+  AddUnitType("file", BaseType("file", ""));
+
+  for (auto& block : GetDocument().GetBlocks()) {
+    if (block->GetType() == Block::TYPE_INTERFACE) {
+      auto& iface = static_cast<const Interface&>(*block);
+      for (const auto& decl : iface.GetDeclarations()) {
+        if (decl->GetMethodType() == Declaration::MethodType::DELEGATE) {
+          AddUnitType("delegate",
+              BaseType(iface.GetID() + "::CallbackBase", "", true));
+          AddUnitType(decl->GetID(), BaseType(decl->GetID(), "", true));
+        }
+
+        for (const auto& param : decl->GetParameters()) {
+          auto& type = param->GetParameterType().GetBaseType();
+          AddUnitType(type.GetFullName(false), BaseType(type));
+        }
+      }
+    } else if (block->GetType() == Block::TYPE_STRUCTURE) {
+      auto& st = static_cast<const Structure&>(*block);
+      AddUnitType(st.GetID(), BaseType(st.GetID(), "", true));
+      for (const auto& elm : st.GetElements()) {
+        auto& type = elm->GetType();
+        AddUnitType(type.GetFullName(false), BaseType(type));
+      }
+    }
+  }
+}
+
+void CppGeneratorBase::AddUnitType(std::string name, BaseType type) {
+  if (type.GetMetaType() != nullptr) {
+    auto meta_type = type.GetMetaType();
+    AddUnitType(meta_type->GetFullName(false), BaseType(*meta_type));
+  }
+
+  unit_types_[std::move(name)] = std::move(type);
+}
+
+std::string CppGeneratorBase::GenUnitMap() {
+  InitUnitTypes();
+  std::string code = GenUnit();
+  code += ReplaceAll(CB_UNIT_MAP)
+      .Change("<UNIT_MAP_READ_WRITE>", GenUnitMapReadWrite());
+  code += GenUnitSerializerBodies();
+  return code;
+}
+
+std::string CppGeneratorBase::GetFullNameFromType(const BaseType& type) {
+  if (IsDelegateType(type) ||
+      type.ToString().find("::CallbackBase") != std::string::npos)
+    return "delegate";
+
+  return type.GetFullName(true);
+}
+
+std::string CppGeneratorBase::GenUnitMapReadWrite() {
+  std::string code;
+  for (auto& iter : unit_types_) {
+    auto& param_type = iter.second;
+    code += ReplaceAll(CB_UNIT_MAP_READ_WRITE)
+        .Change("<TYPE>", GetFullNameFromType(param_type))
+        .Change("<PARAM_TYPE>", ConvertTypeToString(param_type, true));
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppGeneratorBase::GenUnit() {
+  return std::string(
+      ReplaceAll(CB_UNIT)
+          .Change("<SERIALIZER>", GenUnitSerializerHeaders()));
+}
+
+std::string CppGeneratorBase::GenUnitSerializerHeaders() {
+  std::string code;
+  for (auto& iter : unit_types_) {
+    auto& type = iter.second;
+    code += ReplaceAll(CB_UNIT_SERIALIZER_HEADER)
+        .Change("<TYPE>", ConvertTypeToString(type, true));
+  }
+
+  return code;
+}
+
+std::string CppGeneratorBase::GenUnitSerializerBodies() {
+  std::string code;
+  for (auto& iter : unit_types_) {
+    auto& type = iter.second;
+    code += ReplaceAll(CB_UNIT_SERIALIZER_BODY)
+        .Change("<TYPE>", ConvertTypeToString(type, true))
+        .Change("<IMPL_SERIALIZER>\n", GenUnitImplSerializer(type))
+        .Change("<IMPL_DESERIALIZER>\n", GenUnitImplDeserializer(type));
+  }
+
+  return code;
+}
+
+std::string CppGeneratorBase::GenUnitImplSerializer(const BaseType& type) {
+  std::string code;
+  if (type.IsUserDefinedType() || type.GetMetaType() != nullptr) {
+    if (IsDelegateType(type)) {
+      code = CB_UNIT_IMPL_SERIALIZER_DELEGATE;
+    } else {
+      code = ReplaceAll(CB_UNIT_IMPL_SERIALIZER_USER_DEFINED)
+          .Change("<UNIT_MAP_WRITE>", GenUnitMapWrite(type));
+    }
+  } else if (type.ToString() == "string") {
+    code = CB_UNIT_IMPL_SERIALIZER_STRING;
+  } else if (type.ToString() == "bundle") {
+    code = CB_UNIT_IMPL_SERIALIZER_BUNDLE;
+  } else if (type.ToString() == "file") {
+    code = CB_UNIT_IMPL_SERIALIZER_FILE;
+  } else {
+    code = ReplaceAll(CB_UNIT_IMPL_SERIALIZER_BASE)
+        .Change("<PARCEL_TYPE>", GetParcelType(type));
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppGeneratorBase::GenUnitMapWrite(const BaseType& type) {
+  std::string code;
+  if (type.ToString().find("::CallbackBase") != std::string::npos) {
+    code = CB_UNIT_MAP_CALLBACKBASE_WRITE;
+  } else if (type.ToString() == "array") {
+    code = CB_UNIT_MAP_ARRAY_WRITE;
+  } else if (type.ToString() == "list") {
+    code = CB_UNIT_MAP_LIST_WRITE;
+  } else {
+    for (auto& block : GetDocument().GetBlocks()) {
+      if (block->GetType() == Block::TYPE_STRUCTURE) {
+         auto& st = static_cast<const Structure&>(*block);
+         if (st.GetID() == type.ToString()) {
+          for (auto& elm : st.GetElements()) {
+            code += ReplaceAll(CB_UNIT_MAP_BASE_WRITE)
+              .Change("<NAME>", elm->GetID());
+          }
+         }
+      }
+    }
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppGeneratorBase::GenUnitImplDeserializer(const BaseType& type) {
+  std::string code;
+  if (type.IsUserDefinedType() || type.GetMetaType() != nullptr) {
+    if (IsDelegateType(type)) {
+      code = ReplaceAll(CB_UNIT_IMPL_DESERIALIZER_DELEGATE)
+          .Change("<IFACE_NAME>", GetInterfaceNameFromDelegate(type));
+    } else {
+      code = ReplaceAll(CB_UNIT_IMPL_DESERIALIZER_USER_DEFINED)
+          .Change("<UNIT_MAP_READ>\n", GenUnitMapRead(type));
+    }
+  } else if (type.ToString() == "string") {
+    code = CB_UNIT_IMPL_DESERIALIZER_STRING;
+  } else if (type.ToString() == "bundle") {
+    code = CB_UNIT_IMPL_DESERIALIZER_BUNDLE;
+  } else if (type.ToString() == "file") {
+    code = CB_UNIT_IMPL_DESERIALIZER_FILE;
+  } else {
+    code = ReplaceAll(CB_UNIT_IMPL_DESERIALIZER_BASE)
+        .Change("<TYPE>", ConvertTypeToString(type))
+        .Change("<PARCEL_TYPE>", GetParcelType(type));
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppGeneratorBase::GenUnitMapRead(const BaseType& type) {
+  std::string code;
+  if (type.ToString().find("::CallbackBase") != std::string::npos) {
+    code = CB_UNIT_MAP_CALLBACKBASE_READ;
+  } else if (type.ToString() == "array") {
+    code = ReplaceAll(CB_UNIT_MAP_ARRAY_READ)
+        .Change("<TYPE>", ConvertTypeToString(*type.GetMetaType()));
+  } else if (type.ToString() == "list") {
+    code = ReplaceAll(CB_UNIT_MAP_LIST_READ)
+        .Change("<TYPE>", ConvertTypeToString(*type.GetMetaType()));
+  } else {
+    for (auto& block : GetDocument().GetBlocks()) {
+      if (block->GetType() == Block::TYPE_STRUCTURE) {
+        auto& st = static_cast<const Structure&>(*block);
+        if (st.GetID() == type.ToString()) {
+          for (auto& elm : st.GetElements()) {
+            code += ReplaceAll(CB_UNIT_MAP_BASE_READ)
+                        .Change("<TYPE>", ConvertTypeToString(elm->GetType()))
+                        .Change("<NAME>", elm->GetID());
+          }
+        }
+      }
+    }
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppGeneratorBase::GetParcelType(const BaseType& type) {
+  return parcel_type_map_[type.ToString()];
+}
+
+std::string CppGeneratorBase::GenPrivateSharing(const Parameter& param) {
+  std::string code;
+  auto& type = param.GetParameterType().GetBaseType();
+  if (BaseType::IsFile(&type)) {
+    if (type.GetMetaType() != nullptr) {
+      code = ReplaceAll(CB_PRIVATE_SHARING_ARRAY)
+          .Change("<NAME>", param.GetID());
+    } else {
+      code = ReplaceAll(CB_PRIVATE_SHARING)
+          .Change("<NAME>", param.GetID());
+    }
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppGeneratorBase::GetSettingInitValue(const BaseType& type) {
+  auto found = type_init_map_.find(type.ToString());
+  if (found == type_init_map_.end())
+    return {};
+
+  std::string code = " = " + found->second;
+  return code;
+}
+
+}  // namespace version2
+}  // namespace tidl
diff --git a/idlc/gen/version2/cpp_generator_base.hh b/idlc/gen/version2/cpp_generator_base.hh
new file mode 100644 (file)
index 0000000..93da3cd
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_VERSION2_CPP_GENERATOR_BASE_HH_
+#define IDLC_GEN_VERSION2_CPP_GENERATOR_BASE_HH_
+
+#include <memory>
+#include <string>
+#include <unordered_map>
+
+#include "idlc/ast/structure.h"
+#include "idlc/ast/type.h"
+#include "idlc/gen/generator.h"
+
+namespace tidl {
+namespace version2 {
+
+class CppGeneratorBase : public tidl::Generator {
+ public:
+  explicit CppGeneratorBase(std::shared_ptr<Document> doc,
+      bool thread_enabled = false);
+  virtual ~CppGeneratorBase() = default;
+
+  void GenVersion(std::ofstream& stream);
+  void GenIncludeDefaultHeaders(std::ofstream& stream, bool is_body = true);
+  void GenLogTag(std::ofstream& stream, const std::string& log_tag);
+  void GenLogDefinition(std::ofstream& stream);
+  void GenVersionDefinition(std::ofstream& stream);
+
+  std::string GenExceptions();
+  std::string GenStructuresForHeader();
+  std::string GenMethodIds(const Interface& iface);
+  std::string GenDelegateIds(const Interface& iface);
+  std::string GenParameters(const Elements& elms);
+  std::string RemoveLine(std::string lines, unsigned int line_num = 1);
+  std::string RemoveLastLine(std::string lines, unsigned int line_num = 1);
+  std::string Tab(int cnt);
+  std::string NLine(int cnt);
+  std::string Trim(std::string str);
+  std::string ConvertTypeToString(const BaseType& type, bool full_name = false);
+  std::string GetReturnType(const BaseType& type);
+  std::string GetParameterType(const BaseType& type);
+  std::string GetParameters(const Parameters& params);
+  std::string SmartIndent(const std::string& str);
+  std::string GenStructures();
+  std::string GetSetterValue(const BaseType& type, const std::string& value);
+  std::string GenUnitMap();
+  std::string GenPrivateSharing(const Parameter& param);
+  std::string GetSettingInitValue(const BaseType& type);
+
+ private:
+  std::string GenStructureForHeader(const Structure& st);
+  std::string GenStructureGetterSetterForHeader(const Elements& elms);
+  std::string GenStructureMembersForHeader(const Elements& elms);
+  std::string GenStructure(const Structure& st);
+  std::string GenStructureMemberInit(const Elements& elms);
+  std::string GenStructureGetterSetter(const Structure& st);
+  void InitUnitTypes();
+  void AddUnitType(std::string name, BaseType type);
+  std::string GenUnitMapReadWrite();
+  std::string GenUnit();
+  std::string GenUnitSerializerHeaders();
+  std::string GenUnitSerializerBodies();
+  std::string GenUnitImplSerializer(const BaseType& type);
+  std::string GenUnitMapWrite(const BaseType& type);
+  std::string GenUnitImplDeserializer(const BaseType& type);
+  std::string GenUnitMapRead(const BaseType& type);
+  std::string GetParcelType(const BaseType& type);
+  std::string GetFullNameFromType(const BaseType& type);
+
+ private:
+  bool thread_enabled_;
+  std::unordered_map<std::string, std::string> type_map_;
+  std::unordered_map<std::string, std::string> parcel_type_map_;
+  std::unordered_map<std::string, std::string> type_init_map_;
+  std::unordered_map<std::string, BaseType> unit_types_;
+};
+
+}  // namespace version2
+}  // namespace tidl
+
+#endif  // IDLC_GEN_VERSION2_CPP_GENERATOR_BASE_HH_
diff --git a/idlc/gen/version2/cpp_generator_base_cb.hh b/idlc/gen/version2/cpp_generator_base_cb.hh
new file mode 100644 (file)
index 0000000..acc1b90
--- /dev/null
@@ -0,0 +1,810 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_VERSION2_CPP_GENERATOR_BASE_CB_HH_
+#define IDLC_GEN_VERSION2_CPP_GENERATOR_BASE_CB_HH_
+
+namespace tidl {
+namespace version2 {
+
+/**
+ * <VERSION> The version of TIDL compiler.
+ */
+constexpr const char CB_VERSION[] =
+R"__cpp_cb(
+/**
+ * Generated by tidlc <VERSION>.
+ */
+)__cpp_cb";
+
+constexpr const char CB_BODY_HEADER[] =
+R"__cpp_cb(
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <libgen.h>
+#include <glib.h>
+#include <dlog.h>
+#include <rpc-port.h>
+#include <rpc-port-parcel.h>
+
+#include <memory>
+#include <string>
+#include <stdexcept>
+#include <utility>
+#include <unordered_map>
+)__cpp_cb";
+
+constexpr const char CB_HEADER[] =
+R"__cpp_cb(
+#pragma once
+
+#include <bundle.h>
+#include <rpc-port-parcel.h>
+#include <rpc-port.h>
+
+#include <atomic>
+#include <functional>
+#include <list>
+#include <memory>
+#include <mutex>
+#include <string>
+#include <vector>
+#include <unordered_map>
+)__cpp_cb";
+
+/**
+ * <LOG_TAG> The log tag of dlog.
+ */
+constexpr const char CB_LOG_TAG[] =
+R"__cpp_cb(
+#undef LOG_TAG
+#define LOG_TAG "<LOG_TAG>"
+)__cpp_cb";
+
+constexpr const char CB_LOG_DEF[] =
+R"__cpp_cb(
+#undef _E
+#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > " fmt, basename(const_cast<char*>(__FILE__)), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _W
+#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > " fmt, basename(const_cast<char*>(__FILE__)), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _I
+#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > " fmt, basename(const_cast<char*>(__FILE__)), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _D
+#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > " fmt, basename(const_cast<char*>(__FILE__)), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+)__cpp_cb";
+
+constexpr const char CB_TIDL_VERSION[] =
+R"__cpp_cb(
+#undef TIDL_VERSION
+#define TIDL_VERSION "<VERSION>"
+)__cpp_cb";
+
+constexpr const char CB_EXCEPTIONS[] =
+R"__cpp_cb(
+class Exception {};
+class NotConnectedSocketException : public Exception {};
+class InvalidProtocolException : public Exception {};
+class InvalidIOException : public Exception {};
+class PermissionDeniedException : public Exception {};
+class InvalidIDException : public Exception {};
+class InvalidArgumentException : public Exception {};
+class OutOfMemoryException : public Exception {};
+)__cpp_cb";
+
+/**
+ * <FILE_NAMESPACE> The namespace of the file.
+ * <STRUCTURES> The definition of structures.
+ * <EXCEPTIONS> The definition of exceptions.
+ * <INTERFACES> The definition of interfaces.
+ */
+constexpr const char CB_NAMESPACE_PROXY[] =
+R"__cpp_cb(
+namespace rpc_port {
+namespace <FILE_NAMESPACE> {
+
+<STRUCTURES>
+
+namespace proxy {
+
+<EXCEPTIONS>
+<INTERFACES>
+
+}  // namespace proxy
+}  // namespace <FILE_NAMESPACE>
+}  // namespace rpc_port
+)__cpp_cb";
+
+/**
+ * <FILE_NAMESPACE> The namespace of the file.
+ * <STRUCTURES> The definition of structures.
+ * <BASE_IMPL> The base implementation.
+ * <INTERFACES> The definition of interfaces.
+ */
+constexpr const char CB_NAMESPACE_STUB[] =
+R"__cpp_cb(
+namespace rpc_port {
+namespace <FILE_NAMESPACE> {
+
+<STRUCTURES>
+
+namespace stub {
+
+<BASE_IMPL>
+<INTERFACES>
+
+}  // namespace stub
+}  // namespace <FILE_NAMESPACE>
+}  // namespace rpc_port
+)__cpp_cb";
+
+constexpr const char CB_HEADER_BUNDLE[] =
+R"__cpp_cb(
+class Bundle final {
+ public:
+  Bundle();
+  explicit Bundle(bundle* handle, bool copy = true, bool own = true);
+  Bundle(std::string raw);
+  ~Bundle();
+
+  Bundle(const Bundle& b);
+  Bundle& operator = (const Bundle& b);
+  Bundle(Bundle&& b) noexcept;
+  Bundle& operator = (Bundle&&) noexcept;
+
+  bundle* GetHandle() const;
+  bundle* Detach();
+
+ private:
+  bundle* handle_;
+  bool own_ = true;
+};
+)__cpp_cb";
+
+constexpr const char CB_HEADER_FILE[] =
+R"__cpp_cb(
+class File final {
+ public:
+  File(std::string filename = "");
+
+  const std::string& GetFileName() const;
+  int Share(rpc_port_h port);
+
+ private:
+  std::string filename_;
+};
+)__cpp_cb";
+
+constexpr const char CB_HEADER_UNIT_MAP_DEF[] =
+R"__cpp_cb(
+class UnitMap;
+)__cpp_cb";
+
+/**
+ * <CLS_NAME> The class name of the structure.
+ * <PARAMS> The parameters of the structure.
+ * <GETTER_SETTER> The getters and setters.
+ * <MEMBERS> The member variables of the structure.
+ */
+constexpr const char CB_HEADER_STRUCTURE_BASE[] =
+R"__cpp_cb(
+class <CLS_NAME> final {
+ public:
+  <CLS_NAME>();
+  <CLS_NAME>(<PARAMS>);
+  <GETTER_SETTER>
+ private:
+  <MEMBERS>
+};
+)__cpp_cb";
+
+/**
+ * <RETURN_TYPE> The return type of the element.
+ * <NAME> The element name.
+ * <PARAM_TYPE> The parameter type of the element.
+ * <PARAM_NAME> The parameter name of the element.
+ */
+constexpr const char CB_HEADER_STRUCTURE_GETTER_SETTER[] =
+R"__cpp_cb(
+<RETURN_TYPE> Get<NAME>() const;
+void Set<NAME>(<PARAM_TYPE> <PARAM_NAME>);
+)__cpp_cb";
+
+/**
+ * <TYPE> The element type.
+ * <NAME> The element name.
+ */
+constexpr const char CB_HEADER_STRUCTURE_MEMBER[] = "<TYPE> <NAME>_;";
+
+/**
+ * <IDS> The enumeration of methods of the interface.
+ */
+constexpr const char CB_METHOD_IDS[] =
+R"__cpp_cb(
+enum class MethodId : int {
+  __Result = 0,
+  __Callback = 1,
+  <IDS>
+};
+)__cpp_cb";
+
+/**
+ * <IDS> The enumeration of delegates of the interface.
+ */
+constexpr const char CB_DELEGATE_IDS[] =
+R"__cpp_cb(
+enum class DelegateId : int {
+  <IDS>
+};
+)__cpp_cb";
+
+/**
+ * <NAME> The enumeration name.
+ * <VALUE> The enumeration value.
+ */
+constexpr const char CB_ENUM[] = "<NAME> = <VALUE>,";
+
+constexpr const char CB_BODY_BUNDLE[] =
+R"__cpp_cb(
+Bundle::Bundle() {
+  handle_ = bundle_create();
+  if (handle_ == nullptr)
+    throw new std::bad_alloc();
+}
+
+Bundle::Bundle(bundle* handle, bool copy, bool own) : handle_(handle), own_(own) {
+  if (handle == nullptr)
+    throw new std::invalid_argument("handle is nullptr");
+
+  if (copy) {
+    handle_ = bundle_dup(handle);
+    if (handle_ == nullptr)
+      throw new std::bad_alloc();
+  }
+}
+
+Bundle::Bundle(std::string raw) {
+  handle_ = bundle_decode(reinterpret_cast<const bundle_raw*>(raw.c_str()), raw.length());
+  if (handle_ == nullptr)
+    throw new std::bad_alloc();
+}
+
+Bundle::~Bundle() {
+  if (own_ && handle_)
+    bundle_free(handle_);
+}
+
+Bundle::Bundle(const Bundle& b) {
+  handle_ = bundle_dup(b.handle_);
+  if (handle_ == nullptr)
+    throw new std::bad_alloc();
+}
+
+Bundle& Bundle::operator = (const Bundle& b) {
+  if (this != &b) {
+    if (handle_ && own_)
+      bundle_free(handle_);
+
+    handle_ = bundle_dup(b.handle_);
+    if (handle_ == nullptr)
+      throw new std::bad_alloc();
+
+    own_ = true;
+  }
+
+  return *this;
+}
+
+Bundle::Bundle(Bundle&& b) noexcept {
+  handle_ = b.handle_;
+  b.handle_ = bundle_create();
+  own_ = b.own_;
+  b.own_ = true;
+}
+
+Bundle& Bundle::operator = (Bundle&& b) noexcept {
+  if (this != &b) {
+    if (handle_ && own_)
+      bundle_free(handle_);
+
+    handle_ = b.handle_;
+    b.handle_ = bundle_create();
+    own_ = b.own_;
+  }
+
+  return *this;
+}
+
+bundle* Bundle::GetHandle() const {
+  return handle_;
+}
+
+bundle* Bundle::Detach() {
+  bundle* handle = handle_;
+  handle_ = nullptr;
+  return handle;
+}
+)__cpp_cb";
+
+constexpr const char CB_BODY_FILE[] =
+R"__cpp_cb(
+File::File(std::string filename) : filename_(std::move(filename)) {}
+
+const std::string& File::GetFileName() const {
+  return filename_;
+}
+
+int File::Share(rpc_port_h port) {
+  int ret = rpc_port_set_private_sharing(port, filename_.c_str());
+  if (ret != RPC_PORT_ERROR_NONE)
+    _E("Failed to set private sharing. error(%d)", ret);
+
+  return ret;
+}
+)__cpp_cb";
+
+
+/**
+ * <CLS_NAME> The class name of the structure.
+ * <PARAMS> The parameters of the structure.
+ * <GETTER_SETTER> The getters and setters.
+ * <MEMBERS> The member variables of the structure.
+ */
+constexpr const char CB_BODY_STRUCTURE_BASE[] =
+R"__cpp_cb(
+<CLS_NAME>::<CLS_NAME>() {}
+
+<CLS_NAME>::<CLS_NAME>(<PARAMS>) : <MEMBER_INIT> {}
+
+<GETTER_SETTER>
+)__cpp_cb";
+
+constexpr const char CB_BODY_STRUCTURE_MEMBER_INIT[] =
+"<NAME>_(<VALUE>)";
+
+/**
+ * <RETURN_TYPE> The return type of the element.
+ * <NAME> The element name.
+ * <PARAM_TYPE> The parameter type of the element.
+ * <PARAM_NAME> The parameter name of the element.
+ * <SET_VALUE> The setter value of the element.
+ */
+constexpr const char CB_BODY_STRUCTURE_GETTER_SETTER[] =
+R"__cpp_cb(
+<RETURN_TYPE> <CLS_NAME>::Get<NAME>() const {
+  return <NAME>_;
+}
+
+void <CLS_NAME>::Set<NAME>(<PARAM_TYPE> <PARAM_NAME>) {
+  <NAME>_ = <VALUE>;
+}
+)__cpp_cb";
+
+constexpr const char CB_UNIT[] =
+R"__cpp_cb(
+class Unit {
+ public:
+  Unit() {
+    rpc_port_parcel_create_without_header(&parcel_);
+  }
+
+  Unit(std::string name, std::string type) : name_(std::move(name)), type_(std::move(type)) {
+    rpc_port_parcel_create_without_header(&parcel_);
+  }
+
+  ~Unit() {
+    if (parcel_ != nullptr)
+      rpc_port_parcel_destroy(parcel_);
+  }
+
+  const std::string& GetName() const {
+    return name_;
+  }
+
+  void SetName(std::string name) {
+    name_ = std::move(name);
+  }
+
+  const std::string& GetType() const {
+    return type_;
+  }
+
+  void SetType(std::string type) {
+    type_ = std::move(type);
+  }
+
+  rpc_port_parcel_h GetParcel() const {
+    return parcel_;
+  }
+
+  void Serialize(rpc_port_parcel_h parcel) const {
+    rpc_port_parcel_write_string(parcel, GetName().c_str());
+    rpc_port_parcel_write_string(parcel, GetType().c_str());
+
+    void* raw = nullptr;
+    unsigned int size = 0;
+    rpc_port_parcel_get_raw(GetParcel(), &raw, &size);
+    rpc_port_parcel_write_array_count(parcel, size & INT_MAX);
+    rpc_port_parcel_burst_write(parcel, static_cast<unsigned char*>(raw), size);
+  }
+
+  void Deserialize(rpc_port_parcel_h parcel) {
+    char* name = nullptr;
+    rpc_port_parcel_read_string(parcel, &name);
+    if (name != nullptr) {
+      SetName(name);
+      free(name);
+    }
+
+    char* type = nullptr;
+    rpc_port_parcel_read_string(parcel, &type);
+    if (type != nullptr) {
+      SetType(type);
+      free(type);
+    }
+
+    int size = 0;
+    rpc_port_parcel_read_array_count(parcel, &size);
+    if (size == 0)
+      return;
+
+    unsigned char* raw = reinterpret_cast<unsigned char*>(malloc(size));
+    if (raw == nullptr) {
+      _E("malloc() is failed");
+      return;
+    }
+
+    rpc_port_parcel_burst_read(parcel, raw, size);
+    rpc_port_parcel_burst_write(GetParcel(), raw, size);
+    free(raw);
+  }
+
+  <SERIALIZER>
+
+ private:
+  std::string name_;
+  std::string type_;
+  rpc_port_parcel_h parcel_ = nullptr;
+};
+
+)__cpp_cb";
+
+/**
+ * <TYPE> The type name of the serializer.
+ */
+constexpr const char CB_UNIT_SERIALIZER_HEADER[] =
+R"__cpp_cb(
+void Write(const <TYPE>& value);
+void Read(<TYPE>& value);
+)__cpp_cb";
+
+/**
+ * <TYPE> The type name of the serializer.
+ * <IMPL_SERIALIZER> The implementation of the serializer.
+ * <IMPL_DESERIALIZER> The implementation of the deserializer.
+ */
+constexpr const char CB_UNIT_SERIALIZER_BODY[] =
+R"__cpp_cb(
+void Unit::Write(const <TYPE>& value) {
+  <IMPL_SERIALIZER>
+}
+
+void Unit::Read(<TYPE>& value) {
+  <IMPL_DESERIALIZER>
+}
+)__cpp_cb";
+
+/**
+ * <UNIT_MAP_WRITE> The implementation to write the data to the unit map.
+ */
+constexpr const char CB_UNIT_IMPL_SERIALIZER_USER_DEFINED[] =
+R"__cpp_cb(
+UnitMap unit_map;
+<UNIT_MAP_WRITE>
+unit_map.Serialize(GetParcel());
+)__cpp_cb";
+
+constexpr const char CB_UNIT_MAP_ARRAY_WRITE[] =
+R"__cpp_cb(
+unit_map.Write("size", static_cast<int>(value.size() & INT_MAX));
+
+for (size_t index = 0; index < value.size(); ++index)
+  unit_map.Write(std::to_string(index), value[index]);
+)__cpp_cb";
+
+constexpr const char CB_UNIT_MAP_LIST_WRITE[] =
+R"__cpp_cb(
+unit_map.Write("length", static_cast<int>(value.size() & INT_MAX));
+
+int index = 0;
+for (auto& data : value)
+  unit_map.Write(std::to_string(index++), data);
+)__cpp_cb";
+
+/**
+ * <NAME> The name of the element of the value.
+ */
+constexpr const char CB_UNIT_MAP_BASE_WRITE[] =
+R"__cpp_cb(
+unit_map.Write("<NAME>", value.Get<NAME>());
+)__cpp_cb";
+
+constexpr const char CB_UNIT_MAP_CALLBACKBASE_WRITE[] =
+R"__cpp_cb(
+unit_map.Write("id", value.GetId());
+unit_map.Write("seq_id", value.GetSeqId());
+unit_map.Write("once", value.IsOnce());
+)__cpp_cb";
+
+constexpr const char CB_UNIT_IMPL_SERIALIZER_DELEGATE[] =
+R"__cpp_cb(
+UnitMap unit_map;
+unit_map.Write("id", value->GetId());
+unit_map.Write("seq_id", value->GetSeqId());
+unit_map.Write("once", value->IsOnce());
+unit_map.Serialize(GetParcel());
+)__cpp_cb";
+
+constexpr const char CB_UNIT_IMPL_SERIALIZER_BUNDLE[] =
+R"__cpp_cb(
+rpc_port_parcel_write_bundle(GetParcel(), value.GetHandle());
+)__cpp_cb";
+
+constexpr const char CB_UNIT_IMPL_SERIALIZER_STRING[] =
+R"__cpp_cb(
+rpc_port_parcel_write_string(GetParcel(), value.c_str());
+)__cpp_cb";
+
+constexpr const char CB_UNIT_IMPL_SERIALIZER_FILE[] =
+R"__cpp_cb(
+rpc_port_parcel_write_string(GetParcel(), value.GetFileName().c_str());
+)__cpp_cb";
+
+/**
+ * <PARCEL_TYPE> The type of the parcel type of the parameter.
+ */
+constexpr const char CB_UNIT_IMPL_SERIALIZER_BASE[] =
+R"__cpp_cb(
+rpc_port_parcel_write_<PARCEL_TYPE>(GetParcel(), value);
+)__cpp_cb";
+
+/**
+ * <UNIT_MAP_READ> The implementation to read the data from the unit map.
+ */
+constexpr const char CB_UNIT_IMPL_DESERIALIZER_USER_DEFINED[] =
+R"__cpp_cb(
+UnitMap unit_map;
+unit_map.Deserialize(GetParcel());
+<UNIT_MAP_READ>
+)__cpp_cb";
+
+/**
+ * <TYPE> The type of the value of the array.
+ */
+constexpr const char CB_UNIT_MAP_ARRAY_READ[] =
+R"__cpp_cb(
+int tmp_size = 0;
+unit_map.Read("size", tmp_size);
+
+for (int index = 0; index < tmp_size; ++index) {
+  <TYPE> tmp_value;
+  unit_map.Read(std::to_string(index), tmp_value);
+  value.push_back(tmp_value);
+}
+)__cpp_cb";
+
+/**
+ * <TYPE> The type of the value of the list.
+ */
+constexpr const char CB_UNIT_MAP_LIST_READ[] =
+R"__cpp_cb(
+int tmp_length = 0;
+unit_map.Read("length", tmp_length);
+
+for (int index = 0; index < tmp_length; ++index) {
+  <TYPE> tmp_value;
+  unit_map.Read(std::to_string(index), tmp_value);
+  value.push_back(tmp_value);
+}
+)__cpp_cb";
+
+/**
+ * <NAME> The name of the element of the value.
+ */
+constexpr const char CB_UNIT_MAP_BASE_READ[] =
+R"__cpp_cb(
+<TYPE> tmp_<NAME>;
+unit_map.Read("<NAME>", tmp_<NAME>);
+value.Set<NAME>(tmp_<NAME>);
+)__cpp_cb";
+
+constexpr const char CB_UNIT_MAP_CALLBACKBASE_READ[] =
+R"__cpp_cb(
+int tmp_id = 0;
+unit_map.Read("id", tmp_id);
+value.SetId(tmp_id);
+
+int tmp_seq_id = 0;
+unit_map.Read("seq_id", tmp_seq_id);
+value.SetSeqId(tmp_seq_id);
+
+bool tmp_once = false;
+unit_map.Read("once", tmp_once);
+value.SetOnce(tmp_once);
+)__cpp_cb";
+
+/**
+ * <IFACE_NAME> The interface name.
+ */
+constexpr const char CB_UNIT_IMPL_DESERIALIZER_DELEGATE[] =
+R"__cpp_cb(
+UnitMap unit_map;
+unit_map.Deserialize(GetParcel());
+
+int tmp_id = 0;
+unit_map.Read("id", tmp_id);
+value->SetId(tmp_id);
+
+int tmp_seq_id = 0;
+unit_map.Read("seq_id", tmp_seq_id);
+value->SetSeqId(tmp_seq_id);
+
+bool tmp_once = false;
+unit_map.Read("once", tmp_once);
+value->SetOnce(tmp_once);
+)__cpp_cb";
+
+constexpr const char CB_UNIT_IMPL_DESERIALIZER_BUNDLE[] =
+R"__cpp_cb(
+bundle* tmp_b = nullptr;
+rpc_port_parcel_read_bundle(GetParcel(), &tmp_b);
+value = Bundle(tmp_b, false, true);
+)__cpp_cb";
+
+constexpr const char CB_UNIT_IMPL_DESERIALIZER_STRING[] =
+R"__cpp_cb(
+char* tmp_str = nullptr;
+rpc_port_parcel_read_string(GetParcel(), &tmp_str);
+if (tmp_str != nullptr) {
+  value = std::string(tmp_str);
+  free(tmp_str);
+}
+)__cpp_cb";
+
+constexpr const char CB_UNIT_IMPL_DESERIALIZER_FILE[] =
+R"__cpp_cb(
+char* tmp_filename = nullptr;
+rpc_port_parcel_read_string(GetParcel(), &tmp_filename);
+if (tmp_filename != nullptr) {
+  value = File(tmp_filename);
+  free(tmp_filename);
+}
+)__cpp_cb";
+
+/**
+ * <PARCEL_TYPE> The type of the parcel type of the parameter.
+ */
+constexpr const char CB_UNIT_IMPL_DESERIALIZER_BASE[] =
+R"__cpp_cb(
+<TYPE> tmp_value;
+rpc_port_parcel_read_<PARCEL_TYPE>(GetParcel(), &tmp_value);
+value = tmp_value;
+)__cpp_cb";
+
+/**
+ * <UNIT_MAP_READ_WRITE> The implementation of the method to read and write.
+ */
+constexpr const char CB_UNIT_MAP[] =
+R"__cpp_cb(
+class UnitMap {
+ public:
+  UnitMap() {}
+
+  void Clear() {
+    map_.clear();
+  }
+
+  size_t GetSize() const {
+    return map_.size();
+  }
+
+   void Insert(std::string name, std::shared_ptr<Unit> unit) {
+    map_[std::move(name)] = std::move(unit);
+  }
+
+  std::shared_ptr<Unit> Lookup(const std::string& name) const {
+    auto found = map_.find(name);
+    if (found == map_.end())
+      return nullptr;
+
+    return found->second;
+  }
+
+  void Serialize(rpc_port_parcel_h parcel) const {
+    rpc_port_parcel_write_array_count(parcel, GetSize() & INT_MAX);
+    for (auto& iter : map_) {
+      auto& unit = iter.second;
+      unit->Serialize(parcel);
+    }
+  }
+
+  void Deserialize(rpc_port_parcel_h parcel) {
+    int size = 0;
+    rpc_port_parcel_read_array_count(parcel, &size);
+    for (int i = 0; i < size; ++i) {
+      auto unit = std::make_shared<Unit>();
+      unit->Deserialize(parcel);
+      std::string name = unit->GetName();
+      Insert(std::move(name), std::move(unit));
+    }
+  }
+
+  <UNIT_MAP_READ_WRITE>
+
+ private:
+  std::unordered_map<std::string, std::shared_ptr<Unit>> map_;
+};
+)__cpp_cb";
+
+/**
+ * <PARAM_TYPE> The parameter type of the value.
+ * <TYPE> The type name of the value.
+ */
+constexpr const char CB_UNIT_MAP_READ_WRITE[] =
+R"__cpp_cb(
+void Read(const std::string& name, <PARAM_TYPE>& value) const {
+  auto unit = Lookup(name);
+  if (unit == nullptr) {
+    _E("Failed to find %s", name.c_str());
+    return;
+  }
+
+  unit->Read(value);
+}
+
+void Write(std::string name, const <PARAM_TYPE>& value) {
+  auto unit = std::make_shared<Unit>(name, "<TYPE>");
+  unit->Write(value);
+  Insert(std::move(name), std::move(unit));
+}
+)__cpp_cb";
+
+/**
+ * <NAME> The parameter name.
+ */
+constexpr const char CB_PRIVATE_SHARING[] =
+R"__cpp_cb(
+<NAME>.Share(port_);
+)__cpp_cb";
+
+constexpr const char CB_PRIVATE_SHARING_ARRAY[] =
+R"__cpp_cb(
+{
+  std::vector<const char*> paths_;
+  for (auto& f : <NAME>)
+    paths_.push_back(f.GetFileName().c_str());
+
+  rpc_port_set_private_sharing_array(port_, paths_.data(), paths_.size());
+}
+)__cpp_cb";
+
+}  // namespace version2
+}  // namespace tidl
+
+#endif  // IDLC_GEN_VERSION2_CPP_GENERATOR_BASE_CB_HH_
diff --git a/idlc/gen/version2/cpp_proxy_body_generator.cc b/idlc/gen/version2/cpp_proxy_body_generator.cc
new file mode 100644 (file)
index 0000000..b32902f
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "idlc/gen/version2/cpp_proxy_body_generator.hh"
+
+#include <utility>
+
+#include "idlc/gen/version2/cpp_generator_base_cb.hh"
+#include "idlc/gen/version2/cpp_proxy_body_generator_cb.hh"
+
+namespace tidl {
+namespace version2 {
+
+CppProxyBodyGenerator::CppProxyBodyGenerator(std::shared_ptr<Document> doc)
+    : CppGeneratorBase(std::move(doc)) {}
+
+void CppProxyBodyGenerator::OnInitGen(std::ofstream& stream) {
+  GenVersion(stream);
+  GenIncludeProxyBodyHeader(stream);
+  GenIncludeDefaultHeaders(stream);
+  GenLogTag(stream, "RPC_PORT_PROXY");
+  GenLogDefinition(stream);
+  GenVersionDefinition(stream);
+  GenNamespace(stream);
+}
+
+void CppProxyBodyGenerator::OnFiniGen(std::ofstream& stream) {}
+
+void CppProxyBodyGenerator::GenIncludeProxyBodyHeader(std::ofstream& stream) {
+  std::string key(".cc");
+  std::string header_file = FileName;
+
+  auto found = header_file.rfind(key);
+  if (found != std::string::npos)
+    header_file.replace(found, key.length(), ".h");
+
+  ReplaceAll(CB_PROXY_BODY_HEADER)
+      .Change("<FILENAME>", header_file)
+      .Out(stream);
+}
+
+void CppProxyBodyGenerator::GenNamespace(std::ofstream& stream) {
+  ReplaceAll(CB_NAMESPACE_PROXY)
+      .ChangeToLower("<FILE_NAMESPACE>", GetFileNamespace())
+      .Change("<STRUCTURES>", GenStructures())
+      .Change("<EXCEPTIONS>", GenUnitMap())
+      .Change("<INTERFACES>", GenInterfaces())
+      .Transform([&](std::string str) { return SmartIndent(str); })
+      .Out(stream);
+}
+
+std::string CppProxyBodyGenerator::GenInterfaces() {
+  std::string code;
+  for (const auto& block : GetDocument().GetBlocks()) {
+    if (block->GetType() != Block::TYPE_INTERFACE)
+      continue;
+
+    auto& iface = static_cast<Interface&>(*block);
+    code += GenInterface(iface) + NLine(1);
+  }
+
+  return code;
+}
+
+std::string CppProxyBodyGenerator::GenInterface(const Interface& iface) {
+  return std::string(
+      ReplaceAll(CB_INTERFACE_BASE)
+          .Change("<CLS_NAME>", iface.GetID())
+          .Change("<CALLBACKS>", GenInterfaceCallbacks(iface))
+          .Change("<METHODS>", GenInterfaceMethods(iface)));
+}
+
+std::string CppProxyBodyGenerator::GenInterfaceCallbacks(
+    const Interface& iface) {
+  std::string code;
+  for (const auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() != Declaration::MethodType::DELEGATE)
+      continue;
+
+    if (code.empty()) {
+      code += ReplaceAll(CB_INTERFACE_CALKBACBASE_BASE)
+          .Change("<IFACE_NAME>", iface.GetID());
+      code += NLine(1);
+    }
+
+    code += ReplaceAll(CB_INTERFACE_CALLBACK)
+        .Change("<IFACE_NAME>", iface.GetID())
+        .Change("<CLS_NAME>", decl->GetID())
+        .Change("<PARAMS>", GetParameters(decl->GetParameters()))
+        .Change("<IMPL_RECEIVED_EVENT>\n",
+            GenInterfaceCallbackReceivedEvent(decl->GetParameters()));
+    code += NLine(1);
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppProxyBodyGenerator::GenInterfaceCallbackReceivedEvent(
+    const Parameters& params) {
+  std::string callback_params;
+  std::string code;
+  for (auto& param : params) {
+    auto& type = param->GetParameterType().GetBaseType();
+    code += ReplaceAll(CB_INTERFACE_CALLBACK_UNIT_MAP_READ)
+        .Change("<TYPE>", ConvertTypeToString(type))
+        .Change("<NAME>", param->GetID());
+
+    if (!callback_params.empty())
+      callback_params += ", ";
+
+    callback_params += param->GetID() + "_";
+  }
+
+  code += ReplaceAll(CB_INTERFACE_CALLBACK_INVOKE)
+      .Change("<PARAMS>", callback_params);
+
+  return RemoveLine(code);
+}
+
+std::string CppProxyBodyGenerator::GenInterfaceMethods(const Interface& iface) {
+  std::string code;
+  for (const auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() == Declaration::MethodType::DELEGATE) continue;
+
+    code += GenInterfaceMethod(iface, *decl);
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppProxyBodyGenerator::GenInterfaceMethod(const Interface& iface,
+    const Declaration& decl) {
+  if (decl.GetMethodType() == Declaration::MethodType::ASYNC) {
+    return std::string(
+        ReplaceAll(CB_INTERFACE_METHOD_ASYNC_BASE)
+            .Change("<IFACE_NAME>", iface.GetID())
+            .Change("<NAME>", decl.GetID())
+            .Change("<PARAMS>", GetParameters(decl.GetParameters()))
+            .Change("<SERIALIZE>", GenInterfaceMethodSerialize(decl)));
+  }
+
+  return std::string(
+      ReplaceAll(CB_INTERFACE_METHOD_BASE)
+          .Change("<RETURN_TYPE>", ConvertTypeToString(decl.GetType()))
+          .Change("<SET_INIT_VALUE>", GetSettingInitValue(decl.GetType()))
+          .Change("<IFACE_NAME>", iface.GetID())
+          .Change("<NAME>", decl.GetID())
+          .Change("<PARAMS>", GetParameters(decl.GetParameters()))
+          .Change("<SERIALIZE>", GenInterfaceMethodSerialize(decl))
+          .Change("<DESERIALIZE>", GenInterfaceMethodDeserialize(decl)));
+}
+
+std::string CppProxyBodyGenerator::GenInterfaceMethodSerialize(
+    const Declaration& decl) {
+  std::string code;
+  for (auto& param : decl.GetParameters()) {
+    if (param->GetParameterType().GetDirection() !=
+        ParameterType::Direction::IN)
+      continue;
+
+    code += ReplaceAll(CB_INTERFACE_METHOD_UNIT_MAP_WRITE)
+        .Change("<NAME>", param->GetID());
+    if (IsDelegateType(param->GetParameterType().GetBaseType())) {
+      code += ReplaceAll(CB_INTERFACE_METHOD_DELEGATE_INSERT)
+          .Change("<NAME>", param->GetID());
+    } else {
+      code += GenPrivateSharing(*param);
+    }
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppProxyBodyGenerator::GenInterfaceMethodDeserialize(
+    const Declaration& decl) {
+  std::string code;
+  for (auto& param : decl.GetParameters()) {
+    if (param->GetParameterType().GetDirection() ==
+        ParameterType::Direction::IN)
+      continue;
+
+    code += ReplaceAll(CB_INTERFACE_METHOD_UNIT_MAP_READ)
+        .Change("<NAME>", param->GetID());
+  }
+
+  return RemoveLine(code);
+}
+
+}  // namespace version2
+}  // namespace tidl
diff --git a/idlc/gen/version2/cpp_proxy_body_generator.hh b/idlc/gen/version2/cpp_proxy_body_generator.hh
new file mode 100644 (file)
index 0000000..73c1bb0
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_VERSION2_CPP_PROXY_BODY_GENERATOR_HH_
+#define IDLC_GEN_VERSION2_CPP_PROXY_BODY_GENERATOR_HH_
+
+#include <memory>
+#include <string>
+
+#include "idlc/gen/version2/cpp_generator_base.hh"
+
+namespace tidl {
+namespace version2 {
+
+class CppProxyBodyGenerator : public CppGeneratorBase {
+ public:
+  explicit CppProxyBodyGenerator(std::shared_ptr<Document> doc);
+  virtual ~CppProxyBodyGenerator() = default;
+
+  void OnInitGen(std::ofstream& stream) override;
+  void OnFiniGen(std::ofstream& stream) override;
+
+ private:
+  void GenIncludeProxyBodyHeader(std::ofstream& stream);
+  void GenNamespace(std::ofstream& stream);
+  std::string GenInterfaces();
+  std::string GenInterface(const Interface& iface);
+  std::string GenInterfaceCallbacks(const Interface& iface);
+  std::string GenInterfaceCallbackReceivedEvent(const Parameters& params);
+  std::string GenInterfaceMethods(const Interface& iface);
+  std::string GenInterfaceMethod(const Interface& iface,
+      const Declaration& decl);
+  std::string GenInterfaceMethodSerialize(const Declaration& decl);
+  std::string GenInterfaceMethodDeserialize(const Declaration& decl);
+};
+
+}  // namespace version2
+}  // namespace tidl
+
+#endif  // IDLC_GEN_VERSION2_CPP_PROXY_BODY_GENERATOR_HH_
diff --git a/idlc/gen/version2/cpp_proxy_body_generator_cb.hh b/idlc/gen/version2/cpp_proxy_body_generator_cb.hh
new file mode 100644 (file)
index 0000000..3ba70fa
--- /dev/null
@@ -0,0 +1,395 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_VERSION2_CPP_PROXY_BODY_GENERATOR_CB_HH_
+#define IDLC_GEN_VERSION2_CPP_PROXY_BODY_GENERATOR_CB_HH_
+
+namespace tidl {
+namespace version2 {
+
+/**
+ * <FILENAME> The filename of the proxy.
+ */
+constexpr const char CB_PROXY_BODY_HEADER[] =
+R"__cpp_cb(
+#include "<FILENAME>"
+
+#include <stdlib.h>
+#include <assert.h>
+#include <dlog.h>
+)__cpp_cb";
+
+/**
+ * <IFACE_NAME> The interface name of the callback base class.
+ */
+constexpr const char CB_INTERFACE_CALKBACBASE_BASE[] =
+R"__cpp_cb(
+std::atomic<int> <IFACE_NAME>::CallbackBase::seq_num_ { 0 };
+
+<IFACE_NAME>::CallbackBase::CallbackBase(int delegate_id, bool once) : id_(delegate_id), once_(once) {
+  seq_id_ = seq_num_++;
+}
+
+void <IFACE_NAME>::CallbackBase::OnReceivedEvent(const UnitMap& unit_map) {}
+
+int <IFACE_NAME>::CallbackBase::GetId() const {
+  return id_;
+}
+
+void <IFACE_NAME>::CallbackBase::SetId(int id) {
+  id_ = id;
+}
+
+int <IFACE_NAME>::CallbackBase::GetSeqId() const {
+  return seq_id_;
+}
+
+void <IFACE_NAME>::CallbackBase::SetSeqId(int seq_id) {
+  seq_id_ = seq_id;
+}
+
+bool <IFACE_NAME>::CallbackBase::IsOnce() const {
+  return once_;
+}
+
+void <IFACE_NAME>::CallbackBase::SetOnce(bool once) {
+  once_ = once;
+}
+
+std::string <IFACE_NAME>::CallbackBase::GetTag() const {
+  return std::to_string(id_) + "::" + std::to_string(seq_id_);
+}
+)__cpp_cb";
+
+/**
+ * <IFACE_NAME> The interface name of the callback.
+ * <CLS_NAME> The class name of the callback.
+ * <IMPL_RECEIVED_EVENT> The implmenetation of the OnReceivedEvent() of the callback.
+ */
+constexpr const char CB_INTERFACE_CALLBACK[] =
+R"__cpp_cb(
+<IFACE_NAME>::<CLS_NAME>::<CLS_NAME>(bool once) : CallbackBase(static_cast<int>(DelegateId::<CLS_NAME>), once) {}
+
+void <IFACE_NAME>::<CLS_NAME>::OnReceived(<PARAMS>) {}
+
+void <IFACE_NAME>::<CLS_NAME>::OnReceivedEvent(const UnitMap& unit_map) {
+  <IMPL_RECEIVED_EVENT>
+}
+)__cpp_cb";
+
+/**
+ * <NAME> The name of the parameter of the callback.
+ */
+constexpr const char CB_INTERFACE_CALLBACK_UNIT_MAP_READ[] =
+R"__cpp_cb(
+<TYPE> <NAME>_;
+unit_map.Read("<NAME>", <NAME>_);
+)__cpp_cb";
+
+/**
+ * <PARAMS> The parameters of the callback.
+ */
+constexpr const char CB_INTERFACE_CALLBACK_INVOKE[] =
+R"__cpp_cb(
+OnReceived(<PARAMS>);
+)__cpp_cb";
+
+/**
+ * <CLS_NAME> The class name of the interface.
+ * <CALLBACKS> The callbacks of the interface.
+ * <METHODS> The methods of the interface.
+ */
+constexpr const char CB_INTERFACE_BASE[] =
+R"__cpp_cb(
+<CALLBACKS>
+<CLS_NAME>::<CLS_NAME>(<CLS_NAME>::IEventListener* listener, std::string target_appid) : listener_(listener), target_appid_(std::move(target_appid)) {
+  _W("<CLS_NAME> ctor");
+  int ret = rpc_port_proxy_create(&proxy_);
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to create proxy. error(%d)", ret);
+    throw InvalidIOException();
+  }
+
+  rpc_port_proxy_add_connected_event_cb(proxy_, OnConnectedCb, this);
+  rpc_port_proxy_add_disconnected_event_cb(proxy_, OnDisconnectedCb, this);
+  rpc_port_proxy_add_rejected_event_cb(proxy_, OnRejectedCb, this);
+  rpc_port_proxy_add_received_event_cb(proxy_, OnReceivedCb, this);
+}
+
+<CLS_NAME>::~<CLS_NAME>() {
+  _W("<CLS_NAME> dtor");
+  if (proxy_ != nullptr)
+    rpc_port_proxy_destroy(proxy_);
+}
+
+void <CLS_NAME>::Connect(bool sync) {
+  int ret;
+  if (sync)
+    ret = rpc_port_proxy_connect_sync(proxy_, target_appid_.c_str(), "<CLS_NAME>");
+  else
+    ret = rpc_port_proxy_connect(proxy_, target_appid_.c_str(), "<CLS_NAME>");
+
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to connect to <CLS_NAME>. error(%d)", ret);
+    switch (ret) {
+      case RPC_PORT_ERROR_INVALID_PARAMETER: {
+        throw InvalidIDException();
+      }
+      case RPC_PORT_ERROR_IO_ERROR: {
+        throw InvalidIOException();
+      }
+      case RPC_PORT_ERROR_PERMISSION_DENIED: {
+        throw PermissionDeniedException();
+      }
+    }
+  }
+}
+
+void <CLS_NAME>::Disconnect() {
+  int ret = rpc_port_disconnect(port_);
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to disconnect from <CLS_NAME>. error(%d)", ret);
+    throw InvalidIDException();
+  }
+}
+
+void <CLS_NAME>::DisposeCallback(const std::string& tag) {
+  auto iter = delegate_list_.begin();
+  while (iter != delegate_list_.end()) {
+    if ((*iter)->GetTag() == tag) {
+      iter = delegate_list_.erase(iter);
+      break;
+    }
+
+    iter++;
+  }
+}
+
+<METHODS>
+
+void <CLS_NAME>::ProcessReceivedEvent(const UnitMap& unit_map) {
+  CallbackBase callback;
+  unit_map.Read("delegate", callback);
+
+  auto iter = delegate_list_.begin();
+  while (iter != delegate_list_.end()) {
+    auto& delegate = *iter;
+    if (delegate->GetId() == callback.GetId() && delegate->GetSeqId() == callback.GetSeqId()) {
+      delegate->OnReceivedEvent(unit_map);
+      if (delegate->IsOnce())
+        iter = delegate_list_.erase(iter);
+
+      break;
+    }
+
+    iter++;
+  }
+}
+
+void <CLS_NAME>::ConsumeCommand(rpc_port_h port, int seq_num, UnitMap& unit_map) {
+  do {
+    rpc_port_parcel_h parcel;
+    int ret = rpc_port_parcel_create_from_port(&parcel, port);
+    if (ret != RPC_PORT_ERROR_NONE)
+      break;
+
+    rpc_port_parcel_header_h header;
+    ret = rpc_port_parcel_get_header(parcel, &header);
+    if (ret != RPC_PORT_ERROR_NONE)
+      break;
+
+    int received_seq_num = -1;
+    rpc_port_parcel_header_get_seq_num(header, &received_seq_num);
+    if (received_seq_num != seq_num) {
+      _W("%d : %d", received_seq_num, seq_num);
+      rpc_port_parcel_destroy(parcel);
+      continue;
+    }
+
+    unit_map.Deserialize(parcel);
+    rpc_port_parcel_destroy(parcel);
+
+    int cmd = -1;
+    unit_map.Read("[METHOD]", cmd);
+    if (cmd == static_cast<int>(MethodId::__Result))
+      return;
+
+    unit_map.Clear();
+  } while (true);
+}
+
+void <CLS_NAME>::OnConnectedCb(const char* endpoint, const char* port_name, rpc_port_h port, void* user_data) {
+  auto* handle = static_cast<<CLS_NAME>*>(user_data);
+  handle->port_ = port;
+  rpc_port_h cb_port = nullptr;
+  rpc_port_proxy_get_port(handle->proxy_, RPC_PORT_PORT_CALLBACK, &cb_port);
+  handle->callback_port_ = cb_port;
+  handle->listener_->OnConnected();
+}
+
+void <CLS_NAME>::OnDisconnectedCb(const char* endpoint, const char* port_name, void* user_data) {
+  auto* handle = static_cast<<CLS_NAME>*>(user_data);
+  handle->delegate_list_.clear();
+  handle->listener_->OnDisconnected();
+}
+
+void <CLS_NAME>::OnRejectedCb(const char* endpoint, const char* port_name, void* user_data) {
+  auto* handle = static_cast<<CLS_NAME>*>(user_data);
+  handle->listener_->OnRejected();
+}
+
+void <CLS_NAME>::OnReceivedCb(const char* endpoint, const char* port_name, void* user_data) {
+  auto* handle = static_cast<<CLS_NAME>*>(user_data);
+  rpc_port_parcel_h parcel;
+  int ret = rpc_port_parcel_create_from_port(&parcel, handle->callback_port_);
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to create parcel from port. error(%d)", ret);
+    return;
+  }
+
+  UnitMap unit_map;
+  unit_map.Deserialize(parcel);
+  rpc_port_parcel_destroy(parcel);
+
+  int cmd = -1;
+  unit_map.Read("[METHOD]", cmd);
+  if (cmd != static_cast<int>(MethodId::__Callback)) {
+    _E("Invalid procotol");
+    return;
+  }
+
+  handle->ProcessReceivedEvent(unit_map);
+}
+)__cpp_cb";
+
+/**
+ * <IFACE_NAME> The interface name.
+ * <NAME> The method name of the interface.
+ * <PARAMS> The parameters of the method.
+ * <SERIALIZE> The implementation of serialization of the input parameter.
+ */
+constexpr const char CB_INTERFACE_METHOD_ASYNC_BASE[] =
+R"__cpp_cb(
+void <IFACE_NAME>::<NAME>(<PARAMS>) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h parcel_;
+  rpc_port_parcel_create(&parcel_);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(parcel_, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+
+  UnitMap map_;
+  map_.Write("[METHOD]", static_cast<int>(MethodId::<NAME>));
+  <SERIALIZE>
+  map_.Serialize(parcel_);;
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+  int ret_ = rpc_port_parcel_send(parcel_, port_);
+  rpc_port_parcel_destroy(parcel_);
+  if (ret_ != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. error(%d)", ret_);
+    throw InvalidIOException();
+  }
+}
+)__cpp_cb";
+
+/**
+ * <RETURN_TYPE> The return type of the method of the interface.
+ * <SET_INIT_VALUE> The setting initialization value.
+ * <IFACE_NAME> The interface name.
+ * <NAME> The method name of the interface.
+ * <PARAMS> The parameters of the method.
+ * <SERIALIZE> The implementation of serialization of the input parameter.
+ * <DESERIALIZE> The implementation of deserialization of the output parameter.
+ */
+constexpr const char CB_INTERFACE_METHOD_BASE[] =
+R"__cpp_cb(
+<RETURN_TYPE> <IFACE_NAME>::<NAME>(<PARAMS>) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h parcel_;
+  rpc_port_parcel_create(&parcel_);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(parcel_, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+
+  UnitMap map_;
+  map_.Write("[METHOD]", static_cast<int>(MethodId::<NAME>));
+  <SERIALIZE>
+  map_.Serialize(parcel_);
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+  int ret_ = rpc_port_parcel_send(parcel_, port_);
+  rpc_port_parcel_destroy(parcel_);
+  if (ret_ != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. error(%d)", ret_);
+    throw InvalidIOException();
+  }
+
+  <RETURN_TYPE> result_<SET_INIT_VALUE>;
+  UnitMap received_map_;
+  ConsumeCommand(port_, seq_num_, received_map_);
+  if (received_map_.GetSize() == 0) {
+    _E("received map size is zero");
+  }
+
+  <DESERIALIZE>
+  received_map_.Read("[RESULT]", result_);
+  return result_;
+}
+)__cpp_cb";
+
+/**
+ * <NAME> The name of the parameter.
+ */
+constexpr const char CB_INTERFACE_METHOD_UNIT_MAP_WRITE[] =
+R"__cpp_cb(
+map_.Write("<NAME>", <NAME>);
+)__cpp_cb";
+
+/**
+ * <NAME> The name of the parameter.
+ */
+constexpr const char CB_INTERFACE_METHOD_DELEGATE_INSERT[] =
+R"__cpp_cb(
+delegate_list_.push_back(std::move(<NAME>));
+)__cpp_cb";
+
+/**
+ * <NAME> The name of the parameter.
+ */
+constexpr const char CB_INTERFACE_METHOD_UNIT_MAP_READ[] =
+R"__cpp_cb(
+received_map_.Read("<NAME>", <NAME>);
+)__cpp_cb";
+
+
+}  // namespace version2
+}  // namespace tidl
+
+#endif  // IDLC_GEN_VERSION2_CPP_PROXY_BODY_GENERATOR_CB_HH_
diff --git a/idlc/gen/version2/cpp_proxy_header_generator.cc b/idlc/gen/version2/cpp_proxy_header_generator.cc
new file mode 100644 (file)
index 0000000..3e3068e
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "idlc/gen/version2/cpp_proxy_header_generator.hh"
+
+#include <utility>
+
+#include "idlc/gen/version2/cpp_generator_base_cb.hh"
+#include "idlc/gen/version2/cpp_proxy_header_generator_cb.hh"
+
+namespace tidl {
+namespace version2 {
+
+CppProxyHeaderGenerator::CppProxyHeaderGenerator(std::shared_ptr<Document> doc)
+    : CppGeneratorBase(std::move(doc)) {}
+
+void CppProxyHeaderGenerator::OnInitGen(std::ofstream& stream) {
+  GenVersion(stream);
+  GenIncludeDefaultHeaders(stream, false);
+  GenNamespace(stream);
+}
+
+void CppProxyHeaderGenerator::OnFiniGen(std::ofstream& stream) {}
+
+void CppProxyHeaderGenerator::GenNamespace(std::ofstream& stream) {
+  ReplaceAll(CB_NAMESPACE_PROXY)
+      .ChangeToLower("<FILE_NAMESPACE>", GetFileNamespace())
+      .Change("<STRUCTURES>", GenStructuresForHeader())
+      .Change("<EXCEPTIONS>", GenExceptions())
+      .Change("<INTERFACES>", GenInterfaces())
+      .Transform([&](std::string str) { return SmartIndent(str); })
+      .Out(stream);
+}
+
+std::string CppProxyHeaderGenerator::GenInterfaces() {
+  std::string code;
+  for (auto& block : GetDocument().GetBlocks()) {
+    if (block->GetType() != Block::TYPE_INTERFACE)
+      continue;
+
+    auto& iface = static_cast<Interface&>(*block);
+    code += GenInterface(iface) + NLine(1);
+  }
+
+  return code;
+}
+
+std::string CppProxyHeaderGenerator::GenInterface(const Interface& iface) {
+  return std::string(
+      ReplaceAll(CB_INTERFACE_BASE)
+          .Change("<CLS_NAME>", iface.GetID())
+          .Change("<CALLBACKS>", GenInterfaceCallbacks(iface))
+          .Change("<METHODS>", GenInterfaceMethods(iface))
+          .Change("<METHOD_IDS>", GenMethodIds(iface))
+          .Change("<DELEGATE_IDS>", GenDelegateIds(iface)));
+}
+
+std::string CppProxyHeaderGenerator::GenInterfaceCallbacks(
+    const Interface& iface) {
+  std::string code;
+  for (const auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() != Declaration::MethodType::DELEGATE)
+      continue;
+
+    if (code.empty()) {
+      code += ReplaceAll(CB_INTERFACE_CALLBACK_BASE)
+          .Change("<IFACE_NAME>", iface.GetID());
+      code += NLine(1);
+    }
+
+    code += ReplaceAll(CB_INTERFACE_CALLBACK)
+        .Change("<CLS_NAME>", decl->GetID())
+        .Change("<PARAMS>", GetParameters(decl->GetParameters()));
+    code += NLine(1);
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppProxyHeaderGenerator::GenInterfaceMethods(
+    const Interface& iface) {
+  std::string code;
+  for (const auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() == Declaration::MethodType::DELEGATE)
+      continue;
+
+    code += ReplaceAll(CB_INTERFACE_METHOD)
+                .Change("<RETURN_TYPE>", ConvertTypeToString(decl->GetType()))
+                .Change("<NAME>", decl->GetID())
+                .Change("<PARAMS>", GetParameters(decl->GetParameters()));
+  }
+
+  return RemoveLine(code);
+}
+
+}  // namespace version2
+}  // namespace tidl
diff --git a/idlc/gen/version2/cpp_proxy_header_generator.hh b/idlc/gen/version2/cpp_proxy_header_generator.hh
new file mode 100644 (file)
index 0000000..d8f2d5e
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_VERSION2_CPP_PROXY_HEADER_GENERATOR_HH_
+#define IDLC_GEN_VERSION2_CPP_PROXY_HEADER_GENERATOR_HH_
+
+#include <memory>
+#include <string>
+
+#include "idlc/gen/version2/cpp_generator_base.hh"
+
+namespace tidl {
+namespace version2 {
+
+class CppProxyHeaderGenerator : public CppGeneratorBase {
+ public:
+  explicit CppProxyHeaderGenerator(std::shared_ptr<Document> doc);
+  virtual ~CppProxyHeaderGenerator() = default;
+
+  void OnInitGen(std::ofstream& stream) override;
+  void OnFiniGen(std::ofstream& stream) override;
+
+ private:
+  void GenNamespace(std::ofstream& stream);
+  std::string GenInterfaces();
+  std::string GenInterface(const Interface& iface);
+  std::string GenInterfaceCallbacks(const Interface& iface);
+  std::string GenInterfaceMethods(const Interface& iface);
+};
+
+}  // namespace version2
+}  // namespace tidl
+
+#endif  // IDLC_GEN_VERSION2_CPP_PROXY_HEADER_GENERATOR_HH_
diff --git a/idlc/gen/version2/cpp_proxy_header_generator_cb.hh b/idlc/gen/version2/cpp_proxy_header_generator_cb.hh
new file mode 100644 (file)
index 0000000..c7b5b58
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_VERSION2_CPP_PROXY_HEADER_GENERATOR_CB_HH_
+#define IDLC_GEN_VERSION2_CPP_PROXY_HEADER_GENERATOR_CB_HH_
+
+namespace tidl {
+namespace version2 {
+
+/**
+ * <IFACE_NAME> The interface name.
+ */
+constexpr const char CB_INTERFACE_CALLBACK_BASE[] =
+R"__cpp_cb(
+class CallbackBase {
+ public:
+  CallbackBase() = default;
+  CallbackBase(int delegate_id, bool once);
+  virtual ~CallbackBase() = default;
+
+  virtual void OnReceivedEvent(const UnitMap& unit_map);
+  int GetId() const;
+  void SetId(int id);
+
+  int GetSeqId() const;
+  void SetSeqId(int seq_id);
+
+  bool IsOnce() const;
+  void SetOnce(bool once);
+
+  std::string GetTag() const;
+
+ private:
+  static std::atomic<int> seq_num_;
+  int id_ = 0;
+  int seq_id_ = 0;
+  bool once_ = false;
+};
+)__cpp_cb";
+
+/**
+ * <CLS_NAME> The class name of the callback.
+ * <PARAMS> The parameters of the callback.
+ */
+constexpr const char CB_INTERFACE_CALLBACK[] =
+R"__cpp_cb(
+class <CLS_NAME> : public CallbackBase {
+ public:
+  <CLS_NAME>(bool once = false);
+
+  virtual void OnReceived(<PARAMS>);
+
+ private:
+  void OnReceivedEvent(const UnitMap& unit_map) override;
+};
+)__cpp_cb";
+
+/**
+ * <CLS_NAME> The class name of the interface.
+ * <CALLBACKS> The callbacks of the interface.
+ * <METHODS> The methods of the interface.
+ * <METHOD_IDS> The enumeration of methods of the interface.
+ * <DELEGATE_IDS> The enumeration of delegates(callbacks) of the interface.
+ */
+constexpr const char CB_INTERFACE_BASE[] =
+R"__cpp_cb(
+class <CLS_NAME> {
+ public:
+  <CALLBACKS>
+  class IEventListener {
+   public:
+    /// <summary>
+    /// This method will be invoked when the client app is connected to the servicece app.
+    /// </summary>
+    virtual void OnConnected() = 0;
+
+    /// <summary>
+    /// This method will be invoked after the client app was disconnected from the servicece app.
+    /// </summary>
+    virtual void OnDisconnected() = 0;
+
+    /// <summary>
+    /// This method will be invoked when the service app rejects the client app.
+    /// </summary>
+    virtual void OnRejected() = 0;
+  };
+
+  /// <summary>
+  /// Constructor for this class
+  /// </summary>
+  /// <param name="listener">The listener for events</param>
+  /// <param name="target_appid">The service app ID to connect</param>
+  <CLS_NAME>(IEventListener* listener, std::string target_appid);
+
+  /// <summary>
+  /// Destructor for this class
+  /// </summary>
+  virtual ~<CLS_NAME>();
+
+  /// <summary>
+  /// Connects to the service app.
+  /// </summary>
+  /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+  /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+  //  <param name="sync">if true, connects to the service app synchornously</param>
+  /// <exception cref="InvalidIDException">
+  /// Thrown when the appid to connect is invalid.
+  /// </exception>
+  /// <exception cref="InvalidIOException">
+  /// Thrown when internal I/O error happen.
+  /// </exception>
+  /// <exception cref="PermissionDeniedException">
+  /// Thrown when the permission is denied.
+  /// </exception>
+  /// <remark> If you want to use this method, you must add privileges.</remark>
+  void Connect(bool sync = false);
+
+  /// <summary>
+  /// Disconnects from the service app.
+  /// </summary>
+  /// <exception cref="InvalidIDException">
+  /// Thrown when the stub port is invalid.
+  /// </exception>
+  void Disconnect();
+
+  /// <summary>
+  /// Disposes delegate objects in this interface
+  /// </summary>
+  /// <param name="tag">The tag string from delegate object</param>
+  void DisposeCallback(const std::string& tag);
+
+  <METHODS>
+ private:
+  <METHOD_IDS>
+  <DELEGATE_IDS>
+
+  void ProcessReceivedEvent(const UnitMap& unit_map);
+  void ConsumeCommand(rpc_port_h port, int seq_num, UnitMap& unit_map);
+  static void OnConnectedCb(const char* endpoint, const char* port_name, rpc_port_h port, void* user_data);
+  static void OnDisconnectedCb(const char* endpoint, const char* port_name, void* user_data);
+  static void OnRejectedCb(const char* endpoint, const char* port_name, void* user_data);
+  static void OnReceivedCb(const char* endpoint, const char* port_name, void* user_data);
+
+ private:
+  rpc_port_h port_ = nullptr;
+  rpc_port_h callback_port_ = nullptr;
+  rpc_port_proxy_h proxy_ = nullptr;
+  IEventListener* listener_ = nullptr;
+  std::recursive_mutex mutex_;
+  std::list<std::unique_ptr<CallbackBase>> delegate_list_;
+  std::string target_appid_;
+};
+)__cpp_cb";
+
+/**
+ * <RETURN_TYPE> The return type of the method of the interface.
+ * <NAME> The method name of the interface.
+ * <PARAMS> The parameters of the method.
+ */
+constexpr const char CB_INTERFACE_METHOD[] =
+R"__cpp_cb(
+<RETURN_TYPE> <NAME>(<PARAMS>);
+)__cpp_cb";
+
+}  // namespace version2
+}  // namespace tidl
+
+#endif  // IDLC_GEN_VERSION2_CPP_PROXY_HEADER_GENERATOR_CB_HH_
diff --git a/idlc/gen/version2/cpp_stub_body_generator.cc b/idlc/gen/version2/cpp_stub_body_generator.cc
new file mode 100644 (file)
index 0000000..3b080b2
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "idlc/gen/version2/cpp_stub_body_generator.hh"
+
+#include <utility>
+
+#include "idlc/gen/version2/cpp_generator_base_cb.hh"
+#include "idlc/gen/version2/cpp_stub_body_generator_cb.hh"
+
+namespace tidl {
+namespace version2 {
+
+CppStubBodyGenerator::CppStubBodyGenerator(std::shared_ptr<Document> doc,
+    std::shared_ptr<Options> options)
+    : CppGeneratorBase(std::move(doc)), options_(std::move(options)) {}
+
+void CppStubBodyGenerator::OnInitGen(std::ofstream& stream) {
+  GenVersion(stream);
+  GenIncludeStubBodyHeader(stream);
+  GenIncludeDefaultHeaders(stream);
+  GenLogTag(stream, "RPC_PORT_STUB");
+  GenLogDefinition(stream);
+  GenVersionDefinition(stream);
+  GenNamespace(stream);
+}
+
+void CppStubBodyGenerator::OnFiniGen(std::ofstream& stream) {}
+
+void CppStubBodyGenerator::GenIncludeStubBodyHeader(std::ofstream& stream) {
+  std::string key(".cc");
+  std::string header_file = FileName;
+
+  auto found = header_file.rfind(key);
+  if (found != std::string::npos)
+    header_file.replace(found, key.length(), ".h");
+
+  ReplaceAll(CB_STUB_BODY_HEADER)
+      .Change("<FILENAME>", header_file)
+      .Out(stream);
+}
+
+void CppStubBodyGenerator::GenNamespace(std::ofstream& stream) {
+  ReplaceAll(CB_NAMESPACE_STUB)
+      .ChangeToLower("<FILE_NAMESPACE>", GetFileNamespace())
+      .Change("<STRUCTURES>", GenStructures())
+      .Change("<BASE_IMPL>", GenUnitMap())
+      .Change("<INTERFACES>", GenInterfaces())
+      .Transform([&](std::string str) { return SmartIndent(str); })
+      .Out(stream);
+}
+
+std::string CppStubBodyGenerator::GenInterfaces() {
+  std::string code;
+  for (const auto& block : GetDocument().GetBlocks()) {
+    if (block->GetType() != Block::TYPE_INTERFACE)
+      continue;
+
+    auto& iface = static_cast<Interface&>(*block);
+    code += GenInterface(iface) + NLine(1);
+  }
+
+  return code;
+}
+
+std::string CppStubBodyGenerator::GenInterface(const Interface& iface) {
+  return std::string(
+      ReplaceAll(CB_INTERFACE_BASE)
+          .Change("<CLS_NAME>", iface.GetID())
+          .Change("<CALLBACKS>", GenInterfaceCallbacks(iface))
+          .Change("<IMPL_SERVICE_BASE_THREAD_MEMBER_INIT>",
+              GenInterfaceImplServiceBaseThreadMemberInit())
+          .Change("<IMPL_SERVICE_BASE_DISPATCH_FUNC_INIT>",
+              GenInterfaceImplServiceBaseDispatchFuncInit(iface))
+          .Change("<IMPL_SERVICE_BASE_DISPATCH>",
+              GenInterfaceImplServiceBaseDispatch())
+          .Change("<IMPL_SERVICE_BASE_DISPATCH_FUNCS>",
+              GenInterfaceImplServiceBaseDispatchFuncs(iface)));
+}
+
+std::string CppStubBodyGenerator::GenInterfaceCallbacks(
+    const Interface& iface) {
+  std::string code;
+  for (const auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() != Declaration::MethodType::DELEGATE)
+      continue;
+
+    if (code.empty()) {
+      code += ReplaceAll(CB_INTERFACE_CALKBACBASE_BASE)
+          .Change("<IFACE_NAME>", iface.GetID());
+      code += NLine(1);
+    }
+
+    code += ReplaceAll(CB_INTERFACE_CALLBACK)
+        .Change("<IFACE_NAME>", iface.GetID())
+        .Change("<CLS_NAME>", decl->GetID())
+        .Change("<PARAMS>", GetParameters(decl->GetParameters()))
+        .Change("<SERIALIZE>",
+            GenInterfaceCallbackSerialize(decl->GetParameters()));
+    code += NLine(1);
+  }
+
+  if (options_->IsThreadEnabled()) {
+    code += ReplaceAll(CB_INTERFACE_PENDING_JOB)
+        .Change("<IFACE_NAME>", iface.GetID());
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppStubBodyGenerator::GenInterfaceCallbackSerialize(
+    const Parameters& params) {
+  std::string code;
+  for (auto& param : params) {
+    code += ReplaceAll(CB_INTERFACE_CALLBACK_UNIT_MAP_WRITE)
+        .Change("<NAME>", param->GetID());
+    code += GenPrivateSharing(*param);
+  }
+
+  return RemoveLine(code);
+}
+
+std::string
+CppStubBodyGenerator::GenInterfaceImplServiceBaseThreadMemberInit() {
+  if (options_->IsThreadEnabled()) {
+    return RemoveLine(
+        std::string(CB_INTERFACE_IMPL_SERVICE_BASE_THREAD_MEMBER_INIT));
+  }
+
+  return "";
+}
+
+std::string CppStubBodyGenerator::GenInterfaceImplServiceBaseDispatchFuncInit(
+    const Interface& iface) {
+  std::string code;
+  for (auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() == Declaration::MethodType::DELEGATE)
+      continue;
+
+    code += ReplaceAll(CB_INTERFACE_IMPL_SERVICE_BASE_DISPATCH_FUNC_INIT)
+        .Change("<NAME>", decl->GetID())
+        .Change("<IFACE_NAME>", iface.GetID());
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppStubBodyGenerator::GenInterfaceImplServiceBaseDispatch() {
+  std::string code;
+  if (options_->IsThreadEnabled())
+    code = CB_INTERFACE_SERVICE_BASE_DISPATCH_BASE_WITH_THREAD;
+  else
+    code = CB_INTERFACE_SERVICE_BASE_DISPATCH_BASE;
+
+  return RemoveLine(code);
+}
+
+std::string CppStubBodyGenerator::GenInterfaceImplServiceBaseDispatchFuncs(
+    const Interface& iface) {
+  std::string code;
+  for (const auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() == Declaration::MethodType::DELEGATE)
+      continue;
+
+    code += GenInterfaceImplServiceBaseDispatchFunc(iface, *decl);
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppStubBodyGenerator::GenInterfaceImplServiceBaseDispatchFunc(
+    const Interface& iface, const Declaration& decl) {
+  std::string params;
+  for (auto& param : decl.GetParameters()) {
+    if (!params.empty())
+      params += ", ";
+
+    auto& type = param->GetParameterType().GetBaseType();
+    if (IsDelegateType(type))
+      params += "std::move(" + param->GetID() + ")";
+    else
+      params += param->GetID();
+  }
+
+  if (decl.GetMethodType() == Declaration::MethodType::ASYNC) {
+    return std::string(
+        ReplaceAll(CB_INTERFACE_SERVICE_BASE_DISPATCH_FUNC_ASYNC)
+            .Change("<IFACE_NAME>", iface.GetID())
+            .Change("<NAME>", decl.GetID())
+            .Change("<PARAMS>", params)
+            .Change("<DESERIALIZE>", GenInterfaceServiceBaseDeserialize(decl)));
+  }
+
+  return std::string(
+      ReplaceAll(CB_INTERFACE_SERVICE_BASE_DISPATCH_FUNC)
+          .Change("<IFACE_NAME>", iface.GetID())
+          .Change("<NAME>", decl.GetID())
+          .Change("<PARAMS>", params)
+          .Change("<SERIALIZE>", GenInterfaceServiceBaseSerialize(decl))
+          .Change("<DESERIALIZE>", GenInterfaceServiceBaseDeserialize(decl)));
+}
+
+std::string CppStubBodyGenerator::GenInterfaceServiceBaseDeserialize(
+    const Declaration& decl) {
+  std::string code;
+  for (auto& param : decl.GetParameters()) {
+    auto& type = param->GetParameterType().GetBaseType();
+    if (IsDelegateType(type)) {
+      code += ReplaceAll(CB_INTERFACE_SERVICE_BASE_PARAM_DELEGATE)
+          .Change("<TYPE>", ConvertTypeToString(type))
+          .Change("<TYPE_NAME>", type.ToString())
+          .Change("<NAME>", param->GetID());
+    } else {
+      code += ReplaceAll(CB_INTERFACE_SERVICE_BASE_PARAM_BASE)
+          .Change("<TYPE>", ConvertTypeToString(type))
+          .Change("<NAME>", param->GetID());
+    }
+
+    if (param->GetParameterType().GetDirection() !=
+        ParameterType::Direction::IN)
+      continue;
+
+    code += RemoveLine(
+        std::string(
+            ReplaceAll(CB_INTERFACE_SERVICE_BASE_UNIT_MAP_READ)
+                .Change("<TYPE>", ConvertTypeToString(type))
+                .Change("<NAME>", param->GetID())));
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppStubBodyGenerator::GenInterfaceServiceBaseSerialize(
+    const Declaration& decl) {
+  std::string code;
+  for (auto& param : decl.GetParameters()) {
+    if (param->GetParameterType().GetDirection() ==
+        ParameterType::Direction::IN)
+      continue;
+
+    code += ReplaceAll(CB_INTERFACE_SERVICE_BASE_UNIT_MAP_WRITE)
+        .Change("<NAME>", param->GetID());
+    code += GenPrivateSharing(*param);
+  }
+
+  return RemoveLine(code);
+}
+
+}  // namespace version2
+}  // namespace tidl
diff --git a/idlc/gen/version2/cpp_stub_body_generator.hh b/idlc/gen/version2/cpp_stub_body_generator.hh
new file mode 100644 (file)
index 0000000..dc4307b
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_VERSION2_CPP_STUB_BODY_GENERATOR_HH_
+#define IDLC_GEN_VERSION2_CPP_STUB_BODY_GENERATOR_HH_
+
+#include <memory>
+#include <string>
+
+#include "idlc/gen/version2/cpp_generator_base.hh"
+#include "idlc/options.h"
+
+namespace tidl {
+namespace version2 {
+
+class CppStubBodyGenerator : public CppGeneratorBase {
+ public:
+  explicit CppStubBodyGenerator(std::shared_ptr<Document> doc,
+      std::shared_ptr<Options> options);
+  virtual ~CppStubBodyGenerator() = default;
+
+  void OnInitGen(std::ofstream& stream) override;
+  void OnFiniGen(std::ofstream& stream) override;
+
+ private:
+  void GenIncludeStubBodyHeader(std::ofstream& stream);
+  void GenNamespace(std::ofstream& stream);
+  std::string GenInterfaces();
+  std::string GenInterface(const Interface& iface);
+  std::string GenInterfaceCallbacks(const Interface& iface);
+  std::string GenInterfaceCallbackSerialize(const Parameters& params);
+  std::string GenInterfaceImplServiceBaseThreadMemberInit();
+  std::string GenInterfaceImplServiceBaseDispatchFuncInit(
+      const Interface& iface);
+  std::string GenInterfaceImplServiceBaseDispatch();
+  std::string GenInterfaceImplServiceBaseDispatchFuncs(const Interface& iface);
+  std::string GenInterfaceImplServiceBaseDispatchFunc(const Interface& iface,
+      const Declaration& decl);
+  std::string GenInterfaceServiceBaseDeserialize(const Declaration& decl);
+  std::string GenInterfaceServiceBaseSerialize(const Declaration& decl);
+
+ private:
+  std::shared_ptr<Options> options_;
+};
+
+}  // namespace version2
+}  // namespace tidl
+
+#endif  // IDLC_GEN_VERSION2_CPP_STUB_BODY_GENERATOR_HH_
diff --git a/idlc/gen/version2/cpp_stub_body_generator_cb.hh b/idlc/gen/version2/cpp_stub_body_generator_cb.hh
new file mode 100644 (file)
index 0000000..4967ec7
--- /dev/null
@@ -0,0 +1,400 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_VERSION2_CPP_STUB_BODY_GENERATOR_CB_HH_
+#define IDLC_GEN_VERSION2_CPP_STUB_BODY_GENERATOR_CB_HH_
+
+namespace tidl {
+namespace version2 {
+
+/**
+ * <FILENAME> The filename of the stub.
+ */
+constexpr const char CB_STUB_BODY_HEADER[] =
+R"__cpp_cb(
+#include "<FILENAME>"
+
+#include <stdlib.h>
+#include <assert.h>
+#include <dlog.h>
+)__cpp_cb";
+
+/**
+ * <IFACE_NAME> The interface name of the callback base class.
+ */
+constexpr const char CB_INTERFACE_CALKBACBASE_BASE[] =
+R"__cpp_cb(
+std::atomic<int> <IFACE_NAME>::CallbackBase::seq_num_ { 0 };
+
+<IFACE_NAME>::CallbackBase::CallbackBase(int delegate_id, bool once) : id_(delegate_id), once_(once) {
+  seq_id_ = seq_num_++;
+}
+
+int <IFACE_NAME>::CallbackBase::GetId() const {
+  return id_;
+}
+
+void <IFACE_NAME>::CallbackBase::SetId(int id) {
+  id_ = id;
+}
+
+int <IFACE_NAME>::CallbackBase::GetSeqId() const {
+  return seq_id_;
+}
+
+void <IFACE_NAME>::CallbackBase::SetSeqId(int seq_id) {
+  seq_id_ = seq_id;
+}
+
+bool <IFACE_NAME>::CallbackBase::IsOnce() const {
+  return once_;
+}
+
+void <IFACE_NAME>::CallbackBase::SetOnce(bool once) {
+  once_ = once;
+}
+
+std::string <IFACE_NAME>::CallbackBase::GetTag() const {
+  return std::to_string(id_) + "::" + std::to_string(seq_id_);
+}
+)__cpp_cb";
+
+/**
+ * <IFACE_NAME> The interface name of the callback.
+ * <CLS_NAME> The class name of the callback.
+ * <SERILAIZE> The implementation of serialization of the input parameter.
+ */
+constexpr const char CB_INTERFACE_CALLBACK[] =
+R"__cpp_cb(
+void <IFACE_NAME>::<CLS_NAME>::Invoke(<PARAMS>) {
+  if (callback_port_ == nullptr)
+      throw NotConnectedSocketException();
+
+  if (service_.lock().get() == nullptr)
+      throw NotConnectedSocketException();
+
+  if (IsOnce() && !valid_)
+      throw InvalidArgumentException();
+
+  UnitMap unit_map_;
+  unit_map_.Write("[METHOD]", static_cast<int>(MethodId::__Callback));
+  unit_map_.Write("delegate", *this);
+  <SERIALIZE>
+
+  rpc_port_parcel_h parcel_;
+  rpc_port_parcel_create(&parcel_);
+  unit_map_.Serialize(parcel_);
+
+  set_last_result(rpc_port_parcel_send(parcel_, callback_port_));
+  rpc_port_parcel_destroy(parcel_);
+  valid_ = false;
+}
+)__cpp_cb";
+
+/**
+ * <NAME> The name of the parameter of the callback.
+ */
+constexpr const char CB_INTERFACE_CALLBACK_UNIT_MAP_WRITE[] =
+R"__cpp_cb(
+unit_map_.Write("<NAME>", <NAME>);
+)__cpp_cb";
+
+/**
+ * <IFACE_NAME> The interface name.
+ */
+constexpr const char CB_INTERFACE_PENDING_JOB[] =
+R"__cpp_cb(
+<IFACE_NAME>::PendingJob::PendingJob(rpc_port_h port, rpc_port_h callback_port, rpc_port_parcel_h parcel, std::shared_ptr<ServiceBase> service) : port_(port), callback_port_(callback_port), parcel_(parcel), service_(std::move(service)) {}
+
+<IFACE_NAME>::PendingJob::~PendingJob() {
+  if (parcel_ != nullptr)
+    rpc_port_parcel_destroy(parcel_);
+}
+
+void <IFACE_NAME>::PendingJob::OnRun() {
+  service_->Dispatch(port_, callback_port_, parcel_);
+  parcel_ = nullptr;
+}
+)__cpp_cb";
+
+/**
+ * <CLS_NAME> The class name of the interface.
+ * <CALLBACKS> The callbacks of the interface.
+ * <IMPL_SERVICE_BASE_DISPATCH_FUNC_INIT> The implementation of the initialization of dispatch funcs of the service base.
+ * <IMPL_SERVICE_BASE_THREAD_MEMBER_INIT> The implementation of the initialization of thread member variable of the service base.
+ * <IMPL_SERVICE_BASE_DISPATCH> The implementation of the dispatch method of the service base.
+ * <IMPL_SERVICE_BASE_DISPATCH_FUNCS> The implementation of the dispatch functions of the service base.
+ */
+constexpr const char CB_INTERFACE_BASE[] =
+R"__cpp_cb(
+<CALLBACKS>
+
+<CLS_NAME>::ServiceBase::ServiceBase(std::string sender, std::string instance) : sender_(std::move(sender)), instance_(std::move(instance)) {
+  <IMPL_SERVICE_BASE_THREAD_MEMBER_INIT>
+  dispatch_funcs_ = {
+    <IMPL_SERVICE_BASE_DISPATCH_FUNC_INIT>
+  };
+}
+
+void <CLS_NAME>::ServiceBase::SetPort(rpc_port_h port) {
+  port_ = port;
+}
+
+void <CLS_NAME>::ServiceBase::Disconnect() {
+  int ret = rpc_port_disconnect(port_);
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to disconnect the port. error(%d)", ret);
+    return;
+  }
+
+  port_ = nullptr;
+}
+
+void <CLS_NAME>::ServiceBase::Dispatch(rpc_port_h port, rpc_port_h callback_port, rpc_port_parcel_h parcel, std::shared_ptr<ServiceBase> service) {
+  <IMPL_SERVICE_BASE_DISPATCH>
+}
+
+void <CLS_NAME>::ServiceBase::Dispatch(rpc_port_h port, rpc_port_h callback_port, rpc_port_parcel_h parcel) {
+  rpc_port_parcel_header_h header;
+  rpc_port_parcel_get_header(parcel, &header);
+
+  int seq_num = -1;
+  rpc_port_parcel_header_get_seq_num(header, &seq_num);
+
+  UnitMap unit_map_;
+  unit_map_.Deserialize(parcel);
+  rpc_port_parcel_destroy(parcel);
+
+  int cmd_ = -1;
+  unit_map_.Read("[METHOD]", cmd_);
+
+  auto found = dispatch_funcs_.find(cmd_);
+  if (found == dispatch_funcs_.end()) {
+    _E("Unknown command(%d)", cmd_);
+    return;
+  }
+
+  auto& func = found->second;
+  func(port, callback_port, seq_num, unit_map_);
+}
+
+<IMPL_SERVICE_BASE_DISPATCH_FUNCS>
+
+<CLS_NAME>::<CLS_NAME>() {
+  _W("<CLS_NAME> ctor");
+  int ret = rpc_port_stub_create(&stub_, "<CLS_NAME>");
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to create stub. error(%d)", ret);
+    throw InvalidIOException();
+  }
+
+  rpc_port_stub_add_connected_event_cb(stub_, OnConnectedCb, this);
+  rpc_port_stub_add_disconnected_event_cb(stub_, OnDisconnectedCb, this);
+  rpc_port_stub_add_received_event_cb(stub_, OnReceivedCb, this);
+}
+
+<CLS_NAME>::~<CLS_NAME>() {
+  _W("<CLS_NAME> dtor");
+  for (auto& service : services_)
+    service->OnTerminate();
+
+  if (stub_ != nullptr)
+    rpc_port_stub_destroy(stub_);
+}
+
+void <CLS_NAME>::Listen(std::shared_ptr<<CLS_NAME>::ServiceBase::Factory> service_factory) {
+  service_factory_ = std::move(service_factory);
+  int ret = rpc_port_stub_listen(stub_);
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to listen stub. error(%d)", ret);
+    if (ret == RPC_PORT_ERROR_INVALID_PARAMETER || ret == RPC_PORT_ERROR_IO_ERROR)
+      throw InvalidIOException();
+  }
+}
+
+void <CLS_NAME>::OnConnectedCb(const char* sender, const char* instance, void* user_data) {
+  auto* handle = static_cast<<CLS_NAME>*>(user_data);
+  auto service = handle->service_factory_->CreateService(sender, instance);
+
+  rpc_port_h port;
+  int ret = rpc_port_stub_get_port(handle->stub_, RPC_PORT_PORT_CALLBACK, instance, &port);
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to get port. error(%d)", ret);
+    return;
+  }
+
+  service->SetPort(port);
+  service->OnCreate();
+  handle->services_.emplace_back(std::move(service));
+}
+
+void <CLS_NAME>::OnDisconnectedCb(const char* sender, const char* instance, void* user_data) {
+  auto* handle = static_cast<<CLS_NAME>*>(user_data);
+  auto iter = handle->services_.begin();
+  while (iter != handle->services_.end()) {
+    if ((*iter)->GetInstance() == instance) {
+      (*iter)->OnTerminate();
+      iter = handle->services_.erase(iter);
+      break;
+    }
+
+    iter++;
+  }
+}
+
+int <CLS_NAME>::OnReceivedCb(const char* sender, const char* instance, rpc_port_h port, void* user_data) {
+  auto* handle = static_cast<<CLS_NAME>*>(user_data);
+  std::shared_ptr<ServiceBase> service;
+  for (auto& iter : handle->services_) {
+    if (iter->GetInstance() == instance) {
+      service = iter;
+      break;
+    }
+  }
+
+  if (service.get() == nullptr) {
+    _E("Failed to find <CLS_NAME> context. instance(%s)", instance);
+    return -1;
+  }
+
+  rpc_port_h callback_port;
+  int ret = rpc_port_stub_get_port(handle->stub_, RPC_PORT_PORT_CALLBACK, instance, &callback_port);
+  if (ret != 0) {
+    _E("Failed to get callback port. error(%d)", ret);
+    return -1;
+  }
+
+  rpc_port_parcel_h parcel;
+  ret = rpc_port_parcel_create_from_port(&parcel, port);
+  if (ret != 0) {
+    _E("Failed to create parcel from port. error(%d)", ret);
+    return ret;
+  }
+
+  service->Dispatch(port, callback_port, parcel, service);
+  return ret;
+}
+)__cpp_cb";
+
+/**
+ * <NAME> The method name of the interface.
+ * <IFACE_NAME> The interface name.
+ */
+constexpr const char CB_INTERFACE_IMPL_SERVICE_BASE_DISPATCH_FUNC_INIT[] =
+R"__cpp_cb(
+{ static_cast<int>(MethodId::<NAME>), std::bind(&<IFACE_NAME>::ServiceBase::Dispatch<NAME>, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4) },
+)__cpp_cb";
+
+constexpr const char CB_INTERFACE_IMPL_SERVICE_BASE_THREAD_MEMBER_INIT[] =
+R"__cpp_cb(
+active_object_ = std::unique_ptr<ActiveObject>(new ActiveObject());
+)__cpp_cb";
+
+constexpr const char CB_INTERFACE_SERVICE_BASE_DISPATCH_BASE[] =
+R"__cpp_cb(
+Dispatch(port, callback_port, parcel);
+)__cpp_cb";
+
+constexpr const char CB_INTERFACE_SERVICE_BASE_DISPATCH_BASE_WITH_THREAD[] =
+R"__cpp_cb(
+active_object_->Send(std::make_shared<Job>(port, callback_port, parcel, std::move(service)));
+)__cpp_cb";
+
+/**
+ * <IFACE_NAME> The interface name.
+ * <NAME> The method name of the interface.
+ * <PARAMS> The parameters of the method.
+ * <SERIALIZE> The implementation of serialization of the output parameter.
+ * <DESERIALIZE> The implementation of deserialization of the input parameter.
+ */
+constexpr const char CB_INTERFACE_SERVICE_BASE_DISPATCH_FUNC_ASYNC[] =
+R"__cpp_cb(
+void <IFACE_NAME>::ServiceBase::Dispatch<NAME>(rpc_port_h port, rpc_port_h callback_port, int seq_num, const UnitMap& unit_map) {
+  <DESERIALIZE>
+  <NAME>(<PARAMS>);
+}
+)__cpp_cb";
+
+/**
+ * <IFACE_NAME> The interface name.
+ * <NAME> The method name of the interface.
+ * <PARAMS> The parameters of the method.
+ * <SERIALIZE> The implementation of serialization of the output parameter.
+ * <DESERIALIZE> The implementation of deserialization of the input parameter.
+ */
+constexpr const char CB_INTERFACE_SERVICE_BASE_DISPATCH_FUNC[] =
+R"__cpp_cb(
+void <IFACE_NAME>::ServiceBase::Dispatch<NAME>(rpc_port_h port, rpc_port_h callback_port, int seq_num, const UnitMap& unit_map) {
+  <DESERIALIZE>
+  auto ret_ = <NAME>(<PARAMS>);
+
+  UnitMap map_;
+  map_.Write("[METHOD]", static_cast<int>(MethodId::__Result));
+  map_.Write("[RESULT]", ret_);
+  <SERIALIZE>
+
+  rpc_port_parcel_h parcel_;
+  rpc_port_parcel_create(&parcel_);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(parcel_, &header_);
+  rpc_port_parcel_header_set_seq_num(header_, seq_num);
+
+  map_.Serialize(parcel_);
+  rpc_port_parcel_send(parcel_, port);
+  rpc_port_parcel_destroy(parcel_);
+}
+)__cpp_cb";
+
+/**
+ * <NAME> The name of the parameter.
+ */
+constexpr const char CB_INTERFACE_SERVICE_BASE_UNIT_MAP_WRITE[] =
+R"__cpp_cb(
+map_.Write("<NAME>", <NAME>);
+)__cpp_cb";
+
+/**
+ * <TYPE> The type of the parameter.
+ * <NAME> The name of the parameter.
+ */
+constexpr const char CB_INTERFACE_SERVICE_BASE_PARAM_BASE[] =
+R"__cpp_cb(
+<TYPE> <NAME>;
+)__cpp_cb";
+
+/**
+ * <TYPE> The type of the parameter.
+ * <TYPE_NAME> The type name of the parameter.
+ * <NAME> The name of the parameter.
+ */
+constexpr const char CB_INTERFACE_SERVICE_BASE_PARAM_DELEGATE[] =
+R"__cpp_cb(
+<TYPE> <NAME>(new <TYPE_NAME>(callback_port, std::weak_ptr<ServiceBase>(this->shared_from_this())));
+)__cpp_cb";
+
+/**
+ * <NAME> The name of the parameter.
+ */
+constexpr const char CB_INTERFACE_SERVICE_BASE_UNIT_MAP_READ[] =
+R"__cpp_cb(
+unit_map.Read("<NAME>", <NAME>);
+)__cpp_cb";
+
+}  // namespace version2
+}  // namespace tidl
+
+#endif  // IDLC_GEN_VERSION2_CPP_STUB_BODY_GENERATOR_CB_HH_
diff --git a/idlc/gen/version2/cpp_stub_header_generator.cc b/idlc/gen/version2/cpp_stub_header_generator.cc
new file mode 100644 (file)
index 0000000..331a958
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "idlc/gen/version2/cpp_stub_header_generator.hh"
+
+#include <utility>
+
+#include "idlc/gen/version2/cpp_generator_base_cb.hh"
+#include "idlc/gen/version2/cpp_stub_header_generator_cb.hh"
+
+namespace tidl {
+namespace version2 {
+
+CppStubHeaderGenerator::CppStubHeaderGenerator(std::shared_ptr<Document> doc,
+    std::shared_ptr<Options> options)
+    : CppGeneratorBase(std::move(doc)), options_(std::move(options)) {}
+
+void CppStubHeaderGenerator::OnInitGen(std::ofstream& stream) {
+  GenVersion(stream);
+  GenIncludeDefaultHeaders(stream, false);
+  GenNamespace(stream);
+}
+
+void CppStubHeaderGenerator::OnFiniGen(std::ofstream& stream) {}
+
+void CppStubHeaderGenerator::GenNamespace(std::ofstream& stream) {
+  ReplaceAll(CB_NAMESPACE_STUB)
+      .ChangeToLower("<FILE_NAMESPACE>", GetFileNamespace())
+      .Change("<STRUCTURES>", GenStructuresForHeader())
+      .Change("<BASE_IMPL>", GenBaseImpl())
+      .Change("<INTERFACES>", GenInterfaces())
+      .Transform([&](std::string str) { return SmartIndent(str); })
+      .Out(stream);
+}
+
+std::string CppStubHeaderGenerator::GenBaseImpl() {
+  std::string code = GenExceptions();
+  if (options_->IsThreadEnabled())
+    code += CB_THREAD_BASE;
+
+  return code;
+}
+
+std::string CppStubHeaderGenerator::GenInterfaces() {
+  std::string code;
+  for (auto& block : GetDocument().GetBlocks()) {
+    if (block->GetType() != Block::TYPE_INTERFACE)
+      continue;
+
+    auto& iface = static_cast<Interface&>(*block);
+    code += GenInterface(iface) + NLine(1);
+  }
+
+  return code;
+}
+
+std::string CppStubHeaderGenerator::GenInterface(const Interface& iface) {
+  return std::string(
+      ReplaceAll(CB_INTERFACE_BASE)
+          .Change("<CLS_NAME>", iface.GetID())
+          .Change("<CALLBACKS>", GenInterfaceCallbacks(iface))
+          .Change("<SERVICE_BASE_METHODS>",
+              GenInterfaceServiceBaseMethods(iface))
+          .Change("<SERVICE_BASE_DISPATCH_FUNCS>",
+              GenInterfaceServiceBaseDispatchFuncs(iface))
+          .Change("<SERVICE_BASE_IMPL_THREAD_MEMBER>",
+              GenInterfaceServiceBaseImplThreadMember())
+          .Change("<METHOD_IDS>", GenMethodIds(iface))
+          .Change("<DELEGATE_IDS>", GenDelegateIds(iface)));
+}
+
+std::string CppStubHeaderGenerator::GenInterfaceCallbacks(
+    const Interface& iface) {
+  std::string code;
+  for (const auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() != Declaration::MethodType::DELEGATE)
+      continue;
+
+    if (code.empty()) {
+      code += ReplaceAll(CB_INTERFACE_CALLBACK_BASE)
+          .Change("<IFACE_NAME>", iface.GetID());
+      code += NLine(1);
+    }
+
+    code += ReplaceAll(CB_INTERFACE_CALLBACK)
+        .Change("<CLS_NAME>", decl->GetID())
+        .Change("<PARAMS>", GetParameters(decl->GetParameters()));
+    code += NLine(1);
+  }
+
+  if (options_->IsThreadEnabled())
+    code += CB_INTERFACE_PENDING_JOB;
+
+  return RemoveLine(code);
+}
+
+std::string CppStubHeaderGenerator::GenInterfaceServiceBaseMethods(
+    const Interface& iface) {
+  std::string code;
+  for (const auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() == Declaration::MethodType::DELEGATE)
+      continue;
+
+    code += ReplaceAll(CB_INTERFACE_SERVICE_BASE_METHOD)
+                .Change("<RETURN_TYPE>", ConvertTypeToString(decl->GetType()))
+                .Change("<NAME>", decl->GetID())
+                .Change("<PARAMS>", GetParameters(decl->GetParameters()));
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppStubHeaderGenerator::GenInterfaceServiceBaseDispatchFuncs(
+    const Interface& iface) {
+  std::string code;
+  for (const auto& decl : iface.GetDeclarations()) {
+    if (decl->GetMethodType() == Declaration::MethodType::DELEGATE)
+      continue;
+
+    code += ReplaceAll(CB_INTERFACE_SERVICE_BASE_DISPATCH_FUNC)
+                .Change("<NAME>", decl->GetID());
+  }
+
+  return RemoveLine(code);
+}
+
+std::string CppStubHeaderGenerator::GenInterfaceServiceBaseImplThreadMember() {
+  if (options_->IsThreadEnabled())
+    return std::string(CB_INTERFACE_SERVICE_BASE_IMPL_THREAD_MEMBER);
+
+  return "";
+}
+
+}  // namespace version2
+}  // namespace tidl
diff --git a/idlc/gen/version2/cpp_stub_header_generator.hh b/idlc/gen/version2/cpp_stub_header_generator.hh
new file mode 100644 (file)
index 0000000..46935b1
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_VERSION2_CPP_STUB_HEADER_GENERATOR_HH_
+#define IDLC_GEN_VERSION2_CPP_STUB_HEADER_GENERATOR_HH_
+
+#include <memory>
+#include <string>
+
+#include "idlc/gen/version2/cpp_generator_base.hh"
+#include "idlc/options.h"
+
+namespace tidl {
+namespace version2 {
+
+class CppStubHeaderGenerator : public CppGeneratorBase {
+ public:
+  explicit CppStubHeaderGenerator(std::shared_ptr<Document> doc,
+      std::shared_ptr<Options> options);
+  virtual ~CppStubHeaderGenerator() = default;
+
+  void OnInitGen(std::ofstream& stream) override;
+  void OnFiniGen(std::ofstream& stream) override;
+
+ private:
+  void GenNamespace(std::ofstream& stream);
+  std::string GenBaseImpl();
+  std::string GenInterfaces();
+  std::string GenInterface(const Interface& iface);
+  std::string GenInterfaceCallbacks(const Interface& iface);
+  std::string GenInterfaceServiceBaseMethods(const Interface& iface);
+  std::string GenInterfaceServiceBaseDispatchFuncs(const Interface& iface);
+  std::string GenInterfaceServiceBaseImplThreadMember();
+
+ private:
+  std::shared_ptr<Options> options_;
+};
+
+}  // namespace version2
+}  // namespace tidl
+
+#endif  // IDLC_GEN_VERSION2_CPP_STUB_HEADER_GENERATOR_HH_
diff --git a/idlc/gen/version2/cpp_stub_header_generator_cb.hh b/idlc/gen/version2/cpp_stub_header_generator_cb.hh
new file mode 100644 (file)
index 0000000..d585d5b
--- /dev/null
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IDLC_GEN_VERSION2_CPP_STUB_HEADER_GENERATOR_CB_HH_
+#define IDLC_GEN_VERSION2_CPP_STUB_HEADER_GENERATOR_CB_HH_
+
+namespace tidl {
+namespace version2 {
+
+constexpr const char CB_THREAD_BASE[] =
+R"__cpp_cb(
+class Job {
+ public:
+  class IEvent {
+   public:
+    virtual ~IEvent() = default;
+    virtual void OnRun() = 0;
+  };
+
+  Job(IEvent* listener) : listener_(listener) {}
+  Job() = default;
+  virtual ~Job() = default;
+
+  Job(const Job& job) {
+    listener_ = job.listener_;
+  }
+
+  Job& operator = (const Job& job) {
+    if (this != &job)
+      listener_ = job.listener_;
+
+    return *this;
+  }
+
+  Job(Job&& job) noexcept {
+    listener_ = job.listener_;
+    job.listener_ = nullptr;
+  }
+
+  Job& operator = (Job&& job) noexcept {
+    if (this != &job) {
+      listener_ = job.listener_;
+      job.listener_ = nullptr;
+    }
+
+    return *this;
+  }
+
+  void Do() {
+    if (listener_ != nullptr)
+      listener_->OnRun();
+  }
+
+ private:
+  IEvent* listener_ = nullptr;
+};
+
+template <class T>
+class SharedQueue {
+ public:
+  SharedQueue() = default;
+  virtual ~SharedQueue() = default;
+
+  void Push(T item) {
+    std::lock_guard<std::mutex> lock(mutex_);
+    queue_.push_back(item);
+    cond_var_.notify_one();
+  }
+
+  void PushFront(T item) {
+    std::lock_guard<std::mutex> lock(mutex_);
+    queue_.push_front(item);
+    cond_var_.notify_one();
+  }
+
+  bool TryAndPop(T& item) {
+    std::lock_guard<std::mutex> lock(mutex_);
+    if (queue_.empty())
+       return false;
+
+    item = queue_.front();
+    queue_.pop_front();
+
+    return true;
+  }
+
+  void WaitAndPop(T& item) {
+    std::unique_lock<std::mutex> lock(mutex_);
+    while (queue_.empty())
+      cond_var_.wait(lock);
+
+    item = queue_.front();
+    queue_.pop_front();
+  }
+
+  bool Empty() {
+    std::lock_guard<std::mutex> lock(mutex_);
+    return queue_.empty();
+  }
+
+  int Size() {
+    std::lock_guard<std::mutex> lock(mutex_);
+    return queue_.size();
+  }
+
+ private:
+  std::deque<T> queue_;
+  mutable std::mutex mutex_;
+  std::condition_variable cond_var_;
+};
+
+class ActiveObject : public Job::IEvent {
+ public:
+  ActiveObject() {
+    thread_ = std::thread([&]() -> void { RunThread(); });
+  }
+
+  virtual ~ActiveObject() {
+    Quit();
+    thread_.join();
+  }
+
+  void Send(std::shared_ptr<Job> job) {
+    queue_.Push(std::move(job));
+  }
+
+ private:
+  void Quit() {
+    Send(std::make_shared<Job>(new Job(this)));
+  }
+
+  void OnRun() override {
+    done_ = true;
+  }
+
+  void RunThread() {
+    do {
+      std::shared_ptr<Job> item;
+      queue_.WaitAndPop(item);
+      item->Do();
+    } while (!done_);
+  }
+
+ private:
+  std::thread thread_;
+  bool done_ = false;
+  SharedQueue<std::shared_ptr<Job>> queue_;
+};
+)__cpp_cb";
+
+/**
+ * <IFACE_NAME> The interface name.
+ */
+constexpr const char CB_INTERFACE_CALLBACK_BASE[] =
+R"__cpp_cb(
+class ServiceBase;
+
+class CallbackBase {
+ public:
+  CallbackBase(int delegate_id, bool once);
+  CallbackBase() = default;
+  virtual ~CallbackBase() = default;
+
+  int GetId() const;
+  void SetId(int id);
+
+  int GetSeqId() const;
+  void SetSeqId(int seq_id);
+
+  bool IsOnce() const;
+  void SetOnce(bool once);
+
+  std::string GetTag() const;
+
+ private:
+  static std::atomic<int> seq_num_;
+  int id_ = 0;
+  int seq_id_ = 0;
+  bool once_ = false;
+};
+)__cpp_cb";
+
+/**
+ * <CLS_NAME> The class name of the callback.
+ * <PARAMS> The parameters of the callback.
+ */
+constexpr const char CB_INTERFACE_CALLBACK[] =
+R"__cpp_cb(
+class <CLS_NAME> : public CallbackBase {
+ public:
+  <CLS_NAME>(rpc_port_h callback_port, std::weak_ptr<ServiceBase> service) : CallbackBase(static_cast<int>(DelegateId::<CLS_NAME>), false), callback_port_(callback_port), service_(std::move(service)) {}
+
+  void Invoke(<PARAMS>);
+
+ private:
+  rpc_port_h callback_port_;
+  std::weak_ptr<ServiceBase> service_;
+  bool valid_ = true;
+};
+)__cpp_cb";
+
+constexpr const char CB_INTERFACE_PENDING_JOB[] =
+R"__cpp_cb(
+class PendingJob : public Job, Job::IEvent {
+ public:
+  PendingJob(rpc_port_h port, rpc_port_h callback_port, rpc_port_parcel_h parcel, std::shared_ptr<ServiceBase> service);
+
+  virtual ~PendingJob();
+
+ private:
+  void OnRun() override;
+
+ private:
+  rpc_port_h port_;
+  rpc_port_h callback_port_;
+  rpc_port_parcel_h parcel_;
+  std::shared_ptr<ServiceBase> service_;
+};
+)__cpp_cb";
+
+/**
+ * <CLS_NAME> The class name of the interface.
+ * <CALLBACKS> The callbacks of the interface.
+ * <SERVICE_BASE_METHODS> The methods of service base of the interface.
+ * <SERVICE_BASE_DISPATCH_FUNCS> The dispatch function of service base of the interface.
+ * <SERVICE_BASE_IMPL_THREAD_MEMBER> The member variable of the thread of service base.
+ * <METHOD_IDS> The enumeration of methods of the interface.
+ * <DELEGATE_IDS> The enumeration of delegates(callbacks) of the interface.
+ */
+constexpr const char CB_INTERFACE_BASE[] =
+R"__cpp_cb(
+class <CLS_NAME> {
+ public:
+  <CALLBACKS>
+  class ServiceBase : public std::enable_shared_from_this<ServiceBase> {
+   public:
+    class Factory {
+     public:
+      virtual ~Factory() = default;
+
+      /// <summary>
+      /// The method for making service instances
+      /// </summary>
+      /// <param name="sender">The client app ID</param>
+      /// <param name="instance">The client instance ID</param>
+      virtual std::unique_ptr<ServiceBase> CreateService(std::string sender, std::string instance) = 0;
+    };
+
+    virtual ~ServiceBase() = default;
+
+    /// <summary>
+    /// Gets client app ID
+    /// </summary>
+    const std::string& GetSender() const {
+      return sender_;
+    }
+
+    /// <summary>
+    /// Gets client instance ID
+    /// </summary>
+    const std::string& GetInstance() const {
+      return instance_;
+    }
+
+    /// <summary>
+    /// Sets the client app port
+    /// </summary>
+    /// <param name="port">The port of the client</param>
+    void SetPort(rpc_port_h port);
+
+    /// <summary>
+    /// Disconnects from the client app
+    /// </summary>
+    /// <exception cref="InvalidIOException">
+    /// Thrown when internal I/O error happen.
+    /// </exception>
+    void Disconnect();
+
+    /// <summary>
+    /// This method will be called when the client is connected
+    /// </summary>
+    virtual void OnCreate() = 0;
+
+    /// <summary>
+    /// This method will be called when the client is disconnected
+    /// </summary>
+    virtual void OnTerminate() = 0;
+
+    void Dispatch(rpc_port_h port, rpc_port_h callback_port, rpc_port_parcel_h parcel, std::shared_ptr<ServiceBase> service);
+    void Dispatch(rpc_port_h port, rpc_port_h callback_port, rpc_port_parcel_h parcel);
+
+    <SERVICE_BASE_METHODS>
+
+   protected:
+    ServiceBase(std::string sender, std::string instance);
+
+   private:
+    using DispatchFunc = std::function<void(rpc_port_h, rpc_port_h, int, const UnitMap&)>;
+
+    <SERVICE_BASE_DISPATCH_FUNCS>
+
+    <SERVICE_BASE_IMPL_THREAD_MEMBER>
+
+   private:
+    std::string sender_;
+    std::string instance_;
+    rpc_port_h port_ = nullptr;
+    std::unordered_map<int, DispatchFunc> dispatch_funcs_;
+  };
+
+  <CLS_NAME>();
+  ~<CLS_NAME>();
+
+  /// <summary>
+  /// Listens to client apps
+  /// </summary>
+  /// <param name="service_factory">The factory object for making service instances</param>
+  /// <exception cref="InvalidIOException">
+  /// Thrown when internal I/O error happen.
+  /// </exception>
+  void Listen(std::shared_ptr<ServiceBase::Factory> service_factory);
+
+  /// <summary>
+  /// Gets service objects which are connected
+  /// </summary>
+  /// <returns>The list of service objects which are connected</returns>
+  const std::list<std::shared_ptr<ServiceBase>>& GetServices() const {
+    return services_;
+  }
+
+ private:
+  <METHOD_IDS>
+  <DELEGATE_IDS>
+
+  static void OnConnectedCb(const char* sender, const char* instance, void* user_data);
+  static void OnDisconnectedCb(const char* sender, const char* instance, void* user_data);
+  static int OnReceivedCb(const char* sender, const char* instance, rpc_port_h port, void* user_data);
+
+ private:
+  rpc_port_stub_h stub_ = nullptr;
+  std::shared_ptr<ServiceBase::Factory> service_factory_;
+  std::list<std::shared_ptr<ServiceBase>> services_;
+};
+)__cpp_cb";
+
+/**
+ * <RETURN_TYPE> The return type of the method of the interface.
+ * <NAME> The method name of the interface.
+ * <PARAMS> The parameters of the method.
+ */
+constexpr const char CB_INTERFACE_SERVICE_BASE_METHOD[] =
+R"__cpp_cb(
+virtual <RETURN_TYPE> <NAME>(<PARAMS>) = 0;
+)__cpp_cb";
+
+/**
+ * <NAME> The method name of the interface.
+ */
+constexpr const char CB_INTERFACE_SERVICE_BASE_DISPATCH_FUNC[] =
+R"__cpp_cb(
+void Dispatch<NAME>(rpc_port_h port, rpc_port_h callback_port, int seq_num, const UnitMap& unit_map);
+)__cpp_cb";
+
+constexpr const char CB_INTERFACE_SERVICE_BASE_IMPL_THREAD_MEMBER[] =
+R"__cpp_cb(
+std::unique_ptr<ActiveObject> active_object_;
+)__cpp_cb";
+
+}  // namespace version2
+}  // namespace tidl
+
+#endif  // IDLC_GEN_VERSION2_CPP_STUB_HEADER_GENERATOR_CB_HH_
index 10cbc9f..799a98b 100644 (file)
 #include "idlc/gen/version2/c_stub_body_generator.hh"
 #include "idlc/gen/version2/c_group_header_generator.hh"
 #include "idlc/gen/version2/c_group_body_generator.hh"
+#include "idlc/gen/version2/cpp_proxy_body_generator.hh"
+#include "idlc/gen/version2/cpp_proxy_header_generator.hh"
+#include "idlc/gen/version2/cpp_stub_header_generator.hh"
+#include "idlc/gen/version2/cpp_stub_body_generator.hh"
 #include "idlc/gen_cion/c_cion_proxy_header_gen.h"
 #include "idlc/gen_cion/c_cion_proxy_body_gen.h"
 #include "idlc/gen_cion/c_cion_stub_header_gen.h"
@@ -73,7 +77,6 @@
 
 #include "idlc/options.h"
 
-
 #include "idlc/gen_cion/java_cion_stub_gen.h"
 #include "idlc/gen_cion/java_cion_stub_repo_gen.h"
 #include "idlc/gen_cion/java_cion_proxy_gen.h"
@@ -282,10 +285,18 @@ void GenerateStubCodes(std::shared_ptr<tidl::Options> options,
     }
     case tidl::Options::LANGUAGE_TYPE_CPP:
     {
-      tidl::CppStubHeaderGen stub_header(ps.GetDoc(), options);
-      stub_header.Run(options->GetOutput() + ".h");
-      tidl::CppStubBodyGen stub_body(ps.GetDoc(), options);
-      stub_body.Run(options->GetOutput() + ".cc");
+      if (ps.GetVersion() == 2) {
+        tidl::version2::CppStubHeaderGenerator stub_header(
+            ps.GetDoc(), options);
+        stub_header.Run(options->GetOutput() + ".h");
+        tidl::version2::CppStubBodyGenerator stub_body(ps.GetDoc(), options);
+        stub_body.Run(options->GetOutput() + ".cc");
+      } else {
+        tidl::CppStubHeaderGen stub_header(ps.GetDoc(), options);
+        stub_header.Run(options->GetOutput() + ".h");
+        tidl::CppStubBodyGen stub_body(ps.GetDoc(), options);
+        stub_body.Run(options->GetOutput() + ".cc");
+      }
       break;
     }
     case tidl::Options::LANGUAGE_TYPE_CSHARP:
@@ -510,10 +521,17 @@ void GenerateProxyCodes(std::shared_ptr<tidl::Options> options,
     }
     case tidl::Options::LANGUAGE_TYPE_CPP:
     {
-      tidl::CppProxyHeaderGen proxy_header(ps.GetDoc());
-      proxy_header.Run(options->GetOutput() + ".h");
-      tidl::CppProxyBodyGen proxy_body(ps.GetDoc());
-      proxy_body.Run(options->GetOutput() + ".cc");
+      if (ps.GetVersion() == 2) {
+        tidl::version2::CppProxyHeaderGenerator proxy_header(ps.GetDoc());
+        proxy_header.Run(options->GetOutput() + ".h");
+        tidl::version2::CppProxyBodyGenerator proxy_body(ps.GetDoc());
+        proxy_body.Run(options->GetOutput() + ".cc");
+      } else {
+        tidl::CppProxyHeaderGen proxy_header(ps.GetDoc());
+        proxy_header.Run(options->GetOutput() + ".h");
+        tidl::CppProxyBodyGen proxy_body(ps.GetDoc());
+        proxy_body.Run(options->GetOutput() + ".cc");
+      }
       break;
     }
     case tidl::Options::LANGUAGE_TYPE_CSHARP:
index 85689a5..58899b4 100644 (file)
@@ -97,6 +97,8 @@ SET(TIDL_GEN_SRCS
   FooPubsubCionGroupC.c
   Message_v2ProxyC.c
   Message_v2StubC.c
+  Message_v2testProxyCpp.cc
+  Message_v2testStubCpp.cc
   Buffer_v2ProxyC.c
   Buffer_v2StubC.c
   Ex_v2ProxyC.c
index 7a80e19..76e2476 100755 (executable)
@@ -60,6 +60,14 @@ GenerateTIDL() {
     ${TIDLC} -s -n -l C -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
   done
 
+  INPUT="${FILES_V2[0]}test.tidl"
+
+  OUTPUT="${FILES_V2[0]}testProxyCpp"
+  ${TIDLC} -p -n -l C++ -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+
+  OUTPUT="${FILES_V2[0]}testStubCpp"
+  ${TIDLC} -s -n -l C++ -i ${SCRIPT_DIR}/tidl/${INPUT} -o ${TARGET_DIR}/${OUTPUT}
+
   for index in ${!FILES_FOR_GROUP[*]}; do
     echo "Generate ${FILES_FOR_GROUP[index]}"
 
diff --git a/tests/build_tests/tidl/Message_v2test.tidl b/tests/build_tests/tidl/Message_v2test.tidl
new file mode 100644 (file)
index 0000000..5bfae2b
--- /dev/null
@@ -0,0 +1,16 @@
+protocol 2
+
+struct Envelope {
+  list<string> string_list;
+  array<bundle> bundle_array;
+}
+
+interface Message {
+  void NotifyCB(string sender, string msg) delegate;
+
+  int Register(string name, NotifyCB cb);
+  void Unregister() async;
+  int Send(string msg);
+  int SendFiles(list<file> files);
+  int SendFile(file f);
+}