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

Unified Diff: runtime/bin/resources.h

Issue 12377099: Added support for "bin-ified" vmstats web app source files (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: runtime/bin/resources.h
===================================================================
--- runtime/bin/resources.h (revision 0)
+++ runtime/bin/resources.h (revision 0)
@@ -0,0 +1,44 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef BIN_RESOURCES_H_
+#define BIN_RESOURCES_H_
+
+#include <stddef.h>
+#include <string.h>
+
+class Resources {
+ public:
+ static const int kNoSuchInstance = -1;
+
+ static int ResourceLookup(const char* path, const char** resource) {
+ for (unsigned i = 0; i < get_resource_count(); i++) {
srdjan 2013/03/05 23:17:30 for (int i = 0 ...
Tom Ball 2013/03/06 00:34:43 Done.
+ resource_map_entry* entry = get_resource(i);
+ if (!strcmp(path, entry->path_)) {
srdjan 2013/03/05 23:17:30 strcmp(..) == 0
Tom Ball 2013/03/06 00:34:43 Done.
+ *resource = entry->resource_;
siva 2013/03/05 23:12:44 ASSERT(entry->length_ > 0);
Tom Ball 2013/03/06 00:34:43 Done.
+ return entry->length_;
+ }
+ }
+ return kNoSuchInstance;
+ }
+
+ private:
+ typedef struct {
srdjan 2013/03/05 23:17:30 struct resource_map_entry { ... };
Tom Ball 2013/03/06 00:34:43 Done.
+ const char* path_;
+ const char* resource_;
+ size_t length_;
+ } resource_map_entry;
+
+ // These fields are generated by resources_gen.cc.
+ static resource_map_entry builtin_resources_[];
+ static const size_t builtin_resources_count_;
siva 2013/03/05 23:12:44 Wouldn't this just be sizeof(builtin_resources_)
srdjan 2013/03/05 23:17:30 s/size_t/intptr_t/ ? (also below).
Tom Ball 2013/03/06 00:34:43 Done.
Tom Ball 2013/03/06 00:34:43 Done.
Tom Ball 2013/03/06 00:34:43 sizeof(builtin_resources_) won't compile because i
+
+ static resource_map_entry* get_resource(int i) {
siva 2013/03/05 23:12:44 ASSERT(i >= 0 && i < builtin_resources_count_);
Tom Ball 2013/03/06 00:34:43 Done.
+ return builtin_resources_ + i;
+ }
+
+ static size_t get_resource_count() { return builtin_resources_count_; }
siva 2013/03/05 23:12:44 Since all methods in here are static, you could ad
Tom Ball 2013/03/06 00:34:43 Done.
+};
+
+#endif // BIN_RESOURCES_H_

Powered by Google App Engine
This is Rietveld 408576698