@@ -42,6 +42,9 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
42
42
const gd::NamedPropertyDescriptor &property, const gd::String &objectType,
43
43
bool isBehavior, bool isSharedProperties) {
44
44
auto &propertyName = property.GetName ();
45
+ const auto &primitiveType = gd::ValueTypeMetadata::GetPrimitiveValueType (
46
+ gd::ValueTypeMetadata::ConvertPropertyTypeToValueType (
47
+ property.GetType ()));
45
48
auto &functionsContainer = eventsBasedEntity.GetEventsFunctions ();
46
49
gd::String capitalizedName = CapitalizeFirstLetter (property.GetName ());
47
50
gd::String setterName = " Set" + capitalizedName;
@@ -59,9 +62,9 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
59
62
property.GetLabel ().empty () ? property.GetName () : property.GetLabel ();
60
63
61
64
gd::String descriptionSubject =
62
- (property. GetType () == " Boolean " ? " if " : " the " ) +
65
+ (primitiveType == " boolean " ? " if " : " the " ) +
63
66
UnCapitalizeFirstLetter (propertyLabel) +
64
- (isSharedProperties || property. GetType () == " Boolean "
67
+ (isSharedProperties || primitiveType == " boolean "
65
68
? " ."
66
69
: " of the object." ) +
67
70
(property.GetDescription ().empty () ? " "
@@ -71,19 +74,7 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
71
74
" objects using the behavior."
72
75
: " " );
73
76
74
- gd::String propertyGetterName =
75
- (isSharedProperties ? " SharedProperty" : " Property" ) + property.GetName ();
76
- gd::String getterType =
77
- gd::PlatformExtension::GetBehaviorEventsFunctionFullType (
78
- extension.GetName (), eventsBasedEntity.GetName (), propertyGetterName);
79
- gd::String setterType =
80
- gd::PlatformExtension::GetBehaviorEventsFunctionFullType (
81
- extension.GetName (), eventsBasedEntity.GetName (),
82
- " Set" + propertyGetterName);
83
-
84
77
gd::String getterName = capitalizedName;
85
- gd::String numberOrString =
86
- property.GetType () == " Number" ? " Number" : " String" ;
87
78
88
79
if (!functionsContainer.HasEventsFunctionNamed (getterName)) {
89
80
auto &getter = functionsContainer.InsertNewEventsFunction (
@@ -99,7 +90,7 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
99
90
.SetName (legacyExpressionType)
100
91
.SetExtraInfo (GetStringifiedExtraInfo (property));
101
92
getter.SetFullName (propertyLabel).SetGroup (functionGroupName);
102
- if (property. GetType () == " Boolean " ) {
93
+ if (primitiveType == " boolean " ) {
103
94
getter.SetFunctionType (gd::EventsFunction::Condition)
104
95
.SetDescription (" Check " + descriptionSubject)
105
96
.SetSentence (" _PARAM0_ " + UnCapitalizeFirstLetter (propertyLabel));
@@ -112,13 +103,12 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
112
103
auto &event =
113
104
dynamic_cast <gd::StandardEvent &>(getter.GetEvents ().InsertNewEvent (
114
105
project, " BuiltinCommonInstructions::Standard" , 0 ));
115
- if (property. GetType () == " Boolean " ) {
106
+ if (primitiveType == " boolean " ) {
116
107
gd::Instruction condition;
117
- condition.SetType (getterType);
118
- condition.AddParameter (" Object" );
119
- if (isBehavior) {
120
- condition.AddParameter (" Behavior" );
121
- }
108
+ condition.SetType (" BooleanVariable" );
109
+ condition.AddParameter (propertyName);
110
+ condition.AddParameter (" True" );
111
+ condition.AddParameter (" " );
122
112
event.GetConditions ().Insert (condition, 0 );
123
113
124
114
gd::Instruction action;
@@ -127,6 +117,8 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
127
117
event.GetActions ().Insert (action, 0 );
128
118
} else {
129
119
gd::Instruction action;
120
+ gd::String numberOrString =
121
+ primitiveType == " number" ? " Number" : " String" ;
130
122
action.SetType (" SetReturn" + numberOrString);
131
123
action.AddParameter (property.GetName ());
132
124
event.GetActions ().Insert (action, 0 );
@@ -136,7 +128,7 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
136
128
if (!functionsContainer.HasEventsFunctionNamed (setterName)) {
137
129
auto &setter = functionsContainer.InsertNewEventsFunction (
138
130
setterName, functionsContainer.GetEventsFunctionsCount ());
139
- if (property. GetType () == " Boolean " ) {
131
+ if (primitiveType == " boolean " ) {
140
132
setter.SetFunctionType (gd::EventsFunction::Action)
141
133
.SetFullName (propertyLabel)
142
134
.SetGroup (functionGroupName)
@@ -177,26 +169,24 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
177
169
setter.SetGetterName (getterName);
178
170
}
179
171
180
- if (property. GetType () == " Boolean " ) {
172
+ if (primitiveType == " boolean " ) {
181
173
{
182
174
auto &event =
183
175
dynamic_cast <gd::StandardEvent &>(setter.GetEvents ().InsertNewEvent (
184
176
project, " BuiltinCommonInstructions::Standard" , 0 ));
185
177
186
178
gd::Instruction condition;
187
- condition.SetType (" GetArgumentAsBoolean" );
188
- condition.AddParameter (" \" Value\" " );
179
+ condition.SetType (" BooleanVariable" );
180
+ condition.AddParameter (" Value" );
181
+ condition.AddParameter (" True" );
182
+ condition.AddParameter (" " );
189
183
event.GetConditions ().Insert (condition, 0 );
190
184
191
185
gd::Instruction action;
192
- action.SetType (setterType);
193
- action.AddParameter (" Object" );
194
- if (isBehavior) {
195
- action.AddParameter (" Behavior" );
196
- action.AddParameter (" yes" );
197
- } else {
198
- action.AddParameter (" yes" );
199
- }
186
+ action.SetType (" SetBooleanVariable" );
187
+ action.AddParameter (propertyName);
188
+ action.AddParameter (" True" );
189
+ action.AddParameter (" " );
200
190
event.GetActions ().Insert (action, 0 );
201
191
}
202
192
{
@@ -205,20 +195,17 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
205
195
project, " BuiltinCommonInstructions::Standard" , 0 ));
206
196
207
197
gd::Instruction condition;
208
- condition.SetType (" GetArgumentAsBoolean" );
209
- condition.AddParameter (" \" Value\" " );
210
- condition.SetInverted (true );
198
+ condition.SetType (" BooleanVariable" );
199
+ condition.AddParameter (" Value" );
200
+ condition.AddParameter (" False" );
201
+ condition.AddParameter (" " );
211
202
event.GetConditions ().Insert (condition, 0 );
212
203
213
204
gd::Instruction action;
214
- action.SetType (setterType);
215
- action.AddParameter (" Object" );
216
- if (isBehavior) {
217
- action.AddParameter (" Behavior" );
218
- action.AddParameter (" no" );
219
- } else {
220
- action.AddParameter (" no" );
221
- }
205
+ action.SetType (" SetBooleanVariable" );
206
+ action.AddParameter (propertyName);
207
+ action.AddParameter (" False" );
208
+ action.AddParameter (" " );
222
209
event.GetActions ().Insert (action, 0 );
223
210
}
224
211
} else {
@@ -227,16 +214,11 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
227
214
project, " BuiltinCommonInstructions::Standard" , 0 ));
228
215
229
216
gd::Instruction action;
230
- action.SetType (setterType);
231
- action.AddParameter (" Object" );
232
- if (isBehavior) {
233
- action.AddParameter (" Behavior" );
234
- action.AddParameter (" =" );
235
- action.AddParameter (" Value" );
236
- } else {
237
- action.AddParameter (" =" );
238
- action.AddParameter (" Value" );
239
- }
217
+ action.SetType (primitiveType == " number" ? " SetNumberVariable"
218
+ : " SetStringVariable" );
219
+ action.AddParameter (propertyName);
220
+ action.AddParameter (" =" );
221
+ action.AddParameter (" Value" );
240
222
event.GetActions ().Insert (action, 0 );
241
223
}
242
224
}
0 commit comments