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

Side by Side Diff: bin/process_script.h

Issue 8549009: Refactor the library tag handler to share code between standalone dart and the snapshot generator. (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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef BIN_PROCESS_SCRIPT_H_
6 #define BIN_PROCESS_SCRIPT_H_
7
8 #include <stdlib.h>
9 #include <string.h>
10 #include <stdio.h>
11
12 class CommandLineOptions {
13 public:
14 explicit CommandLineOptions(int max_count)
15 : count_(0), max_count_(max_count), arguments_(NULL) {
16 static const int kWordSize = sizeof(intptr_t);
17 arguments_ = reinterpret_cast<const char **>(malloc(max_count * kWordSize));
18 if (arguments_ == NULL) {
19 max_count_ = 0;
20 }
21 }
22 ~CommandLineOptions() {
23 free(arguments_);
24 count_ = 0;
25 max_count_ = 0;
26 arguments_ = NULL;
27 }
28
29 int count() const { return count_; }
30 const char** arguments() const { return arguments_; }
31
32 const char* GetArgument(int index) const {
33 return (index >= 0 && index < count_) ? arguments_[index] : NULL;
34 }
35 void AddArgument(const char* argument) {
36 if (count_ < max_count_) {
37 arguments_[count_] = argument;
38 count_ += 1;
39 } else {
40 abort(); // We should never get into this situation.
41 }
42 }
43
44 void operator delete(void* pointer) { abort(); }
45
46 private:
47 void* operator new(size_t size);
48 CommandLineOptions(const CommandLineOptions&);
49 void operator=(const CommandLineOptions&);
50
51 int count_;
52 int max_count_;
53 const char** arguments_;
54 };
55
56
57 extern Dart_Handle ReadStringFromFile(const char* filename);
58 extern Dart_Handle LoadScript(const char* script_name);
59 extern const char* GetCanonicalPath(const char* reference_dir,
60 const char* filename);
61
62
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