Exemplo n.º 1
0
  @Override
  public void generate(
      final Ds3ApiSpec spec,
      final FileUtils fileUtils,
      final Path destDir,
      final Ds3DocSpec docSpec)
      throws IOException {
    this.fileUtils = fileUtils;

    try {
      final ImmutableList<Request> allRequests = getAllRequests(spec, docSpec);
      final ImmutableList<Enum> allEnums = getAllEnums(spec);
      final ImmutableSet<String> enumNames = EnumHelper.getEnumNamesSet(allEnums);

      final ImmutableSet<String> arrayMemberTypes = getArrayMemberTypes(spec, enumNames);

      final ImmutableSet<String> embeddedTypes = getEmbeddedTypes(spec, enumNames);
      final ImmutableSet<String> responseTypes = RequestHelper.getResponseTypes(allRequests);
      final ImmutableSet<String> paginatedTypes = getPaginatedTypes(spec);

      final ImmutableList<Struct> allStructs =
          getAllStructs(
              spec, enumNames, responseTypes, embeddedTypes, arrayMemberTypes, paginatedTypes);

      generateHeader(allEnums, allStructs, allRequests);
      generateSource(allEnums, allStructs, allRequests);
      generateStaticFiles();
    } catch (final ParseException e) {
      LOG.error("Caught exception: ", e);
    }
  }
Exemplo n.º 2
0
 public CCodeGenerator() throws TemplateModelException {
   config.setDefaultEncoding("UTF-8");
   config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
   config.setClassForTemplateLoading(CCodeGenerator.class, "/templates");
   config.setSharedVariable("cTypeHelper", C_TypeHelper.getInstance());
   config.setSharedVariable("enumHelper", EnumHelper.getInstance());
   config.setSharedVariable("requestHelper", RequestHelper.getInstance());
   config.setSharedVariable("helper", Helper.getInstance());
   config.setSharedVariable("structHelper", StructHelper.getInstance());
   config.setSharedVariable("structMemberHelper", StructMemberHelper.getInstance());
   config.setSharedVariable("parameterHelper", ParameterHelper.getInstance());
 }