LeviLamina
Loading...
Searching...
No Matches
ExpressionNode.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/util/molang/IComplexExpression.h"
5#include "mc/util/molang/MolangParseConfig.h"
6
7// auto generated inclusion list
8#include "mc/molang/MolangVersion.h"
9#include "mc/platform/brstd/flat_set.h"
10#include "mc/util/MolangCompileResult.h"
11#include "mc/util/MolangQueryFunctionReturnType.h"
12#include "mc/util/molang/ExpressionOp.h"
13
14// auto generated forward declare list
15// clang-format off
16class Block;
17class BlockPos;
18class BlockSource;
19class Experiments;
20class HashedString;
22class RenderParams;
27struct MolangScriptArg;
28namespace Json { class Value; }
29namespace Molang::details { class IComplexExpression; }
30namespace Molang::details { class SourceTree; }
31namespace cereal { struct ReflectionCtx; }
32namespace mce { class Color; }
33// clang-format on
34
35class ExpressionNode {
36public:
37 // ExpressionNode inner types declare
38 // clang-format off
39 struct ResourceReference;
40 // clang-format on
41
42 // ExpressionNode inner types define
43 struct ResourceReference {
44 public:
45// member variables
46// NOLINTBEGIN
47#ifdef LL_PLAT_S
49#else // LL_PLAT_C
51#endif
54 // NOLINTEND
55
56 public:
57 // prevent constructor by default
58 ResourceReference& operator=(ResourceReference const&);
59 ResourceReference(ResourceReference const&);
60 ResourceReference();
61
62 public:
63 // member functions
64 // NOLINTBEGIN
65#ifdef LL_PLAT_C
66 MCNAPI explicit ResourceReference(::MolangDataDrivenGeometry const& geometry);
67#endif
68 // NOLINTEND
69
70 public:
71 // constructor thunks
72 // NOLINTBEGIN
73#ifdef LL_PLAT_C
74 MCNAPI void* $ctor(::MolangDataDrivenGeometry const& geometry);
75#endif
76 // NOLINTEND
77 };
78
79 using GetParticleTintFunc = ::std::function<::mce::Color(::Block const&, ::BlockSource&, ::BlockPos const&)>;
80
81 using IComplexExpression = ::Molang::details::IComplexExpression;
82
83 using MissingResourceSet =
85
86 using ResourceTable = ::std::unordered_map<::HashedString, ::ExpressionNode::ResourceReference>;
87
88public:
89 // member variables
90 // NOLINTBEGIN
91 ::ll::TypedStorage<8, 16, ::std::variant<::std::unique_ptr<::Molang::details::IComplexExpression>, float>> mImpl;
92 // NOLINTEND
93
94public:
95 ExpressionNode(
96 std::string const& expression,
97 ::MolangVersion molangVersion,
98 ::gsl::span<::HashedString const> querySetID
99 )
100 : ExpressionNode(expression, molangVersion) {
101 MolangParseConfig config;
102 config.mVersion = molangVersion;
103 config.mAllowedQuerySets = querySetID;
104 parse(expression, config);
105 }
106
107 LLAPI MolangScriptArg const& evalGeneric(RenderParams& renderParams) const;
108
109#ifdef LL_PLAT_S
110 static std::function<::MolangScriptArg const&(RenderParams&, std::vector<::ExpressionNode> const&)> const*
111 queryFunctionAccessorFromString(
112 ::HashedString const& functionName,
113 ::MolangVersion molangVersion,
114 ::MolangQueryFunctionReturnType& functionReturnType,
115 bool missingIsOkay_returnNullIfSo
116 );
117#endif
118
119public:
120 // prevent constructor by default
123
124public:
125 // member functions
126 // NOLINTBEGIN
127#ifdef LL_PLAT_C
128 MCAPI explicit ExpressionNode(::MaterialVariants const& materialVariants);
129#endif
130
132
133 MCAPI ExpressionNode(::std::string const& expression, ::MolangVersion molangVersion);
134
135#ifdef LL_PLAT_C
136 MCAPI ExpressionNode(char const* expression, ::MolangVersion molangVersion);
137#endif
138
139 MCAPI ExpressionNode(::Json::Value const& value, ::MolangParseConfig const& config);
140
141 MCAPI ExpressionNode(::MolangScriptArg const& value, ::ExpressionOp op);
142
143 MCAPI ::std::optional<::MolangScriptArg> _getValueIfConstant() const;
144
145 MCAPI ::std::string getExpressionString() const;
146
147 MCAPI ::MolangCompileResult link();
148
149#ifdef LL_PLAT_C
150 MCAPI ::ExpressionNode& operator=(::MaterialVariants const& materialVariants);
151#endif
152
153 MCAPI ::ExpressionNode& operator=(::ExpressionNode const& rhs);
154
155#ifdef LL_PLAT_C
156 MCAPI ::ExpressionNode& operator=(float value);
157#endif
158
159 MCAPI bool parse(::std::string_view expression, ::MolangParseConfig const& config);
160
161#ifdef LL_PLAT_C
162 MCAPI bool parse(::std::string_view expression, ::MolangVersion version, ::gsl::span<::HashedString const> idSet);
163
164 MCAPI void
165 replaceArrayVariables(::std::unordered_map<::HashedString, ::ExpressionNode>& dataMap, bool compileProgram);
166#endif
167 // NOLINTEND
168
169public:
170 // static functions
171 // NOLINTBEGIN
172 MCAPI static bool _initializeMolangQueries(::ExpressionQueries&& queries);
173
174 MCAPI static void bindType(::cereal::ReflectionCtx& ctx);
175
176#ifdef LL_PLAT_C
177 MCAPI static ::std::function<
178 ::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)> const*
179 queryFunctionAccessorFromString(
180 ::HashedString const& functionName,
181 ::MolangVersion molangVersion,
182 ::MolangQueryFunctionReturnType& functionReturnType,
183 bool missingIsOkay_returnNullIfSo
184 );
185#endif
186
187 MCAPI static ::MolangQueryFunction& registerQueryFunction(
188 ::std::string_view queryFunctionName,
189 ::std::function<::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)> accessor,
190 ::std::string_view documentation,
191 ::MolangQueryFunctionReturnType returnType,
192 ::HashedString querySetIdentifier,
193 uint64 minArgumentCount,
194 uint64 maxArgumentCount,
195 ::std::initializer_list<int> const& experiments
196 );
197
198 MCAPI static void setExperiments(::Experiments const& experiments);
199
200 MCAPI static void
201 unregisterQueryFunction(::std::string const& queryFunctionName, ::HashedString querySetIdentifier);
202 // NOLINTEND
203
204public:
205 // static variables
206 // NOLINTBEGIN
207 MCAPI static ::std::function<::MolangScriptArg const&(::RenderParams&, ::std::vector<::ExpressionNode> const&)>&
208 _defaultUnknownQueryFunction();
209
210 MCAPI static ::std::function<::mce::Color(::Block const&, ::BlockSource&, ::BlockPos const&)>&
211 mGetParticleTintFunc();
212
213 MCAPI static ::std::unordered_multimap<::HashedString, ::MolangQueryFunction>& mQueryFunctionAccessors();
214
215 MCAPI static ::std::unordered_map<::HashedString, ::std::unordered_set<::HashedString>>& mQuerySets();
216 // NOLINTEND
217
218public:
219 // constructor thunks
220 // NOLINTBEGIN
221#ifdef LL_PLAT_C
222 MCAPI void* $ctor(::MaterialVariants const& materialVariants);
223#endif
224
225 MCAPI void* $ctor(::Molang::details::SourceTree root);
226
227 MCAPI void* $ctor(::std::string const& expression, ::MolangVersion molangVersion);
228
229#ifdef LL_PLAT_C
230 MCAPI void* $ctor(char const* expression, ::MolangVersion molangVersion);
231#endif
232
233 MCAPI void* $ctor(::Json::Value const& value, ::MolangParseConfig const& config);
234
235 MCAPI void* $ctor(::MolangScriptArg const& value, ::ExpressionOp op);
236 // NOLINTEND
237};
238
239// free functions
240// NOLINTBEGIN
241MCAPI bool operator==(::ExpressionNode const& lhs, ::ExpressionNode const& rhs);
242// NOLINTEND
Definition BlockPos.h:17
Definition BlockSource.h:71
Definition Block.h:41
Definition Experiments.h:14
Definition ExpressionNode.h:35
Definition HashedString.h:5
Definition Value.h:16
Definition MaterialVariants.h:8
Definition IComplexExpression.h:21
Definition SourceTree.h:14
Definition RenderParams.h:29
Definition flat_set.h:10
Definition Color.h:13
Definition ExpressionNode.h:43
Definition ExpressionQueries.h:12
Definition MolangDataDrivenGeometry.h:13
Definition MolangParseConfig.h:14
Definition MolangQueryFunction.h:16
Definition MolangScriptArg.h:28
Definition ReflectionCtx.h:11
Definition ctx.h:5
Definition Alias.h:14