2 Star 0 Fork 0

chromium_develop/chromium_tools

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
util_cc_helper.py 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
李想 提交于 3年前 . chromium origin init
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
_API_UTIL_NAMESPACE = 'json_schema_compiler::util'
class UtilCCHelper(object):
"""A util class that generates code that uses
tools/json_schema_compiler/util.cc.
"""
def __init__(self, type_manager):
self._type_manager = type_manager
def PopulateArrayFromListFunction(self, optional):
"""Returns the function to turn a list into a vector.
"""
populate_list_fn = ('PopulateOptionalArrayFromList' if optional
else 'PopulateArrayFromList')
return ('%s::%s') % (_API_UTIL_NAMESPACE, populate_list_fn)
def CreateValueFromArray(self, src, optional):
"""Generates code to create a scoped_pt<Value> from the array at src.
|src| The variable to convert, either a vector or std::unique_ptr<vector>.
|optional| Whether |type_| was optional. Optional types are pointers so
must be treated differently.
"""
if optional:
name = 'CreateValueFromOptionalArray'
else:
name = 'CreateValueFromArray'
return '%s::%s(%s)' % (_API_UTIL_NAMESPACE, name, src)
def GetIncludePath(self):
return '#include "tools/json_schema_compiler/util.h"'
def GetValueTypeString(self, value, is_ptr=False):
call = '.type()'
if is_ptr:
call = '->type()'
return 'std::string(base::Value::GetTypeName(%s%s))' % (value, call)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chromium_develop/chromium_tools.git
git@gitee.com:chromium_develop/chromium_tools.git
chromium_develop
chromium_tools
chromium_tools
master

搜索帮助