use of org.gradle.language.nativeplatform.internal.Macro in project gradle by gradle.
the class RegexBackedCSourceParser method parseSource.
protected IncludeDirectives parseSource(Reader sourceReader) throws IOException {
Set<Include> includes = Sets.newLinkedHashSet();
List<Macro> macros = Lists.newArrayList();
List<MacroFunction> macroFunctions = Lists.newArrayList();
BufferedReader reader = new BufferedReader(sourceReader);
PreprocessingReader lineReader = new PreprocessingReader(reader);
Buffer buffer = new Buffer();
while (true) {
buffer.reset();
if (!lineReader.readNextLine(buffer.value)) {
break;
}
buffer.consumeWhitespace();
if (!buffer.consume('#')) {
continue;
}
buffer.consumeWhitespace();
if (buffer.consume("define")) {
parseDefineDirectiveBody(buffer, macros, macroFunctions);
} else if (buffer.consume("include")) {
parseIncludeOrImportDirectiveBody(buffer, false, includes);
} else if (buffer.consume("import")) {
parseIncludeOrImportDirectiveBody(buffer, true, includes);
}
}
return new DefaultIncludeDirectives(ImmutableList.copyOf(includes), ImmutableList.copyOf(macros), ImmutableList.copyOf(macroFunctions));
}
use of org.gradle.language.nativeplatform.internal.Macro in project gradle by gradle.
the class DefaultSourceIncludesResolver method resolveMacro.
private void resolveMacro(MacroLookup visibleMacros, Expression expression, ExpressionVisitor visitor, TokenLookup tokenLookup) {
boolean found = false;
for (IncludeDirectives includeDirectives : visibleMacros) {
Iterable<Macro> macros = includeDirectives.getMacros(expression.getValue());
for (Macro macro : macros) {
found = true;
resolveExpression(visibleMacros, macro, visitor, tokenLookup);
}
}
if (!found) {
visitor.visitIdentifier(new SimpleExpression(expression.getValue(), IncludeType.IDENTIFIER));
}
}
Aggregations