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 30 matching lines...) Expand all Loading... |
41 // setting multiple properties on an ObjectTemplate, used from the | 41 // setting multiple properties on an ObjectTemplate, used from the |
42 // generated bindings initialization (ConfigureXXXTemplate). This greatly | 42 // generated bindings initialization (ConfigureXXXTemplate). This greatly |
43 // reduces the binary size by moving from code driven setup to data table | 43 // reduces the binary size by moving from code driven setup to data table |
44 // driven setup. | 44 // driven setup. |
45 | 45 |
46 enum ExposeConfiguration { | 46 enum ExposeConfiguration { |
47 ExposedToAllScripts, | 47 ExposedToAllScripts, |
48 OnlyExposedToPrivateScript, | 48 OnlyExposedToPrivateScript, |
49 }; | 49 }; |
50 | 50 |
| 51 enum InstanceOrPrototypeConfiguration { |
| 52 OnInstance, |
| 53 OnPrototype, |
| 54 }; |
| 55 |
51 // AttributeConfiguration translates into calls to SetAccessor() on either | 56 // AttributeConfiguration translates into calls to SetAccessor() on either |
52 // the instance or the prototype ObjectTemplate, based on |onPrototype|. | 57 // the instance or the prototype ObjectTemplate, based on |instanceOrPrototy
peConfiguration|. |
53 struct AttributeConfiguration { | 58 struct AttributeConfiguration { |
54 const char* const name; | 59 const char* const name; |
55 v8::AccessorGetterCallback getter; | 60 v8::AccessorGetterCallback getter; |
56 v8::AccessorSetterCallback setter; | 61 v8::AccessorSetterCallback setter; |
57 v8::AccessorGetterCallback getterForMainWorld; | 62 v8::AccessorGetterCallback getterForMainWorld; |
58 v8::AccessorSetterCallback setterForMainWorld; | 63 v8::AccessorSetterCallback setterForMainWorld; |
59 const WrapperTypeInfo* data; | 64 const WrapperTypeInfo* data; |
60 v8::AccessControl settings; | 65 v8::AccessControl settings; |
61 v8::PropertyAttribute attribute; | 66 v8::PropertyAttribute attribute; |
62 ExposeConfiguration exposeConfiguration; | 67 ExposeConfiguration exposeConfiguration; |
63 bool onPrototype; | 68 InstanceOrPrototypeConfiguration instanceOrPrototypeConfiguration; |
64 }; | 69 }; |
65 | 70 |
66 // AccessorConfiguration translates into calls to SetAccessorProperty() | 71 // AccessorConfiguration translates into calls to SetAccessorProperty() |
67 // on prototype ObjectTemplate. | 72 // on prototype ObjectTemplate. |
68 struct AccessorConfiguration { | 73 struct AccessorConfiguration { |
69 const char* const name; | 74 const char* const name; |
70 v8::FunctionCallback getter; | 75 v8::FunctionCallback getter; |
71 v8::FunctionCallback setter; | 76 v8::FunctionCallback setter; |
72 v8::FunctionCallback getterForMainWorld; | 77 v8::FunctionCallback getterForMainWorld; |
73 v8::FunctionCallback setterForMainWorld; | 78 v8::FunctionCallback setterForMainWorld; |
(...skipping 13 matching lines...) Expand all Loading... |
87 return; | 92 return; |
88 | 93 |
89 v8::AccessorGetterCallback getter = attribute.getter; | 94 v8::AccessorGetterCallback getter = attribute.getter; |
90 v8::AccessorSetterCallback setter = attribute.setter; | 95 v8::AccessorSetterCallback setter = attribute.setter; |
91 if (world.isMainWorld()) { | 96 if (world.isMainWorld()) { |
92 if (attribute.getterForMainWorld) | 97 if (attribute.getterForMainWorld) |
93 getter = attribute.getterForMainWorld; | 98 getter = attribute.getterForMainWorld; |
94 if (attribute.setterForMainWorld) | 99 if (attribute.setterForMainWorld) |
95 setter = attribute.setterForMainWorld; | 100 setter = attribute.setterForMainWorld; |
96 } | 101 } |
97 (attribute.onPrototype ? prototype : instanceTemplate)->SetAccessor(v8At
omicString(isolate, attribute.name), | 102 (attribute.instanceOrPrototypeConfiguration == OnPrototype ? prototype :
instanceTemplate)->SetAccessor(v8AtomicString(isolate, attribute.name), |
98 getter, | 103 getter, |
99 setter, | 104 setter, |
100 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.da
ta)), | 105 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.da
ta)), |
101 attribute.settings, | 106 attribute.settings, |
102 attribute.attribute); | 107 attribute.attribute); |
103 } | 108 } |
104 | 109 |
105 enum ConstantType { | 110 enum ConstantType { |
106 ConstantTypeShort, | 111 ConstantTypeShort, |
107 ConstantTypeLong, | 112 ConstantTypeLong, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 const AccessorConfiguration*, size_t accessorCount, | 160 const AccessorConfiguration*, size_t accessorCount, |
156 const MethodConfiguration*, size_t callbackCount, | 161 const MethodConfiguration*, size_t callbackCount, |
157 v8::Isolate*); | 162 v8::Isolate*); |
158 | 163 |
159 static v8::Handle<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrapp
erTypeInfo*, void (*)(v8::Handle<v8::FunctionTemplate>, v8::Isolate*)); | 164 static v8::Handle<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrapp
erTypeInfo*, void (*)(v8::Handle<v8::FunctionTemplate>, v8::Isolate*)); |
160 }; | 165 }; |
161 | 166 |
162 } // namespace blink | 167 } // namespace blink |
163 | 168 |
164 #endif // V8DOMConfiguration_h | 169 #endif // V8DOMConfiguration_h |
OLD | NEW |