LeviLamina
Loading...
Searching...
No Matches
CommandRegistry.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/network/packet/AvailableCommandsPacket.h"
5#include "mc/server/commands/BlockStateCommandParam.h"
6#include "mc/server/commands/CommandChainedSubcommand.h"
7#include "mc/server/commands/CommandCompareOperator.h"
8#include "mc/server/commands/CommandFilePath.h"
9#include "mc/server/commands/CommandFlag.h"
10#include "mc/server/commands/CommandMessage.h"
11#include "mc/server/commands/CommandOperator.h"
12#include "mc/server/commands/CommandRawText.h"
13#include "mc/server/commands/CommandVersion.h"
14#include "mc/server/commands/CommandWildcardInt.h"
15#include "mc/server/commands/WildcardCommandSelector.h"
16
17// auto generated inclusion list
18#include "mc/deps/core/utility/typeid_t.h"
19#include "mc/platform/brstd/copyable_function.h"
20#include "mc/server/commands/CommandFlag.h"
21#include "mc/server/commands/CommandLexer.h"
22#include "mc/server/commands/CommandPermissionLevel.h"
23#include "mc/server/commands/CommandSelector.h"
24#include "mc/server/commands/CommandVersion.h"
25#include "mc/server/commands/SemanticConstraint.h"
26#include "mc/world/actor/selectors/InvertableFilter.h"
27
28// auto generated forward declare list
29// clang-format off
30class Actor;
32class Command;
33class CommandOrigin;
35class CommandRunStats;
38class Packet;
41namespace Json { class Value; }
42// clang-format on
43
45public:
46 // CommandRegistry inner types declare
47 // clang-format off
48 struct ChainedSubcommand;
49 struct ConstrainedValue;
50 struct Enum;
51 struct Factorization;
52 struct LexicalToken;
54 struct Overload;
55 struct ParamSymbols;
56 struct ParseRule;
57 struct ParseTable;
58 struct ParseToken;
59 class Parser;
60 struct RegistryState;
61 struct SemanticInfo;
62 struct Signature;
63 struct SoftEnum;
64 class Symbol;
65 struct SymbolHasher;
66 struct SymbolPairHasher;
67 // clang-format on
68
69 // CommandRegistry inner types define
70 using ValueTypeID = uint64;
71
72 using EnumValueID = uint64;
73
74 using EnumID = uint;
75
76 using SoftEnumID = uint;
77
78 using ChainedSubcommandValueID = uint64;
79
80 using ChainedSubcommandID = uint;
81
82 using SemanticConstraintID = uchar;
83
84 using ConstrainedValueID = uint;
85
86 using ConstrainedValueLookupKey = ::std::pair<uint64, uint>;
87
88 using CustomStorageGetFn = void* (*)(::Command*, int);
89
90 using CustomStorageIsSetFn = bool* (*)(::Command*, int);
91
92 using CommandOverrideFunctor =
93 ::std::function<void(::std::string const&, ::CommandFlag&, ::CommandPermissionLevel&)>;
94 using ScoreboardScoreAccessor = ::std::function<int(bool&, ::std::string const&, ::Actor const&)>;
95
96 using HardTerminal = ::CommandLexer::TokenType;
97
98 enum class HardNonTerminal : int {
99 Epsilon = 1048576,
100 Int = 1048577,
101 Float = 1048578,
102 Val = 1048579,
103 RVal = 1048580,
104 WildcardInt = 1048581,
105 Operator = 1048582,
106 CompareOperator = 1048583,
107 Selection = 1048584,
108 StandaloneSelection = 1048585,
109 WildcardSelection = 1048586,
110 NonIdSelector = 1048587,
111 ScoresArg = 1048588,
112 ScoresArgs = 1048589,
113 ScoreSelectParam = 1048590,
114 ScoreSelector = 1048591,
115 TagSelector = 1048592,
116 FilePath = 1048593,
117 FilePathVal = 1048594,
118 FilePathCont = 1048595,
119 IntegerRangeVal = 1048596,
120 IntegerRangePostVal = 1048597,
121 IntegerRange = 1048598,
122 FullIntegerRange = 1048599,
123 RationalRangeVal = 1048600,
124 RationalRangePostVal = 1048601,
125 RationalRange = 1048602,
126 FullRationalRange = 1048603,
127 SelArgs = 1048604,
128 Args = 1048605,
129 Arg = 1048606,
130 MArg = 1048607,
131 MValue = 1048608,
132 NameArg = 1048609,
133 TypeArg = 1048610,
134 FamilyArg = 1048611,
135 HasPermissionArg = 1048612,
136 HasPermissionArgs = 1048613,
137 HasPermissionSelector = 1048614,
138 HasPermissionElement = 1048615,
139 HasPermissionElements = 1048616,
140 TagArg = 1048617,
141 HasItemElement = 1048618,
142 HasItemElements = 1048619,
143 HasItemArg = 1048620,
144 HasItemArgs = 1048621,
145 HasItemSelector = 1048622,
146 EquipmentSlotEnum = 1048623,
147 PropertyValue = 1048624,
148 HasPropertyParamValue = 1048625,
149 HasPropertyParamEnumValue = 1048626,
150 HasPropertyArg = 1048627,
151 HasPropertyArgs = 1048628,
152 HasPropertyElement = 1048629,
153 HasPropertyElements = 1048630,
154 HasPropertySelector = 1048631,
155 Id = 1048632,
156 IdCont = 1048633,
157 CoordXInt = 1048634,
158 CoordYInt = 1048635,
159 CoordZInt = 1048636,
160 CoordXFloat = 1048637,
161 CoordYFloat = 1048638,
162 CoordZFloat = 1048639,
163 Position = 1048640,
164 PositionFloat = 1048641,
165 MessageExp = 1048642,
166 Message = 1048643,
167 MessageRoot = 1048644,
168 PostSelector = 1048645,
169 RawText = 1048646,
170 RawTextCont = 1048647,
171 JsonValue = 1048648,
172 JsonField = 1048649,
173 JsonObject = 1048650,
174 JsonObjectFields = 1048651,
175 JsonObjectCont = 1048652,
176 JsonArray = 1048653,
177 JsonArrayValues = 1048654,
178 JsonArrayCont = 1048655,
179 BlockState = 1048656,
180 BlockStateKey = 1048657,
181 BlockStateValue = 1048658,
182 BlockStateValues = 1048659,
183 BlockStateArray = 1048660,
184 BlockStateArrayCont = 1048661,
185 Command = 1048662,
186 SlashCommand = 1048663,
187 CodeBuilderArg = 1048664,
188 CodeBuilderArgs = 1048665,
189 CodeBuilderSelectParam = 1048666,
190 CodeBuilderSelector = 1048667,
191 };
192
193 class Symbol {
194 public:
195 int mValue{-1}; // this+0x0
196
197 static int const NonTerminalBit = 0x100000;
198 static int const EnumBit = 0x200000;
199 static int const OptionalBit = 0x400000;
200 static int const FactorizationBit = 0x800000;
201 static int const PostfixBit = 0x1000000;
202 static int const EnumValueBit = 0x2000000;
203 static int const SoftEnumBit = 0x4000000;
204
205 Symbol() = default;
206
207 Symbol(int val) : mValue(val) {}
208
209 // not trivially copyable
210 Symbol(Symbol const& other) : mValue(other.mValue) {}
211
212 Symbol(HardNonTerminal data) : mValue(static_cast<int>(data)) {}
213
214 Symbol(CommandLexer::TokenType data) : mValue(static_cast<int>(data)) {}
215
216 Symbol& operator=(Symbol const& other) {
217 mValue = other.mValue;
218 return *this;
219 }
220
221 [[nodiscard]] inline bool operator==(Symbol const& other) const { return mValue == other.mValue; }
222
223 uint64 toIndex() const { return mValue & 0xffffffffe00fffffull; }
224 };
225
226 struct SymbolHasher {};
227
229 public:
230 uint64 operator()(::std::pair<::CommandRegistry::Symbol, ::CommandRegistry::Symbol> const&) const;
231 };
232
234
236
237 using SymbolVector = ::std::vector<::CommandRegistry::Symbol>;
238
239 using SymbolSet =
240 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>;
241
242 using ParseMap = ::std::map<
244 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>>;
245 struct Overload {
246 public:
247 // Overload inner types define
249
250 public:
251 // member variables
252 // NOLINTBEGIN
253 ::CommandVersion version;
254 AllocFunction alloc;
255 ::std::vector<::CommandParameterData> params;
256 int versionOffset;
257 bool isChaining;
258 ::std::vector<::CommandRegistry::Symbol> paramsSymbol;
259 // NOLINTEND
260 };
261
262 struct Signature {
263 public:
264 // member variables
265 // NOLINTBEGIN
266 ::std::string name;
267 ::std::string description;
268 ::std::vector<::CommandRegistry::Overload> overloads;
269 ::std::vector<uint> chainedSubcommandIndexes;
270 ::CommandPermissionLevel permissionLevel;
271 ::CommandRegistry::Symbol commandSymbol;
272 ::CommandRegistry::Symbol commandAliasEnum;
273 ::CommandFlag flags;
274 int firstRule;
275 int firstFactorization;
276 int firstOptional;
277 bool runnable;
278 uint64 ruleCounter;
279 // NOLINTEND
280
281 public:
282 // prevent constructor by default
283 Signature& operator=(Signature const&);
284 Signature(Signature const&);
285 Signature();
286
287 public:
288 // member functions
289 // NOLINTBEGIN
291
292 MCAPI ~Signature();
293 // NOLINTEND
294
295 public:
296 // constructor thunks
297 // NOLINTBEGIN
298 MCAPI void* $ctor(::CommandRegistry::Signature&&);
299 // NOLINTEND
300
301 public:
302 // destructor thunk
303 // NOLINTBEGIN
304 MCAPI void $dtor();
305 // NOLINTEND
306 };
307
309 public:
310 // member variables
311 // NOLINTBEGIN
312 char const* mText;
313 uint mLength;
315 ::CommandRegistry::Symbol mIdentifierInfo;
316 ::CommandRegistry const& mRegistry;
317 // NOLINTEND
318
319 public:
320 // prevent constructor by default
321 LexicalToken& operator=(LexicalToken const&);
323 LexicalToken();
324
325 public:
326 // member functions
327 // NOLINTBEGIN
328 MCAPI ::CommandRegistry::LexicalToken& operator=(::CommandLexer::Token const& token);
329 // NOLINTEND
330 };
331
332 struct ParseToken {
333 public:
334 // member variables
335 // NOLINTBEGIN
336 ::std::unique_ptr<::CommandRegistry::ParseToken> child;
337 ::std::unique_ptr<::CommandRegistry::ParseToken> next;
339 char const* text;
340 uint length;
342 // NOLINTEND
343
344 public:
345 // member functions
346 // NOLINTBEGIN
347 MCAPI ::std::string toString() const;
348 // NOLINTEND
349 };
350
351 using ProcessFunction =
353 struct ParseRule {
354 public:
355 // member variables
356 // NOLINTBEGIN
357 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> nonTerminal;
358 ::ll::TypedStorage<
359 8,
360 64,
362 process;
363 ::ll::TypedStorage<8, 24, ::std::vector<::CommandRegistry::Symbol>> derivation;
364 ::ll::TypedStorage<4, 8, ::CommandVersion> versions;
365 // NOLINTEND
366
367 public:
368 // prevent constructor by default
369 ParseRule& operator=(ParseRule const&);
370 ParseRule(ParseRule const&);
371 ParseRule();
372
373 public:
374 // member functions
375 // NOLINTBEGIN
376 MCAPI ::CommandRegistry::ParseRule& operator=(::CommandRegistry::ParseRule&& rhs);
377 // NOLINTEND
378 };
379
380 using RuleIndex = int;
381
383 public:
384 // member variables
385 // NOLINTBEGIN
386 ::ll::TypedStorage<4, 4, int> parameterCount;
387 ::ll::TypedStorage<4, 4, int> followingRuleIndex;
388 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> paramSymbol;
389 // NOLINTEND
390 };
391
393 public:
394 // member variables
395 // NOLINTBEGIN
396 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> commandSymbol;
397 // NOLINTEND
398 };
399
400 using ParseFunction = bool (::CommandRegistry::*)(
401 void*,
403 ::CommandOrigin const&,
404 int,
405 ::std::string&,
406 ::std::vector<::std::string>&
407 ) const;
408 using EnumConversionFunction = ::std::function<void(void*, uint64)>;
409
410 struct Enum {
411 public:
412 // member variables
413 // NOLINTBEGIN
414 ::std::string name;
416 ParseFunction parse;
417 ::std::vector<::std::pair<uint64, uint64>> values;
418 // NOLINTEND
419
420 public:
421 // member functions
422 // NOLINTBEGIN
423 MCAPI ~Enum();
424 // NOLINTEND
425
426 public:
427 // destructor thunk
428 // NOLINTBEGIN
429 MCFOLD void $dtor();
430 // NOLINTEND
431 };
432
433 using ChainedSubcommandConversionFunction = ::std::function<void(void*, uint64)>;
434
436 public:
437 // member variables
438 // NOLINTBEGIN
439 ::std::string name;
441 ParseFunction parse;
442 ::std::vector<::std::pair<uint64, uint>> values;
443 // NOLINTEND
444
445 public:
446 // member functions
447 // NOLINTBEGIN
448 MCAPI ~ChainedSubcommand();
449 // NOLINTEND
450
451 public:
452 // destructor thunk
453 // NOLINTBEGIN
454 MCFOLD void $dtor();
455 // NOLINTEND
456 };
457
458 struct SoftEnum {
459 public:
460 // member variables
461 // NOLINTBEGIN
462 ::std::string mName;
463 ::std::vector<::std::string> mValues;
464 // NOLINTEND
465 };
466
468 public:
469 // member variables
470 // NOLINTBEGIN
471 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> mValue;
472 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> mEnum;
473 ::ll::TypedStorage<8, 24, ::std::vector<uchar>> mConstraints;
474 // NOLINTEND
475 };
476
478 public:
479 // member variables
480 // NOLINTBEGIN
481 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> x;
482 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> y;
483 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> z;
484 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> dx;
485 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> dy;
486 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> dz;
487 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> r;
488 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rm;
489 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rx;
490 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rxm;
491 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> ry;
492 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rym;
493 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> l;
494 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> lm;
495 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> c;
496 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> m;
497 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> name;
498 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> type;
499 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> family;
500 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> score;
501 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> tag;
502 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> hasitem;
503 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> haspermission;
504 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> hasproperty;
505 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> codebuilder;
506 // NOLINTEND
507
508 public:
509 // member functions
510 // NOLINTBEGIN
511 MCAPI ParamSymbols();
512 // NOLINTEND
513
514 public:
515 // constructor thunks
516 // NOLINTBEGIN
517 MCAPI void* $ctor();
518 // NOLINTEND
519 };
520
522 public:
523 // member variables
524 // NOLINTBEGIN
525 ::ll::TypedStorage<4, 4, uint> signatureCount;
526 ::ll::TypedStorage<4, 4, uint> enumValueCount;
527 ::ll::TypedStorage<4, 4, uint> postfixCount;
528 ::ll::TypedStorage<4, 4, uint> enumCount;
529 ::ll::TypedStorage<4, 4, uint> enumLookupCount;
530 ::ll::TypedStorage<4, 4, uint> typeLookupCount;
531 ::ll::TypedStorage<4, 4, uint> factorizationCount;
532 ::ll::TypedStorage<4, 4, uint> optionalCount;
533 ::ll::TypedStorage<4, 4, uint> ruleCount;
534 ::ll::TypedStorage<4, 4, uint> softEnumCount;
535 ::ll::TypedStorage<4, 4, uint> constraintCount;
536 ::ll::TypedStorage<4, 4, uint> chainedSubcommandCount;
537 ::ll::TypedStorage<4, 4, uint> chainedSubcommandValueCount;
538 ::ll::TypedStorage<8, 24, ::std::vector<uint>> enumValuesCount;
539 ::ll::TypedStorage<8, 24, ::std::vector<uint>> constrainedValueCount;
540 ::ll::TypedStorage<8, 24, ::std::vector<uint>> softEnumValuesCount;
541 // NOLINTEND
542
543 public:
544 // member functions
545 // NOLINTBEGIN
546 MCAPI ~RegistryState();
547 // NOLINTEND
548
549 public:
550 // destructor thunk
551 // NOLINTBEGIN
552 MCAPI void $dtor();
553 // NOLINTEND
554 };
555
556 using PredictTable = ::entt::dense_map<
557 ::std::pair<::CommandRegistry::Symbol, ::CommandRegistry::Symbol>,
558 int,
560 ::std::equal_to<void>>;
561 struct ParseTable {
562 public:
563 // member variables
564 // NOLINTBEGIN
565 ::std::map<
567 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>>
568
569 first;
570 ::std::map<
572 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>>
573
574 follow;
575 ::entt::dense_map<
576 ::std::pair<::CommandRegistry::Symbol, ::CommandRegistry::Symbol>,
577 int,
579 ::std::equal_to<void>>
580
581 predict;
582 ::std::chrono::nanoseconds buildDuration;
583 // NOLINTEND
584 };
585
587 public:
588 // member variables
589 // NOLINTBEGIN
590 ::ll::TypedStorage<1, 1, bool> mIsValid;
591 ::ll::TypedStorage<8, 24, ::std::vector<::CommandRegistry::Symbol>> mConstrainedParams;
592 ::ll::TypedStorage<8, 32, ::std::string> mSoftEnumText;
593 ::ll::TypedStorage<8, 32, ::std::string> mSoftEnumEscapeCharExceptions;
594 ::ll::TypedStorage<8, 16, ::std::set<::CommandRegistry::Symbol>> mAlreadyCompletedSymbols;
595 // NOLINTEND
596 };
597
598 using ParamVisitCallback = ::std::function<
600 using CommandVisitCallback = ::std::function<bool(::CommandRegistry::ParseToken const*, ::CommandOrigin const&)>;
601
602 using ParseTableMap = ::std::map<uint, ::CommandRegistry::ParseTable>;
603
604 class Parser {
605 public:
606 // member variables
607 // NOLINTBEGIN
608 ::ll::TypedStorage<8, 8, ::CommandRegistry const&> mRegistry;
609 ::ll::TypedStorage<8, 8, ::CommandRegistry::ParseTable const*> mParseTable;
610 ::ll::TypedStorage<8, 40, ::std::deque<::std::pair<::CommandRegistry::Symbol, ::CommandRegistry::ParseToken*>>>
611 mStack;
612 ::ll::TypedStorage<8, 32, ::CommandRegistry::LexicalToken> mNext;
613 ::ll::TypedStorage<8, 32, ::std::string> mInput;
614 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::CommandRegistry::ParseToken>> mRoot;
615 ::ll::TypedStorage<8, 32, ::std::string> mError;
616 ::ll::TypedStorage<8, 24, ::std::vector<::std::string>> mErrorParams;
617 ::ll::TypedStorage<4, 4, int> mVersion;
618 ::ll::TypedStorage<1, 1, bool> mGenerateParams;
619 ::ll::TypedStorage<1, 1, bool> mBreakAtEnd;
620 // NOLINTEND
621
622 public:
623 // prevent constructor by default
624 Parser& operator=(Parser const&);
625 Parser(Parser const&);
626 Parser();
627
628 public:
629 // member functions
630 // NOLINTBEGIN
631 MCAPI Parser(::CommandRegistry const& registry, int version);
632
633 MCAPI bool _parse(::std::string const& in);
634
635 MCAPI ::std::unique_ptr<::CommandSelector<::Actor>>
636 createSelector(::std::string const& selectorString, ::CommandOrigin const& origin);
637 MCAPI ::std::vector<::std::string> getErrorParams() const;
638
639 MCAPI bool parseCommand(::std::string const& in);
640
641 MCAPI bool parseSelector(::std::string const& in);
642
643 MCAPI ~Parser();
644 // NOLINTEND
645
646 public:
647 // constructor thunks
648 // NOLINTBEGIN
649 MCAPI void* $ctor(::CommandRegistry const& registry, int version);
650 // NOLINTEND
651
652 public:
653 // destructor thunk
654 // NOLINTBEGIN
655 MCAPI void $dtor();
656 // NOLINTEND
657 };
658
659public:
660 // member variables
661 // NOLINTBEGIN
662 ::std::function<void(::Packet const&)> mNetworkUpdateCallback;
663 ScoreboardScoreAccessor mGetScoreForObjective;
664 bool mIsEduMode;
665 ::std::vector<::CommandRegistry::ParseRule> mRules;
666 ::std::map<uint, ::CommandRegistry::ParseTable> mParseTables;
667 ::std::vector<::CommandRegistry::OptionalParameterChain> mOptionals;
668 ::std::vector<::std::string> mEnumValues;
669 ::std::vector<::CommandRegistry::Enum> mEnums;
670 ::std::vector<::std::string> mChainedSubcommandValues;
671 ::std::vector<::CommandRegistry::ChainedSubcommand> mChainedSubcommands;
672 ::std::vector<::CommandRegistry::Factorization> mFactorizations;
673 ::std::vector<::std::string> mPostfixes;
674 ::std::map<::std::string, uint> mEnumLookup;
675 ::std::map<::std::string, uint64> mEnumValueLookup;
676 ::std::map<::std::string, uint> mChainedSubcommandLookup;
677 ::std::map<::std::string, uint64> mChainedSubcommandValueLookup;
678 ::std::vector<::CommandRegistry::Symbol> mCommandSymbols;
679 ::std::map<::std::string, ::CommandRegistry::Signature> mSignatures;
680 ::std::map<::Bedrock::typeid_t<::CommandRegistry>, int> mTypeLookup;
681 ::std::map<::std::string, ::std::string> mAliases;
682 ::std::vector<::SemanticConstraint> mSemanticConstraints;
683 ::std::map<::SemanticConstraint, uchar> mSemanticConstraintLookup;
684 ::std::vector<::CommandRegistry::ConstrainedValue> mConstrainedValues;
685 ::std::map<::std::pair<uint64, uint>, uint> mConstrainedValueLookup;
686 ::std::vector<::CommandRegistry::SoftEnum> mSoftEnums;
687 ::std::map<::std::string, uint> mSoftEnumLookup;
688 ::std::vector<::CommandRegistry::RegistryState> mStateStack;
690 ::std::unordered_set<int> mSkipOnEpsAutocompleteSymbols;
691 ::std::unordered_set<int> mAllowEmptySymbols;
692 CommandOverrideFunctor mCommandOverrideFunctor;
693 ::std::unique_ptr<::CommandRunStats> mCommandRunStats;
694 // NOLINTEND
695
696 template <class T>
697 bool parse(
698 void* storage,
699 CommandRegistry::ParseToken const& token,
700 CommandOrigin const& origin,
701 int version,
702 std::string& error,
703 std::vector<std::string>& errorParams
704 ) const;
705
706 template <class E, class C>
707 bool parseEnum(
708 void* storage,
709 CommandRegistry::ParseToken const& token,
710 CommandOrigin const& origin,
711 int version,
712 std::string& error,
713 std::vector<std::string>& errorParams
714 ) const;
715
716 uint64 getEnumData(ParseToken const& token) const {
717 auto& values = mEnums[token.type.toIndex()].values;
718 return std::lower_bound(
719 values.begin(),
720 values.end(),
721 token.child->type.toIndex(),
722 [](auto& pair, auto& child) { return pair.first < child; }
723 )->second;
724 }
725
726public:
727 // prevent constructor by default
729
730public:
731 // member functions
732 // NOLINTBEGIN
733 MCAPI explicit CommandRegistry(bool isEduMode);
734
735 MCAPI ::CommandRegistry::Symbol _addChainedSubcommandValuesInternal(
736 ::std::string const& name,
737 ::std::vector<::std::pair<::std::string, uint>> const& strings,
739 bool (CommandRegistry::*parse)(
740 void*,
742 ::CommandOrigin const&,
743 int,
744 ::std::string&,
745 ::std::vector<::std::string>&
746 ) const,
748 );
749
750 MCAPI ::CommandRegistry::Symbol _addChainedSubcommandValuesInternal(
751 ::std::string const& name,
752 ::std::vector<::std::pair<uint64, uint>> const& values,
754 bool (CommandRegistry::*parse)(
755 void*,
757 ::CommandOrigin const&,
758 int,
759 ::std::string&,
760 ::std::vector<::std::string>&
761 ) const,
763 );
764
765 MCAPI ::CommandRegistry::Symbol _addEnumValuesInternal(
766 ::std::string const& name,
767 ::std::vector<::std::pair<::std::string, uint64>> const& strings,
769 bool (CommandRegistry::*parse)(
770 void*,
772 ::CommandOrigin const&,
773 int,
774 ::std::string&,
775 ::std::vector<::std::string>&
776 ) const
777 );
778
779 MCAPI ::CommandRegistry::Symbol _addEnumValuesInternal(
780 ::std::string const& name,
781 ::std::vector<::std::pair<uint64, uint64>> const& values,
783 bool (CommandRegistry::*parse)(
784 void*,
786 ::CommandOrigin const&,
787 int,
788 ::std::string&,
789 ::std::vector<::std::string>&
790 ) const
791 );
792
793 MCAPI ::CommandRegistry::Symbol _addFunctionSoftEnum();
794
795 MCAPI ::std::unique_ptr<::CommandSelector<::Actor>> _createSelector(
797 ::CommandOrigin const& origin,
798 int version,
799 ::std::string& error,
800 ::std::vector<::std::string>& errorParams
801 ) const;
802
803 MCAPI ::CommandRegistry::Symbol _getConstrainedParamEnumSymbol(::CommandRegistry::Symbol symbol) const;
804
805 MCAPI bool _matchesEnumConstraintsSet(
806 ::CommandRegistry::Symbol const& commandParamSymbol,
807 ::CommandOrigin const& origin,
808 ::CommandRegistry::Symbol const& value,
809 ::SemanticConstraint requiredConstraints
810 ) const;
811
812 MCAPI void addChainedSubcommandValuesToExisting(uint index, ::std::vector<::std::pair<uint64, uint>> const& values);
813
814 MCAPI void addEnumValueConstraints(
815 ::std::string const& enumName,
816 ::std::vector<::std::string> const& values,
817 ::SemanticConstraint constraints
818 );
819
820 MCAPI int addEnumValues(::std::string const& name, ::std::vector<::std::string> const& values);
821
822 MCAPI void addEnumValuesToExisting(uint index, ::std::vector<::std::pair<uint64, uint64>> const& values);
823
824 MCAPI ::CommandRegistry::Symbol addPostfix(::std::string const& name);
825
826 MCAPI void addRule(
828 ::std::vector<::CommandRegistry::Symbol> derivation,
830 process,
831 ::CommandVersion versions
832 );
833
834 MCAPI void addSemanticConstraint(::SemanticConstraint constraintType);
835
836 MCAPI int addSoftEnum(::std::string const& name, ::std::vector<::std::string> values);
837
838 MCAPI void addSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
839
840 MCAPI ::CommandRegistry::Symbol addSoftTerminal(::std::string const& name);
841
842 MCAPI void buildFirstSet(::CommandRegistry::ParseTable& table, ::CommandRegistry::Symbol t, uint version) const;
843
844 MCAPI void buildFollowSet(
847 uint version,
848 ::std::set<::CommandRegistry::Symbol>& workingSet
849 ) const;
850
851 MCAPI ::CommandRegistry::Symbol buildOptionalRuleChain(
852 ::CommandRegistry::Signature const& signature,
853 ::std::vector<::CommandParameterData> const& params,
854 ::std::vector<::CommandRegistry::Symbol> const& symbols
855 );
856
857 MCAPI void buildParseTable(uint version) const;
858
859 MCAPI void buildPredictTable(::CommandRegistry::ParseTable& table, uint version) const;
860
861 MCAPI ::CommandRegistry::Symbol buildRules(
863 ::std::vector<::gsl::not_null<::CommandRegistry::Overload*>> const& overloads,
864 uint64 firstParam
865 );
866
867 MCAPI bool
868 buildSelector(::ActorSelectorArgs const& args, ::CommandSelectorBase* output, ::std::string& error) const;
869
870 MCAPI ::std::unique_ptr<::Command> createCommand(
872 ::CommandOrigin const& origin,
873 int version,
874 ::std::string& error,
875 ::std::vector<::std::string>& errorParams
876 ) const;
877
878 MCAPI ::std::string describe(::CommandParameterData const& param) const;
879
880 MCAPI ::std::string describe(::CommandRegistry::Symbol symbol) const;
881
882 MCAPI ::std::string describe(
883 ::CommandRegistry::Signature const& command,
884 ::std::string const& alias,
885 ::CommandRegistry::Overload const& overload,
886 uint highlight,
887 uint* start,
888 uint* length
889 ) const;
890
891 MCAPI ::CommandRegistry::Signature const* findCommand(::std::string const&) const;
892
893 MCFOLD ::CommandRegistry::Signature* findCommand(::std::string const& name);
894
895 MCAPI ::CommandRegistry::Symbol findEnumValue(::std::string const& name) const;
896
897 MCAPI ::CommandRegistry::Symbol findIdentifierInfo(::std::string const& name) const;
898
899 MCAPI ::CommandRegistry::Symbol findPostfix(::std::string const& input) const;
900
901 MCAPI void fireCommandParseTableTelemetry(::IMinecraftEventing const& eventing, bool isServer) const;
902
903 MCAPI void forEachNonTerminal(::std::function<void(::CommandRegistry::Symbol)> func) const;
904
905 MCAPI ::Json::Value generateDocumentationMetadata(bool generateInternalMetadata) const;
906
907 MCAPI ::std::vector<::std::string> getAliases(::std::string const& command) const;
908
909 MCAPI ::std::vector<::std::string> getAlphabeticalLookup(::CommandOrigin const& origin) const;
910
911 MCAPI ::std::string getCommandName(::std::string const& commandLine) const;
912
913 MCAPI ::CommandSyntaxInformation
914 getCommandOverloadSyntaxInformation(::CommandOrigin const& origin, ::std::string const& commandName) const;
915
916 MCAPI ::InvertableFilter<::std::string> getInvertableFilter(::CommandRegistry::ParseToken const& token) const;
917
918 MCAPI bool isValid(::CommandRegistry::Symbol symbol) const;
919
920 MCAPI bool originCanRun(::CommandOrigin const& origin, ::CommandRegistry::Signature const& command) const;
921
922 MCAPI bool originCanRun(::CommandOrigin const& origin, ::CommandRegistry::Overload const& overload) const;
923
924 MCAPI bool parseSelector(
927 ::CommandOrigin const& origin,
928 int version,
929 ::std::string& error,
930 ::std::vector<::std::string>& errorParams
931 ) const;
932
933 MCAPI void registerAlias(::std::string name, ::std::string alias);
934
935 MCAPI void registerCommand(
936 ::std::string const& name,
937 char const* description,
938 ::CommandPermissionLevel requirement,
939 ::CommandFlag f1,
940 ::CommandFlag f2 = {}
941 );
942
943 MCAPI void registerOverload(
944 char const* command,
945 ::CommandVersion version,
946 ::std::function<::std::unique_ptr<::Command>()> allocFn,
947 ::std::vector<::CommandParameterData> params
948 );
949
950 MCAPI void registerOverloadInternal(::CommandRegistry::Signature& signature, ::CommandRegistry::Overload& overload);
951
952 MCAPI void removeSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
953
954 MCAPI ::AvailableCommandsPacket serializeAvailableCommands() const;
955
956 MCAPI void setCommandRegistrationOverride(CommandOverrideFunctor functor);
957
958 MCAPI void setSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
959
960 MCAPI void setupChainedSubcommandOverloadRules(::CommandRegistry::Signature& signature);
961
962 MCAPI void setupOverloadRules(::CommandRegistry::Signature& signature);
963
964 MCAPI ::std::string symbolToString(::CommandRegistry::Symbol symbol) const;
965
966 MCAPI ~CommandRegistry();
967 // NOLINTEND
968
969public:
970 // static functions
971 // NOLINTBEGIN
972 MCAPI static ::std::string _removeStringQuotes(::std::string const& str);
973
974 MCFOLD static ::CommandRegistry::ParseToken*
976
977 MCAPI static ::CommandRegistry::ParseToken* collapseOn(
980 ::CommandRegistry::Symbol boundSymbol
981 );
982
983 MCAPI static ::CommandRegistry::ParseToken*
985
986 MCAPI static ::CommandRegistry::ParseToken* expandExcept(
989 ::CommandRegistry::Symbol boundSymbol
990 );
991
992 MCAPI static ::CommandRegistry::ParseToken* fold(
995 ::CommandRegistry::Symbol boundSymbol
996 );
997
998 MCAPI static ::CommandRegistry::ParseToken*
1000
1001 MCAPI static bool readFloat(
1002 float& value,
1003 ::CommandRegistry::ParseToken const& token,
1004 ::std::string& error,
1005 ::std::vector<::std::string>& errorParams
1006 );
1007
1008 MCAPI static bool readInt(
1009 int& value,
1010 ::CommandRegistry::ParseToken const& token,
1011 ::std::string& error,
1012 ::std::vector<::std::string>& errorParams
1013 );
1014
1015 MCAPI static bool readRelativeCoordinate(
1016 bool& relative,
1017 float& offset,
1018 ::CommandRegistry::ParseToken const& token,
1019 bool readIntegerAsCentered,
1020 ::std::string& error,
1021 ::std::vector<::std::string>& errorParams
1022 );
1023
1024 MCAPI static bool readString(
1025 ::std::string& value,
1026 ::CommandRegistry::ParseToken const& token,
1027 ::std::string& error,
1028 ::std::vector<::std::string>& errorParams
1029 );
1030 // NOLINTEND
1031
1032public:
1033 // static variables
1034 // NOLINTBEGIN
1035 MCAPI static char const*& CODE_STATUS_PROPERTY_NAME();
1036
1037 MCAPI static char const*& COMMAND_NAME_ENUM_NAME();
1038
1039 MCAPI static char const*& FUNCTION_NAME_SOFTENUM_NAME();
1040
1041 MCAPI static char const*& HASITEM_PARAM_DATA();
1042
1043 MCAPI static char const*& HASITEM_PARAM_ITEM();
1044
1045 MCAPI static char const*& HASITEM_PARAM_LOCATION();
1046
1047 MCAPI static char const*& HASITEM_PARAM_QUANTITY();
1048
1049 MCAPI static char const*& HASITEM_PARAM_SLOT();
1050
1051 MCAPI static char const*& HASPERMISSIONSTATE_ENUM_DISABLED();
1052
1053 MCAPI static char const*& HASPERMISSIONSTATE_ENUM_ENABLED();
1054
1055 MCAPI static char const*& HASPROPERTY_PARAM_PROPERTY_NAME();
1056
1057 MCAPI static ::std::add_lvalue_reference_t<::std::pair<
1058 bool (CommandRegistry::*)(
1059 void*,
1061 ::CommandOrigin const&,
1062 int,
1063 ::std::string&,
1064 ::std::vector<::std::string>&
1065 ) const,
1067 ParseRuleSymbols();
1068
1069 MCAPI static char const*& TAG_VALUES_SOFTENUM_NAME();
1070
1071 MCAPI static char const*& UNLOCKABLE_RECIPES_SOFTENUM_NAME();
1072 // NOLINTEND
1073
1074public:
1075 // constructor thunks
1076 // NOLINTBEGIN
1077 MCAPI void* $ctor(bool isEduMode);
1078 // NOLINTEND
1079
1080public:
1081 // destructor thunk
1082 // NOLINTBEGIN
1083 MCAPI void $dtor();
1084 // NOLINTEND
1085};
1086
1087// following are the functions required by CommandParameterData's ParseFunction
1088MCTAPI bool CommandRegistry::parse<std::string>(
1089 void*,
1091 CommandOrigin const&,
1092 int,
1093 std::string&,
1094 std::vector<std::string>&
1095) const;
1096
1097MCTAPI bool CommandRegistry::parse<int>(
1098 void*,
1100 CommandOrigin const&,
1101 int,
1102 std::string&,
1103 std::vector<std::string>&
1104) const;
1105
1106MCTAPI bool CommandRegistry::parse<float>(
1107 void*,
1109 CommandOrigin const&,
1110 int,
1111 std::string&,
1112 std::vector<std::string>&
1113) const;
1114
1115MCTAPI bool CommandRegistry::parse<Json::Value>(
1116 void*,
1118 CommandOrigin const&,
1119 int,
1120 std::string&,
1121 std::vector<std::string>&
1122) const;
1123
1124MCTAPI bool CommandRegistry::parse<CommandCompareOperator>(
1125 void*,
1127 CommandOrigin const&,
1128 int,
1129 std::string&,
1130 std::vector<std::string>&
1131) const;
1132
1133MCTAPI bool CommandRegistry::parse<CommandFilePath>(
1134 void*,
1136 CommandOrigin const&,
1137 int,
1138 std::string&,
1139 std::vector<std::string>&
1140) const;
1141
1142MCTAPI bool CommandRegistry::parse<CommandIntegerRange>(
1143 void*,
1145 CommandOrigin const&,
1146 int,
1147 std::string&,
1148 std::vector<std::string>&
1149) const;
1150
1151MCTAPI bool CommandRegistry::parse<CommandMessage>(
1152 void*,
1154 CommandOrigin const&,
1155 int,
1156 std::string&,
1157 std::vector<std::string>&
1158) const;
1159
1160MCTAPI bool CommandRegistry::parse<CommandOperator>(
1161 void*,
1163 CommandOrigin const&,
1164 int,
1165 std::string&,
1166 std::vector<std::string>&
1167) const;
1168
1169MCTAPI bool CommandRegistry::parse<CommandPosition>(
1170 void*,
1172 CommandOrigin const&,
1173 int,
1174 std::string&,
1175 std::vector<std::string>&
1176) const;
1177
1178MCTAPI bool CommandRegistry::parse<CommandPositionFloat>(
1179 void*,
1181 CommandOrigin const&,
1182 int,
1183 std::string&,
1184 std::vector<std::string>&
1185) const;
1186
1187MCTAPI bool CommandRegistry::parse<CommandRawText>(
1188 void*,
1190 CommandOrigin const&,
1191 int,
1192 std::string&,
1193 std::vector<std::string>&
1194) const;
1195
1196MCTAPI bool CommandRegistry::parse<CommandSelector<Actor>>(
1197 void*,
1199 CommandOrigin const&,
1200 int,
1201 std::string&,
1202 std::vector<std::string>&
1203) const;
1204
1205MCTAPI bool CommandRegistry::parse<CommandSelector<Player>>(
1206 void*,
1208 CommandOrigin const&,
1209 int,
1210 std::string&,
1211 std::vector<std::string>&
1212) const;
1213
1214MCTAPI bool CommandRegistry::parse<CommandWildcardInt>(
1215 void*,
1217 CommandOrigin const&,
1218 int,
1219 std::string&,
1220 std::vector<std::string>&
1221) const;
1222
1223MCTAPI bool CommandRegistry::parse<class RelativeFloat>(
1224 void*,
1226 CommandOrigin const&,
1227 int,
1228 std::string&,
1229 std::vector<std::string>&
1230) const;
1231
1232MCTAPI bool CommandRegistry::parse<WildcardCommandSelector<Actor>>(
1233 void*,
1235 CommandOrigin const&,
1236 int,
1237 std::string&,
1238 std::vector<std::string>&
1239) const;
1240
1241MCTAPI bool CommandRegistry::parse<std::unique_ptr<::Command>>(
1242 void*,
1244 CommandOrigin const&,
1245 int,
1246 std::string&,
1247 std::vector<std::string>&
1248) const;
1249
1250MCTAPI bool CommandRegistry::parse<std::vector<BlockStateCommandParam>>(
1251 void*,
1253 CommandOrigin const&,
1254 int,
1255 std::string&,
1256 std::vector<std::string>&
1257) const;
1258
1259MCTAPI bool CommandRegistry::parseEnum<CommandChainedSubcommand, void>(
1260 void*,
1262 CommandOrigin const&,
1263 int,
1264 std::string&,
1265 std::vector<std::string>&
1266) const;
Definition Actor.h:102
Definition AvailableCommandsPacket.h:17
Definition typeid_t.h:25
Definition BlockState.h:13
Definition CommandOrigin.h:32
Definition CommandParameterData.h:18
Definition CommandRegistry.h:604
Definition CommandRegistry.h:193
Definition CommandRegistry.h:44
Definition CommandRunStats.h:8
Definition CommandSelectorBase.h:28
Definition CommandVersion.h:13
Definition Command.h:17
Definition IMinecraftEventing.h:149
Definition Packet.h:43
Definition copyable_function.h:8
Definition ActorSelectorArgs.h:21
Definition CommandFlag.h:43
Definition CommandLexer.h:50
Definition CommandRegistry.h:435
Definition CommandRegistry.h:467
Definition CommandRegistry.h:410
Definition CommandRegistry.h:392
Definition CommandRegistry.h:308
Definition CommandRegistry.h:382
Definition CommandRegistry.h:245
Definition CommandRegistry.h:477
Definition CommandRegistry.h:353
Definition CommandRegistry.h:561
Definition CommandRegistry.h:332
Definition CommandRegistry.h:521
Definition CommandRegistry.h:586
Definition CommandRegistry.h:262
Definition CommandRegistry.h:458
Definition CommandRegistry.h:226
Definition CommandRegistry.h:228
Definition CommandSyntaxInformation.h:5