zetasql/resolved_ast/gen_resolved_ast.py
def _ResolveImportEnums(self, cpp_class_name):
    """Import enums under <cpp_class_name>Enums message into the C++ class.

    Args:
      cpp_class_name: C++ class name the enums should be imported into.

    Returns:
      Tuple of C++ declarations and definitions for the .h and .cc files.

    Load definitions of enums defined under <cpp_class_name>Enums message in
    resolved_ast_enums.proto if any, and convert them to C++ declarations and
    definitions to be included in the generated .h/.cc files, so that the enum
    values can be referred as static consts under the C++ class.
    E.g.: if cpp_class_name='ResolvedWindowFrame' and there's a FrameUnit enum
    defined under ResolvedWindowFrameEnums in resolved_ast_enums.proto as:
    message ResolvedWindowFrameEnums {
      enum FrameUnit {
        ROWS = 0;
        RANGE = 1;
      };
    };
    then this function will return the C++ declarations:
      typedef ResolvedWindowFrameEnums::FrameUnit FrameUnit;
      static const FrameUnit ROWS = ResolvedWindowFrameEnums::ROWS;
      static const FrameUnit RANGE = ResolvedWindowFrameEnums::RANGE;
    which should be included in the class declaration, and C++ definitions:
      const ResolvedWindowFrame::FrameUnit ResolvedWindowFrame::ROWS;
      const ResolvedWindowFrame::FrameUnit ResolvedWindowFrame::RANGE;
    which should be included in the .cc file.

    """
    message_types = resolved_ast_enums_pb2.DESCRIPTOR.message_types_by_name
    message_name = cpp_class_name + 'Enums'

    # Hack: We import the same enum names into ResolvedArgument{Ref,Def}.
    if message_name == 'ResolvedArgumentRefEnums':
      message_name = 'ResolvedArgumentDefEnums'

    if message_name not in message_types:
      return '', ''

    typedefs = []
    declarations = []
    definitions = []

    for enum_type in message_types[message_name].enum_types:
      enum_name = enum_type.name
      typedefs.append('  typedef %s::%s %s;\n' % (message_name, enum_name,
                                                  enum_name))
      for value in enum_type.values:
        declarations.append('  static const %s %s = %s::%s;\n' %
                            (enum_name, value.name, message_name, value.name))
        definitions.append('const %s::%s %s::%s;\n' %
                           (cpp_class_name, enum_name, cpp_class_name,
                            value.name))
    return ''.join(typedefs) + ''.join(declarations), ''.join(definitions)
Import enums under <cpp_class_name>Enums message into the C++ class.

    Args:
      cpp_class_name: C++ class name the enums should be imported into.

    Returns:
      Tuple of C++ declarations and definitions for the .h and .cc files.

    Load definitions of enums defined under <cpp_class_name>Enums message in
    resolved_ast_enums.proto if any, and convert them to C++ declarations and
    definitions to be included in the generated .h/.cc files, so that the enum
    values can be referred as static consts under the C++ class.
    E.g.: if cpp_class_name='ResolvedWindowFrame' and there's a FrameUnit enum
    defined under ResolvedWindowFrameEnums in resolved_ast_enums.proto as:
    message ResolvedWindowFrameEnums {
      enum FrameUnit {
        ROWS = 0;
        RANGE = 1;
      };
    };
    then this function will return the C++ declarations:
      typedef ResolvedWindowFrameEnums::FrameUnit FrameUnit;
      static const FrameUnit ROWS = ResolvedWindowFrameEnums::ROWS;
      static const FrameUnit RANGE = ResolvedWindowFrameEnums::RANGE;
    which should be included in the class declaration, and C++ definitions:
      const ResolvedWindowFrame::FrameUnit ResolvedWindowFrame::ROWS;
      const ResolvedWindowFrame::FrameUnit ResolvedWindowFrame::RANGE;
    which should be included in the .cc file.

    
