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/CommandIntegerRange.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/CommandWildcardInt.h"
14#include "mc/server/commands/WildcardCommandSelector.h"
15
16// auto generated inclusion list
17#include "mc/deps/core/utility/typeid_t.h"
18#include "mc/platform/brstd/copyable_function.h"
19#include "mc/server/commands/CommandFlag.h"
20#include "mc/server/commands/CommandLexer.h"
21#include "mc/server/commands/CommandPermissionLevel.h"
22#include "mc/server/commands/CommandSelector.h"
23#include "mc/server/commands/CommandTypeFlag.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 BlockType;
33class Command;
34class CommandOrigin;
36class CommandRunStats;
39class Packet;
40class PlayerListEntry;
45namespace Json { class Value; }
46namespace mce { class UUID; }
47// clang-format on
48
49class CommandRegistry {
50public:
51 // CommandRegistry inner types declare
52 // clang-format off
53 struct RegistryState;
54 struct SoftEnum;
55 class Symbol;
56 struct ConstrainedValue;
57 struct Factorization;
58 struct LexicalToken;
60 struct Overload;
61 struct ParamSymbols;
62 struct ParseToken;
63 struct ChainedSubcommand;
64 struct Enum;
65 struct ParamParseRule;
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 ClockTimeMarkerName = 1048662,
174 Command = 1048663,
175 SlashCommand = 1048664,
176 CodeBuilderArg = 1048665,
177 CodeBuilderArgs = 1048666,
178 CodeBuilderSelectParam = 1048667,
179 CodeBuilderSelector = 1048668,
180 };
181
183 public:
184 // member variables
185 // NOLINTBEGIN
186 ::ll::TypedStorage<4, 4, uint> signatureCount;
187 ::ll::TypedStorage<4, 4, uint> enumValueCount;
188 ::ll::TypedStorage<4, 4, uint> postfixCount;
189 ::ll::TypedStorage<4, 4, uint> enumCount;
190 ::ll::TypedStorage<4, 4, uint> enumLookupCount;
191 ::ll::TypedStorage<4, 4, uint> typeLookupCount;
192 ::ll::TypedStorage<4, 4, uint> factorizationCount;
193 ::ll::TypedStorage<4, 4, uint> optionalCount;
194 ::ll::TypedStorage<4, 4, uint> ruleCount;
195 ::ll::TypedStorage<4, 4, uint> softEnumCount;
196 ::ll::TypedStorage<4, 4, uint> constraintCount;
197 ::ll::TypedStorage<4, 4, uint> chainedSubcommandCount;
198 ::ll::TypedStorage<4, 4, uint> chainedSubcommandValueCount;
199 ::ll::TypedStorage<8, 24, ::std::vector<uint>> enumValuesCount;
200 ::ll::TypedStorage<8, 24, ::std::vector<uint>> constrainedValueCount;
201 ::ll::TypedStorage<8, 24, ::std::vector<uint>> softEnumValuesCount;
202 // NOLINTEND
203
204 public:
205 // member functions
206 // NOLINTBEGIN
207 MCAPI ~RegistryState();
208 // NOLINTEND
209
210 public:
211 // destructor thunk
212 // NOLINTBEGIN
213 MCAPI void $dtor();
214 // NOLINTEND
215 };
216
217 struct SoftEnum {
218 public:
219 // member variables
220 // NOLINTBEGIN
221 ::std::string mName;
222 ::std::vector<::std::string> mValues;
223 // NOLINTEND
224
225 public:
226 // prevent constructor by default
227 SoftEnum();
228
229 public:
230 // member functions
231 // NOLINTBEGIN
232 MCAPI SoftEnum(::std::string const& name, ::std::vector<::std::string> values);
233 // NOLINTEND
234
235 public:
236 // constructor thunks
237 // NOLINTBEGIN
238 MCAPI void* $ctor(::std::string const& name, ::std::vector<::std::string> values);
239 // NOLINTEND
240 };
241
242 class Symbol {
243 public:
244 int mValue{-1}; // this+0x0
245
246 static int const NonTerminalBit = 0x100000;
247 static int const EnumBit = 0x200000;
248 static int const OptionalBit = 0x400000;
249 static int const FactorizationBit = 0x800000;
250 static int const PostfixBit = 0x1000000;
251 static int const EnumValueBit = 0x2000000;
252 static int const SoftEnumBit = 0x4000000;
253
254 Symbol() = default;
255
256 Symbol(int val) : mValue(val) {}
257
258 // not trivially copyable
259 Symbol(Symbol const& other) : mValue(other.mValue) {}
260
261 Symbol(HardNonTerminal data) : mValue(static_cast<int>(data)) {}
262
263 Symbol(CommandLexer::TokenType data) : mValue(static_cast<int>(data)) {}
264
265 Symbol& operator=(Symbol const& other) {
266 mValue = other.mValue;
267 return *this;
268 }
269
270 [[nodiscard]] inline bool operator==(Symbol const& other) const { return mValue == other.mValue; }
271
272 uint64 toIndex() const { return mValue & 0xffffffffe00fffffull; }
273 };
274
276 public:
277 // member variables
278 // NOLINTBEGIN
279 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> mValue;
280 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> mEnum;
281 ::ll::TypedStorage<8, 24, ::std::vector<uchar>> mConstraints;
282 // NOLINTEND
283 };
284
286 public:
287 // member variables
288 // NOLINTBEGIN
289 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> commandSymbol;
290 // NOLINTEND
291 };
292
293 struct LexicalToken {
294 public:
295 // member variables
296 // NOLINTBEGIN
297 char const* mText;
298 uint mLength;
300 ::CommandRegistry::Symbol mIdentifierInfo;
301 ::CommandRegistry const& mRegistry;
302 // NOLINTEND
303
304 public:
305 // prevent constructor by default
306 LexicalToken& operator=(LexicalToken const&);
307 LexicalToken(LexicalToken const&);
308 LexicalToken();
309
310 public:
311 // member functions
312 // NOLINTBEGIN
313 MCAPI ::CommandRegistry::LexicalToken& operator=(::CommandLexer::Token const& token);
314 // NOLINTEND
315 };
316
318 public:
319 // member variables
320 // NOLINTBEGIN
321 ::ll::TypedStorage<4, 4, int> parameterCount;
322 ::ll::TypedStorage<4, 4, int> followingRuleIndex;
323 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> paramSymbol;
324 // NOLINTEND
325 };
326
327 struct Overload {
328 public:
329 // Overload inner types define
330 using AllocFunction = ::brstd::copyable_function<::std::unique_ptr<::Command>() const>;
331
332 public:
333 // member variables
334 // NOLINTBEGIN
335 ::CommandVersion version;
336 AllocFunction alloc;
337 ::std::vector<::CommandParameterData> params;
338 int versionOffset;
339 bool isChaining;
340 ::std::vector<::CommandRegistry::Symbol> paramsSymbol;
341 // NOLINTEND
342 };
343
345 public:
346 // member variables
347 // NOLINTBEGIN
348 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> x;
349 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> y;
350 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> z;
351 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> dx;
352 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> dy;
353 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> dz;
354 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> r;
355 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rm;
356 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rx;
357 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rxm;
358 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> ry;
359 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> rym;
360 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> l;
361 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> lm;
362 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> c;
363 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> m;
364 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> name;
365 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> type;
366 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> family;
367 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> score;
368 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> tag;
369 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> hasitem;
370 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> haspermission;
371 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> hasproperty;
372 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> codebuilder;
373 // NOLINTEND
374 };
375
376 struct ParseToken {
377 public:
378 // member variables
379 // NOLINTBEGIN
380 ::std::unique_ptr<::CommandRegistry::ParseToken> child;
381 ::std::unique_ptr<::CommandRegistry::ParseToken> next;
383 char const* text;
384 uint length;
386 // NOLINTEND
387
388 public:
389 // member functions
390 // NOLINTBEGIN
391 MCAPI ::std::string toString() const;
392
393 MCAPI ~ParseToken();
394 // NOLINTEND
395
396 public:
397 // destructor thunk
398 // NOLINTBEGIN
399 MCAPI void $dtor();
400 // NOLINTEND
401 };
402
404 public:
405 // member variables
406 // NOLINTBEGIN
407 ::std::string name;
409 ParseFunction parse;
410 ::std::vector<::std::pair<uint64, uint>> values;
411 // NOLINTEND
412 };
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
426 public:
427 // member variables
428 // NOLINTBEGIN
429 ::ll::TypedStorage<
430 8,
431 8,
432 bool (CommandRegistry::*)(
433 void*,
435 ::CommandOrigin const&,
436 int,
437 ::std::string&,
438 ::std::vector<::std::string>&
439 ) const>
440 parse;
441 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> symbol;
442 // NOLINTEND
443 };
444
445 struct ParseRule {
446 public:
447 // member variables
448 // NOLINTBEGIN
449 ::ll::TypedStorage<4, 4, ::CommandRegistry::Symbol> nonTerminal;
450 ::ll::TypedStorage<
451 8,
452 64,
454 process;
455 ::ll::TypedStorage<8, 24, ::std::vector<::CommandRegistry::Symbol>> derivation;
456 ::ll::TypedStorage<4, 8, ::CommandVersion> versions;
457 // NOLINTEND
458
459 public:
460 // prevent constructor by default
461 ParseRule& operator=(ParseRule const&);
462 ParseRule(ParseRule const&);
463 ParseRule();
464
465 public:
466 // member functions
467 // NOLINTBEGIN
468 MCAPI ::CommandRegistry::ParseRule& operator=(::CommandRegistry::ParseRule&& rhs);
469 // NOLINTEND
470 };
471
473 public:
474 // member variables
475 // NOLINTBEGIN
476 ::ll::TypedStorage<1, 1, bool> mIsValid;
477 ::ll::TypedStorage<8, 24, ::std::vector<::CommandRegistry::Symbol>> mConstrainedParams;
478 ::ll::TypedStorage<8, 32, ::std::string> mSoftEnumText;
479 ::ll::TypedStorage<8, 32, ::std::string> mSoftEnumEscapeCharExceptions;
480 ::ll::TypedStorage<8, 16, ::std::set<::CommandRegistry::Symbol>> mAlreadyCompletedSymbols;
481 // NOLINTEND
482 };
483
484 struct Signature {
485 public:
486 // member variables
487 // NOLINTBEGIN
488 ::std::string name;
489 ::std::string description;
490 ::std::vector<::CommandRegistry::Overload> overloads;
491 ::std::vector<uint> chainedSubcommandIndexes;
492 ::CommandPermissionLevel permissionLevel;
493 ::CommandRegistry::Symbol commandSymbol;
494 ::CommandRegistry::Symbol commandAliasEnum;
495 ::CommandFlag flags;
496 int firstRule;
497 int firstFactorization;
498 int firstOptional;
499 bool runnable;
500 uint64 ruleCounter;
501 // NOLINTEND
502
503 public:
504 // member functions
505 // NOLINTBEGIN
506 MCAPI ~Signature();
507 // NOLINTEND
508
509 public:
510 // destructor thunk
511 // NOLINTBEGIN
512 MCAPI void $dtor();
513 // NOLINTEND
514 };
515
516 struct SymbolHasher {};
517
519
520 struct ParseTable {
521 public:
522 // member variables
523 // NOLINTBEGI
524 ::std::map<
526 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>>
527 first;
528
529 ::std::map<
531 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>>
532 follow;
533
534 ::entt::dense_map<
535 ::std::pair<::CommandRegistry::Symbol, ::CommandRegistry::Symbol>,
536 int,
538 ::std::equal_to<void>>
539 predict;
540 ::std::chrono::nanoseconds buildDuration;
541 // NOLINTEND
542 };
543
544 class Parser {
545 public:
546 // member variables
547 // NOLINTBEGIN
548 ::ll::TypedStorage<8, 8, ::CommandRegistry const&> mRegistry;
549 ::ll::TypedStorage<8, 8, ::CommandRegistry::ParseTable const*> mParseTable;
550 ::ll::TypedStorage<8, 40, ::std::deque<::std::pair<::CommandRegistry::Symbol, ::CommandRegistry::ParseToken*>>>
551 mStack;
552 ::ll::TypedStorage<8, 32, ::CommandRegistry::LexicalToken> mNext;
553 ::ll::TypedStorage<8, 32, ::std::string> mInput;
554 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::CommandRegistry::ParseToken>> mRoot;
555 ::ll::TypedStorage<8, 32, ::std::string> mError;
556 ::ll::TypedStorage<8, 24, ::std::vector<::std::string>> mErrorParams;
557 ::ll::TypedStorage<4, 4, int> mVersion;
558 ::ll::TypedStorage<1, 1, bool> mGenerateParams;
559 ::ll::TypedStorage<1, 1, bool> mBreakAtEnd;
560 // NOLINTEND
561
562 public:
563 // prevent constructor by default
564 Parser& operator=(Parser const&);
565 Parser(Parser const&);
566 Parser();
567
568 public:
569 // member functions
570 // NOLINTBEGIN
571 MCAPI Parser(::CommandRegistry const& registry, int version);
572
573 MCAPI bool _parse(::std::string const& in);
574
575 MCAPI ::std::unique_ptr<::CommandSelector<::Actor>>
576 createSelector(::std::string const& selectorString, ::CommandOrigin const& origin);
577
578 MCAPI ::std::vector<::std::string> getErrorParams() const;
579
580 MCAPI bool parseCommand(::std::string const& in);
581
582 MCAPI bool parseSelector(::std::string const& in);
583
584 MCAPI ~Parser();
585 // NOLINTEND
586
587 public:
588 // constructor thunks
589 // NOLINTBEGIN
590 MCAPI void* $ctor(::CommandRegistry const& registry, int version);
591 // NOLINTEND
592
593 public:
594 // destructor thunk
595 // NOLINTBEGIN
596 MCAPI void $dtor();
597 // NOLINTEND
598 };
599
600 using ChainedSubcommandConversionFunction = ::std::function<void(void*, uint64)>;
601
602 using ChainedSubcommandID = uint;
603
604 using ChainedSubcommandValueID = uint64;
605
606 using CommandOverrideFunctor =
607 ::std::function<void(::std::string const&, ::CommandFlag&, ::CommandPermissionLevel&)>;
608
609 using CommandVisitCallback = ::std::function<bool(::CommandRegistry::ParseToken const*, ::CommandOrigin const&)>;
610
611 using ConstrainedValueID = uint;
612
613 using ConstrainedValueLookupKey = ::std::pair<uint64, uint>;
614
615 using CustomStorageGetFn = void* (*)(::Command*, int);
616
617 using CustomStorageIsSetFn = bool* (*)(::Command*, int);
618
619 using EnumConversionFunction = ::std::function<void(void*, uint64)>;
620
621 using EnumID = uint;
622
623 using EnumValueID = uint64;
624
625 using HardTerminal = ::CommandLexer::TokenType;
626
627 using ParamVisitCallback = ::std::function<
629
630 using ParseMap = ::std::map<
632 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>>;
633
634 using ParseTableMap = ::std::map<uint, ::CommandRegistry::ParseTable>;
635
636 using PredictTable = ::entt::dense_map<
637 ::std::pair<::CommandRegistry::Symbol, ::CommandRegistry::Symbol>,
638 int,
640 ::std::equal_to<void>>;
641
642 using ProcessFunction =
644
645 using RuleIndex = int;
646
647 using ScoreboardScoreAccessor = ::std::function<int(bool&, ::std::string const&, ::Actor const&)>;
648
649 using SemanticConstraintID = uchar;
650
651 using SoftEnumID = uint;
652
654
655 using SymbolSet =
656 ::entt::dense_set<::CommandRegistry::Symbol, ::CommandRegistry::SymbolHasher, ::std::equal_to<void>>;
657
658 using SymbolVector = ::std::vector<::CommandRegistry::Symbol>;
659
660 using Terminal = ::CommandRegistry::Symbol;
661
662 using ValueTypeID = uint64;
663
664public:
665 // member variables
666 // NOLINTBEGIN
667 ::std::function<void(::Packet const&)> mNetworkUpdateCallback;
668 ScoreboardScoreAccessor mGetScoreForObjective;
669 bool mIsEduMode;
670 ::std::vector<::CommandRegistry::ParseRule> mRules;
671 ::std::map<uint, ::CommandRegistry::ParseTable> mParseTables;
672 ::std::vector<::CommandRegistry::OptionalParameterChain> mOptionals;
673 ::std::vector<::std::string> mEnumValues;
674 ::std::vector<::CommandRegistry::Enum> mEnums;
675 ::std::vector<::std::string> mChainedSubcommandValues;
676 ::std::vector<::CommandRegistry::ChainedSubcommand> mChainedSubcommands;
677 ::std::vector<::CommandRegistry::Factorization> mFactorizations;
678 ::std::vector<::std::string> mPostfixes;
679 ::std::map<::std::string, uint> mEnumLookup;
680 ::std::map<::std::string, uint64> mEnumValueLookup;
681 ::std::map<::std::string, uint> mChainedSubcommandLookup;
682 ::std::map<::std::string, uint64> mChainedSubcommandValueLookup;
683 ::std::vector<::CommandRegistry::Symbol> mCommandSymbols;
684 ::std::map<::std::string, ::CommandRegistry::Signature> mSignatures;
685 ::std::map<::Bedrock::typeid_t<::CommandRegistry>, int> mTypeLookup;
686 ::std::map<::std::string, ::std::string> mAliases;
687 ::std::vector<::SemanticConstraint> mSemanticConstraints;
688 ::std::map<::SemanticConstraint, uchar> mSemanticConstraintLookup;
689 ::std::vector<::CommandRegistry::ConstrainedValue> mConstrainedValues;
690 ::std::map<::std::pair<uint64, uint>, uint> mConstrainedValueLookup;
691 ::std::vector<::CommandRegistry::SoftEnum> mSoftEnums;
692 ::std::map<::std::string, uint> mSoftEnumLookup;
693 ::std::vector<::CommandRegistry::RegistryState> mStateStack;
695 ::std::unordered_set<int> mSkipOnEpsAutocompleteSymbols;
696 ::std::unordered_set<int> mAllowEmptySymbols;
697 CommandOverrideFunctor mCommandOverrideFunctor;
698 ::std::unique_ptr<::CommandRunStats> mCommandRunStats;
699 ::ll::TypedStorage<
700 8,
701 8,
702 ::std::string (*)(
703 ::std::string const&,
704 ::std::unordered_map<::mce::UUID, ::PlayerListEntry> const&,
706 )>
707 mAutoCompletePlayerMention;
708 // NOLINTEND
709
710 template <class T>
711 bool parse(
712 void* storage,
713 CommandRegistry::ParseToken const& token,
714 CommandOrigin const& origin,
715 int version,
716 std::string& error,
717 std::vector<std::string>& errorParams
718 ) const;
719
720 template <class E, class C>
721 bool parseEnum(
722 void* storage,
723 CommandRegistry::ParseToken const& token,
724 CommandOrigin const& origin,
725 int version,
726 std::string& error,
727 std::vector<std::string>& errorParams
728 ) const;
729
730 uint64 getEnumData(ParseToken const& token) const {
731 auto& values = mEnums[token.type.toIndex()].values;
732 return std::lower_bound(
733 values.begin(),
734 values.end(),
735 token.child->type.toIndex(),
736 [](auto& pair, auto& child) { return pair.first < child; }
737 )->second;
738 }
739
740 template <class T>
742 MCAPI static ParamParseRule const& instance();
743 };
744
745public:
746 // prevent constructor by default
747 CommandRegistry();
748
749public:
750 // member functions
751 // NOLINTBEGIN
752 MCAPI explicit CommandRegistry(::CommandRegistryArguments args);
753
754 MCAPI ::CommandRegistry::Symbol _addChainedSubcommandValuesInternal(
755 ::std::string const& name,
756 ::std::vector<::std::pair<::std::string, uint>> const& strings,
758 bool (CommandRegistry::*parse)(
759 void*,
761 ::CommandOrigin const&,
762 int,
763 ::std::string&,
764 ::std::vector<::std::string>&
765 ) const,
767 );
768
769#ifdef LL_PLAT_C
770 MCAPI ::CommandRegistry::Symbol _addChainedSubcommandValuesInternal(
771 ::std::string const& name,
772 ::std::vector<::std::pair<uint64, uint>> const& values,
774 bool (::CommandRegistry::*parse)(
775 void*,
777 ::CommandOrigin const&,
778 int,
779 ::std::string&,
780 ::std::vector<::std::string>&
781 ) const,
783 );
784#endif
785
786 MCAPI ::CommandRegistry::Symbol _addEnumValuesInternal(
787 ::std::string const& name,
788 ::std::vector<::std::pair<::std::string, uint64>> const& strings,
790 bool (CommandRegistry::*parse)(
791 void*,
793 ::CommandOrigin const&,
794 int,
795 ::std::string&,
796 ::std::vector<::std::string>&
797 ) const
798 );
799
800 MCAPI ::CommandRegistry::Symbol _addEnumValuesInternal(
801 ::std::string const& name,
802 ::std::vector<::std::pair<uint64, uint64>> const& values,
804 bool (::CommandRegistry::*parse)(
805 void*,
807 ::CommandOrigin const&,
808 int,
809 ::std::string&,
810 ::std::vector<::std::string>&
811 ) const
812 );
813
814 MCAPI ::std::unique_ptr<::CommandSelector<::Actor>> _createSelector(
816 ::CommandOrigin const& origin,
817 int version,
818 ::std::string& error,
819 ::std::vector<::std::string>& errorParams
820 ) const;
821
822#ifdef LL_PLAT_C
823 MCAPI ::CommandRegistry::Symbol _getConstrainedParamEnumSymbol(::CommandRegistry::Symbol symbol) const;
824#endif
825
826 MCAPI bool _matchesEnumConstraintsSet(
827 ::CommandRegistry::Symbol const& commandParamSymbol,
828 ::CommandOrigin const& origin,
829 ::CommandRegistry::Symbol const& value,
830 ::SemanticConstraint requiredConstraints
831 ) const;
832
833#ifdef LL_PLAT_C
834 MCAPI void addChainedSubcommandValuesToExisting(uint index, ::std::vector<::std::pair<uint64, uint>> const& values);
835#endif
836
837 MCAPI void addEnumValueConstraints(
838 ::std::string const& enumName,
839 ::std::vector<::std::string> const& values,
840 ::SemanticConstraint constraints
841 );
842
843 MCAPI int addEnumValues(::std::string const& name, ::std::vector<::std::string> const& values);
844
845 MCAPI void addEnumValuesToExisting(uint index, ::std::vector<::std::pair<uint64, uint64>> const& values);
846
847#ifdef LL_PLAT_C
848 MCAPI ::CommandRegistry::Symbol addPostfix(::std::string const& name);
849#endif
850
851 MCAPI void addRule(
853 ::std::vector<::CommandRegistry::Symbol> derivation,
855 process,
856 ::CommandVersion versions
857 );
858
859 MCAPI void addSemanticConstraint(::SemanticConstraint constraintType);
860
861 MCAPI int addSoftEnum(::std::string const& name, ::std::vector<::std::string> values);
862
863 MCAPI void addSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
864
865 MCAPI ::CommandRegistry::Symbol addSoftTerminal(::std::string const& name);
866
867#ifdef LL_PLAT_C
868 MCAPI void autoComplete(
870 ::std::string const& cmdLine,
871 ::std::string const& partialMatch,
872 bool newWord,
873 ::CommandOrigin const& origin,
876 ) const;
877
878 MCAPI void autoCompleteCommand(
879 ::std::string const& partialMatch,
880 ::CommandOrigin const& origin,
882 ) const;
883#endif
884
885 MCAPI void buildFirstSet(::CommandRegistry::ParseTable& table, ::CommandRegistry::Symbol t, uint version) const;
886
887 MCAPI void buildFollowSet(
890 uint version,
891 ::std::set<::CommandRegistry::Symbol>& workingSet
892 ) const;
893
894 MCAPI ::CommandRegistry::Symbol buildRules(
896 ::std::vector<::gsl::not_null<::CommandRegistry::Overload*>> const& overloads,
897 uint64 firstParam
898 );
899
900 MCAPI bool
901 buildSelector(::ActorSelectorArgs const& args, ::CommandSelectorBase* output, ::std::string& error) const;
902
903#ifdef LL_PLAT_C
904 MCAPI bool canCommandBeUsed(
905 ::std::string const& commandLine,
906 ::CommandPermissionLevel const& permissionLevel,
907 bool cheatsEnabled,
908 bool isEditorWorld
909 ) const;
910#endif
911
912 MCAPI ::std::unique_ptr<::Command> createCommand(
914 ::CommandOrigin const& origin,
915 int version,
916 ::std::string& error,
917 ::std::vector<::std::string>& errorParams
918 ) const;
919
920 MCAPI ::std::string describe(::CommandRegistry::Symbol symbol) const;
921
922#ifdef LL_PLAT_C
923 MCAPI ::std::string describe(
924 ::CommandRegistry::Signature const& command,
925 ::std::string const& alias,
926 ::CommandRegistry::Overload const& overload,
927 uint highlight,
928 uint* start,
929 uint* length
930 ) const;
931#endif
932
933 MCAPI void finalizeChainedSubcommandOverloadRules(char const* command);
934
935 MCFOLD ::CommandRegistry::Signature const* findCommand(::std::string const& name) const;
936
937 MCFOLD ::CommandRegistry::Signature* findCommand(::std::string const& name);
938
939 MCAPI void fireCommandParseTableTelemetry(::IMinecraftEventing const& eventing, bool isServer) const;
940
941 MCAPI void forEachNonTerminal(::std::function<void(::CommandRegistry::Symbol)> func) const;
942
943 MCAPI ::Json::Value generateDocumentationMetadata(bool generateInternalMetadata) const;
944
945 MCAPI ::std::vector<::std::string> getAliases(::std::string const& command) const;
946
947 MCAPI ::std::vector<::std::string> getAlphabeticalLookup(::CommandOrigin const& origin) const;
948
949#ifdef LL_PLAT_C
950 MCAPI ::std::unique_ptr<::AutoCompleteInformation> getAutoCompleteOptions(
951 ::CommandOrigin const& origin,
952 ::std::string const& _cmdLine,
953 uint cursorPositionUnsafe
954 ) const;
955#endif
956
957 MCAPI ::std::string getCommandName(::std::string const& commandLine) const;
958
959 MCAPI ::CommandSyntaxInformation
960 getCommandOverloadSyntaxInformation(::CommandOrigin const& origin, ::std::string const& commandName) const;
961
962 MCAPI ::InvertableFilter<::std::string> getInvertableFilter(::CommandRegistry::ParseToken const& token) const;
963
964#ifdef LL_PLAT_C
965 MCAPI ::CommandSyntaxInformation getOverloadSyntaxInformation(
966 ::CommandOrigin const& origin,
967 ::std::string const& cmdLine,
968 uint cursorPosition
969 ) const;
970
971 MCAPI bool isCommandOfType(::std::string const& nameIn, ::CommandTypeFlag commandType) const;
972#endif
973
974 MCAPI bool isValid(::CommandRegistry::Symbol symbol) const;
975
976#ifdef LL_PLAT_C
977 MCAPI void loadRemoteCommands(::AvailableCommandsPacket const& packet);
978#endif
979
980 MCAPI bool originCanRun(::CommandOrigin const& origin, ::CommandRegistry::Signature const& command) const;
981
982#ifdef LL_PLAT_C
983 MCAPI bool originCanRunOverloadWithParam(::CommandOrigin const& origin, ::CommandParameterData const& param) const;
984
985 MCAPI ::std::string parsePartialCommand(
987 ::std::string const& _cmdLine,
988 uint cursorPosition,
989 bool cutLastToken
990 ) const;
991#endif
992
993 MCAPI bool parseSelector(
996 ::CommandOrigin const& origin,
997 int version,
998 ::std::string& error,
999 ::std::vector<::std::string>& errorParams
1000 ) const;
1001
1002 MCAPI bool parseSelector(
1003 ::CommandSelectorBase* output,
1004 ::CommandRegistry::ParseToken const& token,
1005 ::CommandOrigin const& origin,
1006 int version,
1007 ::std::string& error,
1008 ::std::vector<::std::string>& errorParams,
1009 bool wildcard
1010 ) const;
1011
1012#ifdef LL_PLAT_C
1013 MCAPI void popState();
1014
1015 MCAPI void pushState();
1016#endif
1017
1018 MCAPI void registerAlias(::std::string name, ::std::string alias);
1019
1020 MCAPI void registerCommand(
1021 ::std::string const& name,
1022 char const* description,
1023 ::CommandPermissionLevel requirement,
1024 ::CommandFlag f1,
1025 ::CommandFlag f2 = {}
1026 );
1027
1028 MCAPI void registerOverload(
1029 char const* command,
1030 ::CommandVersion version,
1031 ::std::function<::std::unique_ptr<::Command>()> allocFn,
1032 ::std::vector<::CommandParameterData> params
1033 );
1034
1035 MCAPI void registerOverloadInternal(::CommandRegistry::Signature& signature, ::CommandRegistry::Overload& overload);
1036
1037 MCAPI void removeSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
1038
1039 MCAPI ::AvailableCommandsPacket serializeAvailableCommands() const;
1040
1041 MCAPI void setCommandRegistrationOverride(CommandOverrideFunctor functor);
1042
1043 MCAPI void setScoreCallback(::std::function<int(bool&, ::std::string const&, ::Actor const&)> callback);
1044
1045 MCAPI void setSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
1046
1047 MCAPI void setupChainedSubcommandOverloadRules(::CommandRegistry::Signature& signature);
1048
1049#ifdef LL_PLAT_C
1050 MCAPI void setupOverloadRules(::CommandRegistry::Signature& signature);
1051#endif
1052
1053 MCAPI ::std::string symbolToString(::CommandRegistry::Symbol symbol) const;
1054
1055 MCAPI ~CommandRegistry();
1056 // NOLINTEND
1057
1058public:
1059 // static functions
1060 // NOLINTBEGIN
1061#ifdef LL_PLAT_C
1062 MCAPI static ::BlockType const* _getBlockFromCmdParameters(::std::string const& parameters);
1063#endif
1064
1065 MCAPI static ::std::string _removeStringQuotes(::std::string const& str);
1066
1067 MCFOLD static ::CommandRegistry::ParseToken*
1069
1070 MCAPI static ::CommandRegistry::ParseToken* collapseOn(
1073 ::CommandRegistry::Symbol boundSymbol
1074 );
1075
1076 MCAPI static ::CommandRegistry::ParseToken*
1078
1079 MCAPI static ::CommandRegistry::ParseToken* expandExcept(
1082 ::CommandRegistry::Symbol boundSymbol
1083 );
1084
1085 MCAPI static ::CommandRegistry::ParseToken* fold(
1088 ::CommandRegistry::Symbol boundSymbol
1089 );
1090
1091 MCAPI static ::CommandRegistry::ParseToken*
1093
1094 MCAPI static bool readFloat(
1095 float& value,
1096 ::CommandRegistry::ParseToken const& token,
1097 ::std::string& error,
1098 ::std::vector<::std::string>& errorParams
1099 );
1100
1101 MCAPI static bool readInt(
1102 int& value,
1103 ::CommandRegistry::ParseToken const& token,
1104 ::std::string& error,
1105 ::std::vector<::std::string>& errorParams
1106 );
1107
1108 MCAPI static bool readRelativeCoordinate(
1109 bool& relative,
1110 float& offset,
1111 ::CommandRegistry::ParseToken const& token,
1112 bool readIntegerAsCentered,
1113 ::std::string& error,
1114 ::std::vector<::std::string>& errorParams
1115 );
1116
1117 MCAPI static bool readString(
1118 ::std::string& value,
1119 ::CommandRegistry::ParseToken const& token,
1120 ::std::string& error,
1121 ::std::vector<::std::string>& errorParams
1122 );
1123 // NOLINTEND
1124
1125public:
1126 // static variables
1127 // NOLINTBEGIN
1128 MCAPI static char const*& COMMAND_NAME_ENUM_NAME();
1129
1130 MCAPI static char const*& TAG_VALUES_SOFTENUM_NAME();
1131
1132 MCAPI static char const*& UNLOCKABLE_RECIPES_SOFTENUM_NAME();
1133 // NOLINTEND
1134
1135public:
1136 // constructor thunks
1137 // NOLINTBEGIN
1138 MCAPI void* $ctor(::CommandRegistryArguments args);
1139 // NOLINTEND
1140
1141public:
1142 // destructor thunk
1143 // NOLINTBEGIN
1144 MCAPI void $dtor();
1145 // NOLINTEND
1146};
1147
1148// following are the functions required by CommandParameterData's ParseFunction
1149MCTAPI bool CommandRegistry::parse<std::string>(
1150 void*,
1152 CommandOrigin const&,
1153 int,
1154 std::string&,
1155 std::vector<std::string>&
1156) const;
1157
1158MCTAPI bool CommandRegistry::parse<int>(
1159 void*,
1161 CommandOrigin const&,
1162 int,
1163 std::string&,
1164 std::vector<std::string>&
1165) const;
1166
1167MCTAPI bool CommandRegistry::parse<float>(
1168 void*,
1170 CommandOrigin const&,
1171 int,
1172 std::string&,
1173 std::vector<std::string>&
1174) const;
1175
1176MCTAPI bool CommandRegistry::parse<Json::Value>(
1177 void*,
1179 CommandOrigin const&,
1180 int,
1181 std::string&,
1182 std::vector<std::string>&
1183) const;
1184
1185MCTAPI bool CommandRegistry::parse<CommandCompareOperator>(
1186 void*,
1188 CommandOrigin const&,
1189 int,
1190 std::string&,
1191 std::vector<std::string>&
1192) const;
1193
1194MCTAPI bool CommandRegistry::parse<CommandFilePath>(
1195 void*,
1197 CommandOrigin const&,
1198 int,
1199 std::string&,
1200 std::vector<std::string>&
1201) const;
1202
1203MCTAPI bool CommandRegistry::parse<CommandIntegerRange>(
1204 void*,
1206 CommandOrigin const&,
1207 int,
1208 std::string&,
1209 std::vector<std::string>&
1210) const;
1211
1212MCTAPI bool CommandRegistry::parse<CommandMessage>(
1213 void*,
1215 CommandOrigin const&,
1216 int,
1217 std::string&,
1218 std::vector<std::string>&
1219) const;
1220
1221MCTAPI bool CommandRegistry::parse<CommandOperator>(
1222 void*,
1224 CommandOrigin const&,
1225 int,
1226 std::string&,
1227 std::vector<std::string>&
1228) const;
1229
1230MCTAPI bool CommandRegistry::parse<CommandPosition>(
1231 void*,
1233 CommandOrigin const&,
1234 int,
1235 std::string&,
1236 std::vector<std::string>&
1237) const;
1238
1239MCTAPI bool CommandRegistry::parse<CommandPositionFloat>(
1240 void*,
1242 CommandOrigin const&,
1243 int,
1244 std::string&,
1245 std::vector<std::string>&
1246) const;
1247
1248MCTAPI bool CommandRegistry::parse<CommandRawText>(
1249 void*,
1251 CommandOrigin const&,
1252 int,
1253 std::string&,
1254 std::vector<std::string>&
1255) const;
1256
1257MCTAPI bool CommandRegistry::parse<CommandSelector<Actor>>(
1258 void*,
1260 CommandOrigin const&,
1261 int,
1262 std::string&,
1263 std::vector<std::string>&
1264) const;
1265
1266MCTAPI bool CommandRegistry::parse<CommandSelector<Player>>(
1267 void*,
1269 CommandOrigin const&,
1270 int,
1271 std::string&,
1272 std::vector<std::string>&
1273) const;
1274
1275MCTAPI bool CommandRegistry::parse<CommandWildcardInt>(
1276 void*,
1278 CommandOrigin const&,
1279 int,
1280 std::string&,
1281 std::vector<std::string>&
1282) const;
1283
1284MCTAPI bool CommandRegistry::parse<class RelativeFloat>(
1285 void*,
1287 CommandOrigin const&,
1288 int,
1289 std::string&,
1290 std::vector<std::string>&
1291) const;
1292
1293MCTAPI bool CommandRegistry::parse<WildcardCommandSelector<Actor>>(
1294 void*,
1296 CommandOrigin const&,
1297 int,
1298 std::string&,
1299 std::vector<std::string>&
1300) const;
1301
1302MCTAPI bool CommandRegistry::parse<std::unique_ptr<::Command>>(
1303 void*,
1305 CommandOrigin const&,
1306 int,
1307 std::string&,
1308 std::vector<std::string>&
1309) const;
1310
1311MCTAPI bool CommandRegistry::parse<std::vector<BlockStateCommandParam>>(
1312 void*,
1314 CommandOrigin const&,
1315 int,
1316 std::string&,
1317 std::vector<std::string>&
1318) const;
1319
1320MCTAPI bool CommandRegistry::parseEnum<CommandChainedSubcommand, void>(
1321 void*,
1323 CommandOrigin const&,
1324 int,
1325 std::string&,
1326 std::vector<std::string>&
1327) const;
1328
1329// clang-format off
1330template <>
1331MCAPI ::ll::type_id_ref Bedrock::typeid_storage_impl<class CommandRegistry, ::std::basic_string<char, ::std::char_traits<char>, ::std::allocator<char> >>();
1332template <>
1333MCAPI ::ll::type_id_ref Bedrock::typeid_storage_impl<class CommandRegistry, bool>();
1334template <>
1335MCAPI ::ll::type_id_ref Bedrock::typeid_storage_impl<class CommandRegistry, float>();
1336template <>
1337MCAPI ::ll::type_id_ref Bedrock::typeid_storage_impl<class CommandRegistry, int>();
1338// clang-format on
Definition Actor.h:114
Definition AvailableCommandsPacket.h:19
Definition typeid_t.h:36
Definition BlockState.h:14
Definition BlockType.h:79
Definition CommandOrigin.h:32
Definition CommandParameterData.h:18
Definition CommandRegistry.h:544
Definition CommandRegistry.h:242
Definition CommandRegistry.h:49
Definition CommandRunStats.h:8
Definition CommandSelectorBase.h:24
Definition CommandVersion.h:10
Definition Command.h:17
Definition IMinecraftEventing.h:145
Definition Value.h:16
Definition Packet.h:29
Definition PlayerListEntry.h:17
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:403
Definition CommandRegistry.h:275
Definition CommandRegistry.h:414
Definition CommandRegistry.h:285
Definition CommandRegistry.h:293
Definition CommandRegistry.h:317
Definition CommandRegistry.h:327
Definition CommandRegistry.h:425
Definition CommandRegistry.h:344
Definition CommandRegistry.h:741
Definition CommandRegistry.h:445
Definition CommandRegistry.h:520
Definition CommandRegistry.h:376
Definition CommandRegistry.h:182
Definition CommandRegistry.h:472
Definition CommandRegistry.h:484
Definition CommandRegistry.h:217
Definition CommandRegistry.h:516
Definition CommandRegistry.h:518
Definition CommandSyntaxInformation.h:10