本文整理汇总了Python中mozbuild.preprocessor.Preprocessor.do_if方法的典型用法代码示例。如果您正苦于以下问题:Python Preprocessor.do_if方法的具体用法?Python Preprocessor.do_if怎么用?Python Preprocessor.do_if使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozbuild.preprocessor.Preprocessor
的用法示例。
在下文中一共展示了Preprocessor.do_if方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_if
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_if [as 别名]
def do_if(self, *args, **kwargs):
# The C preprocessor handles numbers following C rules, which is a
# different handling than what our Preprocessor does out of the box.
# Hack around it enough that the configure tests work properly.
context = self.context
def normalize_numbers(value):
if isinstance(value, types.StringTypes):
if value[-1:] == 'L' and value[:-1].isdigit():
value = int(value[:-1])
return value
self.context = self.Context(
(k, normalize_numbers(v)) for k, v in context.iteritems()
)
try:
return Preprocessor.do_if(self, *args, **kwargs)
finally:
self.context = context
示例2: do_if
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_if [as 别名]
def do_if(self, expression, **kwargs):
# The C preprocessor handles numbers following C rules, which is a
# different handling than what our Preprocessor does out of the box.
# Hack around it enough that the configure tests work properly.
context = self.context
def normalize_numbers(value):
if isinstance(value, types.StringTypes):
if value[-1:] == 'L' and value[:-1].isdigit():
value = int(value[:-1])
return value
# Our Preprocessor doesn't handle macros with parameters, so we hack
# around that for __has_feature()-like things.
def normalize_has_feature(expr):
return self.HAS_FEATURE.sub(r'\1\2', expr)
self.context = self.Context(
(normalize_has_feature(k), normalize_numbers(v))
for k, v in context.iteritems()
)
try:
return Preprocessor.do_if(self, normalize_has_feature(expression),
**kwargs)
finally:
self.context = context