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