mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Fix: the cache where never used because the node was moved outside of the expression.
This commit is contained in:
@@ -11,16 +11,16 @@
|
||||
|
||||
namespace gd {
|
||||
|
||||
Expression::Expression() : node(nullptr){};
|
||||
Expression::Expression() : node(nullptr), parserObjectsContainer(nullptr){};
|
||||
|
||||
Expression::Expression(gd::String plainString_)
|
||||
: node(nullptr), plainString(plainString_){};
|
||||
: node(nullptr), parserObjectsContainer(nullptr), plainString(plainString_){};
|
||||
|
||||
Expression::Expression(const char* plainString_)
|
||||
: node(nullptr), plainString(plainString_){};
|
||||
: node(nullptr), parserObjectsContainer(nullptr), plainString(plainString_){};
|
||||
|
||||
Expression::Expression(const Expression& copy)
|
||||
: node(nullptr), plainString{copy.plainString} {};
|
||||
: node(nullptr), parserObjectsContainer(nullptr), plainString{copy.plainString} {};
|
||||
|
||||
Expression& Expression::operator=(const Expression& expression) {
|
||||
plainString = expression.plainString;
|
||||
@@ -30,12 +30,17 @@ Expression& Expression::operator=(const Expression& expression) {
|
||||
|
||||
Expression::~Expression(){};
|
||||
|
||||
std::unique_ptr<ExpressionNode> Expression::GetRootNode(
|
||||
ExpressionNode* Expression::GetRootNode(
|
||||
const gd::String& type, gd::ExpressionParser2& parser) const {
|
||||
if (!node) {
|
||||
node = parser.ParseExpression(type, plainString);
|
||||
node = std::move(parser.ParseExpression(type, plainString));
|
||||
parserObjectsContainer = &parser.GetObjectsContainer();
|
||||
}
|
||||
return std::unique_ptr<ExpressionNode>(std::move(node));
|
||||
if (&parser.GetObjectsContainer() != parserObjectsContainer) {
|
||||
std::cout << "Unable to get events from a link ( Invalid start )"
|
||||
<< std::endl;
|
||||
}
|
||||
return node.get();
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
class ExpressionParser2;
|
||||
class ObjectsContainer;
|
||||
struct ExpressionNode;
|
||||
} // namespace gd
|
||||
|
||||
@@ -64,7 +65,7 @@ class GD_CORE_API Expression {
|
||||
* before.
|
||||
* @return std::unique_ptr<gd::ExpressionNode>
|
||||
*/
|
||||
std::unique_ptr<gd::ExpressionNode> GetRootNode(
|
||||
gd::ExpressionNode* GetRootNode(
|
||||
const gd::String& type, gd::ExpressionParser2& parser) const;
|
||||
|
||||
/**
|
||||
@@ -77,6 +78,7 @@ class GD_CORE_API Expression {
|
||||
private:
|
||||
gd::String plainString; ///< The expression string
|
||||
mutable std::unique_ptr<gd::ExpressionNode> node;
|
||||
mutable const gd::ObjectsContainer *parserObjectsContainer;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -66,6 +66,11 @@ class GD_CORE_API ExpressionParser2 {
|
||||
currentPosition = 0;
|
||||
return Start(type, objectName);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return the object container used by the parser.
|
||||
*/
|
||||
const gd::ObjectsContainer& GetObjectsContainer() const { return objectsContainer; };
|
||||
|
||||
/**
|
||||
* Given an object name (or empty if none) and a behavior name (or empty if
|
||||
|
@@ -155,7 +155,7 @@ bool ExpressionsParameterMover::DoVisitInstruction(gd::Instruction& instruction,
|
||||
? expression.GetRootNode("number", parser)
|
||||
: (gd::ParameterMetadata::IsExpression("string", type)
|
||||
? expression.GetRootNode("string", parser)
|
||||
: std::unique_ptr<gd::ExpressionNode>());
|
||||
: nullptr);
|
||||
if (node) {
|
||||
ExpressionParameterMover mover(GetGlobalObjectsContainer(),
|
||||
GetObjectsContainer(),
|
||||
|
@@ -166,7 +166,7 @@ bool ExpressionsRenamer::DoVisitInstruction(gd::Instruction& instruction,
|
||||
? expression.GetRootNode("number", parser)
|
||||
: (gd::ParameterMetadata::IsExpression("string", type)
|
||||
? expression.GetRootNode("string", parser)
|
||||
: std::unique_ptr<gd::ExpressionNode>());
|
||||
: nullptr);
|
||||
if (node) {
|
||||
ExpressionFunctionRenamer renamer(GetGlobalObjectsContainer(),
|
||||
GetObjectsContainer(),
|
||||
|
@@ -8,7 +8,7 @@ namespace gdjs {
|
||||
_object: gdjs.SpriteRuntimeObject;
|
||||
_spriteDirty: boolean = true;
|
||||
_textureDirty: boolean = true;
|
||||
_sprite: any;
|
||||
_sprite: PIXI.Sprite;
|
||||
_cachedWidth: float = 0;
|
||||
_cachedHeight: float = 0;
|
||||
|
||||
@@ -21,11 +21,9 @@ namespace gdjs {
|
||||
runtimeScene: gdjs.RuntimeScene
|
||||
) {
|
||||
this._object = runtimeObject;
|
||||
if (this._sprite === undefined) {
|
||||
this._sprite = new PIXI.Sprite(
|
||||
runtimeScene.getGame().getImageManager().getInvalidPIXITexture()
|
||||
);
|
||||
}
|
||||
this._sprite = new PIXI.Sprite(
|
||||
runtimeScene.getGame().getImageManager().getInvalidPIXITexture()
|
||||
);
|
||||
const layer = runtimeScene.getLayer('');
|
||||
if (layer) {
|
||||
layer
|
||||
|
4071
GDJS/package-lock.json
generated
4071
GDJS/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1082,7 +1082,7 @@ interface Instruction {
|
||||
|
||||
interface Expression {
|
||||
[Const, Ref] DOMString GetPlainString();
|
||||
[Value] UniquePtrExpressionNode GetRootNode([Const] DOMString type, [Ref] ExpressionParser2 parser);
|
||||
ExpressionNode GetRootNode([Const] DOMString type, [Ref] ExpressionParser2 parser);
|
||||
};
|
||||
|
||||
interface VectorPairStringTextFormatting {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// Automatically generated by GDevelop.js/scripts/generate-types.js
|
||||
declare class gdExpression {
|
||||
getPlainString(): string;
|
||||
getRootNode(type: string, parser: gdExpressionParser2): gdUniquePtrExpressionNode;
|
||||
getRootNode(type: string, parser: gdExpressionParser2): gdExpressionNode;
|
||||
delete(): void;
|
||||
ptr: number;
|
||||
};
|
@@ -187,8 +187,7 @@ const Instruction = (props: Props) => {
|
||||
);
|
||||
const expressionNode = instruction
|
||||
.getParameter(parameterIndex)
|
||||
.getRootNode(parameterType, parser)
|
||||
.get();
|
||||
.getRootNode(parameterType, parser);
|
||||
const expressionValidator = new gd.ExpressionValidator();
|
||||
expressionNode.visit(expressionValidator);
|
||||
expressionIsValid = expressionValidator.getErrors().size() === 0;
|
||||
|
Reference in New Issue
Block a user