1 /* 2 * Copyright 2016 Google Inc. 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_EXTENSION 9 #define SKSL_EXTENSION 10 11 #include "include/private/SkSLProgramElement.h" 12 13 namespace SkSL { 14 15 /** 16 * An extension declaration. 17 */ 18 class Extension final : public ProgramElement { 19 public: 20 inline static constexpr Kind kProgramElementKind = Kind::kExtension; 21 Extension(int line,skstd::string_view name)22 Extension(int line, skstd::string_view name) 23 : INHERITED(line, kProgramElementKind) 24 , fName(name) {} 25 name()26 skstd::string_view name() const { 27 return fName; 28 } 29 clone()30 std::unique_ptr<ProgramElement> clone() const override { 31 return std::unique_ptr<ProgramElement>(new Extension(fLine, this->name())); 32 } 33 description()34 String description() const override { 35 return "#extension " + this->name() + " : enable"; 36 } 37 38 private: 39 skstd::string_view fName; 40 41 using INHERITED = ProgramElement; 42 }; 43 44 } // namespace SkSL 45 46 #endif 47