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

Side by Side Diff: Source/bindings/core/v8/V8DOMConfiguration.h

Issue 968583002: bindings: Supports conditionally-enabled accessors. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 v8::AccessorSetterCallback setter; 61 v8::AccessorSetterCallback setter;
62 v8::AccessorGetterCallback getterForMainWorld; 62 v8::AccessorGetterCallback getterForMainWorld;
63 v8::AccessorSetterCallback setterForMainWorld; 63 v8::AccessorSetterCallback setterForMainWorld;
64 const WrapperTypeInfo* data; 64 const WrapperTypeInfo* data;
65 v8::AccessControl settings; 65 v8::AccessControl settings;
66 v8::PropertyAttribute attribute; 66 v8::PropertyAttribute attribute;
67 ExposeConfiguration exposeConfiguration; 67 ExposeConfiguration exposeConfiguration;
68 InstanceOrPrototypeConfiguration instanceOrPrototypeConfiguration; 68 InstanceOrPrototypeConfiguration instanceOrPrototypeConfiguration;
69 }; 69 };
70 70
71 static void installAttributes(v8::Isolate*, v8::Handle<v8::ObjectTemplate> i nstanceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfig uration*, size_t attributeCount); 71 static void installAttributes(v8::Isolate*, v8::Handle<v8::ObjectTemplate> i nstanceTemplate, v8::Handle<v8::ObjectTemplate> prototypeTemplate, const Attribu teConfiguration*, size_t attributeCount);
72 72
73 static void installAttribute(v8::Isolate*, v8::Handle<v8::ObjectTemplate> in stanceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfigu ration&); 73 static void installAttribute(v8::Isolate*, v8::Handle<v8::ObjectTemplate> in stanceTemplate, v8::Handle<v8::ObjectTemplate> prototypeTemplate, const Attribut eConfiguration&);
74 74
75 static void installAttribute(v8::Isolate*, v8::Handle<v8::Object> instanceTe mplate, v8::Handle<v8::Object> prototype, const AttributeConfiguration&); 75 static void installAttribute(v8::Isolate*, v8::Handle<v8::Object> instance, v8::Handle<v8::Object> prototype, const AttributeConfiguration&);
76 76
77 // AccessorConfiguration translates into calls to SetAccessorProperty() 77 // AccessorConfiguration translates into calls to SetAccessorProperty()
78 // on prototype ObjectTemplate. 78 // on prototype ObjectTemplate.
79 struct AccessorConfiguration { 79 struct AccessorConfiguration {
80 const char* const name; 80 const char* const name;
81 v8::FunctionCallback getter; 81 v8::FunctionCallback getter;
82 v8::FunctionCallback setter; 82 v8::FunctionCallback setter;
83 v8::FunctionCallback getterForMainWorld; 83 v8::FunctionCallback getterForMainWorld;
84 v8::FunctionCallback setterForMainWorld; 84 v8::FunctionCallback setterForMainWorld;
85 const WrapperTypeInfo* data; 85 const WrapperTypeInfo* data;
86 v8::AccessControl settings; 86 v8::AccessControl settings;
87 v8::PropertyAttribute attribute; 87 v8::PropertyAttribute attribute;
88 ExposeConfiguration exposeConfiguration; 88 ExposeConfiguration exposeConfiguration;
89 }; 89 };
90 90
91 static void installAccessors(v8::Isolate*, v8::Handle<v8::ObjectTemplate> pr ototype, v8::Handle<v8::Signature>, const AccessorConfiguration*, size_t accesso rCount); 91 static void installAccessors(v8::Isolate*, v8::Handle<v8::ObjectTemplate> pr ototypeTemplate, v8::Handle<v8::Signature>, const AccessorConfiguration*, size_t accessorCount);
92 92
93 static void installAccessor(v8::Isolate*, v8::Handle<v8::ObjectTemplate> pro totype, v8::Handle<v8::Signature>, const AccessorConfiguration&); 93 static void installAccessor(v8::Isolate*, v8::Handle<v8::ObjectTemplate> pro totypeTemplate, v8::Handle<v8::Signature>, const AccessorConfiguration&);
94
95 static void installAccessor(v8::Isolate*, v8::Handle<v8::Object> prototype, const AccessorConfiguration&);
94 96
95 enum ConstantType { 97 enum ConstantType {
96 ConstantTypeShort, 98 ConstantTypeShort,
97 ConstantTypeLong, 99 ConstantTypeLong,
98 ConstantTypeUnsignedShort, 100 ConstantTypeUnsignedShort,
99 ConstantTypeUnsignedLong, 101 ConstantTypeUnsignedLong,
100 ConstantTypeFloat, 102 ConstantTypeFloat,
101 ConstantTypeDouble, 103 ConstantTypeDouble,
102 ConstantTypeString 104 ConstantTypeString
103 }; 105 };
(...skipping 10 matching lines...) Expand all
114 }; 116 };
115 117
116 // Constant installation 118 // Constant installation
117 // 119 //
118 // installConstants and installConstant are used for simple constants. They 120 // installConstants and installConstant are used for simple constants. They
119 // install constants using v8::Template::Set(), which results in a property 121 // install constants using v8::Template::Set(), which results in a property
120 // that is much faster to access from scripts. 122 // that is much faster to access from scripts.
121 // installConstantWithGetter is used when some C++ code needs to be executed 123 // installConstantWithGetter is used when some C++ code needs to be executed
122 // when the constant is accessed, e.g. to handle deprecation or measuring 124 // when the constant is accessed, e.g. to handle deprecation or measuring
123 // usage. The property appears the same to scripts, but is slower to access. 125 // usage. The property appears the same to scripts, but is slower to access.
124 static void installConstants(v8::Isolate*, v8::Handle<v8::FunctionTemplate> functionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const ConstantConf iguration*, size_t constantCount); 126 static void installConstants(v8::Isolate*, v8::Handle<v8::FunctionTemplate> functionDescriptor, v8::Handle<v8::ObjectTemplate> prototypeTemplate, const Cons tantConfiguration*, size_t constantCount);
125 127
126 static void installConstant(v8::Isolate*, v8::Handle<v8::FunctionTemplate> f unctionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const ConstantConfi guration&); 128 static void installConstant(v8::Isolate*, v8::Handle<v8::FunctionTemplate> f unctionDescriptor, v8::Handle<v8::ObjectTemplate> prototypeTemplate, const Const antConfiguration&);
127 129
128 static void installConstantWithGetter(v8::Isolate*, v8::Handle<v8::FunctionT emplate> functionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const cha r* name, v8::AccessorGetterCallback); 130 static void installConstantWithGetter(v8::Isolate*, v8::Handle<v8::FunctionT emplate> functionDescriptor, v8::Handle<v8::ObjectTemplate> prototypeTemplate, c onst char* name, v8::AccessorGetterCallback);
129 131
130 // MethodConfiguration translates into calls to Set() for setting up an 132 // MethodConfiguration translates into calls to Set() for setting up an
131 // object's callbacks. It sets the method on both the FunctionTemplate or 133 // object's callbacks. It sets the method on both the FunctionTemplate or
132 // the ObjectTemplate. 134 // the ObjectTemplate.
133 struct MethodConfiguration { 135 struct MethodConfiguration {
134 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return v8At omicString(isolate, name); } 136 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return v8At omicString(isolate, name); }
135 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) cons t 137 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) cons t
136 { 138 {
137 return world.isMainWorld() && callbackForMainWorld ? callbackForMain World : callback; 139 return world.isMainWorld() && callbackForMainWorld ? callbackForMain World : callback;
138 } 140 }
(...skipping 12 matching lines...) Expand all
151 return callback; 153 return callback;
152 } 154 }
153 155
154 v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*); 156 v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*);
155 v8::FunctionCallback callback; 157 v8::FunctionCallback callback;
156 // SymbolKeyedMethodConfiguration doesn't support per-world bindings. 158 // SymbolKeyedMethodConfiguration doesn't support per-world bindings.
157 int length; 159 int length;
158 ExposeConfiguration exposeConfiguration; 160 ExposeConfiguration exposeConfiguration;
159 }; 161 };
160 162
161 static void installMethods(v8::Isolate*, v8::Handle<v8::ObjectTemplate> prot otype, v8::Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfigurati on*, size_t callbackCount); 163 static void installMethods(v8::Isolate*, v8::Handle<v8::ObjectTemplate> prot otypeTemplate, v8::Handle<v8::Signature>, v8::PropertyAttribute, const MethodCon figuration*, size_t callbackCount);
162 164
163 static void installMethod(v8::Isolate*, v8::Handle<v8::FunctionTemplate>, v8 ::Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration&); 165 static void installMethod(v8::Isolate*, v8::Handle<v8::FunctionTemplate>, v8 ::Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration&);
164 166
165 static void installMethod(v8::Isolate*, v8::Handle<v8::ObjectTemplate>, v8:: Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration&); 167 static void installMethod(v8::Isolate*, v8::Handle<v8::ObjectTemplate>, v8:: Handle<v8::Signature>, v8::PropertyAttribute, const MethodConfiguration&);
166 168
167 static void installMethod(v8::Isolate*, v8::Handle<v8::ObjectTemplate>, v8:: Handle<v8::Signature>, v8::PropertyAttribute, const SymbolKeyedMethodConfigurati on&); 169 static void installMethod(v8::Isolate*, v8::Handle<v8::ObjectTemplate>, v8:: Handle<v8::Signature>, v8::PropertyAttribute, const SymbolKeyedMethodConfigurati on&);
168 170
169 static v8::Local<v8::Signature> installDOMClassTemplate(v8::Isolate*, v8::Lo cal<v8::FunctionTemplate>, const char* interfaceName, v8::Handle<v8::FunctionTem plate> parentClass, size_t fieldCount, 171 static v8::Local<v8::Signature> installDOMClassTemplate(v8::Isolate*, v8::Lo cal<v8::FunctionTemplate>, const char* interfaceName, v8::Handle<v8::FunctionTem plate> parentClass, size_t fieldCount,
170 const AttributeConfiguration*, size_t attributeCount, 172 const AttributeConfiguration*, size_t attributeCount,
171 const AccessorConfiguration*, size_t accessorCount, 173 const AccessorConfiguration*, size_t accessorCount,
172 const MethodConfiguration*, size_t callbackCount); 174 const MethodConfiguration*, size_t callbackCount);
173 175
174 static v8::Handle<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrapp erTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*)); 176 static v8::Handle<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrapp erTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*));
175 }; 177 };
176 178
177 } // namespace blink 179 } // namespace blink
178 180
179 #endif // V8DOMConfiguration_h 181 #endif // V8DOMConfiguration_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8DOMConfiguration.cpp » ('j') | Source/bindings/core/v8/V8DOMConfiguration.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698