1 /** 2 Copyright: Copyright (c) 2017, Joakim Brännström. All rights reserved. 3 License: MPL-2 4 Author: Joakim Brännström (joakim.brannstrom@gmx.com) 5 6 This Source Code Form is subject to the terms of the Mozilla Public License, 7 v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 8 one at http://mozilla.org/MPL/2.0/. 9 */ 10 module dextool.plugin.intercept.backend.interface_; 11 12 import dsrcgen.cpp : CppModule, CppHModule; 13 import dsrcgen.sh : ShScriptModule; 14 15 import cpptooling.testdouble.header_filter : LocationType; 16 17 import dextool.type : FileName, DirName, MainName, StubPrefix, DextoolVersion, 18 CustomHeader, MainNs, MainInterface; 19 import cpptooling.data.type : LocationTag; 20 21 struct FileData { 22 import dextool.type : FileName, WriteStrategy; 23 24 FileName filename; 25 string data; 26 WriteStrategy strategy; 27 } 28 29 /** Control various aspectes of the analyze and generation like what nodes to 30 * process. 31 */ 32 @safe interface Controller { 33 /** Query the controller for a decision if it shall be processed. */ 34 bool doSymbol(string symbol); 35 } 36 37 @safe interface Parameters { 38 static struct Files { 39 FileName hdr; 40 FileName impl; 41 FileName script; 42 } 43 44 /// Files to write generated test double data to. 45 Files getFiles(); 46 47 /// Output directory to store files in. 48 DirName getOutputDirectory(); 49 50 /// Dextool Tool version. 51 DextoolVersion getToolVersion(); 52 53 /// Custom header to prepend generated files with. 54 CustomHeader getCustomHeader(); 55 56 /** A list of includes for the test double header. 57 * 58 * Part of the controller because they are dynamic, may change depending on 59 * for example calls to doFile. 60 */ 61 FileName[] getIncludes(); 62 63 /// The prefix to use for a symbol. 64 StubPrefix symbolPrefix(string symbol); 65 } 66 67 /// Data produced by the generator like files. 68 @safe interface Products { 69 /** Data pushed from the generator to be written to files. 70 * 71 * The put value is the code generation tree. It allows the caller of 72 * Generator to inject more data in the tree before writing. For example a 73 * custom header. 74 * 75 * Params: 76 * fname = file the content is intended to be written to. 77 * hdr_data = data to write to the file. 78 */ 79 void putFile(FileName fname, CppHModule data); 80 81 /// ditto. 82 void putFile(FileName fname, CppModule data); 83 84 /// ditto. 85 void putFile(FileName fname, ShScriptModule data); 86 87 /** During the translation phase the location of symbols that aren't 88 * filtered out are pushed to the variant. 89 * 90 * It is intended that the variant control the #include directive strategy. 91 * Just the files that was input? 92 * Deduplicated list of files where the symbols was found? 93 */ 94 void putLocation(FileName loc, LocationType type); 95 }