Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
601 changes: 0 additions & 601 deletions BREAKPOINTS.md

This file was deleted.

12 changes: 2 additions & 10 deletions Core/GDCore/Events/CodeGeneration/EventsCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,14 +1102,6 @@ gd::String EventsCodeGenerator::GenerateEventsListCode(
if (event.IsDisabled() || !event.IsExecutable())
continue;

// Synthetic AsyncEvent wrappers (inserted by PreprocessAsyncActions) are
// not user-visible; skip so flat indices stay aligned with the IDE's DFS walk.
gd::String breakpointCode;
if (event.GetType() != "BuiltinAsync::Async") {
size_t breakpointIndex = GetNextBreakpointEventIndex();
breakpointCode = GenerateBreakpointCode(breakpointIndex);
}

if (event.HasVariables()) {
GetProjectScopedContainers().GetVariablesContainersList().Push(
event.GetVariables());
Expand Down Expand Up @@ -1181,8 +1173,8 @@ gd::String EventsCodeGenerator::GenerateEventsListCode(
gd::String scopeEnd = GenerateScopeEnd(context);
gd::String declarationsCode = GenerateObjectsDeclarationCode(context);

output += "\n" + breakpointCode + scopeBegin + "\n" + declarationsCode +
"\n" + eventCoreCode + "\n" + scopeEnd + "\n";
output += "\n" + scopeBegin + "\n" + declarationsCode + "\n" +
eventCoreCode + "\n" + scopeEnd + "\n";

if (event.HasVariables()) {
GetProjectScopedContainers().GetVariablesContainersList().Pop();
Expand Down
14 changes: 0 additions & 14 deletions Core/GDCore/Events/CodeGeneration/EventsCodeGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,18 +449,6 @@ class GD_CORE_API EventsCodeGenerator {
return "";
};

/**
* \brief Generate breakpoint check code for the event at the given flat
* index. Only emitted in preview mode; default returns empty string.
*/
virtual gd::String GenerateBreakpointCode(size_t eventIndex) { return ""; }

/**
* \brief Return the next sequential breakpoint event index and increment
* the counter. The counter follows DFS traversal order.
*/
size_t GetNextBreakpointEventIndex() { return nextBreakpointEventIndex++; }

/**
* \brief Get the namespace to be used to store code generated
* objects/values/functions, with the extra "dot" at the end to be used to
Expand Down Expand Up @@ -889,8 +877,6 @@ class GD_CORE_API EventsCodeGenerator {
instructionUniqueIds; ///< The unique ids generated for instructions.
size_t eventsListNextUniqueId; ///< The next identifier to use for an events
///< list function name.
size_t nextBreakpointEventIndex = 0; ///< DFS counter for breakpoint event
///< indices in generated code.

gd::DiagnosticReport* diagnosticReport;
};
Expand Down
2 changes: 1 addition & 1 deletion Core/GDCore/IDE/Events/ExpressionSyntaxColoringHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class GD_CORE_API ExpressionSyntaxColoringHelper
} else if (gd::ValueTypeMetadata::IsTypeLegacyPreScopedVariable(type)) {
AddColoration(
gd::ExpressionColorationDescription::ColorationKind::Variable,
node.location.GetStartPosition(), node.location.GetStartPosition());
node.location.GetStartPosition(), node.location.GetEndPosition());

} else {
// Might be:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "ObjectVariableHelper.h"
#include "ObjectRefactorer.h"

#include "GDCore/IDE/WholeProjectRefactorer.h"
#include "GDCore/Project/EventsBasedObject.h"
Expand All @@ -18,7 +18,7 @@

namespace gd {

void ObjectVariableHelper::FillAnyVariableBetweenObjects(
void ObjectRefactorer::FillAnyVariableBetweenObjects(
gd::ObjectsContainer &globalObjectsContainer,
gd::ObjectsContainer &objectsContainer,
const gd::ObjectGroup &objectGroup) {
Expand Down Expand Up @@ -67,7 +67,7 @@ void ObjectVariableHelper::FillAnyVariableBetweenObjects(
}
}

gd::VariablesContainer ObjectVariableHelper::MergeVariableContainers(
gd::VariablesContainer ObjectRefactorer::MergeVariableContainers(
const gd::ObjectsContainersList &objectsContainersList,
const gd::ObjectGroup &objectGroup) {
gd::VariablesContainer mergedVariablesContainer;
Expand Down Expand Up @@ -115,12 +115,13 @@ gd::VariablesContainer ObjectVariableHelper::MergeVariableContainers(
return mergedVariablesContainer;
}

void ObjectVariableHelper::FillMissingGroupVariablesToObjects(
void ObjectRefactorer::FillMissingGroupVariablesToObjects(
gd::ObjectsContainer &globalObjectsContainer,
gd::ObjectsContainer &objectsContainer, const gd::ObjectGroup &objectGroup,
const gd::SerializerElement &originalSerializedVariables) {
gd::VariablesContainer groupVariablesContainer;
groupVariablesContainer.UnserializeFrom(originalSerializedVariables);

// Add missing variables to objects added in the group.
for (const gd::String &objectName : objectGroup.GetAllObjectsNames()) {
const bool hasObject = objectsContainer.HasObjectNamed(objectName);
Expand All @@ -129,25 +130,55 @@ void ObjectVariableHelper::FillMissingGroupVariablesToObjects(
}
auto &object = hasObject ? objectsContainer.GetObject(objectName)
: globalObjectsContainer.GetObject(objectName);
auto &variablesContainer = object.GetVariables();
for (std::size_t variableIndex = 0;
variableIndex < groupVariablesContainer.Count(); ++variableIndex) {
auto &groupVariable = groupVariablesContainer.Get(variableIndex);
const auto &variableName =
groupVariablesContainer.GetNameAt(variableIndex);

if (!variablesContainer.Has(variableName)) {
variablesContainer.Insert(variableName, groupVariable,
variablesContainer.Count());
}
gd::ObjectRefactorer::FillMissingGroupVariablesToObject(
object, groupVariablesContainer);
}
}

void ObjectRefactorer::FillMissingGroupVariablesToObject(
gd::Object &object, const gd::VariablesContainer &groupVariablesContainer) {
auto &variablesContainer = object.GetVariables();
for (std::size_t variableIndex = 0;
variableIndex < groupVariablesContainer.Count(); ++variableIndex) {
auto &groupVariable = groupVariablesContainer.Get(variableIndex);
const auto &variableName = groupVariablesContainer.GetNameAt(variableIndex);

if (!variablesContainer.Has(variableName)) {
variablesContainer.Insert(variableName, groupVariable,
variablesContainer.Count());
}
}
};
}

void ObjectRefactorer::FillMissingGroupBehaviorToObject(
gd::ObjectsContainer &globalObjectsContainer,
gd::ObjectsContainer &objectsContainer, gd::Object &object,
const gd::ObjectGroup &objectGroup, const gd::String &behaviorName) {
if (object.HasBehaviorNamed(behaviorName) ||
objectGroup.GetAllObjectsNames().size() == 0) {
return;
}
const gd::String &firstObjectName = objectGroup.GetAllObjectsNames()[0];
const bool hasObject = objectsContainer.HasObjectNamed(firstObjectName);
if (!hasObject && !globalObjectsContainer.HasObjectNamed(firstObjectName)) {
return;
}
auto &firstObject = hasObject
? objectsContainer.GetObject(firstObjectName)
: globalObjectsContainer.GetObject(firstObjectName);

if (!firstObject.HasBehaviorNamed(behaviorName)) {
return;
}
object.GetBehaviors().AddBehavior(firstObject.GetBehavior(behaviorName),
behaviorName);
}

// TODO Handle position changes for group variables.
// We could try to change the order of object variables in a way that the next
// call to MergeVariableContainers rebuild them in the same order.
void ObjectVariableHelper::ApplyChangesToObjects(
void ObjectRefactorer::ApplyChangesToObjects(
gd::ObjectsContainer &globalObjectsContainer,
gd::ObjectsContainer &objectsContainer,
const gd::VariablesContainer &groupVariablesContainer,
Expand Down Expand Up @@ -196,7 +227,7 @@ void ObjectVariableHelper::ApplyChangesToObjects(
}
}

void ObjectVariableHelper::ApplyChangesToObjectInstances(
void ObjectRefactorer::ApplyChangesToObjectInstances(
gd::VariablesContainer &objectVariablesContainer,
gd::InitialInstancesContainer &initialInstancesContainer,
const gd::String &objectName, const gd::VariablesChangeset &changeset) {
Expand Down Expand Up @@ -243,7 +274,7 @@ void ObjectVariableHelper::ApplyChangesToObjectInstances(
});
}

void ObjectVariableHelper::ApplyChangesToVariants(
void ObjectRefactorer::ApplyChangesToVariants(
gd::EventsBasedObject &eventsBasedObject, const gd::String &objectName,
const gd::VariablesChangeset &changeset) {
auto &defaultVariablesContainer = eventsBasedObject.GetDefaultVariant()
Expand Down Expand Up @@ -295,7 +326,7 @@ void ObjectVariableHelper::ApplyChangesToVariants(
}
}

gd::ObjectVariableHelper::ApplyChangesToObjectInstances(
gd::ObjectRefactorer::ApplyChangesToObjectInstances(
variablesContainer, variant->GetInitialInstances(), objectName,
changeset);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace gd {
class EventsBasedObject;
class InitialInstancesContainer;
class Object;
class ObjectsContainersList;
class ObjectsContainer;
class ObjectGroup;
Expand All @@ -24,7 +25,7 @@ namespace gd {
*
* This is used by the object group variable editor.
*/
class GD_CORE_API ObjectVariableHelper {
class GD_CORE_API ObjectRefactorer {
public:
/**
* Copy every variable from every object of the group to the other objects
Expand Down Expand Up @@ -54,14 +55,31 @@ class GD_CORE_API ObjectVariableHelper {
* Objects can be added during the group edition and may not necessarily have
* all the variables initially shared by the group.
*
* \see gd::ObjectVariableHelper::MergeVariableContainers
* \see gd::ObjectRefactorer::MergeVariableContainers
*/
static void FillMissingGroupVariablesToObjects(
gd::ObjectsContainer &globalObjectsContainer,
gd::ObjectsContainer &objectsContainer,
const gd::ObjectGroup &objectGroup,
const gd::SerializerElement &originalSerializedVariables);

/**
* @brief Copy the variables of the group to the object newly added to the
* group.
*/
static void FillMissingGroupVariablesToObject(
gd::Object &object,
const gd::VariablesContainer &groupVariablesContainer);

/**
* @brief Copy the behavior of the group to the object newly added to the
* group.
*/
static void FillMissingGroupBehaviorToObject(
gd::ObjectsContainer &globalObjectsContainer,
gd::ObjectsContainer &objectsContainer, gd::Object &object,
const gd::ObjectGroup &objectGroup, const gd::String &behaviorName);

/**
* @brief Apply the changes done with the variables editor to the objects of
* the group.
Expand Down
10 changes: 5 additions & 5 deletions Core/GDCore/IDE/WholeProjectRefactorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/IDE/DependenciesAnalyzer.h"
#include "GDCore/IDE/ObjectVariableHelper.h"
#include "GDCore/IDE/ObjectRefactorer.h"
#include "GDCore/IDE/EventBasedBehaviorBrowser.h"
#include "GDCore/IDE/EventBasedObjectBrowser.h"
#include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
Expand Down Expand Up @@ -364,7 +364,7 @@ void WholeProjectRefactorer::ApplyRefactoringForObjectVariablesContainer(
project, objectVariablesContainer, changeset,
originalSerializedVariables);

gd::ObjectVariableHelper::ApplyChangesToObjectInstances(
gd::ObjectRefactorer::ApplyChangesToObjectInstances(
objectVariablesContainer, initialInstancesContainer, objectName,
changeset);
}
Expand Down Expand Up @@ -394,7 +394,7 @@ void WholeProjectRefactorer::ApplyRefactoringForGroupVariablesContainer(
: globalObjectsContainer.GetObject(objectName);
auto &objectVariablesContainer = object.GetVariables();

gd::ObjectVariableHelper::ApplyChangesToObjectInstances(
gd::ObjectRefactorer::ApplyChangesToObjectInstances(
objectVariablesContainer, initialInstancesContainer, objectName,
changeset);

Expand All @@ -413,12 +413,12 @@ void WholeProjectRefactorer::ApplyRefactoringForGroupVariablesContainer(
eventsVariableReplacer);

// Apply changes to objects.
gd::ObjectVariableHelper::FillMissingGroupVariablesToObjects(
gd::ObjectRefactorer::FillMissingGroupVariablesToObjects(
globalObjectsContainer,
objectsContainer,
objectGroup,
originalSerializedVariables);
gd::ObjectVariableHelper::ApplyChangesToObjects(
gd::ObjectRefactorer::ApplyChangesToObjects(
globalObjectsContainer, objectsContainer, groupVariablesContainer,
objectGroup, changeset);

Expand Down
6 changes: 6 additions & 0 deletions Core/GDCore/Project/BehaviorsContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ gd::Behavior *BehaviorsContainer::AddNewBehavior(const gd::Project &project,
}
}

gd::Behavior *BehaviorsContainer::AddBehavior(const gd::Behavior &behavior,
const gd::String &name) {
behaviors[name] = std::move(behavior.Clone());
return behaviors[name].get();
}

void BehaviorsContainer::UnserializeFrom(gd::Project &project,
const SerializerElement &element) {
element.ConsiderAsArrayOf("behavior", "automatism");
Expand Down
2 changes: 2 additions & 0 deletions Core/GDCore/Project/BehaviorsContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class GD_CORE_API BehaviorsContainer {
gd::Behavior *AddNewBehavior(const gd::Project &project,
const gd::String &type, const gd::String &name);

gd::Behavior *AddBehavior(const gd::Behavior &behavior, const gd::String &name);

/**
* \brief Get a read-only access to the map containing the behaviors with
* their properties.
Expand Down
12 changes: 12 additions & 0 deletions Core/GDCore/Project/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ class GD_CORE_API Object {
GetAllBehaviorContents() const {
return behaviors.GetAllBehaviorContents();
};

/**
* \brief Provide access to the gd::BehaviorsContainer member containing the
* object behaviors
*/
const gd::BehaviorsContainer& GetBehaviors() const { return behaviors; }

/**
* \brief Provide access to the gd::BehaviorsContainer member containing the
* object behaviors
*/
gd::BehaviorsContainer& GetBehaviors() { return behaviors; }
///@}

/** \name Variable management
Expand Down
2 changes: 1 addition & 1 deletion Core/GDCore/Project/ObjectsContainersList.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class GD_CORE_API ObjectsContainersList {
* group of objects.
*
* \warning In most cases, prefer to use other methods to access variables or use
* ObjectVariableHelper::MergeVariableContainers if you know you're dealing with a group.
* ObjectRefactorer::MergeVariableContainers if you know you're dealing with a group.
* This is because the variables container of an object group does not exist and the one from
* first object of the group will be returned.
*/
Expand Down
Loading
Loading