1# Copyright (C) 2013 Google Inc. All rights reserved. 2# 3# Redistribution and use in source and binary forms, with or without 4# modification, are permitted provided that the following conditions are 5# met: 6# 7# * Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. 9# * Redistributions in binary form must reproduce the above 10# copyright notice, this list of conditions and the following disclaimer 11# in the documentation and/or other materials provided with the 12# distribution. 13# * Neither the name of Google Inc. nor the names of its 14# contributors may be used to endorse or promote products derived from 15# this software without specific prior written permission. 16# 17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 29from blinkbuild.name_style_converter import NameStyleConverter 30 31 32def cpp_bool(value): 33 if value is True: 34 return 'true' 35 if value is False: 36 return 'false' 37 # Return value as is, which for example may be a platform-dependent constant 38 # such as "defaultSelectTrailingWhitespaceEnabled". 39 return value 40 41 42def cpp_name(entry): 43 return entry['ImplementedAs'] or entry['name'].original 44 45 46def enum_key_for_css_keyword(keyword): 47 return 'k' + _upper_camel_case(keyword) 48 49 50def enum_key_for_css_property(property_name): 51 return 'k' + _upper_camel_case(property_name) 52 53 54def enum_key_for_css_property_alias(property_name): 55 return 'kAlias' + property_name.to_upper_camel_case() 56 57 58# This id is used to build function names returning CSS properties (e.g. 59# GetCSSPropertyX(), GetCSSPropertyXInternal(), etc.) 60def id_for_css_property(property_name): 61 return 'CSSProperty' + _upper_camel_case(property_name) 62 63 64def id_for_css_property_alias(property_name): 65 return 'CSSPropertyAlias' + property_name.to_upper_camel_case() 66 67 68def _upper_camel_case(property_name): 69 converter = NameStyleConverter(property_name) if isinstance( 70 property_name, str) else property_name 71 return converter.to_upper_camel_case() 72