| 1 | /* | 
|---|---|
| 2 | * Copyright 2019 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 | #include "src/sksl/SkSLOutputStream.h" | 
| 9 | |
| 10 | namespace SkSL { | 
| 11 | |
| 12 | void OutputStream::writeString(String s) { | 
| 13 | this->write(s.c_str(), s.size()); | 
| 14 | } | 
| 15 | |
| 16 | void OutputStream::printf(const char format[], ...) { | 
| 17 | va_list args; | 
| 18 | va_start(args, format); | 
| 19 | this->appendVAList(format, args); | 
| 20 | va_end(args); | 
| 21 | } | 
| 22 | |
| 23 | void OutputStream::appendVAList(const char format[], va_list args) { | 
| 24 | char buffer[kBufferSize]; | 
| 25 | int length = vsnprintf(buffer, kBufferSize, format, args); | 
| 26 | SkASSERT(length >= 0 && length < (int) kBufferSize); | 
| 27 | this->write(buffer, length); | 
| 28 | } | 
| 29 | |
| 30 | } | 
| 31 | 
