Skip to content

Commit 2b8d503

Browse files
committed
Remove obsolete parameters from broadcast methods
1 parent 3c8b34f commit 2b8d503

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

include/scratchcpp/iengine.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ class LIBSCRATCHCPP_EXPORT IEngine
5656
/*! Starts a script with the given top level block as the given Target (a sprite or the stage). */
5757
virtual VirtualMachine *startScript(std::shared_ptr<Block> topLevelBlock, Target *) = 0;
5858

59-
/*! Starts the script of the broadcast with the given index. */
60-
virtual void broadcast(unsigned int index, VirtualMachine *sourceScript, bool wait = false) = 0;
59+
/*! Starts the scripts of the broadcast with the given index. */
60+
virtual void broadcast(unsigned int index) = 0;
6161

62-
/*! Starts the script of the given broadcast. */
63-
virtual void broadcastByPtr(Broadcast *broadcast, VirtualMachine *sourceScript, bool wait = false) = 0;
62+
/*! Starts the scripts of the given broadcast. */
63+
virtual void broadcastByPtr(Broadcast *broadcast) = 0;
6464

6565
/*! Starts the "when backdrop switches to" scripts for the given backdrop broadcast. */
6666
virtual void startBackdropScripts(Broadcast *broadcast) = 0;

src/blocks/eventblocks.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,25 @@ void EventBlocks::compileWhenKeyPressed(Compiler *compiler)
9393

9494
unsigned int EventBlocks::broadcast(VirtualMachine *vm)
9595
{
96-
vm->engine()->broadcast(vm->engine()->findBroadcast(vm->getInput(0, 1)->toString()), vm);
96+
vm->engine()->broadcast(vm->engine()->findBroadcast(vm->getInput(0, 1)->toString()));
9797
return 1;
9898
}
9999

100100
unsigned int EventBlocks::broadcastByIndex(VirtualMachine *vm)
101101
{
102-
vm->engine()->broadcast(vm->getInput(0, 1)->toLong(), vm);
102+
vm->engine()->broadcast(vm->getInput(0, 1)->toLong());
103103
return 1;
104104
}
105105

106106
unsigned int EventBlocks::broadcastAndWait(VirtualMachine *vm)
107107
{
108-
vm->engine()->broadcast(vm->engine()->findBroadcast(vm->getInput(0, 1)->toString()), vm, true);
108+
vm->engine()->broadcast(vm->engine()->findBroadcast(vm->getInput(0, 1)->toString()));
109109
return 1;
110110
}
111111

112112
unsigned int EventBlocks::broadcastByIndexAndWait(VirtualMachine *vm)
113113
{
114-
vm->engine()->broadcast(vm->getInput(0, 1)->toLong(), vm, true);
114+
vm->engine()->broadcast(vm->getInput(0, 1)->toLong());
115115
return 1;
116116
}
117117

src/engine/internal/engine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,15 @@ VirtualMachine *Engine::startScript(std::shared_ptr<Block> topLevelBlock, Target
195195
return pushThread(topLevelBlock, target).get();
196196
}
197197

198-
void Engine::broadcast(unsigned int index, VirtualMachine *sourceScript, bool wait)
198+
void Engine::broadcast(unsigned int index)
199199
{
200200
if (index < 0 || index >= m_broadcasts.size())
201201
return;
202202

203-
broadcastByPtr(m_broadcasts[index].get(), sourceScript, wait);
203+
broadcastByPtr(m_broadcasts[index].get());
204204
}
205205

206-
void Engine::broadcastByPtr(Broadcast *broadcast, VirtualMachine *sourceScript, bool wait)
206+
void Engine::broadcastByPtr(Broadcast *broadcast)
207207
{
208208
startHats(HatType::BroadcastReceived, { { EventBlocks::Fields::BROADCAST_OPTION, broadcast->name() } }, nullptr);
209209
}

src/engine/internal/engine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class Engine : public IEngine
3333
void start() override;
3434
void stop() override;
3535
VirtualMachine *startScript(std::shared_ptr<Block> topLevelBlock, Target *target) override;
36-
void broadcast(unsigned int index, VirtualMachine *sourceScript, bool wait = false) override;
37-
void broadcastByPtr(Broadcast *broadcast, VirtualMachine *sourceScript, bool wait = false) override;
36+
void broadcast(unsigned int index) override;
37+
void broadcastByPtr(Broadcast *broadcast) override;
3838
void startBackdropScripts(Broadcast *broadcast) override;
3939
void stopScript(VirtualMachine *vm) override;
4040
void stopTarget(Target *target, VirtualMachine *exceptScript) override;

test/blocks/event_blocks_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ TEST_F(EventBlocksTest, BroadcastImpl)
165165
vm.setConstValues(constValues);
166166

167167
EXPECT_CALL(m_engineMock, findBroadcast("test")).WillOnce(Return(1));
168-
EXPECT_CALL(m_engineMock, broadcast(1, &vm, false)).Times(1);
168+
EXPECT_CALL(m_engineMock, broadcast(1)).Times(1);
169169

170170
vm.setBytecode(bytecode1);
171171
vm.run();
172172

173173
ASSERT_EQ(vm.registerCount(), 0);
174174

175-
EXPECT_CALL(m_engineMock, broadcast(2, &vm, false)).Times(1);
175+
EXPECT_CALL(m_engineMock, broadcast(2)).Times(1);
176176

177177
vm.setBytecode(bytecode2);
178178
vm.run();
@@ -230,7 +230,7 @@ TEST_F(EventBlocksTest, BroadcastAndWaitImpl)
230230
vm.setConstValues(constValues);
231231

232232
EXPECT_CALL(m_engineMock, findBroadcast("test")).WillOnce(Return(1));
233-
EXPECT_CALL(m_engineMock, broadcast(1, &vm, true)).Times(1);
233+
EXPECT_CALL(m_engineMock, broadcast(1)).Times(1);
234234

235235
vm.setBytecode(bytecode1);
236236
vm.run();
@@ -254,7 +254,7 @@ TEST_F(EventBlocksTest, BroadcastAndWaitImpl)
254254
ASSERT_EQ(vm.registerCount(), 0);
255255
ASSERT_EQ(vm.atEnd(), true);
256256

257-
EXPECT_CALL(m_engineMock, broadcast(3, &vm, true)).Times(1);
257+
EXPECT_CALL(m_engineMock, broadcast(3)).Times(1);
258258

259259
vm.setBytecode(bytecode3);
260260
vm.run();

test/mocks/enginemock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class EngineMock : public IEngine
1717
MOCK_METHOD(void, start, (), (override));
1818
MOCK_METHOD(void, stop, (), (override));
1919
MOCK_METHOD(VirtualMachine *, startScript, (std::shared_ptr<Block>, Target *), (override));
20-
MOCK_METHOD(void, broadcast, (unsigned int, VirtualMachine *, bool), (override));
21-
MOCK_METHOD(void, broadcastByPtr, (Broadcast *, VirtualMachine *, bool), (override));
20+
MOCK_METHOD(void, broadcast, (unsigned int), (override));
21+
MOCK_METHOD(void, broadcastByPtr, (Broadcast *), (override));
2222
MOCK_METHOD(void, startBackdropScripts, (Broadcast *), (override));
2323
MOCK_METHOD(void, stopScript, (VirtualMachine *), (override));
2424
MOCK_METHOD(void, stopTarget, (Target *, VirtualMachine *), (override));

0 commit comments

Comments
 (0)