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