OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var Event = require('event_bindings').Event; | 5 var Event = require('event_bindings').Event; |
6 var forEach = require('utils').forEach; | 6 var forEach = require('utils').forEach; |
7 var GetAvailability = requireNative('v8_context').GetAvailability; | 7 var GetAvailability = requireNative('v8_context').GetAvailability; |
8 var exceptionHandler = require('uncaught_exception_handler'); | 8 var exceptionHandler = require('uncaught_exception_handler'); |
9 var lastError = require('lastError'); | 9 var lastError = require('lastError'); |
10 var logActivity = requireNative('activityLogger'); | 10 var logActivity = requireNative('activityLogger'); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 // [{'name': 'foo'}, {'name': 'bar'}]. | 300 // [{'name': 'foo'}, {'name': 'bar'}]. |
301 enumValue = $Object.hasOwnProperty(enumValue, 'name') ? | 301 enumValue = $Object.hasOwnProperty(enumValue, 'name') ? |
302 enumValue.name : enumValue; | 302 enumValue.name : enumValue; |
303 if (enumValue) { // Avoid setting any empty enums. | 303 if (enumValue) { // Avoid setting any empty enums. |
304 // Make all properties in ALL_CAPS_STYLE. | 304 // Make all properties in ALL_CAPS_STYLE. |
305 // Replace myEnum-Foo with my_Enum-Foo: | 305 // Replace myEnum-Foo with my_Enum-Foo: |
306 var propertyName = | 306 var propertyName = |
307 $String.replace(enumValue, /([a-z])([A-Z])/g, '$1_$2'); | 307 $String.replace(enumValue, /([a-z])([A-Z])/g, '$1_$2'); |
308 // Replace my_Enum-Foo with my_Enum_Foo: | 308 // Replace my_Enum-Foo with my_Enum_Foo: |
309 propertyName = $String.replace(propertyName, /\W/g, '_'); | 309 propertyName = $String.replace(propertyName, /\W/g, '_'); |
| 310 // If the first character is a digit (we know it must be one of |
| 311 // a digit, a letter, or an underscore), precede it with an |
| 312 // underscore. |
| 313 propertyName = $String.replace(propertyName, /^(\d)/g, '_$1'); |
310 // Uppercase (replace my_Enum_Foo with MY_ENUM_FOO): | 314 // Uppercase (replace my_Enum_Foo with MY_ENUM_FOO): |
311 propertyName = $String.toUpperCase(propertyName); | 315 propertyName = $String.toUpperCase(propertyName); |
312 mod[id][propertyName] = enumValue; | 316 mod[id][propertyName] = enumValue; |
313 } | 317 } |
314 }); | 318 }); |
315 } | 319 } |
316 }, this); | 320 }, this); |
317 } | 321 } |
318 | 322 |
319 // TODO(cduvall): Take out when all APIs have been converted to features. | 323 // TODO(cduvall): Take out when all APIs have been converted to features. |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 availability.message); | 518 availability.message); |
515 return; | 519 return; |
516 } | 520 } |
517 | 521 |
518 this.runHooks_(mod); | 522 this.runHooks_(mod); |
519 return mod; | 523 return mod; |
520 } | 524 } |
521 }; | 525 }; |
522 | 526 |
523 exports.Binding = Binding; | 527 exports.Binding = Binding; |
OLD | NEW |