aboutsummaryrefslogtreecommitdiff
path: root/src/deps/skia/include/sksl/DSLBlock.h
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-04-03 16:34:10 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-04-03 16:34:10 -0700
commita87508008dfa1604baf2d4e39bf44704c00f261c (patch)
tree0be2ade96772037a02803b30e157c367d931e3d9 /src/deps/skia/include/sksl/DSLBlock.h
parent4a19a3f07f1887903e5638a3be167f0c7b377ba3 (diff)
downloadbun-jarred/canvas.tar.gz
bun-jarred/canvas.tar.zst
bun-jarred/canvas.zip
Diffstat (limited to 'src/deps/skia/include/sksl/DSLBlock.h')
-rw-r--r--src/deps/skia/include/sksl/DSLBlock.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/deps/skia/include/sksl/DSLBlock.h b/src/deps/skia/include/sksl/DSLBlock.h
new file mode 100644
index 000000000..3fcbb34c8
--- /dev/null
+++ b/src/deps/skia/include/sksl/DSLBlock.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2021 Google LLC.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SKSL_DSL_BLOCK
+#define SKSL_DSL_BLOCK
+
+#include "include/private/SkSLDefines.h"
+#include "include/sksl/DSLExpression.h"
+#include "include/sksl/DSLStatement.h"
+
+#include <memory>
+
+namespace SkSL {
+
+class Block;
+class SymbolTable;
+
+namespace dsl {
+
+class DSLBlock {
+public:
+ template<class... Statements>
+ DSLBlock(Statements... statements) {
+ fStatements.reserve_back(sizeof...(statements));
+ // in C++17, we could just do:
+ // (fStatements.push_back(DSLStatement(statements.release()).release()), ...);
+ int unused[] =
+ {0,
+ (static_cast<void>(fStatements.push_back(DSLStatement(statements.release()).release())),
+ 0)...};
+ static_cast<void>(unused);
+ }
+
+ DSLBlock(DSLBlock&& other) = default;
+
+ DSLBlock(SkSL::StatementArray statements, std::shared_ptr<SymbolTable> symbols = nullptr);
+
+ DSLBlock(SkTArray<DSLStatement> statements, std::shared_ptr<SymbolTable> symbols = nullptr);
+
+ ~DSLBlock();
+
+ DSLBlock& operator=(DSLBlock&& other) {
+ fStatements = std::move(other.fStatements);
+ return *this;
+ }
+
+ void append(DSLStatement stmt);
+
+ std::unique_ptr<SkSL::Block> release();
+
+private:
+ SkSL::StatementArray fStatements;
+ std::shared_ptr<SkSL::SymbolTable> fSymbols;
+
+ friend class DSLStatement;
+ friend class DSLFunction;
+};
+
+} // namespace dsl
+
+} // namespace SkSL
+
+#endif