daed2592bb
In addition to the unsurprising changes to eliminate references to src/, we also had to tighten up some C++17-isms as they are not permitted in public headers. Change-Id: Ie5005a33d7a135e69fb66beca5e7a5f960dbd453 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378496 Reviewed-by: Brian Osman <brianosman@google.com>
60 lines
1.2 KiB
C++
60 lines
1.2 KiB
C++
/*
|
|
* 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_ERROR_HANDLING
|
|
#define SKSL_DSL_ERROR_HANDLING
|
|
|
|
namespace SkSL {
|
|
|
|
namespace dsl {
|
|
|
|
#ifndef __has_builtin
|
|
#define __has_builtin(x) 0
|
|
#endif
|
|
|
|
class PositionInfo {
|
|
public:
|
|
#if __has_builtin(__builtin_FILE) && __has_builtin(__builtin_LINE)
|
|
PositionInfo(const char* file = __builtin_FILE(), int line = __builtin_LINE())
|
|
#else
|
|
PositionInfo(const char* file = nullptr, int line = -1)
|
|
#endif // __has_builtin(__builtin_FILE) && __has_builtin(__builtin_LINE)
|
|
: fFile(file)
|
|
, fLine(line) {}
|
|
|
|
const char* file_name() {
|
|
return fFile;
|
|
}
|
|
|
|
int line() {
|
|
return fLine;
|
|
}
|
|
|
|
private:
|
|
const char* fFile;
|
|
int fLine;
|
|
};
|
|
|
|
/**
|
|
* Class which is notified in the event of an error.
|
|
*/
|
|
class ErrorHandler {
|
|
public:
|
|
virtual ~ErrorHandler() {}
|
|
|
|
/**
|
|
* Reports a DSL error. Position may not be available, in which case it will be null.
|
|
*/
|
|
virtual void handleError(const char* msg, PositionInfo* position) = 0;
|
|
};
|
|
|
|
} // namespace dsl
|
|
|
|
} // namespace SkSL
|
|
|
|
#endif
|