Skip to content

Commit 4b46a89

Browse files
committed
ScriptBuilder: Rewrite run()
1 parent e94e605 commit 4b46a89

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/test/scriptbuilder.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <scratchcpp/variable.h>
1313
#include <scratchcpp/list.h>
1414
#include <scratchcpp/broadcast.h>
15+
#include <scratchcpp/thread.h>
1516

1617
#include "scriptbuilder_p.h"
1718

@@ -37,6 +38,7 @@ ScriptBuilder::ScriptBuilder(IExtension *extension, IEngine *engine, std::shared
3738
return nullptr;
3839
});
3940
addBlockToList(block);
41+
impl->hatBlock = block.get();
4042
}
4143

4244
// Add compile function for return value capture block
@@ -275,7 +277,11 @@ void ScriptBuilder::build()
275277
/*! Runs the built script. */
276278
void ScriptBuilder::run()
277279
{
278-
impl->engine->run();
280+
impl->engine->startScript(impl->hatBlock, impl->target.get());
281+
282+
do {
283+
impl->engine->step();
284+
} while (impl->engine->isRunning());
279285
}
280286

281287
/*! Returns the list of captured block return values. */

src/test/scriptbuilder_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ScriptBuilderPrivate
2727

2828
IEngine *engine = nullptr;
2929
std::shared_ptr<Target> target;
30+
Block *hatBlock = nullptr;
3031
Block *lastBlock = nullptr;
3132
std::vector<std::shared_ptr<Block>> blocks;
3233
std::vector<std::shared_ptr<Block>> inputBlocks;

0 commit comments

Comments
 (0)