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

Side by Side Diff: bin/process_script.h

Issue 8439061: Support command line parameters to specify a url to file name mapping. This is used during snapsh... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 1 month 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 | « bin/main.cc ('k') | bin/process_script.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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_PROCESS_SCRIPT_H_ 5 #ifndef BIN_PROCESS_SCRIPT_H_
6 #define BIN_PROCESS_SCRIPT_H_ 6 #define BIN_PROCESS_SCRIPT_H_
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 #include <stdio.h> 10 #include <stdio.h>
11 11
12 class CommandLineOptions { 12 class CommandLineOptions {
13 public: 13 public:
14 explicit CommandLineOptions(int max_count) 14 explicit CommandLineOptions(int max_count)
15 : count_(0), max_count_(max_count), arguments_(NULL) { 15 : count_(0), max_count_(max_count), arguments_(NULL) {
16 static const int kWordSize = sizeof(intptr_t); 16 static const int kWordSize = sizeof(intptr_t);
17 arguments_ = reinterpret_cast<char **>(malloc(max_count * kWordSize)); 17 arguments_ = reinterpret_cast<const char **>(malloc(max_count * kWordSize));
18 if (arguments_ == NULL) { 18 if (arguments_ == NULL) {
19 max_count_ = 0; 19 max_count_ = 0;
20 } 20 }
21 } 21 }
22 ~CommandLineOptions() { 22 ~CommandLineOptions() {
23 free(arguments_); 23 free(arguments_);
24 count_ = 0; 24 count_ = 0;
25 max_count_ = 0; 25 max_count_ = 0;
26 arguments_ = NULL; 26 arguments_ = NULL;
27 } 27 }
28 28
29 int count() const { return count_; } 29 int count() const { return count_; }
30 char** arguments() const { return arguments_; } 30 const char** arguments() const { return arguments_; }
31 31
32 char* GetArgument(int index) const { 32 const char* GetArgument(int index) const {
33 return (index >= 0 && index < count_) ? arguments_[index] : NULL; 33 return (index >= 0 && index < count_) ? arguments_[index] : NULL;
34 } 34 }
35 void AddArgument(char* argument) { 35 void AddArgument(const char* argument) {
36 if (count_ < max_count_) { 36 if (count_ < max_count_) {
37 arguments_[count_] = argument; 37 arguments_[count_] = argument;
38 count_ += 1; 38 count_ += 1;
39 } else { 39 } else {
40 abort(); // We should never get into this situation. 40 abort(); // We should never get into this situation.
41 } 41 }
42 } 42 }
43 43
44 void operator delete(void* pointer) { abort(); } 44 void operator delete(void* pointer) { abort(); }
45 45
46 private: 46 private:
47 void* operator new(size_t size); 47 void* operator new(size_t size);
48 CommandLineOptions(const CommandLineOptions&); 48 CommandLineOptions(const CommandLineOptions&);
49 void operator=(const CommandLineOptions&); 49 void operator=(const CommandLineOptions&);
50 50
51 int count_; 51 int count_;
52 int max_count_; 52 int max_count_;
53 char** arguments_; 53 const char** arguments_;
54 }; 54 };
55 55
56 56
57 extern Dart_Handle ReadStringFromFile(const char* filename);
57 extern Dart_Handle LoadScript(const char* script_name); 58 extern Dart_Handle LoadScript(const char* script_name);
58 extern Dart_Handle LoadSnapshotCreationScript(const char* script_name); 59 extern const char* GetCanonicalPath(const char* reference_dir,
60 const char* filename);
61
59 62
60 #endif // BIN_PROCESS_SCRIPT_H_ 63 #endif // BIN_PROCESS_SCRIPT_H_
OLDNEW
« no previous file with comments | « bin/main.cc ('k') | bin/process_script.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698