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

Side by Side Diff: bin/dartutils.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/bin.gypi ('k') | bin/dartutils.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_DARTUTILS_H_ 5 #ifndef BIN_DARTUTILS_H_
6 #define BIN_DARTUTILS_H_ 6 #define BIN_DARTUTILS_H_
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/globals.h" 9 #include "bin/globals.h"
10 10
11 #include "include/dart_api.h" 11 #include "include/dart_api.h"
12 12
13 class CommandLineOptions {
14 public:
15 explicit CommandLineOptions(int max_count)
16 : count_(0), max_count_(max_count), arguments_(NULL) {
17 static const int kWordSize = sizeof(intptr_t);
18 arguments_ = reinterpret_cast<const char **>(malloc(max_count * kWordSize));
19 if (arguments_ == NULL) {
20 max_count_ = 0;
21 }
22 }
23 ~CommandLineOptions() {
24 free(arguments_);
25 count_ = 0;
26 max_count_ = 0;
27 arguments_ = NULL;
28 }
29
30 int count() const { return count_; }
31 const char** arguments() const { return arguments_; }
32
33 const char* GetArgument(int index) const {
34 return (index >= 0 && index < count_) ? arguments_[index] : NULL;
35 }
36 void AddArgument(const char* argument) {
37 if (count_ < max_count_) {
38 arguments_[count_] = argument;
39 count_ += 1;
40 } else {
41 abort(); // We should never get into this situation.
42 }
43 }
44
45 void operator delete(void* pointer) { abort(); }
46
47 private:
48 void* operator new(size_t size);
49 CommandLineOptions(const CommandLineOptions&);
50 void operator=(const CommandLineOptions&);
51
52 int count_;
53 int max_count_;
54 const char** arguments_;
55 };
56
57
13 class DartUtils { 58 class DartUtils {
14 public: 59 public:
15 static int64_t GetIntegerValue(Dart_Handle value_obj); 60 static int64_t GetIntegerValue(Dart_Handle value_obj);
16 static const char* GetStringValue(Dart_Handle str_obj); 61 static const char* GetStringValue(Dart_Handle str_obj);
17 static bool GetBooleanValue(Dart_Handle bool_obj); 62 static bool GetBooleanValue(Dart_Handle bool_obj);
18 static void SetIntegerInstanceField(Dart_Handle handle, 63 static void SetIntegerInstanceField(Dart_Handle handle,
19 const char* name, 64 const char* name,
20 intptr_t val); 65 intptr_t val);
21 static intptr_t GetIntegerInstanceField(Dart_Handle handle, 66 static intptr_t GetIntegerInstanceField(Dart_Handle handle,
22 const char* name); 67 const char* name);
23 static void SetStringInstanceField(Dart_Handle handle, 68 static void SetStringInstanceField(Dart_Handle handle,
24 const char* name, 69 const char* name,
25 const char* val); 70 const char* val);
71 static bool IsDartSchemeURL(const char* url_name);
72 static Dart_Handle CanonicalizeURL(CommandLineOptions* url_mapping,
73 Dart_Handle library,
74 const char* url_str);
75 static Dart_Handle ReadStringFromFile(const char* filename);
76 static Dart_Handle LoadSource(CommandLineOptions* url_mapping,
77 Dart_Handle library,
78 Dart_Handle url,
79 Dart_LibraryTag tag,
80 const char* filename);
26 81
82 static const char* kDartScheme;
27 static const char* kBuiltinLibURL; 83 static const char* kBuiltinLibURL;
28 static const char* kCoreLibURL; 84 static const char* kCoreLibURL;
29 static const char* kCoreImplLibURL; 85 static const char* kCoreImplLibURL;
30 static const char* kCoreNativeWrappersLibURL; 86 static const char* kCoreNativeWrappersLibURL;
31 87
32 static const char* kIdFieldName; 88 static const char* kIdFieldName;
89
33 private: 90 private:
91 static const char* GetCanonicalPath(const char* reference_dir,
92 const char* filename);
93
34 DISALLOW_ALLOCATION(); 94 DISALLOW_ALLOCATION();
35 DISALLOW_IMPLICIT_CONSTRUCTORS(DartUtils); 95 DISALLOW_IMPLICIT_CONSTRUCTORS(DartUtils);
36 }; 96 };
37 97
38 #endif // BIN_DARTUTILS_H_ 98 #endif // BIN_DARTUTILS_H_
OLDNEW
« no previous file with comments | « bin/bin.gypi ('k') | bin/dartutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698