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::unique_ptr<::CommandSelector<::Actor>>
641 createSelector(::std::string const& selectorString, ::CommandOrigin const& origin);
642
643 MCAPI ::std::vector<::std::string> getErrorParams() const;
644
645 MCAPI bool parseCommand(::std::string const& in);
646
647 MCAPI bool parseSelector(::std::string const& in);
648
649 MCAPI ~Parser();
650 // NOLINTEND
651
652 public:
653 // constructor thunks
654 // NOLINTBEGIN
655 MCAPI void* $ctor(::CommandRegistry const& registry, int version);
656 // NOLINTEND
657
658 public:
659 // destructor thunk
660 // NOLINTBEGIN
661 MCAPI void $dtor();
662 // NOLINTEND
663 };
664
666
667public:
668 // member variables
669 // NOLINTBEGIN
670 ::std::function<void(::Packet const&)> mNetworkUpdateCallback;
671 ScoreboardScoreAccessor mGetScoreForObjective;
672 bool mIsEduMode;
673 ::std::vector<::CommandRegistry::ParseRule> mRules;
674 ::std::map<uint, ::CommandRegistry::ParseTable> mParseTables;
675 ::std::vector<::CommandRegistry::OptionalParameterChain> mOptionals;
676 ::std::vector<::std::string> mEnumValues;
677 ::std::vector<::CommandRegistry::Enum> mEnums;
678 ::std::vector<::std::string> mChainedSubcommandValues;
679 ::std::vector<::CommandRegistry::ChainedSubcommand> mChainedSubcommands;
680 ::std::vector<::CommandRegistry::Factorization> mFactorizations;
681 ::std::vector<::std::string> mPostfixes;
682 ::std::map<::std::string, uint> mEnumLookup;
683 ::std::map<::std::string, uint64> mEnumValueLookup;
684 ::std::map<::std::string, uint> mChainedSubcommandLookup;
685 ::std::map<::std::string, uint64> mChainedSubcommandValueLookup;
686 ::std::vector<::CommandRegistry::Symbol> mCommandSymbols;
687 ::std::map<::std::string, ::CommandRegistry::Signature> mSignatures;
688 ::std::map<::Bedrock::typeid_t<::CommandRegistry>, int> mTypeLookup;
689 ::std::map<::std::string, ::std::string> mAliases;
690 ::std::vector<::SemanticConstraint> mSemanticConstraints;
691 ::std::map<::SemanticConstraint, uchar> mSemanticConstraintLookup;
692 ::std::vector<::CommandRegistry::ConstrainedValue> mConstrainedValues;
693 ::std::map<::std::pair<uint64, uint>, uint> mConstrainedValueLookup;
694 ::std::vector<::CommandRegistry::SoftEnum> mSoftEnums;
695 ::std::map<::std::string, uint> mSoftEnumLookup;
696 ::std::vector<::CommandRegistry::RegistryState> mStateStack;
698 ::std::unordered_set<int> mSkipOnEpsAutocompleteSymbols;
699 ::std::unordered_set<int> mAllowEmptySymbols;
700 CommandOverrideFunctor mCommandOverrideFunctor;
701 ::std::unique_ptr<::CommandRunStats> mCommandRunStats;
702 // NOLINTEND
703
704 template <class T>
705 bool parse(
706 void* storage,
707 CommandRegistry::ParseToken const& token,
708 CommandOrigin const& origin,
709 int version,
710 std::string& error,
711 std::vector<std::string>& errorParams
712 ) const;
713
714 template <class E, class C>
715 bool parseEnum(
716 void* storage,
717 CommandRegistry::ParseToken const& token,
718 CommandOrigin const& origin,
719 int version,
720 std::string& error,
721 std::vector<std::string>& errorParams
722 ) const;
723
724 uint64 getEnumData(ParseToken const& token) const {
725 auto& values = mEnums[token.type.toIndex()].values;
726 return std::lower_bound(
727 values.begin(),
728 values.end(),
729 token.child->type.toIndex(),
730 [](auto& pair, auto& child) { return pair.first < child; }
731 )->second;
732 }
733
734public:
735 // prevent constructor by default
737
738public:
739 // member functions
740 // NOLINTBEGIN
741 MCAPI explicit CommandRegistry(bool isEduMode);
742
743 MCAPI ::CommandRegistry::Symbol _addChainedSubcommandValuesInternal(
744 ::std::string const& name,
745 ::std::vector<::std::pair<::std::string, uint>> const& strings,
747 bool (CommandRegistry::*parse)(
748 void*,
750 ::CommandOrigin const&,
751 int,
752 ::std::string&,
753 ::std::vector<::std::string>&
754 ) const,
756 );
757
758 MCAPI ::CommandRegistry::Symbol _addChainedSubcommandValuesInternal(
759 ::std::string const& name,
760 ::std::vector<::std::pair<uint64, uint>> const& values,
762 bool (CommandRegistry::*parse)(
763 void*,
765 ::CommandOrigin const&,
766 int,
767 ::std::string&,
768 ::std::vector<::std::string>&
769 ) const,
771 );
772
773 MCAPI ::CommandRegistry::Symbol _addEnumValuesInternal(
774 ::std::string const& name,
775 ::std::vector<::std::pair<::std::string, uint64>> const& strings,
777 bool (CommandRegistry::*parse)(
778 void*,
780 ::CommandOrigin const&,
781 int,
782 ::std::string&,
783 ::std::vector<::std::string>&
784 ) const
785 );
786
787 MCAPI ::CommandRegistry::Symbol _addEnumValuesInternal(
788 ::std::string const& name,
789 ::std::vector<::std::pair<uint64, uint64>> const& values,
791 bool (CommandRegistry::*parse)(
792 void*,
794 ::CommandOrigin const&,
795 int,
796 ::std::string&,
797 ::std::vector<::std::string>&
798 ) const
799 );
800
801 MCAPI ::CommandRegistry::Symbol _addFunctionSoftEnum();
802
803 MCAPI ::std::unique_ptr<::CommandSelector<::Actor>> _createSelector(
805 ::CommandOrigin const& origin,
806 int version,
807 ::std::string& error,
808 ::std::vector<::std::string>& errorParams
809 ) const;
810
811 MCAPI ::CommandRegistry::Symbol _getConstrainedParamEnumSymbol(::CommandRegistry::Symbol symbol) const;
812
813 MCAPI bool _isCommandElementValid(::std::string const& name) const;
814
815 MCAPI bool _matchesEnumConstraintsSet(
816 ::CommandRegistry::Symbol const& commandParamSymbol,
817 ::CommandOrigin const& origin,
818 ::CommandRegistry::Symbol const& value,
819 ::SemanticConstraint requiredConstraints
820 ) const;
821
822 MCAPI void addChainedSubcommandValuesToExisting(uint index, ::std::vector<::std::pair<uint64, uint>> const& values);
823
824 MCAPI void addEnumValueConstraints(
825 ::std::string const& enumName,
826 ::std::vector<::std::string> const& values,
827 ::SemanticConstraint constraints
828 );
829
830 MCAPI int addEnumValues(::std::string const& name, ::std::vector<::std::string> const& values);
831
832 MCAPI void addEnumValuesToExisting(uint index, ::std::vector<::std::pair<uint64, uint64>> const& values);
833
834 MCAPI ::CommandRegistry::Symbol addPostfix(::std::string const& name);
835
836 MCAPI void addRule(
838 ::std::vector<::CommandRegistry::Symbol> derivation,
840 process,
841 ::CommandVersion versions
842 );
843
844 MCAPI void addSemanticConstraint(::SemanticConstraint constraintType);
845
846 MCAPI int addSoftEnum(::std::string const& name, ::std::vector<::std::string> values);
847
848 MCAPI void addSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
849
850 MCAPI ::CommandRegistry::Symbol addSoftTerminal(::std::string const& name);
851
852 MCAPI void buildFirstSet(::CommandRegistry::ParseTable& table, ::CommandRegistry::Symbol t, uint version) const;
853
854 MCAPI void buildFollowSet(
857 uint version,
858 ::std::set<::CommandRegistry::Symbol>& workingSet
859 ) const;
860
861 MCAPI ::CommandRegistry::Symbol buildOptionalRuleChain(
862 ::CommandRegistry::Signature const& signature,
863 ::std::vector<::CommandParameterData> const& params,
864 ::std::vector<::CommandRegistry::Symbol> const& symbols
865 );
866
867 MCAPI void buildParseTable(uint version) const;
868
869 MCAPI void buildPredictTable(::CommandRegistry::ParseTable& table, uint version) const;
870
871 MCAPI ::CommandRegistry::Symbol buildRules(
873 ::std::vector<::gsl::not_null<::CommandRegistry::Overload*>> const& overloads,
874 uint64 firstParam
875 );
876
877 MCAPI bool
878 buildSelector(::ActorSelectorArgs const& args, ::CommandSelectorBase* output, ::std::string& error) const;
879
880 MCAPI ::std::unique_ptr<::Command> createCommand(
882 ::CommandOrigin const& origin,
883 int version,
884 ::std::string& error,
885 ::std::vector<::std::string>& errorParams
886 ) const;
887
888 MCAPI ::std::string describe(::CommandParameterData const& param) const;
889
890 MCAPI ::std::string describe(::CommandRegistry::Symbol symbol) const;
891
892 MCAPI ::std::string describe(
893 ::CommandRegistry::Signature const& command,
894 ::std::string const& alias,
895 ::CommandRegistry::Overload const& overload,
896 uint highlight,
897 uint* start,
898 uint* length
899 ) const;
900
901 MCAPI ::CommandRegistry::Signature const* findCommand(::std::string const&) const;
902
903 MCFOLD ::CommandRegistry::Signature* findCommand(::std::string const& name);
904
905 MCAPI ::CommandRegistry::Symbol findEnumValue(::std::string const& name) const;
906
907 MCAPI ::CommandRegistry::Symbol findIdentifierInfo(::std::string const& name) const;
908
909 MCAPI ::CommandRegistry::Symbol findPostfix(::std::string const& input) const;
910
911 MCAPI void fireCommandParseTableTelemetry(::IMinecraftEventing const& eventing, bool isServer) const;
912
913 MCAPI void forEachNonTerminal(::std::function<void(::CommandRegistry::Symbol)> func) const;
914
915 MCAPI ::Json::Value generateDocumentationMetadata(bool generateInternalMetadata) const;
916
917 MCAPI ::std::vector<::std::string> getAliases(::std::string const& command) const;
918
919 MCAPI ::std::vector<::std::string> getAlphabeticalLookup(::CommandOrigin const& origin) const;
920
921 MCAPI ::std::string getCommandName(::std::string const& commandLine) const;
922
923 MCAPI ::CommandSyntaxInformation
924 getCommandOverloadSyntaxInformation(::CommandOrigin const& origin, ::std::string const& commandName) const;
925
926 MCAPI ::InvertableFilter<::std::string> getInvertableFilter(::CommandRegistry::ParseToken const& token) const;
927
928 MCAPI bool isValid(::CommandRegistry::Symbol symbol) const;
929
930 MCAPI bool originCanRun(::CommandOrigin const& origin, ::CommandRegistry::Signature const& command) const;
931
932 MCAPI bool originCanRun(::CommandOrigin const& origin, ::CommandRegistry::Overload const& overload) const;
933
934 MCAPI bool parseSelector(
937 ::CommandOrigin const& origin,
938 int version,
939 ::std::string& error,
940 ::std::vector<::std::string>& errorParams
941 ) const;
942
943 MCAPI void registerAlias(::std::string name, ::std::string alias);
944
945 MCAPI void registerCommand(
946 ::std::string const& name,
947 char const* description,
948 ::CommandPermissionLevel requirement,
949 ::CommandFlag f1,
950 ::CommandFlag f2 = {}
951 );
952
953 MCAPI void registerOverload(
954 char const* command,
955 ::CommandVersion version,
956 ::std::function<::std::unique_ptr<::Command>()> allocFn,
957 ::std::vector<::CommandParameterData> params
958 );
959
960 MCAPI void registerOverloadInternal(::CommandRegistry::Signature& signature, ::CommandRegistry::Overload& overload);
961
962 MCAPI void removeSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
963
964 MCAPI ::AvailableCommandsPacket serializeAvailableCommands() const;
965
966 MCAPI void setCommandRegistrationOverride(CommandOverrideFunctor functor);
967
968 MCAPI void setSoftEnumValues(::std::string const& enumName, ::std::vector<::std::string> values);
969
970 MCAPI void setupChainedSubcommandOverloadRules(::CommandRegistry::Signature& signature);
971
972 MCAPI void setupOverloadRules(::CommandRegistry::Signature& signature);
973
974 MCAPI ::std::string symbolToString(::CommandRegistry::Symbol symbol) const;
975
976 MCAPI ~CommandRegistry();
977 // NOLINTEND
978
979public:
980 // static functions
981 // NOLINTBEGIN
982 MCAPI static ::std::string _removeStringQuotes(::std::string const& str);
983
984 MCFOLD static ::CommandRegistry::ParseToken*
986
987 MCAPI static ::CommandRegistry::ParseToken* collapseOn(
990 ::CommandRegistry::Symbol boundSymbol
991 );
992
993 MCAPI static ::CommandRegistry::ParseToken*
995
996 MCAPI static ::CommandRegistry::ParseToken* expandExcept(
999 ::CommandRegistry::Symbol boundSymbol
1000 );
1001
1002 MCAPI static ::CommandRegistry::ParseToken* fold(
1005 ::CommandRegistry::Symbol boundSymbol
1006 );
1007
1008 MCAPI static ::CommandRegistry::ParseToken*
1010
1011 MCAPI static bool readFloat(
1012 float& value,
1013 ::CommandRegistry::ParseToken const& token,
1014 ::std::string& error,
1015 ::std::vector<::std::string>& errorParams
1016 );
1017
1018 MCAPI static bool readInt(
1019 int& value,
1020 ::CommandRegistry::ParseToken const& token,
1021 ::std::string& error,
1022 ::std::vector<::std::string>& errorParams
1023 );
1024
1025 MCAPI static bool readRelativeCoordinate(
1026 bool& relative,
1027 float& offset,
1028 ::CommandRegistry::ParseToken const& token,
1029 bool readIntegerAsCentered,
1030 ::std::string& error,
1031 ::std::vector<::std::string>& errorParams
1032 );
1033
1034 MCAPI static bool readString(
1035 ::std::string& value,
1036 ::CommandRegistry::ParseToken const& token,
1037 ::std::string& error,
1038 ::std::vector<::std::string>& errorParams
1039 );
1040 // NOLINTEND
1041
1042public:
1043 // static variables
1044 // NOLINTBEGIN
1045 MCAPI static char const*& CODE_STATUS_PROPERTY_NAME();
1046
1047 MCAPI static char const*& COMMAND_NAME_ENUM_NAME();
1048
1049 MCAPI static char const*& FUNCTION_NAME_SOFTENUM_NAME();
1050
1051 MCAPI static char const*& HASITEM_PARAM_DATA();
1052
1053 MCAPI static char const*& HASITEM_PARAM_ITEM();
1054
1055 MCAPI static char const*& HASITEM_PARAM_LOCATION();
1056
1057 MCAPI static char const*& HASITEM_PARAM_QUANTITY();
1058
1059 MCAPI static char const*& HASITEM_PARAM_SLOT();
1060
1061 MCAPI static char const*& HASPERMISSIONSTATE_ENUM_DISABLED();
1062
1063 MCAPI static char const*& HASPERMISSIONSTATE_ENUM_ENABLED();
1064
1065 MCAPI static char const*& HASPROPERTY_PARAM_PROPERTY_NAME();
1066
1067 MCAPI static ::std::add_lvalue_reference_t<::std::pair<
1068 bool (CommandRegistry::*)(
1069 void*,
1071 ::CommandOrigin const&,
1072 int,
1073 ::std::string&,
1074 ::std::vector<::std::string>&
1075 ) const,
1077 ParseRuleSymbols();
1078
1079 MCAPI static char const*& TAG_VALUES_SOFTENUM_NAME();
1080
1081 MCAPI static char const*& UNLOCKABLE_RECIPES_SOFTENUM_NAME();
1082 // NOLINTEND
1083
1084public:
1085 // constructor thunks
1086 // NOLINTBEGIN
1087 MCAPI void* $ctor(bool isEduMode);
1088 // NOLINTEND
1089
1090public:
1091 // destructor thunk
1092 // NOLINTBEGIN
1093 MCAPI void $dtor();
1094 // NOLINTEND
1095};
1096
1097// following are the functions required by CommandParameterData's ParseFunction
1098MCTAPI bool CommandRegistry::parse<
1099 std::
1100 string>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1101 const;
1102
1103MCTAPI bool CommandRegistry::parse<
1104 int>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1105 const;
1106
1107MCTAPI bool CommandRegistry::parse<
1108 float>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1109 const;
1110
1111MCTAPI bool CommandRegistry::parse<
1112 Json::
1113 Value>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1114 const;
1115
1116MCTAPI bool CommandRegistry::parse<
1117 CommandCompareOperator>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1118 const;
1119
1120MCTAPI bool CommandRegistry::parse<
1121 CommandFilePath>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1122 const;
1123
1124MCTAPI bool CommandRegistry::parse<
1125 CommandIntegerRange>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1126 const;
1127
1128MCTAPI bool CommandRegistry::parse<
1129 CommandMessage>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1130 const;
1131
1132MCTAPI bool CommandRegistry::parse<
1133 CommandOperator>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1134 const;
1135
1136MCTAPI bool CommandRegistry::parse<
1137 CommandPosition>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1138 const;
1139
1140MCTAPI bool CommandRegistry::parse<
1141 CommandPositionFloat>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1142 const;
1143
1144MCTAPI bool CommandRegistry::parse<
1145 CommandRawText>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1146 const;
1147
1148MCTAPI bool CommandRegistry::parse<CommandSelector<
1149 Actor>>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1150 const;
1151
1152MCTAPI bool CommandRegistry::parse<CommandSelector<
1153 Player>>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1154 const;
1155
1156MCTAPI bool CommandRegistry::parse<
1157 CommandWildcardInt>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1158 const;
1159
1160MCTAPI bool CommandRegistry::parse<
1161 class
1162 RelativeFloat>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1163 const;
1164
1165MCTAPI bool CommandRegistry::parse<WildcardCommandSelector<
1166 Actor>>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1167 const;
1168
1169MCTAPI bool CommandRegistry::parse<std::unique_ptr<
1170 ::Command>>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1171 const;
1172
1173MCTAPI bool CommandRegistry::parse<std::vector<
1174 BlockStateCommandParam>>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1175 const;
1176
1177MCTAPI bool CommandRegistry::parseEnum<
1179 void>(void*, CommandRegistry::ParseToken const&, CommandOrigin const&, int, std::string&, std::vector<std::string>&)
1180 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:145
Definition Packet.h:26
Definition Player.h:119
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:665
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