コード例 #1
0
  protected void outputConvertedStruct(
      Struct struct,
      Signatures signatures,
      DeclarationsHolder out,
      Identifier callerLibraryClass,
      String callerLibrary,
      boolean onlyFields)
      throws IOException {
    Struct structJavaClass =
        convertStruct(struct, signatures, callerLibraryClass, callerLibrary, onlyFields);
    if (structJavaClass == null) return;

    if (result.config.putTopStructsInSeparateFiles
        && struct.findParentOfType(Struct.class) == null) {
      String library = result.getLibrary(struct);
      Identifier javaPackage = result.getLibraryPackage(library);
      Identifier fullClassName = ident(javaPackage, structJavaClass.getTag().clone());

      if (result.config.runtime == JNAeratorConfig.Runtime.BridJ)
        structJavaClass.addAnnotation(new Annotation(org.bridj.ann.Library.class, expr(library)));
      structJavaClass.removeModifiers(ModifierType.Static);
      structJavaClass =
          result.notifyBeforeWritingClass(fullClassName, structJavaClass, signatures, library);
      if (structJavaClass != null) {
        PrintWriter pout = result.classOutputter.getClassSourceWriter(fullClassName.toString());
        result.printJavaClass(javaPackage, structJavaClass, pout);
        pout.close();
      }
    } else out.addDeclaration(decl(structJavaClass));
  }
コード例 #2
0
  public void convertStructs(
      List<Struct> structs,
      Signatures signatures,
      DeclarationsHolder out,
      Identifier libraryClassName,
      String library)
      throws IOException {
    if (structs != null) {
      for (Struct struct : structs) {
        if (struct.findParentOfType(Struct.class) != null) continue;

        if (!result.config.genCPlusPlus && struct.getType().isCpp()) continue;

        outputConvertedStruct(struct, signatures, out, libraryClassName, library, false);
      }
    }
  }