Search in sources :

Example 1 with NetCodeGenerator

use of com.spectralogic.ds3autogen.net.NetCodeGenerator in project ds3_autogen by SpectraLogic.

the class Main method run.

public void run() throws Exception {
    final Ds3SpecParser parser = new Ds3SpecParserImpl();
    System.out.println("Generating " + args.getType().toString() + " ds3 sdk code for the spec " + args.getInputSpec());
    //TODO make the input file also accept a url that we can read from
    final Ds3ApiSpec spec = parser.getSpec(Files.newInputStream(Paths.get(args.getInputSpec())), args.generateInternal());
    final CodeGenerator generator;
    switch(args.getType()) {
        case C:
            generator = new CCodeGenerator();
            break;
        case JAVA:
            generator = new JavaCodeGenerator();
            break;
        case NET:
            generator = new NetCodeGenerator();
            break;
        case PYTHON:
            generator = new PythonCodeGenerator();
            break;
        case PYTHON3:
            generator = new Python3CodeGenerator();
            break;
        case GO:
            generator = new GoCodeGenerator();
            break;
        default:
            throw new IllegalArgumentException("Unknown generator typeName " + args.getType().toString());
    }
    final FileUtils fileUtils = new FileUtilsImpl();
    final Ds3DocSpec docSpec;
    if (args.isNoDoc()) {
        docSpec = new Ds3DocSpecEmptyImpl();
    } else {
        final Ds3DocSpecParser docSpecParser = new Ds3DocSpecParserImpl(new NameMapper());
        docSpec = docSpecParser.getDocSpec();
    }
    generator.generate(spec, fileUtils, Paths.get(args.getTargetDir()), docSpec);
}
Also used : PythonCodeGenerator(com.spectralogic.ds3autogen.python.PythonCodeGenerator) FileUtilsImpl(com.spectralogic.ds3autogen.utils.FileUtilsImpl) Ds3SpecParser(com.spectralogic.ds3autogen.api.Ds3SpecParser) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) NetCodeGenerator(com.spectralogic.ds3autogen.net.NetCodeGenerator) Ds3DocSpecParserImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecParserImpl) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) Ds3SpecParserImpl(com.spectralogic.ds3autogen.Ds3SpecParserImpl) JavaCodeGenerator(com.spectralogic.ds3autogen.java.JavaCodeGenerator) Python3CodeGenerator(com.spectralogic.ds3autogen.python3.Python3CodeGenerator) PythonCodeGenerator(com.spectralogic.ds3autogen.python.PythonCodeGenerator) CodeGenerator(com.spectralogic.ds3autogen.api.CodeGenerator) NetCodeGenerator(com.spectralogic.ds3autogen.net.NetCodeGenerator) CCodeGenerator(com.spectralogic.ds3autogen.c.CCodeGenerator) GoCodeGenerator(com.spectralogic.ds3autogen.go.GoCodeGenerator) GoCodeGenerator(com.spectralogic.ds3autogen.go.GoCodeGenerator) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) Python3CodeGenerator(com.spectralogic.ds3autogen.python3.Python3CodeGenerator) NameMapper(com.spectralogic.ds3autogen.NameMapper) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) CCodeGenerator(com.spectralogic.ds3autogen.c.CCodeGenerator) Ds3DocSpecParser(com.spectralogic.ds3autogen.api.Ds3DocSpecParser) JavaCodeGenerator(com.spectralogic.ds3autogen.java.JavaCodeGenerator)

Example 2 with NetCodeGenerator

use of com.spectralogic.ds3autogen.net.NetCodeGenerator in project ds3_autogen by SpectraLogic.

the class TestGenerateCode method generateCode.

/**
     * Generates the .net code associated with an input file. THis captures the
     * Request, Client and IDsClient code. This allows for a Ds3DocSpec parser to
     * be specified
     */
public void generateCode(final FileUtils fileUtils, final String inputFileName, final Ds3DocSpec docSpec) throws IOException, TemplateModelException {
    final Ds3SpecParser parser = new Ds3SpecParserImpl();
    final Ds3ApiSpec spec = parser.getSpec(TestGenerateCode.class.getResourceAsStream(inputFileName));
    final CodeGenerator codeGenerator = new NetCodeGenerator();
    codeGenerator.generate(spec, fileUtils, Paths.get("."), docSpec);
    requestCode = new String(requestOutputStream.toByteArray());
    responseCode = new String(responseOutputStream.toByteArray());
    clientCode = new String(clientOutputStream.toByteArray());
    idsClientCode = new String(idsClientOutputStream.toByteArray());
    typeParser = new String(typeParserOutputStream.toByteArray());
    parserCode = new String(parserOutputStream.toByteArray());
    if (responseTypeOutputStream != null) {
        typeCode = new String(responseTypeOutputStream.toByteArray());
    }
}
Also used : NetCodeGenerator(com.spectralogic.ds3autogen.net.NetCodeGenerator) Ds3SpecParserImpl(com.spectralogic.ds3autogen.Ds3SpecParserImpl) NetCodeGenerator(com.spectralogic.ds3autogen.net.NetCodeGenerator) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)

Aggregations

Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)2 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)2 NetCodeGenerator (com.spectralogic.ds3autogen.net.NetCodeGenerator)2 NameMapper (com.spectralogic.ds3autogen.NameMapper)1 CodeGenerator (com.spectralogic.ds3autogen.api.CodeGenerator)1 Ds3DocSpecParser (com.spectralogic.ds3autogen.api.Ds3DocSpecParser)1 Ds3SpecParser (com.spectralogic.ds3autogen.api.Ds3SpecParser)1 FileUtils (com.spectralogic.ds3autogen.api.FileUtils)1 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)1 CCodeGenerator (com.spectralogic.ds3autogen.c.CCodeGenerator)1 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)1 Ds3DocSpecParserImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecParserImpl)1 GoCodeGenerator (com.spectralogic.ds3autogen.go.GoCodeGenerator)1 JavaCodeGenerator (com.spectralogic.ds3autogen.java.JavaCodeGenerator)1 PythonCodeGenerator (com.spectralogic.ds3autogen.python.PythonCodeGenerator)1 Python3CodeGenerator (com.spectralogic.ds3autogen.python3.Python3CodeGenerator)1 FileUtilsImpl (com.spectralogic.ds3autogen.utils.FileUtilsImpl)1