Skip to content

Commit b7035b7

Browse files
committed
Add target getter to Script
1 parent d7645d5 commit b7035b7

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

include/scratchcpp/script.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class LIBSCRATCHCPP_EXPORT Script
2525
Script(Target *target, IEngine *engine);
2626
Script(const Script &) = delete;
2727

28+
Target *target() const;
29+
2830
unsigned int *bytecode() const;
2931
const std::vector<unsigned int> &bytecodeVector() const;
3032
void setBytecode(const std::vector<unsigned int> &code);

src/engine/script.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Script::Script(Target *target, IEngine *engine) :
1313
{
1414
}
1515

16+
/*! Returns the Target. */
17+
Target *Script::target() const
18+
{
19+
return impl->target;
20+
}
21+
1622
/*! Returns the bytecode array. */
1723
unsigned int *Script::bytecode() const
1824
{

test/script/script_test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ class ScriptTest : public testing::Test
1515
EngineMock m_engine;
1616
};
1717

18+
TEST_F(ScriptTest, Constructors)
19+
{
20+
Script script(&m_target, &m_engine);
21+
ASSERT_EQ(script.target(), &m_target);
22+
}
23+
1824
TEST_F(ScriptTest, Bytecode)
1925
{
2026
Script script(nullptr, nullptr);

0 commit comments

Comments
 (0)