| OLD | NEW |
| (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_ | |
| OLD | NEW |