OROCHI
 
Loading...
Searching...
No Matches
GxScript.h
Go to the documentation of this file.
1//===========================================================================
9//===========================================================================
10#pragma once
11
12GX_CORE_NAMESPACE_BEGIN()
13class GxScriptRuntime;
14
15//===========================================================================
17//===========================================================================
18class GxScript : public GxClassBase
19{
20 //-----------------------------------------------------------
22 //-----------------------------------------------------------
24public:
25 class GxArgument;
26 class GxBlock;
27 class GxBlockCommand;
31 class GxBlockStart;
32 class GxBlockEnd;
33 class GxBlockBranch;
34 class GxBlockIf;
35 class GxBlockIfElse;
36 class GxBlockLoop;
37 class GxBlockParameter;
39 class GxBlockParameterPropertyDynamic;
42
43 GX_RTTI_CLASS(GxScript, GxClassBase)
44 // ClassBase継承クラス用禁止宣言
46
47
48 //-----------------------------------------------------------
50 //-----------------------------------------------------------
52public:
54 GxScript(void);
56 ~GxScript(void) override;
57
59 //-----------------------------------------------------------
61 //-----------------------------------------------------------
63public:
65 void replaceData(const GxArrayClassBase& staticFunctions, const GxArrayClassBase& eventFunctions, const GxArrayClassBase& dynamicProperties);
67 GxFunction::GxValue execute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime, u32 argumentCount = 0, GxFunction::GxValue* pValues = nullptr) const;
68#if GX_DEVELOP
70 void render(const GxPoint2& offset, f32 zoom);
72 GxBlock* addBlock(GxRtti* pRtti, GxFunction* pFunction = nullptr, GxProperty* pProperty = nullptr, GxScript* pScript = nullptr);
74 void addBlock(GxBlock* pBlock);
76 void changeBottomBlock(GxBlock* pBlock);
78 GxBlockBranch* removeFromBranch(GxBlockCommand* pBlockCommand, s32* pBranchIndex = nullptr) const;
80 void removeSelectBlocks(void);
82 void removeBlock(GxBlock* pBlock);
84 void removeBlocks(GxFunction* pFunction);
86 void removeBlocks(GxProperty* pProperty);
87#endif //GX_DEVELOP
88private:
90 GxFunction::GxValue reExecute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime) const;
91
93 //-----------------------------------------------------------
95 //-----------------------------------------------------------
97public:
99 constexpr GxBlockStart* getBlockStart(void) const { return _pBlockStart; }
100#if GX_DEVELOP
102 GxBlock* getBlock(const GxPoint2& position);
104 static GxBlock* getTopParentBlock(GxBlockParameter* pBlockParameter);
106 void getSelectBlocks(GxArrayClassBase& blocks) const;
107#endif //GX_DEVELOP
109 template<class T>
110 void getBlocks(GxArrayClassBase& blocks) const
111 {
112 for (auto* pObject : _blocks)
113 {
114 auto* pBlock = gx_cast<T*>(pObject);
115 if (pBlock)
116 {
117 blocks.addBottom(pBlock);
118 }
119 }
120 }
122 GX_FORCE_INLINE GxArrayClassBase& getBlocks(void) { return _blocks; }
124 b32 isUsingFunction(GxFunction* pFunction) const;
126 b32 isUsingProperty(GxProperty* pProperty) const;
127
129 //-----------------------------------------------------------
131 //-----------------------------------------------------------
133private:
134 GxArrayClassBase _blocks;
135 GxBlockStart* _pBlockStart;
136
138};
139
140//===========================================================================
142//===========================================================================
144{
145 //-----------------------------------------------------------
147 //-----------------------------------------------------------
149public:
150 GX_RTTI_CLASS(GxArgument, GxClassBase)
151 // ClassBase継承クラス用禁止宣言
153
154#if GX_DEVELOP
155 static constexpr u32 MARGIN_WIDTH = 2;
156 static constexpr u32 MARGIN_HEIGHT = 2;
157 static constexpr u32 MARGIN_HEIGHT_HALF = MARGIN_HEIGHT / 2;
158#endif //GX_DEVELOP
159
161 //-----------------------------------------------------------
163 //-----------------------------------------------------------
165public:
167 GxArgument(void) : _pBlock(nullptr)
168#if GX_DEVELOP
169 , _pEnum(nullptr), _enumCount(0)
170#endif //GX_DEVELOP
171 {}
172
174 //-----------------------------------------------------------
176 //-----------------------------------------------------------
178#if GX_DEVELOP
180 static GxGuiBase* createGui(GxProperty& property, GxTypedObject* pOwner, const GxRtti& rtti, u32 index);
181#endif //GX_DEVELOP
182
184 //-----------------------------------------------------------
186 //-----------------------------------------------------------
188public:
190 constexpr GxBlockParameter* getBlock(void) const { return _pBlock; }
192 GX_FORCE_INLINE GxFunction::GxValue getValue(void) const { return _value; }
194 GX_FORCE_INLINE GxFunction::GxType getType(void) const { return _type; }
195#if GX_DEVELOP
197 u32 getWidth(void) const;
199 constexpr void setBlock(GxBlockParameter* pBlock) { _pBlock = pBlock; }
201 GX_FORCE_INLINE void setValue(GxFunction::GxValue value) { _value = value; }
203 GX_FORCE_INLINE void setType(GxFunction::GxType type) { _type = type; }
205 constexpr void setEnum(const GX_ENUM* pEnum) { _pEnum = pEnum; }
207 constexpr void setEnumCount(u32 count) { _enumCount = count; }
208#endif //GX_DEVELOP
209
211 //-----------------------------------------------------------
213 //-----------------------------------------------------------
215private:
216 GxBlockParameter* _pBlock;
217 GxFunction::GxValue _value;
218 GxFunction::GxType _type;
219#if GX_DEVELOP
220 const GX_ENUM* _pEnum;
221 u32 _enumCount;
222#endif //GX_DEVELOP
223
225};
226
227//===========================================================================
229//===========================================================================
231{
232 //-----------------------------------------------------------
234 //-----------------------------------------------------------
236public:
237 GX_RTTI_ABSTRACT_CLASS(GxBlock, GxClassBaseReference)
238 // ClassBase継承クラス用禁止宣言
240
241#if GX_DEVELOP
243 enum class CONNECT
244 {
245 NONE,
246 PREVIOUS,
247 NEXT,
248 BRANCH_FIRST,
249 BRANCH_SECOND,
250 ARGUMENT_START,
251 ARGUMENT_1 = ARGUMENT_START,
252 ARGUMENT_2,
253 ARGUMENT_3,
254 ARGUMENT_4,
255 ARGUMENT_END = ARGUMENT_4,
256 MAX,
257 };
258
259 static constexpr u32 CHAR_WIDTH = 10;
260 static constexpr u32 CONNECT_HEIGHT = 8;
261 static constexpr u32 HIT_CONNECT_WIDTH = 2;
262 static constexpr u32 ARGUMENT_EDGE_WIDTH = 2;
263 static const u32 FONT_HEIGHT;
264 static const u32 FONT_WIDTH;
265 static const GxColor COLOR_TEXT;
266 static const GxColor COLOR_SELECT;
267 static const GxColor COLOR_EXECUTED;
268 static const GxColor COLOR_HIT_CONNECT;
269 static const GxColor COLOR_COMMAND;
270 static const GxColor COLOR_SYSTEM;
271#endif //GX_DEVELOP
272
274 //-----------------------------------------------------------
276 //-----------------------------------------------------------
278public:
280 GxBlock(void);
282 void cleanup(void) override;
284 virtual void initialize(void) = 0;
285
287 //-----------------------------------------------------------
289 //-----------------------------------------------------------
291public:
293 GX_FORCE_INLINE virtual GxFunction::GxValue execute(GxClassBaseRoot* /*pObject*/, GxScriptRuntime& /*runtime*/, u32 /*argumentIndex*/ = 0, GxFunction::GxValue* /*pValues*/ = nullptr) const { return GxFunction::GxValue(); }
294#if GX_DEVELOP
296 GX_FORCE_INLINE void updatePosition(void) { updatePositionSub(_position._x); }
298 virtual void updateSize(void);
300 virtual void render(const GxPoint2& offset, f32 zoom);
302 virtual void renderBlock(const GxPoint2& position, f32 zoom) = 0;
304 void renderArguments(const GxPoint2& position, f32 zoom);
306 GX_FORCE_INLINE void addArgument(GxArgument& argument) { _arguments.addBottom(&argument); }
308 GX_FORCE_INLINE virtual void addMenuItems(GxPropertyTable& /*propertyTable*/) {}
310 GX_FORCE_INLINE virtual CONNECT isHit(const GxBlock& /*block*/) const { return CONNECT::NONE; }
312 GX_FORCE_INLINE virtual s32 isHitArgument(const GxBlock& /*block*/) const { return -1; }
314 s32 isHitPositionArgument(const GxPoint2& position) const;
316 GX_FORCE_INLINE virtual b32 isIncluding(const GxPoint2& position) const { return GxRect(_position, _size).isIncluding(position); }
318 GX_FORCE_INLINE virtual void connect(CONNECT /*connect*/, GxBlock* /*pBlock*/) {}
319protected:
321 GX_FORCE_INLINE virtual void updatePositionSub(s32 /*x*/) {}
323 void updatePositionArgument(const GxPoint2& position);
324#endif //GX_DEVELOP
325
327 //-----------------------------------------------------------
329 //-----------------------------------------------------------
331public:
333 virtual void getConnectBlocksSub(GxArrayClassBase& blocks, b32 isUnique = false) const;
335 constexpr GxBlock* getParent(void) const { return _pParent; }
337 GxBlockCommand* getParentCommand(void) const;
338#if GX_DEVELOP
340 constexpr void setParent(GxBlock* pParent) { _pParent = pParent; }
341#endif //GX_DEVELOP
343 constexpr u32 getArgumentCount(void) const { return _arguments.getCount(); }
345 GX_FORCE_INLINE GxArgument* getArgument(u32 index) const { return static_cast<GxArgument*>(_arguments[index]); }
346#if GX_DEVELOP
348 void setArgumentBlock(u32 index, GxBlockParameter* pBlockParameter);
350 u32 getArgumentDepth(void) const;
352 GX_FORCE_INLINE const GxPoint2& getPosition(void) const { return _position; }
354 GX_FORCE_INLINE void setPosition(const GxPoint2& position) { _position = position; }
356 GX_FORCE_INLINE const GxSize& getSize(void) const { return _size; }
358 GX_FORCE_INLINE void setSize(const GxSize& size) { _size = size; }
360 GX_FORCE_INLINE b32 isSelect(void) const { return _isSelect; }
362 GX_FORCE_INLINE void setSelect(b32 enable) { _isSelect = enable; }
364 constexpr CONNECT getHitConnect(void) const { return _hitConnect; }
366 constexpr void setHitConnect(CONNECT connect) { _hitConnect = connect; }
368 GX_FORCE_INLINE virtual b32 isMovable(void) const { return true; }
370 GX_FORCE_INLINE virtual b32 isRemovable(void) const { return true; }
372 static const GxColor& getTypeColor(GxFunction::TYPE type);
374 GX_FORCE_INLINE virtual void getHelp(GxString& /*help*/) const {}
375#endif //GX_DEVELOP
376
378 //-----------------------------------------------------------
380 //-----------------------------------------------------------
382private:
383 GxBlock* _pParent;
384 GxArrayClassBase _arguments;
385 GxPoint2 _position;
386 GxSize _size;
387#if GX_DEVELOP
388 b32 _isSelect;
389 CONNECT _hitConnect;
390#endif //GX_DEVELOP
391
393};
394
395//===========================================================================
397//===========================================================================
399{
400 //-----------------------------------------------------------
402 //-----------------------------------------------------------
404public:
405 GX_RTTI_ABSTRACT_CLASS(GxBlockCommand, GxBlock)
406 // ClassBase継承クラス用禁止宣言
408
409
410 //-----------------------------------------------------------
412 //-----------------------------------------------------------
414public:
416 GxBlockCommand(GxFunction& function) : _pPrevious(nullptr), _pNext(nullptr), _pFunction(&function), _isBreak(false)
417#if GX_DEVELOP
418 , _isExecuted(false)
419#endif //GX_DEVELOP
420 {}
421protected:
423 GxBlockCommand(void) : _pPrevious(nullptr), _pNext(nullptr), _pFunction(nullptr), _isBreak(false)
424#if GX_DEVELOP
425 , _isExecuted(false)
426#endif //GX_DEVELOP
427 {}
428
430 //-----------------------------------------------------------
432 //-----------------------------------------------------------
434public:
436 GxFunction::GxValue execute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime, u32 argumentIndex = 0, GxFunction::GxValue* pValues = nullptr) const override;
437#if GX_DEVELOP
439 CONNECT isHit(const GxBlock& block) const override;
441 void connect(CONNECT connect, GxBlock* pBlock) override;
443 void render(const GxPoint2& offset, f32 zoom) override;
444protected:
446 void updatePositionSub(s32 x) override;
447#endif //GX_DEVELOP
448
450 //-----------------------------------------------------------
452 //-----------------------------------------------------------
454public:
456 constexpr GxBlockCommand* getPrevious(void) const { return _pPrevious; }
458 constexpr GxBlockCommand* getNext(void) const { return _pNext; }
460 GxBlockCommand* getFirst(void) const;
462 GxBlockCommand* getLast(void) const;
464 void getConnectBlocks(GxArrayClassBase& blocks, b32 isUnique = false) const;
466 constexpr GxFunction* getFunction(void) const { return _pFunction; }
468 void setFunction(GxFunction& function);
469#if GX_DEVELOP
471 constexpr void setPrevious(GxBlockCommand* pBlock) { _pPrevious = pBlock; }
473 constexpr void setNext(GxBlockCommand* pBlock) { _pNext = pBlock; }
475 GxSize getConnectBlocksSize(void) const;
477 GX_FORCE_INLINE void setBreak(b32 enable) { _isBreak = enable; }
479 GX_FORCE_INLINE b32 isBreak(void) const { return _isBreak; }
481 GX_FORCE_INLINE void setExecuted(b32 enable) { _isExecuted = enable; }
483 GX_FORCE_INLINE b32 isExecuted(void) const { return _isExecuted; }
485 void getHelp(GxString& help) const override;
486#endif //GX_DEVELOP
487
489 //-----------------------------------------------------------
491 //-----------------------------------------------------------
493private:
494 GxBlockCommand* _pPrevious;
495 GxBlockCommand* _pNext;
496 GxFunction* _pFunction;
497 b32 _isBreak;
498#if GX_DEVELOP
499 b32 _isExecuted;
500#endif //GX_DEVELOP
501
503};
504
505//===========================================================================
507//===========================================================================
509{
510 //-----------------------------------------------------------
512 //-----------------------------------------------------------
514public:
516 // ClassBase継承クラス用禁止宣言
518
519
520 //-----------------------------------------------------------
522 //-----------------------------------------------------------
524public:
528 void initialize(void) override;
529protected:
532
534 //-----------------------------------------------------------
536 //-----------------------------------------------------------
538#if GX_DEVELOP
539public:
541 void updateSize(void) override;
543 void renderBlock(const GxPoint2& position, f32 zoom) override;
544protected:
546 void updatePositionSub(s32 x) override;
548 s32 isHitArgument(const GxBlock& block) const override;
549#endif //GX_DEVELOP
550
552};
553
554//===========================================================================
556//===========================================================================
558{
559 //-----------------------------------------------------------
561 //-----------------------------------------------------------
563public:
565 // ClassBase継承クラス用禁止宣言
567
568
569 //-----------------------------------------------------------
571 //-----------------------------------------------------------
573public:
576protected:
578 GxBlockCommandFunctionDynamic(void) : _pScript(nullptr){}
579
581 //-----------------------------------------------------------
583 //-----------------------------------------------------------
585public:
587 GxFunction::GxValue execute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime, u32 argumentIndex = 0, GxFunction::GxValue* pValues = nullptr) const override;
588
590 //-----------------------------------------------------------
592 //-----------------------------------------------------------
594public:
596 GX_FORCE_INLINE void setScript(GxScript& script) { _pScript = &script; }
597
599 //-----------------------------------------------------------
601 //-----------------------------------------------------------
603private:
604 GxScript* _pScript;
605
607};
608
609//===========================================================================
611//===========================================================================
613{
614 //-----------------------------------------------------------
616 //-----------------------------------------------------------
618public:
619 GX_RTTI_CLASS(GxBlockCommandSet, GxBlockCommand)
620 // ClassBase継承クラス用禁止宣言
622
623
624 //-----------------------------------------------------------
626 //-----------------------------------------------------------
628public:
630 GxBlockCommandSet(GxProperty& property);
632 void initialize(void) override;
633private:
635 GxBlockCommandSet(void) : _pProperty(nullptr), _propertyId(GxProperty::DEFAULT_ID) {}
636
638 //-----------------------------------------------------------
640 //-----------------------------------------------------------
642public:
644 GxFunction::GxValue execute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime, u32 argumentIndex = 0, GxFunction::GxValue* pValues = nullptr) const override;
645#if GX_DEVELOP
647 void renderBlock(const GxPoint2& position, f32 zoom) override;
649 void updateSize(void) override;
650protected:
652 void updatePositionSub(s32 x) override;
654 s32 isHitArgument(const GxBlock& block) const override;
655#endif //GX_DEVELOP
656
658 //-----------------------------------------------------------
660 //-----------------------------------------------------------
662public:
664 constexpr GxProperty* getProperty(void) const { return _pProperty; }
666 constexpr void setProperty(GxProperty& property) { _pProperty = &property; _propertyId = property.getId(); }
668 constexpr u32 getPropertyId(void) const { return _propertyId; }
669private:
671 GX_FORCE_INLINE b32 isDynamic(void) const { return !_pProperty->getOwnerRtti(); }
672
674 //-----------------------------------------------------------
676 //-----------------------------------------------------------
678private:
679 GxProperty* _pProperty;
680 u32 _propertyId;
681
683};
684
685//===========================================================================
687//===========================================================================
689{
690 //-----------------------------------------------------------
692 //-----------------------------------------------------------
694public:
695 GX_RTTI_CLASS(GxBlockStart, GxBlockCommand)
696 // ClassBase継承クラス用禁止宣言
698
699
700 //-----------------------------------------------------------
702 //-----------------------------------------------------------
704public:
706 GxBlockStart(GxFunction& function);
708 void cleanup(void) override;
710 void initialize(void) override;
711private:
713 GxBlockStart(void);
714
716 //-----------------------------------------------------------
718 //-----------------------------------------------------------
720public:
722 GX_FORCE_INLINE GxFunction::GxValue execute(GxClassBaseRoot* /*pObject*/, GxScriptRuntime& /*runtime*/, u32 /*argumentIndex*/ = 0, GxFunction::GxValue* /*pValues*/ = nullptr) const override { return GxFunction::GxValue(); }
723#if GX_DEVELOP
725 void renderBlock(const GxPoint2& position, f32 zoom) override;
727 CONNECT isHit(const GxBlock& block) const override;
729 void updateSize(void) override;
730#endif //GX_DEVELOP
731
733 //-----------------------------------------------------------
735 //-----------------------------------------------------------
737public:
738#if GX_DEVELOP
740 GX_FORCE_INLINE b32 isRemovable(void) const override { return false; }
741#endif //GX_DEVELOP
743 constexpr GxProperty* getProperty(u32 index) const { return _pProperties[index]; }
745 GxProperty* getPropertyFromId(u32 id) const;
746
748 //-----------------------------------------------------------
750 //-----------------------------------------------------------
752private:
754 u32 _propertyId[GxFunction::ARGUMENT_MAX];
755
757};
758
759//===========================================================================
761//===========================================================================
763{
764 //-----------------------------------------------------------
766 //-----------------------------------------------------------
768public:
769 GX_RTTI_CLASS(GxBlockEnd, GxBlockCommand)
770 // ClassBase継承クラス用禁止宣言
772
773
774 //-----------------------------------------------------------
776 //-----------------------------------------------------------
778public:
780 GxBlockEnd(GxFunction& function) : Super(function) {}
782 void initialize(void) override;
783private:
785 GxBlockEnd(void) {}
786
788 //-----------------------------------------------------------
790 //-----------------------------------------------------------
792public:
794 GxFunction::GxValue execute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime, u32 argumentIndex = 0, GxFunction::GxValue* pValues = nullptr) const override;
795#if GX_DEVELOP
797 void renderBlock(const GxPoint2& position, f32 zoom) override;
799 CONNECT isHit(const GxBlock& block) const override;
801 s32 isHitArgument(const GxBlock& block) const override;
803 void updateSize(void) override;
805 void updatePositionSub(s32 x) override;
806#endif //GX_DEVELOP
807
809 //-----------------------------------------------------------
811 //-----------------------------------------------------------
813public:
814#if GX_DEVELOP
816 GX_FORCE_INLINE b32 isMovable(void) const override { return false; }
818 GX_FORCE_INLINE b32 isRemovable(void) const override { return false; }
819#endif //GX_DEVELOP
820
822};
823
824//===========================================================================
826//===========================================================================
828{
829 //-----------------------------------------------------------
831 //-----------------------------------------------------------
833public:
834 GX_RTTI_ABSTRACT_CLASS(GxBlockBranch, GxBlockCommand)
835 // ClassBase継承クラス用禁止宣言
837
838#if GX_DEVELOP
839 static constexpr u32 MARGIN_BRANCH_LEFT = 1;
840#endif //GX_DEVELOP
841
843 //-----------------------------------------------------------
845 //-----------------------------------------------------------
847public:
849 GxBlockBranch(u32 branchCount) : _branchCount(branchCount){ _pBranch[0] = nullptr; _pBranch[1] = nullptr; }
851 void initialize(void) override;
852private:
854 GxBlockBranch(void) : _branchCount(1) { _pBranch[0] = nullptr; _pBranch[1] = nullptr; }
855
857 //-----------------------------------------------------------
859 //-----------------------------------------------------------
861#if GX_DEVELOP
862public:
864 void updateSize(void) override;
866 void renderBlock(const GxPoint2& position, f32 zoom) override;
868 CONNECT isHit(const GxBlock& block) const override;
870 b32 isIncluding(const GxPoint2& position) const override;
872 void connect(CONNECT connect, GxBlock* pBlock) override;
873protected:
875 void updatePositionSub(s32 x) override;
877 s32 isHitArgument(const GxBlock& block) const override;
878#endif //GX_DEVELOP
879
881 //-----------------------------------------------------------
883 //-----------------------------------------------------------
885public:
887 constexpr GxBlockCommand* getBranch(u32 index = 0) const { return _pBranch[index]; }
888#if GX_DEVELOP
890 void setBranch(GxBlockCommand* pBlock, u32 index = 0);
891#endif //GX_DEVELOP
893 s32 isBranch(GxBlockCommand* pBlock) const;
895 constexpr u32 getBranchCount(void) const { return _branchCount; }
897 void getConnectBlocksSub(GxArrayClassBase& blocks, b32 isUnique = false) const override;
898protected:
899#if GX_DEVELOP
900 // 名前用の幅を取得
901 virtual u32 getNameWidth(void) const = 0;
902#endif //GX_DEVELOP
903
905 //-----------------------------------------------------------
907 //-----------------------------------------------------------
909private:
910 GxBlockCommand* _pBranch[2];
911 u32 _branchCount;
912
914};
915
916//===========================================================================
918//===========================================================================
920{
921 //-----------------------------------------------------------
923 //-----------------------------------------------------------
925public:
926 GX_RTTI_CLASS(GxBlockIf, GxBlockBranch)
927 // ClassBase継承クラス用禁止宣言
929
930
931 //-----------------------------------------------------------
933 //-----------------------------------------------------------
935public:
937 GxBlockIf(void) : Super(1) {}
939 GxBlockIf(u32 branchCount) : Super(branchCount){}
940
942 //-----------------------------------------------------------
944 //-----------------------------------------------------------
946public:
948 GxFunction::GxValue execute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime, u32 argumentIndex = 0, GxFunction::GxValue* pValues = nullptr) const override;
949#if GX_DEVELOP
951 void renderBlock(const GxPoint2& position, f32 zoom) override;
952#endif //GX_DEVELOP
953
955 //-----------------------------------------------------------
957 //-----------------------------------------------------------
959public:
961 constexpr GxBlockCommand* getTrue(void) const { return getBranch(); }
962#if GX_DEVELOP
964 GX_FORCE_INLINE void setTrue(GxBlockCommand* pBlock) { setBranch(pBlock); }
965protected:
967 GX_FORCE_INLINE u32 getNameWidth(void) const override { return GX_STRLEN("if") * FONT_WIDTH; }
968#endif //GX_DEVELOP
969
971};
972
973//===========================================================================
975//===========================================================================
977{
978 //-----------------------------------------------------------
980 //-----------------------------------------------------------
982public:
983 GX_RTTI_CLASS(GxBlockIfElse, GxBlockIf)
984 // ClassBase継承クラス用禁止宣言
986
987
988 //-----------------------------------------------------------
990 //-----------------------------------------------------------
992public:
994 GxBlockIfElse(void) : Super(2) {}
995
997 //-----------------------------------------------------------
999 //-----------------------------------------------------------
1001public:
1003 GxFunction::GxValue execute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime, u32 argumentIndex = 0, GxFunction::GxValue* pValues = nullptr) const override;
1004#if GX_DEVELOP
1006 void renderBlock(const GxPoint2& position, f32 zoom) override;
1007#endif //GX_DEVELOP
1008
1010 //-----------------------------------------------------------
1012 //-----------------------------------------------------------
1014public:
1016 constexpr GxBlockCommand* getFalse(void) const { return getBranch(1); }
1017#if GX_DEVELOP
1019 GX_FORCE_INLINE void setFalse(GxBlockCommand* pBlock) { setBranch(pBlock, 1); }
1020#endif //GX_DEVELOP
1021
1023};
1024
1025//===========================================================================
1027//===========================================================================
1029{
1030 //-----------------------------------------------------------
1032 //-----------------------------------------------------------
1034public:
1035 GX_RTTI_CLASS(GxBlockLoop, GxBlockBranch)
1036 // ClassBase継承クラス用禁止宣言
1038
1039
1040 //-----------------------------------------------------------
1042 //-----------------------------------------------------------
1044public:
1046 GxBlockLoop(void) : Super(1){}
1047
1049 //-----------------------------------------------------------
1051 //-----------------------------------------------------------
1053public:
1055 GxFunction::GxValue execute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime, u32 argumentIndex = 0, GxFunction::GxValue* pValues = nullptr) const override;
1056#if GX_DEVELOP
1058 void renderBlock(const GxPoint2& position, f32 zoom) override;
1059#endif //GX_DEVELOP
1060
1062 //-----------------------------------------------------------
1064 //-----------------------------------------------------------
1066protected:
1067#if GX_DEVELOP
1069 GX_FORCE_INLINE u32 getNameWidth(void) const override { return GX_STRLEN("while") * FONT_WIDTH; }
1070#endif //GX_DEVELOP
1071
1073};
1074
1075//===========================================================================
1077//===========================================================================
1079{
1080 //-----------------------------------------------------------
1082 //-----------------------------------------------------------
1084public:
1085 GX_RTTI_ABSTRACT_CLASS(GxBlockParameter, GxBlock)
1086 // ClassBase継承クラス用禁止宣言
1088
1089
1090 //-----------------------------------------------------------
1092 //-----------------------------------------------------------
1094public:
1096 GxBlockParameter(GxFunction::GxType type) : _argumentIndex(-1), _type(type) {}
1098 GX_FORCE_INLINE void initialize(void) override {}
1099protected:
1101 GxBlockParameter(void) : _argumentIndex(-1){}
1102
1104 //-----------------------------------------------------------
1106 //-----------------------------------------------------------
1108public:
1109#if GX_DEVELOP
1111 void renderBlock(const GxPoint2& position, f32 zoom) override;
1113 static GxGuiBase* createGui(GxProperty& property, GxTypedObject* pOwner, const GxRtti& rtti, u32 index);
1114#endif //GX_DEVELOP
1115
1117 //-----------------------------------------------------------
1119 //-----------------------------------------------------------
1121public:
1123 constexpr s32 getArgumentIndex(void) const { return _argumentIndex; }
1124#if GX_DEVELOP
1126 constexpr void setArgumentIndex(s32 index) { _argumentIndex = index; }
1127#endif //GX_DEVELOP
1129 GX_FORCE_INLINE GxFunction::GxType getType(void) const { return _type; }
1131 GX_FORCE_INLINE void setType(GxFunction::GxType type) { _type = type; }
1132
1134 //-----------------------------------------------------------
1136 //-----------------------------------------------------------
1138private:
1139 s32 _argumentIndex;
1140 GxFunction::GxType _type;
1141
1143};
1144
1145//===========================================================================
1147//===========================================================================
1149{
1150 //-----------------------------------------------------------
1152 //-----------------------------------------------------------
1154public:
1156 // ClassBase継承クラス用禁止宣言
1158
1159
1160 //-----------------------------------------------------------
1162 //-----------------------------------------------------------
1164public:
1167protected:
1169 GxBlockParameterProperty(void) : _pProperty(nullptr), _propertyId(GxProperty::DEFAULT_ID){}
1170
1172 //-----------------------------------------------------------
1174 //-----------------------------------------------------------
1176public:
1178 GxFunction::GxValue execute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime, u32 argumentIndex = 0, GxFunction::GxValue* pValues = nullptr) const override;
1179#if GX_DEVELOP
1181 void renderBlock(const GxPoint2& position, f32 zoom) override;
1182protected:
1184 void updateSize(void) override;
1185#endif //GX_DEVELOP
1186
1188 //-----------------------------------------------------------
1190 //-----------------------------------------------------------
1192public:
1194 constexpr GxProperty* getProperty(void) const { return _pProperty; }
1196 constexpr void setProperty(GxProperty& property) { _pProperty = &property; _propertyId = property.getId(); }
1198 constexpr u32 getPropertyId(void) const { return _propertyId; }
1200 static b32 isSupport(GxProperty& property);
1201private:
1203 GX_FORCE_INLINE b32 isDynamic(void) const { return !_pProperty->getOwnerRtti(); }
1204
1206 //-----------------------------------------------------------
1208 //-----------------------------------------------------------
1210private:
1211 GxProperty* _pProperty;
1212 u32 _propertyId;
1213
1215};
1216
1217//===========================================================================
1219//===========================================================================
1221{
1222 //-----------------------------------------------------------
1224 //-----------------------------------------------------------
1226public:
1228 // ClassBase継承クラス用禁止宣言
1230
1231
1232 //-----------------------------------------------------------
1234 //-----------------------------------------------------------
1236public:
1240 void initialize(void) override;
1241protected:
1243 GxBlockParameterFunction(void) : _pFunction(nullptr){}
1244
1246 //-----------------------------------------------------------
1248 //-----------------------------------------------------------
1250public:
1252 GxFunction::GxValue execute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime, u32 argumentIndex = 0, GxFunction::GxValue* pValues = nullptr) const override;
1253#if GX_DEVELOP
1255 void renderBlock(const GxPoint2& position, f32 zoom) override;
1256protected:
1258 void updatePositionSub(s32 x) override;
1260 void updateSize(void) override;
1262 s32 isHitArgument(const GxBlock& block) const override;
1263#endif //GX_DEVELOP
1264
1266 //-----------------------------------------------------------
1268 //-----------------------------------------------------------
1270public:
1272 constexpr GxFunction* getFunction(void) const { return _pFunction; }
1274 constexpr void setFunction(GxFunction& function) { _pFunction = &function; }
1275#if GX_DEVELOP
1277 GX_FORCE_INLINE void getHelp(GxString& text) const override { _pFunction->getHelp(text); }
1278#endif //GX_DEVELOP
1279
1281 //-----------------------------------------------------------
1283 //-----------------------------------------------------------
1285private:
1286 GxFunction* _pFunction;
1287
1289};
1290
1291//===========================================================================
1293//===========================================================================
1295{
1296 //-----------------------------------------------------------
1298 //-----------------------------------------------------------
1300public:
1302 // ClassBase継承クラス用禁止宣言
1304
1305
1306 //-----------------------------------------------------------
1308 //-----------------------------------------------------------
1310public:
1313private:
1315 GxBlockParameterFunctionDynamic(void) : _pScript(nullptr){}
1316
1318 //-----------------------------------------------------------
1320 //-----------------------------------------------------------
1322public:
1324 GxFunction::GxValue execute(GxClassBaseRoot* pObject, GxScriptRuntime& runtime, u32 argumentIndex = 0, GxFunction::GxValue* pValues = nullptr) const override;
1325
1327 //-----------------------------------------------------------
1329 //-----------------------------------------------------------
1331public:
1333 constexpr void setScript(GxScript& script) { _pScript = &script; }
1334
1336 //-----------------------------------------------------------
1338 //-----------------------------------------------------------
1340private:
1341 GxScript* _pScript;
1342
1344};
1345
1346GX_CORE_NAMESPACE_END()
#define GX_PROHIBIT_CLASS_BASE_REFERENCE(__CLASS__)
GxClassBaseReference継承の禁止宣言(new以外の生成禁止 + コピー禁止)
Definition GxBase.h:244
T gx_cast(GxClassBaseRoot *pObject)
Definition GxBase.h:264
#define GX_PROHIBIT_CLASS_BASE(__CLASS__)
GxClassBase継承の禁止宣言
Definition GxBase.h:240
@ MAX
定義数
void GxTypedObject
その他
Definition GxDefine.h:213
@ NONE
何もしない
#define GX_STRLEN(__STRING__)
文字列の長さ取得
Definition GxString.h:604
配列クラス
Definition GxArrayClassBase.h:18
void addBottom(GxClassBaseRoot *pObject)
末尾に追加
Definition GxArrayClassBase.cpp:59
オブジェクト基底クラス
Definition GxBase.h:88
参照オブジェクト基底クラス
Definition GxBase.h:122
基底クラス
Definition GxBase.h:51
型情報
Definition GxFunction.h:48
関数型情報
Definition GxFunction.h:18
TYPE
型定義
Definition GxFunction.h:28
static const u32 ARGUMENT_MAX
引数の最大数
Definition GxFunction.h:234
プロパティクラス
Definition GxProperty.h:48
constexpr GxRtti * getOwnerRtti(void) const
所持者のRTTIを取得
Definition GxProperty.h:1031
static constexpr u32 DEFAULT_ID
デフォルトID
Definition GxProperty.h:126
プロパティテーブルクラス
Definition GxProperty.h:1641
実行時型情報クラス
Definition GxRtti.h:154
引数クラス
Definition GxScript.h:144
GxArgument(void)
デフォルトコンストラクタ
Definition GxScript.h:167
GX_FORCE_INLINE GxFunction::GxType getType(void) const
型を取得
Definition GxScript.h:194
GX_FORCE_INLINE GxFunction::GxValue getValue(void) const
値を取得
Definition GxScript.h:192
constexpr GxBlockParameter * getBlock(void) const
ブロックを取得
Definition GxScript.h:190
分岐ブロッククラス
Definition GxScript.h:828
GxBlockBranch(u32 branchCount)
コンストラクタ
Definition GxScript.h:849
void initialize(void) override
初期化
Definition GxScript.cpp:1989
constexpr GxBlockCommand * getBranch(u32 index=0) const
分岐先のブロックを取得
Definition GxScript.h:887
void getConnectBlocksSub(GxArrayClassBase &blocks, b32 isUnique=false) const override
接続ブロックリストを取得
Definition GxScript.cpp:2334
constexpr u32 getBranchCount(void) const
分岐数を取得
Definition GxScript.h:895
命令動的関数ブロッククラス
Definition GxScript.h:558
GX_FORCE_INLINE void setScript(GxScript &script)
スクリプトを設定
Definition GxScript.h:596
GxBlockCommandFunctionDynamic(void)
デフォルトコンストラクタ
Definition GxScript.h:578
GxFunction::GxValue execute(GxClassBaseRoot *pObject, GxScriptRuntime &runtime, u32 argumentIndex=0, GxFunction::GxValue *pValues=nullptr) const override
実行
Definition GxScript.cpp:1416
命令関数ブロッククラス
Definition GxScript.h:509
void initialize(void) override
初期化
Definition GxScript.cpp:1280
GxBlockCommandFunction(void)
デフォルトコンストラクタ
Definition GxScript.h:531
命令ブロッククラス
Definition GxScript.h:399
constexpr GxBlockCommand * getPrevious(void) const
前のブロックを取得
Definition GxScript.h:456
GxBlockCommand(void)
デフォルトコンストラクタ
Definition GxScript.h:423
GxBlockCommand(GxFunction &function)
コンストラクタ
Definition GxScript.h:416
GxBlockCommand * getFirst(void) const
先頭のブロックを取得
Definition GxScript.cpp:1088
void setFunction(GxFunction &function)
関数を設定
Definition GxScript.cpp:1131
GxFunction::GxValue execute(GxClassBaseRoot *pObject, GxScriptRuntime &runtime, u32 argumentIndex=0, GxFunction::GxValue *pValues=nullptr) const override
実行
Definition GxScript.cpp:1030
constexpr GxFunction * getFunction(void) const
関数を取得
Definition GxScript.h:466
constexpr GxBlockCommand * getNext(void) const
次のブロックを取得
Definition GxScript.h:458
void getConnectBlocks(GxArrayClassBase &blocks, b32 isUnique=false) const
接続ブロックリストを取得
Definition GxScript.cpp:1117
GxBlockCommand * getLast(void) const
最後のブロックを取得
Definition GxScript.cpp:1102
代入ブロッククラス
Definition GxScript.h:613
constexpr void setProperty(GxProperty &property)
プロパティを設定
Definition GxScript.h:666
constexpr u32 getPropertyId(void) const
プロパティIDを取得
Definition GxScript.h:668
GxFunction::GxValue execute(GxClassBaseRoot *pObject, GxScriptRuntime &runtime, u32 argumentIndex=0, GxFunction::GxValue *pValues=nullptr) const override
実行
Definition GxScript.cpp:1499
void initialize(void) override
初期化
Definition GxScript.cpp:1479
constexpr GxProperty * getProperty(void) const
プロパティを取得
Definition GxScript.h:664
終了ブロッククラス
Definition GxScript.h:763
GxBlockEnd(GxFunction &function)
コンストラクタ
Definition GxScript.h:780
GxFunction::GxValue execute(GxClassBaseRoot *pObject, GxScriptRuntime &runtime, u32 argumentIndex=0, GxFunction::GxValue *pValues=nullptr) const override
実行
Definition GxScript.cpp:1864
void initialize(void) override
初期化
Definition GxScript.cpp:1842
標準ブロッククラス
Definition GxScript.h:231
virtual GX_FORCE_INLINE GxFunction::GxValue execute(GxClassBaseRoot *, GxScriptRuntime &, u32=0, GxFunction::GxValue *=nullptr) const
実行
Definition GxScript.h:293
virtual void getConnectBlocksSub(GxArrayClassBase &blocks, b32 isUnique=false) const
接続ブロックリストを取得
Definition GxScript.cpp:971
constexpr GxBlock * getParent(void) const
設定したブロックを取得
Definition GxScript.h:335
GxBlockCommand * getParentCommand(void) const
設定したコマンドブロックを取得
Definition GxScript.cpp:910
GxBlock(void)
デフォルトコンストラクタ
Definition GxScript.cpp:786
void cleanup(void) override
delete直前に呼び出される関数
Definition GxScript.cpp:799
GX_FORCE_INLINE GxArgument * getArgument(u32 index) const
引数を取得
Definition GxScript.h:345
virtual void initialize(void)=0
初期化
条件分岐2ブロッククラス
Definition GxScript.h:977
constexpr GxBlockCommand * getFalse(void) const
偽のブロックを取得
Definition GxScript.h:1016
GxFunction::GxValue execute(GxClassBaseRoot *pObject, GxScriptRuntime &runtime, u32 argumentIndex=0, GxFunction::GxValue *pValues=nullptr) const override
実行
Definition GxScript.cpp:2438
GxBlockIfElse(void)
デフォルトコンストラクタ
Definition GxScript.h:994
条件分岐1ブロッククラス
Definition GxScript.h:920
GxBlockIf(u32 branchCount)
コンストラクタ
Definition GxScript.h:939
constexpr GxBlockCommand * getTrue(void) const
真のブロックを取得
Definition GxScript.h:961
GxFunction::GxValue execute(GxClassBaseRoot *pObject, GxScriptRuntime &runtime, u32 argumentIndex=0, GxFunction::GxValue *pValues=nullptr) const override
実行
Definition GxScript.cpp:2357
GxBlockIf(void)
デフォルトコンストラクタ
Definition GxScript.h:937
繰り返しブロッククラス
Definition GxScript.h:1029
GxBlockLoop(void)
デフォルトコンストラクタ
Definition GxScript.h:1046
GxFunction::GxValue execute(GxClassBaseRoot *pObject, GxScriptRuntime &runtime, u32 argumentIndex=0, GxFunction::GxValue *pValues=nullptr) const override
実行
Definition GxScript.cpp:2521
パラメータ動的関数ブロッククラス
Definition GxScript.h:1295
constexpr void setScript(GxScript &script)
スクリプトを設定
Definition GxScript.h:1333
GxFunction::GxValue execute(GxClassBaseRoot *pObject, GxScriptRuntime &runtime, u32 argumentIndex=0, GxFunction::GxValue *pValues=nullptr) const override
実行
Definition GxScript.cpp:3038
パラメータ関数ブロッククラス
Definition GxScript.h:1221
GxBlockParameterFunction(void)
デフォルトコンストラクタ
Definition GxScript.h:1243
void initialize(void) override
初期化
Definition GxScript.cpp:2803
GxFunction::GxValue execute(GxClassBaseRoot *pObject, GxScriptRuntime &runtime, u32 argumentIndex=0, GxFunction::GxValue *pValues=nullptr) const override
実行
Definition GxScript.cpp:2831
constexpr GxFunction * getFunction(void) const
関数を取得
Definition GxScript.h:1272
constexpr void setFunction(GxFunction &function)
関数を設定
Definition GxScript.h:1274
パラメータブロッククラス
Definition GxScript.h:1079
GX_FORCE_INLINE void initialize(void) override
初期化
Definition GxScript.h:1098
GxBlockParameter(void)
デフォルトコンストラクタ
Definition GxScript.h:1101
constexpr s32 getArgumentIndex(void) const
設定した引数のインデックスを取得
Definition GxScript.h:1123
GxBlockParameter(GxFunction::GxType type)
コンストラクタ
Definition GxScript.h:1096
GX_FORCE_INLINE void setType(GxFunction::GxType type)
型を設定
Definition GxScript.h:1131
パラメータプロパティブロッククラス
Definition GxScript.h:1149
GxFunction::GxValue execute(GxClassBaseRoot *pObject, GxScriptRuntime &runtime, u32 argumentIndex=0, GxFunction::GxValue *pValues=nullptr) const override
実行
Definition GxScript.cpp:2690
constexpr void setProperty(GxProperty &property)
プロパティを設定
Definition GxScript.h:1196
GxBlockParameterProperty(void)
デフォルトコンストラクタ
Definition GxScript.h:1169
constexpr u32 getPropertyId(void) const
プロパティIDを取得
Definition GxScript.h:1198
constexpr GxProperty * getProperty(void) const
プロパティを取得
Definition GxScript.h:1194
static b32 isSupport(GxProperty &property)
サポートしているプロパティ判定
Definition GxScript.cpp:2758
開始ブロッククラス
Definition GxScript.h:689
void initialize(void) override
初期化
Definition GxScript.cpp:1723
void cleanup(void) override
delete直前に呼び出される関数
Definition GxScript.cpp:1710
GX_FORCE_INLINE GxFunction::GxValue execute(GxClassBaseRoot *, GxScriptRuntime &, u32=0, GxFunction::GxValue *=nullptr) const override
実行
Definition GxScript.h:722
GxProperty * getPropertyFromId(u32 id) const
IDからプロパティを取得
Definition GxScript.cpp:1821
スクリプトクラス
Definition GxScript.h:19
constexpr GxBlockStart * getBlockStart(void) const
開始ブロックを取得
Definition GxScript.h:99
GX_FORCE_INLINE GxArrayClassBase & getBlocks(void)
ブロックリストを取得
Definition GxScript.h:122
void getBlocks(GxArrayClassBase &blocks) const
ブロックリストを取得
Definition GxScript.h:110
スクリプトランタイムクラス
Definition GxScriptRuntime.h:19
GUI用
Definition GxDefine.h:194
Definition GxColor.h:21
値の共用体
Definition GxFunction.h:81
座標
Definition GxStruct.h:867
s32 _x
X値
Definition GxStruct.h:941
矩形
Definition GxStruct.h:951
GX_INLINE b32 isIncluding(const GxRect &rect) const
内包判定
Definition GxStruct.inl:1801
サイズ
Definition GxStruct.h:730
文字列型クラス
Definition GxString.h:18
32bitブーリアン
Definition GxDefine.h:173