Import enums under Enums message into the C++ class.
Import enums under Enums message into the C ++ class .
def _ResolveImportEnums(self, cpp_class_name):
    message_types = resolved_ast_enums_pb2.DESCRIPTOR.message_types_by_name
    message_name = cpp_class_name + 'Enums'
    if message_name == 'ResolvedArgumentRefEnums':
      message_name = 'ResolvedArgumentDefEnums'
    if message_name not in message_types:
      return '', ''
    typedefs = []
    declarations = []
    definitions = []
    for enum_type in message_types[message_name].enum_types:
      enum_name = enum_type.name
      typedefs.append('  typedef %s::%s %s;\n' % (message_name, enum_name,
                                                  enum_name))
      for value in enum_type.values:
        declarations.append('  static const %s %s = %s::%s;\n' %
                            (enum_name, value.name, message_name, value.name))
        definitions.append('const %s::%s %s::%s;\n' %
                           (cpp_class_name, enum_name, cpp_class_name,
                            value.name))
    return ''.join(typedefs) + ''.join(declarations), ''.join(definitions)
def _ResolveImportEnums ( self , cpp_class_name ) : message_types = resolved_ast_enums_pb2 . DESCRIPTOR . message_types_by_name message_name = cpp_class_name + 'Enums' if message_name == 'ResolvedArgumentRefEnums' : message_name = 'ResolvedArgumentDefEnums' if message_name not in message_types : return '' , '' typedefs = [ ] declarations = [ ] definitions = [ ] for enum_type in message_types [ message_name ] . enum_types : enum_name = enum_type . name typedefs . append ( '  typedef %s::%s %s;\n' % ( message_name , enum_name , enum_name ) ) for value in enum_type . values : declarations . append ( '  static const %s %s = %s::%s;\n' % ( enum_name , value . name , message_name , value . name ) ) definitions . append ( 'const %s::%s %s::%s;\n' % ( cpp_class_name , enum_name , cpp_class_name , value . name ) ) return '' . join ( typedefs ) + '' . join ( declarations ) , '' . join ( definitions )
Import enums under <cpp_class_name>Enums message into the C++ class.
Import enums under <cpp_class_name > Enums message into the C ++ class .
"""Import enums under <cpp_class_name>Enums message into the C++ class.

    Args:
      cpp_class_name: C++ class name the enums should be imported into.

    Returns:
      Tuple of C++ declarations and definitions for the .h and .cc files.

    Load definitions of enums defined under <cpp_class_name>Enums message in
    resolved_ast_enums.proto if any, and convert them to C++ declarations and
    definitions to be included in the generated .h/.cc files, so that the enum
    values can be referred as static consts under the C++ class.
    E.g.: if cpp_class_name='ResolvedWindowFrame' and there's a FrameUnit enum
    defined under ResolvedWindowFrameEnums in resolved_ast_enums.proto as:
    message ResolvedWindowFrameEnums {
      enum FrameUnit {
        ROWS = 0;
        RANGE = 1;
      };
    };
    then this function will return the C++ declarations:
      typedef ResolvedWindowFrameEnums::FrameUnit FrameUnit;
      static const FrameUnit ROWS = ResolvedWindowFrameEnums::ROWS;
      static const FrameUnit RANGE = ResolvedWindowFrameEnums::RANGE;
    which should be included in the class declaration, and C++ definitions:
      const ResolvedWindowFrame::FrameUnit ResolvedWindowFrame::ROWS;
      const ResolvedWindowFrame::FrameUnit ResolvedWindowFrame::RANGE;
    which should be included in the .cc file.

    """ # Hack: We import the same enum names into ResolvedArgument{Ref,Def}.
Tuple of C++ declarations and definitions for the .h and .cc files.
Tuple of C ++ declarations and definitions for the . h and . cc files .
self
cpp_class_name
C++ class name the enums should be imported into.
C ++ class name the enums should be imported into .