Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: src/string-stream.h

Issue 12427: Merge regexp2000 back into bleeding_edge (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 unsigned size_; 68 unsigned size_;
69 char* space_; 69 char* space_;
70 }; 70 };
71 71
72 72
73 class FmtElm { 73 class FmtElm {
74 public: 74 public:
75 FmtElm(int value) : type_(INT) { data_.u_int_ = value; } // NOLINT 75 FmtElm(int value) : type_(INT) { data_.u_int_ = value; } // NOLINT
76 explicit FmtElm(double value) : type_(DOUBLE) { data_.u_double_ = value; } // NOLINT 76 explicit FmtElm(double value) : type_(DOUBLE) { data_.u_double_ = value; } // NOLINT
77 FmtElm(const char* value) : type_(C_STR) { data_.u_c_str_ = value; } // NOLIN T 77 FmtElm(const char* value) : type_(C_STR) { data_.u_c_str_ = value; } // NOLIN T
78 FmtElm(const Vector<const uc16>& value) : type_(LC_STR) { data_.u_lc_str_ = &v alue; } // NOLINT
78 FmtElm(Object* value) : type_(OBJ) { data_.u_obj_ = value; } // NOLINT 79 FmtElm(Object* value) : type_(OBJ) { data_.u_obj_ = value; } // NOLINT
79 FmtElm(Handle<Object> value) : type_(HANDLE) { data_.u_handle_ = value.locatio n(); } // NOLINT 80 FmtElm(Handle<Object> value) : type_(HANDLE) { data_.u_handle_ = value.locatio n(); } // NOLINT
80 FmtElm(void* value) : type_(INT) { data_.u_int_ = reinterpret_cast<int>(value) ; } // NOLINT 81 FmtElm(void* value) : type_(INT) { data_.u_int_ = reinterpret_cast<int>(value) ; } // NOLINT
81 private: 82 private:
82 friend class StringStream; 83 friend class StringStream;
83 enum Type { INT, DOUBLE, C_STR, OBJ, HANDLE }; 84 enum Type { INT, DOUBLE, C_STR, LC_STR, OBJ, HANDLE };
84 Type type_; 85 Type type_;
85 union { 86 union {
86 int u_int_; 87 int u_int_;
87 double u_double_; 88 double u_double_;
88 const char* u_c_str_; 89 const char* u_c_str_;
90 const Vector<const uc16>* u_lc_str_;
89 Object* u_obj_; 91 Object* u_obj_;
90 Object** u_handle_; 92 Object** u_handle_;
91 } data_; 93 } data_;
92 }; 94 };
93 95
94 96
95 class StringStream { 97 class StringStream {
96 public: 98 public:
97 explicit StringStream(StringAllocator* allocator): 99 explicit StringStream(StringAllocator* allocator):
98 allocator_(allocator), 100 allocator_(allocator),
99 capacity_(kInitialCapacity), 101 capacity_(kInitialCapacity),
100 length_(0), 102 length_(0),
101 buffer_(allocator_->allocate(kInitialCapacity)) { 103 buffer_(allocator_->allocate(kInitialCapacity)) {
102 buffer_[0] = 0; 104 buffer_[0] = 0;
103 } 105 }
104 106
105 ~StringStream() { 107 ~StringStream() {
106 } 108 }
107 109
108 bool Put(char c); 110 bool Put(char c);
109 bool Put(String* str); 111 bool Put(String* str);
110 bool Put(String* str, int start, int end); 112 bool Put(String* str, int start, int end);
111 void Add(const char* format, Vector<FmtElm> elms); 113 void Add(Vector<const char> format, Vector<FmtElm> elms);
112 void Add(const char* format); 114 void Add(const char* format);
115 void Add(Vector<const char> format);
113 void Add(const char* format, FmtElm arg0); 116 void Add(const char* format, FmtElm arg0);
114 void Add(const char* format, FmtElm arg0, FmtElm arg1); 117 void Add(const char* format, FmtElm arg0, FmtElm arg1);
115 void Add(const char* format, FmtElm arg0, FmtElm arg1, FmtElm arg2); 118 void Add(const char* format, FmtElm arg0, FmtElm arg1, FmtElm arg2);
119 void Add(const char* format,
120 FmtElm arg0,
121 FmtElm arg1,
122 FmtElm arg2,
123 FmtElm arg3);
116 124
117 // Getting the message out. 125 // Getting the message out.
118 void OutputToStdOut(); 126 void OutputToStdOut();
119 void Log(); 127 void Log();
120 Handle<String> ToString(); 128 Handle<String> ToString();
121 SmartPointer<const char> ToCString(); 129 SmartPointer<const char> ToCString();
122 130
123 // Object printing support. 131 // Object printing support.
124 void PrintName(Object* o); 132 void PrintName(Object* o);
125 void PrintFixedArray(FixedArray* array, unsigned int limit); 133 void PrintFixedArray(FixedArray* array, unsigned int limit);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 int space() const { return capacity_ - length_; } 165 int space() const { return capacity_ - length_; }
158 char* cursor() const { return buffer_ + length_; } 166 char* cursor() const { return buffer_ + length_; }
159 167
160 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); 168 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream);
161 }; 169 };
162 170
163 171
164 } } // namespace v8::internal 172 } } // namespace v8::internal
165 173
166 #endif // V8_STRING_STREAM_H_ 174 #endif // V8_STRING_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698