Skip to content

Commit 3adec5c

Browse files
committed
Switching to codelib.{cc,h} generated by codelib-gen
1 parent 436230b commit 3adec5c

File tree

4 files changed

+63
-45
lines changed

4 files changed

+63
-45
lines changed

src/codelib.cc

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,49 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*
18-
* @author "Parthipan Ramesh <[email protected]>"
19-
* @author "Oliver Schranz <[email protected]>"
20-
*
2118
*/
2219

2320
#include "codelib.h"
2421

25-
const std::string TemplateCodeLib::INJECTION_ARTIST_TARGET("Lsaarland/cispa/artist/codelib/CodeLib;injectionArtistTarget(I)V");
26-
const std::string TemplateCodeLib::BASIC_ARTIST_TARGET("Lsaarland/cispa/artist/codelib/CodeLib;basicArtistTarget(ILjava/lang/Object;)V");
2722

23+
// CODE_GENERATOR //////////////////////////////////////////////////////////////////////////////////////////////////////
24+
// METHODS //////////////////////////////////
25+
const string TemplateCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__BASICARTISTTARGET__IL__V =
26+
"Lsaarland/cispa/artist/codelib/CodeLib;basicArtistTarget(ILjava/lang/Object;)V";
27+
const string TemplateCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__INJECTIONARTISTTARGET__I__V =
28+
"Lsaarland/cispa/artist/codelib/CodeLib;injectionArtistTarget(I)V";
29+
30+
// FIELDS ///////////////////////////////////
31+
const string TemplateCodeLib::_F_CODECLASS_INSTANCE =
32+
"Lsaarland/cispa/artist/codelib/CodeLib;INSTANCE";
33+
34+
// CLASSES //////////////////////////////////
35+
const string TemplateCodeLib::_C_JAVA_LANG_STRING =
36+
"Ljava/lang/String;";
37+
const string TemplateCodeLib::_C_JAVA_LANG_OBJECT =
38+
"Ljava/lang/Object;";
39+
const string TemplateCodeLib::_C_CODECLASS =
40+
"Lsaarland/cispa/artist/codelib/CodeLib;";
2841

2942
unordered_set<string> &TemplateCodeLib::getMethods() const {
30-
// here we expose the signatures of codelib methods that are meant to be used from ARTist
31-
static unordered_set<string> methods({INJECTION_ARTIST_TARGET, BASIC_ARTIST_TARGET});
32-
return methods;
43+
static unordered_set<string> methods({
44+
TemplateCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__BASICARTISTTARGET__IL__V,
45+
TemplateCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__INJECTIONARTISTTARGET__I__V,
46+
});
47+
return methods;
3348
}
3449

3550
string &TemplateCodeLib::getInstanceField() const {
36-
// here we expose the static field with our singleton instance. This will be used by ARTist to obtain an instance
37-
// of the codelib to call methods on it.
38-
static string instanceField = "Lsaarland/cispa/artist/codelib/CodeLib;INSTANCE";
39-
return instanceField;
51+
static string instanceField = TemplateCodeLib::_F_CODECLASS_INSTANCE;
52+
return instanceField;
4053
}
4154

4255
string &TemplateCodeLib::getCodeClass() const {
43-
// here we expose the codelib's java class to be able to load it in ARTist
44-
static string codeClass = "Lsaarland/cispa/artist/codelib/CodeLib;";
45-
return codeClass;
56+
static string codeClass = TemplateCodeLib::_C_CODECLASS;
57+
return codeClass;
4658
}
59+
60+
61+
// CODE_GENERATOR END //////////////////////////////////////////////////////////////////////////////////////////////////
62+
63+

src/codelib.h

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*
18-
* @author "Parthipan Ramesh <[email protected]>"
19-
* @author "Oliver Schranz <[email protected]>"
20-
*
2118
*/
2219

