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