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, six.string_types): 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_or_builtin(expr): return (self.HAS_FEATURE_OR_BUILTIN.sub(r"\1\2", expr).replace( "-", "_").replace("+", "_")) self.context = self.Context( (normalize_has_feature_or_builtin(k), normalize_numbers(v)) for k, v in six.iteritems(context)) try: return Preprocessor.do_if( self, normalize_has_feature_or_builtin(expression), **kwargs) finally: self.context = context
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
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
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