Skip to content

Commit d3ce1dd

Browse files
committed
InputValue: Automatically determine type of value pointer
1 parent d8fe75e commit d3ce1dd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/scratch/inputvalue.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include <scratchcpp/inputvalue.h>
44
#include <scratchcpp/compiler.h>
55
#include <scratchcpp/entity.h>
6+
#include <scratchcpp/broadcast.h>
7+
#include <scratchcpp/variable.h>
8+
#include <scratchcpp/list.h>
69
#include <map>
710

811
#include "inputvalue_p.h"
@@ -106,6 +109,13 @@ std::shared_ptr<Entity> InputValue::valuePtr() const
106109
void InputValue::setValuePtr(const std::shared_ptr<Entity> &newValuePtr)
107110
{
108111
impl->valuePtr = newValuePtr;
112+
113+
if (std::static_pointer_cast<Broadcast>(newValuePtr))
114+
setType(Type::Broadcast);
115+
else if (std::static_pointer_cast<Variable>(newValuePtr))
116+
setType(Type::Variable);
117+
else if (std::static_pointer_cast<List>(newValuePtr))
118+
setType(Type::List);
109119
}
110120

111121
/*! Returns the ID of the value. */

0 commit comments

Comments
 (0)