Beispiel #1
0
def relative_dest(fs, filename):
    """Returns a destination path string for given filename.

    |filename| is a path relative to third_party/WebKit, and the resultant path
    is relative to third_party/blink.
    """
    dest = None
    if filename.startswith('Source'):
        dest = re.sub(r'^Source', 'renderer', filename)
    elif filename.startswith('common') or filename.startswith('public'):
        dest = filename
    else:
        raise ValueError(
            '|filename| must start with "common", "public", or "Source": %s' %
            filename)
    if filename.endswith(
        ('.h', '.cpp', '.mm', '.idl', '.typemap', 'Settings.json5')):
        dirname, basename = fs.split(dest)
        basename, ext = fs.splitext(basename)
        # Skip some inspector-related files. #includes for these files are
        # generated by a script outside of Blink.
        if (re.match(r'Inspector.*Agent', basename)
                or basename == 'InspectorTraceEvents'
                or basename == 'PerformanceMonitor'
                or basename == 'PlatformTraceEventsAgent'):
            return dest
        if filename.endswith('.cpp'):
            ext = '.cc'
        # WebKit.h should be renamed to blink.h.
        if basename == 'WebKit' and ext == '.h':
            basename = 'blink'
        if basename.lower() != basename:
            basename = NameStyleConverter(basename).to_snake_case()
        return fs.join(dirname, basename + ext)
    return dest
 def create_method(self, idl_operation, arguments):
     name_converter = NameStyleConverter(idl_operation.name)
     return_type = self.type_resolver.type_from_definition(idl_operation)
     return {
         'name': name_converter.to_upper_camel_case(),
         'type': return_type,
         'arguments': arguments
     }
    def _replace_include_path(self, match):
        include_or_import = match.group(1)
        path = match.group(2)

        # If |path| starts with 'blink/public/resources', we should prepend
        # 'third_party/'.
        #
        # If |path| starts with 'third_party/WebKit', we should adjust the
        # directory name for third_party/blink, and replace its basename by
        # self._basename_map.
        #
        # If |path| starts with a Blink-internal directory such as bindings,
        # core, modules, platform, public, it refers to a checked-in file, or a
        # generated file. For the former, we should add 'third_party/blink/' and
        # replace the basename.  For the latter, we should update the basename
        # for a name mapped from an IDL renaming, and should add
        # 'third_party/blink/'.

        if path.startswith('blink/public/resources'):
            path = path.replace('blink/public', 'third_party/blink/public')
            return '#%s "%s"' % (include_or_import, path)

        if path.startswith('third_party/WebKit'):
            path = path.replace('third_party/WebKit/Source',
                                'third_party/blink/renderer')
            path = path.replace('third_party/WebKit/common',
                                'third_party/blink/common')
            path = path.replace('third_party/WebKit/public',
                                'third_party/blink/public')
            path = self._update_basename(path)
            return '#%s "%s"' % (include_or_import, path)

        match = None
        for regex in self._checked_in_header_re_list:
            match = regex.search(path)
            if match:
                break
        if match:
            if match.group(1) in self._basename_map:
                path = path[:match.start(1)] + self._basename_map[match.group(
                    1)]
        elif 'core/inspector/protocol/' not in path:
            basename_start = path.rfind('/') + 1
            basename = path[basename_start:]
            if basename in self._idl_generated_impl_headers:
                path = path[:basename_start] + self._basename_map[basename]
            elif basename.startswith('V8'):
                path = path[:basename_start] + NameStyleConverter(
                    basename[:len(basename) - 2]).to_snake_case() + '.h'
        if path.startswith('public'):
            path = 'third_party/blink/' + path
        else:
            path = 'third_party/blink/renderer/' + path
        return '#%s "%s"' % (include_or_import, path)
Beispiel #4
0
def to_snake_case(name):
    if name.lower() == name:
        return name
    return NameStyleConverter(name).to_snake_case()
 def get_file_basename(self, name):
     # Use NameStyleConverter instead of name_utilities for consistency.
     if self.snake_case_source_files:
         return NameStyleConverter(name).to_snake_case()
     return name
 def create_argument(self, argument_name, argument_type):
     name_converter = NameStyleConverter(argument_name)
     return {
         'name': name_converter.to_snake_case(),
         'type': argument_type.base_type,
     }
 def set_class_name(self, class_name):
     converter = NameStyleConverter(class_name)
     self.result['class_name'] = converter.to_all_cases()
     self._ensure_set('cpp_includes').update(
         self.type_resolver.includes_from_interface(class_name))