Skip to content

Commit 8a25123

Browse files
authored
Merge branch 'master' into electron-32
2 parents 1ced1aa + 5db23c5 commit 8a25123

File tree

1,035 files changed

+108334
-24611
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,035 files changed

+108334
-24611
lines changed

.circleci/config.yml

Lines changed: 260 additions & 42 deletions
Large diffs are not rendered by default.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@
3333
.Spotlight-V100
3434
.Trashes
3535
Thumbs.db
36+
.claude

.vscode/tasks.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
"presentation": {
3939
"reveal": "silent"
4040
},
41-
"isBackground": true,
42-
"runOptions": { "instanceLimit": 1, "runOn": "folderOpen" }
41+
"isBackground": true
4342
},
4443
{
4544
"type": "npm",

Core/GDCore/Events/Builtin/GroupEvent.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ void GroupEvent::UnserializeFrom(gd::Project& project,
6161
project, events, element.GetChild("events"));
6262

6363
parameters.clear();
64-
gd::SerializerElement& parametersElement = element.GetChild("parameters");
65-
parametersElement.ConsiderAsArrayOf("parameters");
66-
for (std::size_t i = 0; i < parametersElement.GetChildrenCount(); ++i)
67-
parameters.push_back(parametersElement.GetChild(i).GetValue().GetString());
64+
if (element.HasChild("parameters")) {
65+
gd::SerializerElement& parametersElement = element.GetChild("parameters");
66+
parametersElement.ConsiderAsArrayOf("parameters");
67+
for (std::size_t i = 0; i < parametersElement.GetChildrenCount(); ++i)
68+
parameters.push_back(parametersElement.GetChild(i).GetValue().GetString());
69+
}
6870
}
6971