23-
#ifndef ART_MODULES_CODELIB_H_
24-
#define ART_MODULES_CODELIB_H_
20+
#ifndef ART_MODULES_TEMPLATE_TEMPLATE_CODELIB_H_
21+
#define ART_MODULES_TEMPLATE_TEMPLATE_CODELIB_H_
22+
2523

2624
#include <string>
2725
#include <unordered_set>
@@ -33,28 +31,31 @@ using std::unordered_set;
3331
using art::CodeLib;
3432

3533
class TemplateCodeLib : public CodeLib {
36-
public:
37-
static const string INJECTION_ARTIST_TARGET;
38-
static const string BASIC_ARTIST_TARGET;
39-
40-
41-
TemplateCodeLib() = default;
42-
43-
TemplateCodeLib(const TemplateCodeLib &other) = default;
44-
45-
TemplateCodeLib(TemplateCodeLib &&other) = default;
46-
47-
~TemplateCodeLib() override = default;
48-
49-
TemplateCodeLib &operator=(const TemplateCodeLib &) = default;
50-
51-
TemplateCodeLib &operator=(TemplateCodeLib &&) = default;
52-
53-
unordered_set<string> &getMethods() const override;
54-
55-
string &getInstanceField() const override;
56-
57-
string &getCodeClass() const override;
34+
public:
35+
// METHODS //////////////////////////////////
36+
static const string _M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__BASICARTISTTARGET__IL__V;
37+
static const string _M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__INJECTIONARTISTTARGET__I__V;
38+
// FIELDS ///////////////////////////////////
39+
static const string _F_CODECLASS_INSTANCE;
40+
// CLASSES //////////////////////////////////
41+
static const string _C_JAVA_LANG_STRING;
42+
static const string _C_JAVA_LANG_OBJECT;
43+
static const string _C_CODECLASS;
44+
45+
public:
46+
TemplateCodeLib() = default;
47+
TemplateCodeLib(const TemplateCodeLib& other) = default;
48+
TemplateCodeLib(TemplateCodeLib&& other) = default;
49+
50+
~TemplateCodeLib() override = default;
51+
52+
TemplateCodeLib& operator=(const TemplateCodeLib&) = default;
53+
TemplateCodeLib& operator=(TemplateCodeLib&&) = default;
54+
55+
unordered_set<string>& getMethods() const override;
56+
string& getInstanceField() const override;
57+
string& getCodeClass() const override;
5858
}; // class TemplateCodeLib
5959

60-
#endif // ART_MODULES_CODELIB_H_
60+
61+
#endif // ART_MODULES_TEMPLATE_TEMPLATE_CODELIB_H_

src/template_basic_pass.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void HTemplateBasicArtist::RunPass() {
5757
art::HInstruction* cursor = graph_->GetEntryBlock()->GetLastInstruction();
5858

5959
// we will add a call to this method
60-
auto codelib_method = TemplateCodeLib::BASIC_ARTIST_TARGET;
60+
auto codelib_method = TemplateCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__BASICARTISTTARGET__IL__V;
6161

6262
// we will collect all parameters as HInstructions. Instructions also represent their return value, hence if you
6363
// want to use the return value of a method invocation, use the invocation instruction as a parameter.

src/template_injection_pass.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ vector<shared_ptr<const Injection>> HTemplateInjectionArtist::ProvideInjections(
6565

6666
// The injection combines the signature of the method we want to inject a call to, its parameters, and the targets
6767
// we defined earlier.
68-
auto injection = make_shared<const Injection>(TemplateCodeLib::INJECTION_ARTIST_TARGET, params, targets);
68+
auto injection = make_shared<const Injection>(TemplateCodeLib::_M_SAARLAND_CISPA_ARTIST_CODELIB_CODELIB__INJECTIONARTISTTARGET__I__V, params, targets);
6969

7070
// In theory, you can have as many injections as you want, but due to the so called *clone bug*
7171
// (https://github.com/Project-ARTist/ARTist/issues/10), this is currently not possible.

0 commit comments

Comments
 (0)