OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 ConstantTypeDouble, | 118 ConstantTypeDouble, |
119 ConstantTypeString | 119 ConstantTypeString |
120 }; | 120 }; |
121 | 121 |
122 // ConstantConfiguration translates into calls to Set() for setting up an | 122 // ConstantConfiguration translates into calls to Set() for setting up an |
123 // object's constants. It sets the constant on both the FunctionTemplate and | 123 // object's constants. It sets the constant on both the FunctionTemplate and |
124 // the ObjectTemplate. PropertyAttributes is always ReadOnly. | 124 // the ObjectTemplate. PropertyAttributes is always ReadOnly. |
125 struct ConstantConfiguration { | 125 struct ConstantConfiguration { |
126 ConstantConfiguration& operator=(const ConstantConfiguration&) = delete; | 126 ConstantConfiguration& operator=(const ConstantConfiguration&) = delete; |
127 DISALLOW_ALLOCATION(); | 127 DISALLOW_ALLOCATION(); |
| 128 ConstantConfiguration(const char* const name, unsigned value, ConstantTy
pe type) |
| 129 : name(name) |
| 130 , ivalue(value) |
| 131 , type(type) {} |
| 132 ConstantConfiguration(const char* const name, int value, ConstantType ty
pe) |
| 133 : name(name) |
| 134 , ivalue(value) |
| 135 , type(type) {} |
| 136 ConstantConfiguration(const char* const name, double value, ConstantType
type) |
| 137 : name(name) |
| 138 , dvalue(value) |
| 139 , type(type) {} |
| 140 ConstantConfiguration(const char* const name, const char* const value, C
onstantType type) |
| 141 : name(name) |
| 142 , svalue(value) |
| 143 , type(type) {} |
128 const char* const name; | 144 const char* const name; |
129 int ivalue; | 145 union { |
130 double dvalue; | 146 int ivalue; |
131 const char* const svalue; | 147 double dvalue; |
| 148 const char* const svalue; |
| 149 }; |
132 ConstantType type; | 150 ConstantType type; |
133 }; | 151 }; |
134 | 152 |
135 // Constant installation | 153 // Constant installation |
136 // | 154 // |
137 // installConstants and installConstant are used for simple constants. They | 155 // installConstants and installConstant are used for simple constants. They |
138 // install constants using v8::Template::Set(), which results in a property | 156 // install constants using v8::Template::Set(), which results in a property |
139 // that is much faster to access from scripts. | 157 // that is much faster to access from scripts. |
140 // installConstantWithGetter is used when some C++ code needs to be executed | 158 // installConstantWithGetter is used when some C++ code needs to be executed |
141 // when the constant is accessed, e.g. to handle deprecation or measuring | 159 // when the constant is accessed, e.g. to handle deprecation or measuring |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 const AttributeConfiguration*, size_t attributeCount, | 211 const AttributeConfiguration*, size_t attributeCount, |
194 const AccessorConfiguration*, size_t accessorCount, | 212 const AccessorConfiguration*, size_t accessorCount, |
195 const MethodConfiguration*, size_t callbackCount); | 213 const MethodConfiguration*, size_t callbackCount); |
196 | 214 |
197 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrappe
rTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*)); | 215 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrappe
rTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*)); |
198 }; | 216 }; |
199 | 217 |
200 } // namespace blink | 218 } // namespace blink |
201 | 219 |
202 #endif // V8DOMConfiguration_h | 220 #endif // V8DOMConfiguration_h |
OLD | NEW |