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

Side by Side Diff: tools/grit/grit/format/resource_map.py

Issue 2608763002: Move GritResourceMap arrays (~12,500 bytes) to read-only data segment (Closed)
Patch Set: Update unit tests to match new struct Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/grit/grit/format/resource_map_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 '''This file contains item formatters for resource_map_header and 6 '''This file contains item formatters for resource_map_header and
7 resource_map_source files. A resource map is a mapping between resource names 7 resource_map_source files. A resource map is a mapping between resource names
8 (string) and the internal resource ID.''' 8 (string) and the internal resource ID.'''
9 9
10 import os 10 import os
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 '''Create the header file for the resource mapping. This file just declares 49 '''Create the header file for the resource mapping. This file just declares
50 an array of name/value pairs.''' 50 an array of name/value pairs.'''
51 return '''\ 51 return '''\
52 // This file is automatically generated by GRIT. Do not edit. 52 // This file is automatically generated by GRIT. Do not edit.
53 53
54 #include <stddef.h> 54 #include <stddef.h>
55 55
56 #ifndef GRIT_RESOURCE_MAP_STRUCT_ 56 #ifndef GRIT_RESOURCE_MAP_STRUCT_
57 #define GRIT_RESOURCE_MAP_STRUCT_ 57 #define GRIT_RESOURCE_MAP_STRUCT_
58 struct GritResourceMap { 58 struct GritResourceMap {
59 const char* const name; 59 const char* name;
60 int value; 60 int value;
61 }; 61 };
62 #endif // GRIT_RESOURCE_MAP_STRUCT_ 62 #endif // GRIT_RESOURCE_MAP_STRUCT_
63 63
64 extern const GritResourceMap %(map_name)s[]; 64 extern const GritResourceMap %(map_name)s[];
65 extern const size_t %(map_name)sSize; 65 extern const size_t %(map_name)sSize;
66 ''' % { 'map_name': GetMapName(root) } 66 ''' % { 'map_name': GetMapName(root) }
67 67
68 68
69 def _FormatSourceHeader(root): 69 def _FormatSourceHeader(root):
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 yield ' {"%s", %s},\n' % (key, tid) 126 yield ' {"%s", %s},\n' % (key, tid)
127 yield _FormatSourceFooter(root) 127 yield _FormatSourceFooter(root)
128 128
129 129
130 def _GetItemName(item): 130 def _GetItemName(item):
131 return item.attrs['name'] 131 return item.attrs['name']
132 132
133 133
134 def _GetItemPath(item): 134 def _GetItemPath(item):
135 return item.GetInputPath().replace("\\", "/") 135 return item.GetInputPath().replace("\\", "/")
OLDNEW
« no previous file with comments | « no previous file | tools/grit/grit/format/resource_map_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698