7072
void GroupEvent::SetBackgroundColor(unsigned int colorR_,

Core/GDCore/Events/Builtin/LinkEvent.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,21 @@ void LinkEvent::UnserializeFrom(gd::Project& project,
163163
// end of compatibility code
164164
}
165165

166+
vector<gd::String> LinkEvent::GetAllSearchableStrings() const {
167+
vector<gd::String> allSearchableStrings;
168+
169+
allSearchableStrings.push_back(target);
170+
171+
return allSearchableStrings;
172+
}
173+
174+
bool LinkEvent::ReplaceAllSearchableStrings(
175+
std::vector<gd::String> newSearchableString) {
176+
if (newSearchableString[0] == target) return false;
177+
SetTarget(newSearchableString[0]);
178+
return true;
179+
}
180+
166181
bool LinkEvent::AcceptVisitor(gd::EventVisitor &eventVisitor) {
167182
return BaseEvent::AcceptVisitor(eventVisitor) ||
168183
eventVisitor.VisitLinkEvent(*this);

Core/GDCore/Events/Builtin/LinkEvent.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ class GD_CORE_API LinkEvent : public gd::BaseEvent {
109109

110110
virtual bool IsExecutable() const override { return true; };
111111

112+
virtual std::vector<gd::String> GetAllSearchableStrings() const override;
113+
virtual bool ReplaceAllSearchableStrings(
114+
std::vector<gd::String> newSearchableString) override;
115+
112116
virtual void SerializeTo(SerializerElement& element) const override;
113117
virtual void UnserializeFrom(gd::Project& project,
114118
const SerializerElement& element) override;

Core/GDCore/Events/CodeGeneration/EventsCodeGenerator.cpp

Lines changed: 253 additions & 167 deletions
Large diffs are not rendered by default.

Core/GDCore/Events/CodeGeneration/EventsCodeGenerator.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#include <utility>
1010
#include <vector>
1111

12+
#include "GDCore/Events/CodeGeneration/DiagnosticReport.h"
1213
#include "GDCore/Events/Event.h"
1314
#include "GDCore/Events/Instruction.h"
14-
#include "GDCore/Events/CodeGeneration/DiagnosticReport.h"
1515
#include "GDCore/Project/ProjectScopedContainers.h"
1616
#include "GDCore/String.h"
1717

@@ -62,7 +62,7 @@ class GD_CORE_API EventsCodeGenerator {
6262
EventsCodeGenerator(
6363
const gd::Platform& platform,
6464
const gd::ProjectScopedContainers& projectScopedContainers_);
65-
virtual ~EventsCodeGenerator(){};
65+
virtual ~EventsCodeGenerator() {};
6666

6767
/**
6868
* \brief Preprocess an events list (replacing for example links with the
@@ -160,15 +160,16 @@ class GD_CORE_API EventsCodeGenerator {
160160
gd::String GenerateActionCode(
161161
gd::Instruction& action,
162162
EventsCodeGenerationContext& context,
163-
const gd::String& optionalAsyncCallbackName = "");
163+
const gd::String& optionalAsyncCallbackName = "",
164+
const gd::String& optionalAsyncCallbackId = "");
164165

165166
struct CallbackDescriptor {
166167
CallbackDescriptor(const gd::String functionName_,
167168
const gd::String argumentsList_,
168169
const std::set<gd::String> requiredObjects_)
169170
: functionName(functionName_),
170171
argumentsList(argumentsList_),
171-
requiredObjects(requiredObjects_){};
172+
requiredObjects(requiredObjects_) {};
172173
/**
173174
* The name by which the function can be invoked.
174175
*/
@@ -338,9 +339,9 @@ class GD_CORE_API EventsCodeGenerator {
338339
}
339340

340341
/**
341-
* @brief Give access to the project scoped containers as code generation might
342-
* push and pop variable containers (for local variables).
343-
* This could be passed as a parameter recursively in code generation, but this requires
342+
* @brief Give access to the project scoped containers as code generation
343+
* might push and pop variable containers (for local variables). This could be
344+
* passed as a parameter recursively in code generation, but this requires
344345
* heavy refactoring. Instead, we use this single instance.
345346
*/
346347
gd::ProjectScopedContainers& GetProjectScopedContainers() {
@@ -387,9 +388,7 @@ class GD_CORE_API EventsCodeGenerator {
387388
diagnosticReport = diagnosticReport_;
388389
}
389390

390-
gd::DiagnosticReport* GetDiagnosticReport() {
391-
return diagnosticReport;
392-
}
391+
gd::DiagnosticReport* GetDiagnosticReport() { return diagnosticReport; }
393392

394393
/**
395394
* \brief Generate the full name for accessing to a boolean variable used for
@@ -513,16 +512,16 @@ class GD_CORE_API EventsCodeGenerator {
513512
* \brief Generate an any variable getter that fallbacks on scene variable for
514513
* compatibility reason.
515514
*/
516-
gd::String
517-
GenerateAnyOrSceneVariableGetter(const gd::Expression &variableExpression,
518-
EventsCodeGenerationContext &context);
515+
gd::String GenerateAnyOrSceneVariableGetter(
516+
const gd::Expression& variableExpression,
517+
EventsCodeGenerationContext& context);
519518

520519
virtual gd::String GeneratePropertySetterWithoutCasting(
521-
const gd::PropertiesContainer &propertiesContainer,
522-
const gd::NamedPropertyDescriptor &property,
523-
const gd::String &operandCode);
520+
const gd::PropertiesContainer& propertiesContainer,
521+
const gd::NamedPropertyDescriptor& property,
522+
const gd::String& operandCode);
524523

525-
protected:
524+
protected:
526525
virtual const gd::String GenerateRelationalOperatorCodes(
527526
const gd::String& operatorString);
528527

@@ -643,16 +642,16 @@ class GD_CORE_API EventsCodeGenerator {
643642
gd::EventsCodeGenerationContext& context);
644643

645644
virtual gd::String GeneratePropertyGetterWithoutCasting(
646-
const gd::PropertiesContainer &propertiesContainer,
647-
const gd::NamedPropertyDescriptor &property);
645+
const gd::PropertiesContainer& propertiesContainer,
646+
const gd::NamedPropertyDescriptor& property);
648647

649648
virtual gd::String GenerateParameterGetter(
650649
const gd::ParameterMetadata& parameter,
651650
const gd::String& type,
652651
gd::EventsCodeGenerationContext& context);
653652

654-
virtual gd::String
655-
GenerateParameterGetterWithoutCasting(const gd::ParameterMetadata &parameter);
653+
virtual gd::String GenerateParameterGetterWithoutCasting(
654+
const gd::ParameterMetadata& parameter);
656655

657656
/**
658657
* \brief Generate the code to reference an object which is
@@ -769,7 +768,8 @@ class GD_CORE_API EventsCodeGenerator {
769768
const std::vector<gd::String>& arguments,
770769
const gd::InstructionMetadata& instrInfos,
771770
gd::EventsCodeGenerationContext& context,
772-
const gd::String& optionalAsyncCallbackName = "");
771+
const gd::String& optionalAsyncCallbackName = "",
772+
const gd::String& optionalAsyncCallbackId = "");
773773

774774
virtual gd::String GenerateObjectAction(
775775
const gd::String& objectName,
@@ -778,7 +778,8 @@ class GD_CORE_API EventsCodeGenerator {
778778
const std::vector<gd::String>& arguments,
779779
const gd::InstructionMetadata& instrInfos,
780780
gd::EventsCodeGenerationContext& context,
781-
const gd::String& optionalAsyncCallbackName = "");
781+
const gd::String& optionalAsyncCallbackName = "",
782+
const gd::String& optionalAsyncCallbackId = "");
782783

783784
virtual gd::String GenerateBehaviorAction(
784785
const gd::String& objectName,
@@ -788,7 +789,8 @@ class GD_CORE_API EventsCodeGenerator {
788789
const std::vector<gd::String>& arguments,
789790
const gd::InstructionMetadata& instrInfos,
790791
gd::EventsCodeGenerationContext& context,
791-
const gd::String& optionalAsyncCallbackName = "");
792+
const gd::String& optionalAsyncCallbackName = "",
793+
const gd::String& optionalAsyncCallbackId = "");
792794

793795
gd::String GenerateRelationalOperatorCall(
794796
const gd::InstructionMetadata& instrInfos,
@@ -837,9 +839,8 @@ class GD_CORE_API EventsCodeGenerator {
837839
virtual gd::String GenerateGetBehaviorNameCode(
838840
const gd::String& behaviorName);
839841

840-
void CheckBehaviorParameters(
841-
const gd::Instruction &instruction,
842-
const gd::InstructionMetadata &instrInfos);
842+
bool CheckBehaviorParameters(const gd::Instruction& instruction,
843+
const gd::InstructionMetadata& instrInfos);
843844

844845
const gd::Platform& platform; ///< The platform being used.
845846

@@ -876,4 +877,3 @@ class GD_CORE_API EventsCodeGenerator {
876877
};
877878

878879
} // namespace gd
879-

Core/GDCore/Events/Event.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,20 @@ class GD_CORE_API BaseEvent {
286286
* \brief True if the event should be folded in the events editor.
287287
*/
288288
bool IsFolded() const { return folded; }
289+
290+
/**
291+
* \brief Set the AI generated event ID.
292+
*/
293+
void SetAiGeneratedEventId(const gd::String& aiGeneratedEventId_) {
294+
aiGeneratedEventId = aiGeneratedEventId_;
295+
}
296+
297+
/**
298+
* \brief Get the AI generated event ID.
299+
*/
300+
const gd::String& GetAiGeneratedEventId() const {
301+
return aiGeneratedEventId;
302+
}
289303
///@}
290304

291305
std::weak_ptr<gd::BaseEvent>
@@ -304,6 +318,7 @@ class GD_CORE_API BaseEvent {
304318
bool disabled; ///< True if the event is disabled and must not be executed
305319
gd::String type; ///< Type of the event. Must be assigned at the creation.
306320
///< Used for saving the event for instance.
321+
gd::String aiGeneratedEventId; ///< When generated by an AI/external tool.
307322

308323
static gd::EventsList badSubEvents;
309324
static gd::VariablesContainer badLocalVariables;

Core/GDCore/Events/Serialization.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ void EventsListSerialization::UnserializeEventsFrom(
221221

222222
event->SetDisabled(eventElem.GetBoolAttribute("disabled", false));
223223
event->SetFolded(eventElem.GetBoolAttribute("folded", false));
224+
event->SetAiGeneratedEventId(
225+
eventElem.GetStringAttribute("aiGeneratedEventId", ""));
224226

225227
list.InsertEvent(event, list.GetEventsCount());
226228
}
@@ -236,6 +238,8 @@ void EventsListSerialization::SerializeEventsTo(const EventsList& list,
236238
if (event.IsDisabled())
237239
eventElem.SetAttribute("disabled", event.IsDisabled());
238240
if (event.IsFolded()) eventElem.SetAttribute("folded", event.IsFolded());
241+
if (!event.GetAiGeneratedEventId().empty())
242+
eventElem.SetAttribute("aiGeneratedEventId", event.GetAiGeneratedEventId());
239243
eventElem.AddChild("type").SetValue(event.GetType());
240244

241245
event.SerializeTo(eventElem);

0 commit comments

Comments
 (0)