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