|
16 | 16 | * limitations under the License.
|
17 | 17 | *
|
18 | 18 | * @author "Parthipan Ramesh <[email protected]>"
|
| 19 | + * @author "Oliver Schranz <[email protected]>" |
19 | 20 | *
|
20 | 21 | */
|
21 | 22 |
|
22 |
| -#include <artist/filtering/method_name_filters.h> |
| 23 | +#include <artist/api/filtering/method_name_filters.h> |
23 | 24 |
|
24 | 25 | #include "module.h"
|
25 |
| -#include "instrumentation_pass.h" |
| 26 | +//#include "template_basic_pass.h" |
| 27 | +#include "template_injection_pass.h" |
26 | 28 | #include "codelib.h"
|
| 29 | +#include "simple_method_filter.h" |
27 | 30 |
|
28 | 31 | using std::make_shared;
|
29 | 32 | using std::unique_ptr;
|
30 | 33 |
|
31 |
| -shared_ptr<HArtist> ArtistModule::createPass(const MethodInfo &method_info) const { |
32 |
| - return make_shared<HModule>(method_info); |
| 34 | +using art::ModuleId; |
| 35 | + |
| 36 | +TemplateModule::TemplateModule(const shared_ptr<const art::FilesystemHelper> fs) : Module(fs) {} |
| 37 | + |
| 38 | +HArtist * TemplateModule::createPass(const MethodInfo &method_info) const { |
| 39 | + // Due to the *clone bug* (https://github.com/Project-ARTist/ARTist/issues/10), we can only define one pass per |
| 40 | + // module right now, but this will change as soon as this bug is resolved. |
| 41 | + return new (method_info.GetGraph()->GetArena()) HTemplateInjectionArtist(method_info); |
| 42 | +// return new (method_info.GetGraph()->GetArena()) HTemplateBasicArtist(method_info); |
33 | 43 | }
|
34 | 44 |
|
35 |
| -shared_ptr<const CodeLib> ArtistModule::createCodeLib() const { |
36 |
| - return make_shared<ModuleCodeLib>(); |
| 45 | +shared_ptr<const CodeLib> TemplateModule::createCodeLib() const { |
| 46 | + return make_shared<TemplateCodeLib>(); |
37 | 47 | }
|
38 | 48 |
|
39 |
| -// Possible MethodFilter: skip android support lib ui methods since they bloat up the log |
40 |
| -unique_ptr<Filter> ArtistModule::getMethodFilter() const { |
41 |
| - const vector<const string> ui = {"android.support."}; |
42 |
| - return unique_ptr<Filter>(new art::BlacklistFilter(ui)); |
| 49 | + |
| 50 | +// Here we can restrict for which methods our module should be executed. |
| 51 | +unique_ptr<Filter> TemplateModule::getMethodFilter() const { |
| 52 | + // creating blacklists/whitelists for method names is straightforward: |
| 53 | + // const vector<const string> ui = {"android.support."}; |
| 54 | + // return unique_ptr<Filter>(new MethodNameBlacklist(ui)); |
| 55 | + |
| 56 | + // but here we use a custom filter that only excepts non-static methods (and only a fragment of the others) |
| 57 | + return unique_ptr<Filter>(new SimpleMethodFilter()); |
| 58 | +} |
| 59 | +// the module factory |
| 60 | +extern "C" shared_ptr<Module> create(shared_ptr<const FilesystemHelper> fshelper) { |
| 61 | + return make_shared<TemplateModule>(fshelper); |
43 | 62 | }
|
44 | 63 |
|
45 |
| -// the class factories |
46 |
| -extern "C" shared_ptr<art::Module> create() { |
47 |
| - return make_shared<ArtistModule>(); |
| 64 | +extern "C" ModuleId get_id() { |
| 65 | + return "saarland.cispa.artist.module.template"; |
48 | 66 | }
|
0 commit comments