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

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

Issue 1181113006: bindings: Introduces on_{instance,prototype,interface} in the code generator. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed review comments. Created 5 years, 6 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
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8DOMConfiguration.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 21 matching lines...) Expand all
32 #include "bindings/core/v8/V8Binding.h" 32 #include "bindings/core/v8/V8Binding.h"
33 #include "bindings/core/v8/V8DOMWrapper.h" 33 #include "bindings/core/v8/V8DOMWrapper.h"
34 #include "core/CoreExport.h" 34 #include "core/CoreExport.h"
35 #include <v8.h> 35 #include <v8.h>
36 36
37 namespace blink { 37 namespace blink {
38 38
39 class CORE_EXPORT V8DOMConfiguration final { 39 class CORE_EXPORT V8DOMConfiguration final {
40 public: 40 public:
41 // The following Configuration structs and install methods are used for 41 // The following Configuration structs and install methods are used for
42 // setting multiple properties on an ObjectTemplate, used from the 42 // setting multiple properties on ObjectTemplate / FunctionTemplate, used
43 // generated bindings initialization (ConfigureXXXTemplate). This greatly 43 // from the generated bindings initialization (ConfigureXXXTemplate).
44 // reduces the binary size by moving from code driven setup to data table 44 // This greatly reduces the binary size by moving from code driven setup to
45 // driven setup. 45 // data table driven setup.
46 46
47 enum ExposeConfiguration { 47 enum ExposeConfiguration {
48 ExposedToAllScripts, 48 ExposedToAllScripts,
49 OnlyExposedToPrivateScript, 49 OnlyExposedToPrivateScript,
50 }; 50 };
51 51
52 enum InstanceOrPrototypeConfiguration { 52 // Bitflags to show where the member will be defined.
53 OnInstance, 53 enum PropertyLocationConfiguration {
54 OnPrototype, 54 OnInstance = 1 << 0,
55 OnPrototype = 1 << 1,
56 OnInterface = 1 << 2,
55 }; 57 };
56 58
57 enum HolderCheckConfiguration { 59 enum HolderCheckConfiguration {
58 CheckHolder, 60 CheckHolder,
59 DoNotCheckHolder, 61 DoNotCheckHolder,
60 }; 62 };
61 63
62 // AttributeConfiguration translates into calls to SetAccessor() on either 64 // AttributeConfiguration translates into calls to SetAccessor() on either
63 // the instance or the prototype ObjectTemplate, based on |instanceOrPrototy peConfiguration|. 65 // the instance or the prototype ObjectTemplate, based on |instanceOrPrototy peConfiguration|.
64 struct AttributeConfiguration { 66 struct AttributeConfiguration {
65 const char* const name; 67 const char* const name;
66 v8::AccessorNameGetterCallback getter; 68 v8::AccessorNameGetterCallback getter;
67 v8::AccessorNameSetterCallback setter; 69 v8::AccessorNameSetterCallback setter;
68 v8::AccessorNameGetterCallback getterForMainWorld; 70 v8::AccessorNameGetterCallback getterForMainWorld;
69 v8::AccessorNameSetterCallback setterForMainWorld; 71 v8::AccessorNameSetterCallback setterForMainWorld;
70 const WrapperTypeInfo* data; 72 const WrapperTypeInfo* data;
71 v8::AccessControl settings; 73 v8::AccessControl settings;
72 v8::PropertyAttribute attribute; 74 v8::PropertyAttribute attribute;
73 unsigned exposeConfiguration : 1; // ExposeConfiguration 75 unsigned exposeConfiguration : 1; // ExposeConfiguration
74 unsigned instanceOrPrototypeConfiguration : 1; // InstanceOrPrototypeCon figuration 76 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura tion
77 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration
75 }; 78 };
76 79
77 static void installAttributes(v8::Isolate*, v8::Local<v8::ObjectTemplate> in stanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Attribute Configuration*, size_t attributeCount); 80 static void installAttributes(v8::Isolate*, v8::Local<v8::ObjectTemplate> in stanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Attribute Configuration*, size_t attributeCount);
78 81
79 static void installAttribute(v8::Isolate*, v8::Local<v8::ObjectTemplate> ins tanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const AttributeC onfiguration&); 82 static void installAttribute(v8::Isolate*, v8::Local<v8::ObjectTemplate> ins tanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const AttributeC onfiguration&);
80 83
81 static void installAttribute(v8::Isolate*, v8::Local<v8::Object> instance, v 8::Local<v8::Object> prototype, const AttributeConfiguration&);
82
83 // AccessorConfiguration translates into calls to SetAccessorProperty() 84 // AccessorConfiguration translates into calls to SetAccessorProperty()
84 // on prototype ObjectTemplate. 85 // on prototype ObjectTemplate.
85 struct AccessorConfiguration { 86 struct AccessorConfiguration {
86 const char* const name; 87 const char* const name;
87 v8::FunctionCallback getter; 88 v8::FunctionCallback getter;
88 v8::FunctionCallback setter; 89 v8::FunctionCallback setter;
89 v8::FunctionCallback getterForMainWorld; 90 v8::FunctionCallback getterForMainWorld;
90 v8::FunctionCallback setterForMainWorld; 91 v8::FunctionCallback setterForMainWorld;
91 const WrapperTypeInfo* data; 92 const WrapperTypeInfo* data;
92 v8::AccessControl settings; 93 v8::AccessControl settings;
93 v8::PropertyAttribute attribute; 94 v8::PropertyAttribute attribute;
94 unsigned exposeConfiguration : 1; // ExposeConfiguration 95 unsigned exposeConfiguration : 1; // ExposeConfiguration
96 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura tion
95 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration 97 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration
96 }; 98 };
97 99
98 static void installAccessors(v8::Isolate*, v8::Local<v8::ObjectTemplate> pro totypeTemplate, v8::Local<v8::Signature>, const AccessorConfiguration*, size_t a ccessorCount); 100 static void installAccessors(v8::Isolate*, v8::Local<v8::ObjectTemplate> ins tanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v8::Local<v8::Fu nctionTemplate> interfaceTemplate, v8::Local<v8::Signature>, const AccessorConfi guration*, size_t accessorCount);
99 101
100 static void installAccessor(v8::Isolate*, v8::Local<v8::ObjectTemplate> prot otypeTemplate, v8::Local<v8::Signature>, const AccessorConfiguration&); 102 static void installAccessor(v8::Isolate*, v8::Local<v8::ObjectTemplate> inst anceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v8::Local<v8::Fun ctionTemplate> interfaceTemplate, v8::Local<v8::Signature>, const AccessorConfig uration&);
101
102 static void installAccessor(v8::Isolate*, v8::Local<v8::Object> prototype, c onst AccessorConfiguration&);
103 103
104 enum ConstantType { 104 enum ConstantType {
105 ConstantTypeShort, 105 ConstantTypeShort,
106 ConstantTypeLong, 106 ConstantTypeLong,
107 ConstantTypeUnsignedShort, 107 ConstantTypeUnsignedShort,
108 ConstantTypeUnsignedLong, 108 ConstantTypeUnsignedLong,
109 ConstantTypeFloat, 109 ConstantTypeFloat,
110 ConstantTypeDouble, 110 ConstantTypeDouble,
111 ConstantTypeString 111 ConstantTypeString
112 }; 112 };
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 const AttributeConfiguration*, size_t attributeCount, 179 const AttributeConfiguration*, size_t attributeCount,
180 const AccessorConfiguration*, size_t accessorCount, 180 const AccessorConfiguration*, size_t accessorCount,
181 const MethodConfiguration*, size_t callbackCount); 181 const MethodConfiguration*, size_t callbackCount);
182 182
183 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrappe rTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*)); 183 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrappe rTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*));
184 }; 184 };
185 185
186 } // namespace blink 186 } // namespace blink
187 187
188 #endif // V8DOMConfiguration_h 188 #endif // V8DOMConfiguration_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8DOMConfiguration.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698