Search in sources :

Example 6 with Import

use of com.google.devtools.j2objc.types.Import in project j2objc by google.

the class ObjectiveCSegmentedHeaderGenerator method printTypeDeclaration.

@Override
protected void printTypeDeclaration(GeneratedType type) {
    String typeName = type.getTypeName();
    String code = type.getPublicDeclarationCode();
    if (code.length() == 0) {
        return;
    }
    newline();
    printf("#if !defined (%s_) && (INCLUDE_ALL_%s || defined(INCLUDE_%s))\n", typeName, varPrefix, typeName);
    printf("#define %s_\n", typeName);
    Set<Import> forwardDeclarations = Sets.newHashSet(type.getHeaderForwardDeclarations());
    for (Import imp : type.getHeaderIncludes()) {
        // Verify this import isn't declared in this source file.
        if (isLocalType(imp.getTypeName())) {
            continue;
        }
        newline();
        printf("#define RESTRICT_%s 1\n", getVarPrefix(imp.getImportFileName()));
        printf("#define INCLUDE_%s 1\n", imp.getTypeName());
        printf("#include \"%s\"\n", imp.getImportFileName());
        forwardDeclarations.remove(imp);
    }
    printForwardDeclarations(forwardDeclarations);
    print(code);
    newline();
    println("#endif");
}
Also used : Import(com.google.devtools.j2objc.types.Import)

Aggregations

Import (com.google.devtools.j2objc.types.Import)6 HeaderImportCollector (com.google.devtools.j2objc.types.HeaderImportCollector)2 ImplementationImportCollector (com.google.devtools.j2objc.types.ImplementationImportCollector)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Options (com.google.devtools.j2objc.Options)1 CompilationUnit (com.google.devtools.j2objc.ast.CompilationUnit)1 NameTable (com.google.devtools.j2objc.util.NameTable)1 TypeElement (javax.lang.model.element.TypeElement)1