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