File tree Expand file tree Collapse file tree 4 files changed +30
-0
lines changed Expand file tree Collapse file tree 4 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 1111namespace libscratchcpp
1212{
1313
14+ class Target ;
1415class ListPrivate ;
1516
1617/* ! \brief The List class represents a Scratch list. */
@@ -25,6 +26,9 @@ class LIBSCRATCHCPP_EXPORT List
2526 const std::string &name ();
2627 void setName (const std::string &name);
2728
29+ Target *target () const ;
30+ void setTarget (Target *target);
31+
2832 long indexOf (const Value &value) const ;
2933 bool contains (const Value &value) const ;
3034
Original file line number Diff line number Diff line change @@ -26,6 +26,18 @@ void List::setName(const std::string &name)
2626 impl->name = name;
2727}
2828
29+ /* ! Returns the sprite or stage this list belongs to. */
30+ Target *List::target () const
31+ {
32+ return impl->target ;
33+ }
34+
35+ /* ! Sets the sprite or stage this list belongs to. */
36+ void List::setTarget (Target *target)
37+ {
38+ impl->target = target;
39+ }
40+
2941/* ! Returns the index of the given item. */
3042long List::indexOf (const Value &value) const
3143{
Original file line number Diff line number Diff line change 77namespace libscratchcpp
88{
99
10+ class Target ;
11+
1012struct ListPrivate
1113{
1214 ListPrivate (const std::string &name);
1315
1416 std::string name;
17+ Target *target = nullptr ;
1518};
1619
1720} // namespace libscratchcpp
Original file line number Diff line number Diff line change 11#include < scratchcpp/list.h>
2+ #include < scratchcpp/target.h>
23
34#include " ../common.h"
45
@@ -18,6 +19,16 @@ TEST(ListTest, Name)
1819 ASSERT_EQ (list.name (), " test list" );
1920}
2021
22+ TEST (ListTest, Target)
23+ {
24+ List list (" " , " " );
25+ ASSERT_EQ (list.target (), nullptr );
26+
27+ Target target;
28+ list.setTarget (&target);
29+ ASSERT_EQ (list.target (), &target);
30+ }
31+
2132TEST (ListTest, IndexOf)
2233{
2334 List list (" " , " test list" );
You can’t perform that action at this time.
0 commit comments