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

Side by Side Diff: src/flags.cc

Issue 1940: Replaced calls to functions that msvc consider deprecated. Used... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 months 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
« no previous file with comments | « src/execution.cc ('k') | src/log.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 case Flag::INT: return "int"; 127 case Flag::INT: return "int";
128 case Flag::FLOAT: return "float"; 128 case Flag::FLOAT: return "float";
129 case Flag::STRING: return "string"; 129 case Flag::STRING: return "string";
130 } 130 }
131 UNREACHABLE(); 131 UNREACHABLE();
132 return NULL; 132 return NULL;
133 } 133 }
134 134
135 135
136 static char* ToString(Flag::Type type, FlagValue* variable) { 136 static char* ToString(Flag::Type type, FlagValue* variable) {
137 char* value = NULL; 137 Vector<char> value;
138 switch (type) { 138 switch (type) {
139 case Flag::BOOL: 139 case Flag::BOOL:
140 value = NewArray<char>(6); 140 value = Vector<char>::New(6);
141 OS::SNPrintF(value, 6, "%s", (variable->b ? "true" : "false")); 141 OS::SNPrintF(value, "%s", (variable->b ? "true" : "false"));
142 break; 142 break;
143 case Flag::INT: 143 case Flag::INT:
144 value = NewArray<char>(12); 144 value = Vector<char>::New(12);
145 OS::SNPrintF(value, 12, "%d", variable->i); 145 OS::SNPrintF(value, "%d", variable->i);
146 break; 146 break;
147 case Flag::FLOAT: 147 case Flag::FLOAT:
148 value = NewArray<char>(20); 148 value = Vector<char>::New(20);
149 OS::SNPrintF(value, 20, "%f", variable->f); 149 OS::SNPrintF(value, "%f", variable->f);
150 break; 150 break;
151 case Flag::STRING: 151 case Flag::STRING:
152 if (variable->s) { 152 if (variable->s) {
153 int length = strlen(variable->s) + 1; 153 int length = strlen(variable->s) + 1;
154 value = NewArray<char>(length); 154 value = Vector<char>::New(length);
155 OS::SNPrintF(value, length, "%s", variable->s); 155 OS::SNPrintF(value, "%s", variable->s);
156 } else { 156 } else {
157 value = NewArray<char>(5); 157 value = Vector<char>::New(5);
158 OS::SNPrintF(value, 5, "NULL"); 158 OS::SNPrintF(value, "NULL");
159 } 159 }
160 break; 160 break;
161 } 161 }
162 ASSERT(value != NULL); 162 ASSERT(!value.is_empty());
163 return value; 163 return value.start();
164 } 164 }
165 165
166 166
167 static void PrintFlagValue(Flag::Type type, FlagValue* variable) { 167 static void PrintFlagValue(Flag::Type type, FlagValue* variable) {
168 char* value = ToString(type, variable); 168 char* value = ToString(type, variable);
169 printf("%s", value); 169 printf("%s", value);
170 DeleteArray(value); 170 DeleteArray(value);
171 } 171 }
172 172
173 173
(...skipping 17 matching lines...) Expand all
191 // ----------------------------------------------------------------------------- 191 // -----------------------------------------------------------------------------
192 // Implementation of FlagList 192 // Implementation of FlagList
193 193
194 Flag* FlagList::list_ = NULL; 194 Flag* FlagList::list_ = NULL;
195 195
196 196
197 List<char *>* FlagList::argv() { 197 List<char *>* FlagList::argv() {
198 List<char *>* args = new List<char*>(8); 198 List<char *>* args = new List<char*>(8);
199 for (Flag* f = list_; f != NULL; f = f->next()) { 199 for (Flag* f = list_; f != NULL; f = f->next()) {
200 if (!f->IsDefault()) { 200 if (!f->IsDefault()) {
201 char* cmdline_flag; 201 Vector<char> cmdline_flag;
202 if (f->type() != Flag::BOOL || *(f->bool_variable())) { 202 if (f->type() != Flag::BOOL || *(f->bool_variable())) {
203 int length = strlen(f->name()) + 2 + 1; 203 int length = strlen(f->name()) + 2 + 1;
204 cmdline_flag = NewArray<char>(length); 204 cmdline_flag = Vector<char>::New(length);
205 OS::SNPrintF(cmdline_flag, length, "--%s", f->name()); 205 OS::SNPrintF(cmdline_flag, "--%s", f->name());
206 } else { 206 } else {
207 int length = strlen(f->name()) + 4 + 1; 207 int length = strlen(f->name()) + 4 + 1;
208 cmdline_flag = NewArray<char>(length); 208 cmdline_flag = Vector<char>::New(length);
209 OS::SNPrintF(cmdline_flag, length, "--no%s", f->name()); 209 OS::SNPrintF(cmdline_flag, "--no%s", f->name());
210 } 210 }
211 args->Add(cmdline_flag); 211 args->Add(cmdline_flag.start());
212 if (f->type() != Flag::BOOL) { 212 if (f->type() != Flag::BOOL) {
213 args->Add(f->StringValue()); 213 args->Add(f->StringValue());
214 } 214 }
215 } 215 }
216 } 216 }
217 return args; 217 return args;
218 } 218 }
219 219
220 220
221 void FlagList::Print(const char* file, bool print_current_value) { 221 void FlagList::Print(const char* file, bool print_current_value) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 429
430 void FlagList::Register(Flag* flag) { 430 void FlagList::Register(Flag* flag) {
431 ASSERT(flag != NULL && strlen(flag->name()) > 0); 431 ASSERT(flag != NULL && strlen(flag->name()) > 0);
432 if (Lookup(flag->name()) != NULL) 432 if (Lookup(flag->name()) != NULL)
433 V8_Fatal(flag->file(), 0, "flag %s declared twice", flag->name()); 433 V8_Fatal(flag->file(), 0, "flag %s declared twice", flag->name());
434 flag->next_ = list_; 434 flag->next_ = list_;
435 list_ = flag; 435 list_ = flag;
436 } 436 }
437 437
438 } } // namespace v8::internal 438 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.cc ('k') | src/log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698