Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLErrorReporter.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google LLC.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SKSL_ERROR_REPORTER
9#define SKSL_ERROR_REPORTER
10
12
13#include <string_view>
14
15namespace SkSL {
16
17class Position;
18
19/**
20 * Class which is notified in the event of an error.
21 */
23public:
25
26 virtual ~ErrorReporter() {}
27
28 void error(Position position, std::string_view msg);
29
30 std::string_view source() const { return fSource; }
31
32 void setSource(std::string_view source) { fSource = source; }
33
34 int errorCount() const {
35 return fErrorCount;
36 }
37
39 fErrorCount = 0;
40 }
41
42protected:
43 /**
44 * Called when an error is reported.
45 */
46 virtual void handleError(std::string_view msg, Position position) = 0;
47
48private:
49 Position position(int offset) const;
50
51 std::string_view fSource;
52 int fErrorCount = 0;
53};
54
55/**
56 * Error reporter for tests that need an SkSL context; aborts immediately if an error is reported.
57 */
59public:
60 void handleError(std::string_view msg, Position pos) override;
61};
62
63} // namespace SkSL
64
65#endif
SkPoint pos
void setSource(std::string_view source)
virtual void handleError(std::string_view msg, Position position)=0
std::string_view source() const
void handleError(std::string_view msg, Position pos) override
const uint8_t uint32_t uint32_t GError ** error
Point offset