1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ART_RUNTIME_STRING_BUILDER_APPEND_H_ 18 #define ART_RUNTIME_STRING_BUILDER_APPEND_H_ 19 20 #include <stddef.h> 21 #include <stdint.h> 22 23 #include "base/bit_utils.h" 24 #include "base/locks.h" 25 #include "base/macros.h" 26 #include "obj_ptr.h" 27 28 namespace art HIDDEN { 29 30 class Thread; 31 32 namespace mirror { 33 class String; 34 } // namespace mirror 35 36 class StringBuilderAppend { 37 public: 38 enum class Argument : uint8_t { 39 kEnd = 0u, 40 kObject, 41 kStringBuilder, 42 kString, 43 kCharArray, 44 kBoolean, 45 kChar, 46 kInt, 47 kLong, 48 kFloat, 49 kDouble, 50 kLast = kDouble 51 }; 52 53 static constexpr size_t kBitsPerArg = 54 MinimumBitsToStore(static_cast<size_t>(Argument::kLast)); 55 static constexpr size_t kMaxArgs = BitSizeOf<uint32_t>() / kBitsPerArg; 56 static_assert(kMaxArgs * kBitsPerArg == BitSizeOf<uint32_t>(), "Expecting no extra bits."); 57 static constexpr uint32_t kArgMask = MaxInt<uint32_t>(kBitsPerArg); 58 59 static ObjPtr<mirror::String> AppendF(uint32_t format, const uint32_t* args, Thread* self) 60 REQUIRES_SHARED(Locks::mutator_lock_); 61 62 private: 63 class Builder; 64 }; 65 66 } // namespace art 67 68 #endif // ART_RUNTIME_STRING_BUILDER_APPEND_H_ 69