OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 static const int v8DefaultWrapperInternalFieldCount = static_cast<int>(gin::kNum
berOfInternalFields); | 47 static const int v8DefaultWrapperInternalFieldCount = static_cast<int>(gin::kNum
berOfInternalFields); |
48 static const int v8PrototypeTypeIndex = 0; | 48 static const int v8PrototypeTypeIndex = 0; |
49 static const int v8PrototypeInternalFieldcount = 1; | 49 static const int v8PrototypeInternalFieldcount = 1; |
50 | 50 |
51 typedef v8::Local<v8::FunctionTemplate> (*DomTemplateFunction)(v8::Isolate*); | 51 typedef v8::Local<v8::FunctionTemplate> (*DomTemplateFunction)(v8::Isolate*); |
52 typedef void (*RefObjectFunction)(ScriptWrappable*); | 52 typedef void (*RefObjectFunction)(ScriptWrappable*); |
53 typedef void (*DerefObjectFunction)(ScriptWrappable*); | 53 typedef void (*DerefObjectFunction)(ScriptWrappable*); |
54 typedef void (*TraceFunction)(Visitor*, ScriptWrappable*); | 54 typedef void (*TraceFunction)(Visitor*, ScriptWrappable*); |
55 typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Local<v8::Object>); | 55 typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Local<v8::Object>); |
56 typedef void (*ResolveWrapperReachabilityFunction)(v8::Isolate*, ScriptWrappable
*, const v8::Persistent<v8::Object>&); | 56 typedef void (*ResolveWrapperReachabilityFunction)(v8::Isolate*, ScriptWrappable
*, const v8::Persistent<v8::Object>&); |
57 typedef void (*InstallConditionallyEnabledMethodsFunction)(v8::Local<v8::Object>
, v8::Isolate*); | 57 typedef void (*PreparePrototypeObjectFunction)(v8::Isolate*, v8::Local<v8::Objec
t>); |
58 typedef void (*InstallConditionallyEnabledPropertiesFunction)(v8::Local<v8::Obje
ct>, v8::Isolate*); | 58 typedef void (*InstallConditionallyEnabledPropertiesFunction)(v8::Local<v8::Obje
ct>, v8::Isolate*); |
59 | 59 |
60 inline void setObjectGroup(v8::Isolate* isolate, ScriptWrappable* scriptWrappabl
e, const v8::Persistent<v8::Object>& wrapper) | 60 inline void setObjectGroup(v8::Isolate* isolate, ScriptWrappable* scriptWrappabl
e, const v8::Persistent<v8::Object>& wrapper) |
61 { | 61 { |
62 isolate->SetObjectGroupId(wrapper, v8::UniqueId(reinterpret_cast<intptr_t>(s
criptWrappable))); | 62 isolate->SetObjectGroupId(wrapper, v8::UniqueId(reinterpret_cast<intptr_t>(s
criptWrappable))); |
63 } | 63 } |
64 | 64 |
65 // This struct provides a way to store a bunch of information that is helpful wh
en unwrapping | 65 // This struct provides a way to store a bunch of information that is helpful wh
en unwrapping |
66 // v8 objects. Each v8 bindings class has exactly one static WrapperTypeInfo mem
ber, so | 66 // v8 objects. Each v8 bindings class has exactly one static WrapperTypeInfo mem
ber, so |
67 // comparing pointers is a safe way to determine if types match. | 67 // comparing pointers is a safe way to determine if types match. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 ASSERT(derefObjectFunction); | 135 ASSERT(derefObjectFunction); |
136 derefObjectFunction(scriptWrappable); | 136 derefObjectFunction(scriptWrappable); |
137 } | 137 } |
138 | 138 |
139 void trace(Visitor* visitor, ScriptWrappable* scriptWrappable) const | 139 void trace(Visitor* visitor, ScriptWrappable* scriptWrappable) const |
140 { | 140 { |
141 ASSERT(traceFunction); | 141 ASSERT(traceFunction); |
142 return traceFunction(visitor, scriptWrappable); | 142 return traceFunction(visitor, scriptWrappable); |
143 } | 143 } |
144 | 144 |
145 void installConditionallyEnabledMethods(v8::Local<v8::Object> prototypeTempl
ate, v8::Isolate* isolate) const | 145 void preparePrototypeObject(v8::Isolate* isolate, v8::Local<v8::Object> prot
otypeTemplate) const |
146 { | 146 { |
147 if (installConditionallyEnabledMethodsFunction) | 147 if (preparePrototypeObjectFunction) |
148 installConditionallyEnabledMethodsFunction(prototypeTemplate, isolat
e); | 148 preparePrototypeObjectFunction(isolate, prototypeTemplate); |
149 } | 149 } |
150 | 150 |
151 void installConditionallyEnabledProperties(v8::Local<v8::Object> prototypeTe
mplate, v8::Isolate* isolate) const | 151 void installConditionallyEnabledProperties(v8::Local<v8::Object> prototypeTe
mplate, v8::Isolate* isolate) const |
152 { | 152 { |
153 if (installConditionallyEnabledPropertiesFunction) | 153 if (installConditionallyEnabledPropertiesFunction) |
154 installConditionallyEnabledPropertiesFunction(prototypeTemplate, iso
late); | 154 installConditionallyEnabledPropertiesFunction(prototypeTemplate, iso
late); |
155 } | 155 } |
156 | 156 |
157 ActiveDOMObject* toActiveDOMObject(v8::Local<v8::Object> object) const | 157 ActiveDOMObject* toActiveDOMObject(v8::Local<v8::Object> object) const |
158 { | 158 { |
(...skipping 14 matching lines...) Expand all Loading... |
173 | 173 |
174 // This field must be the first member of the struct WrapperTypeInfo. This i
s also checked by a static_assert() below. | 174 // This field must be the first member of the struct WrapperTypeInfo. This i
s also checked by a static_assert() below. |
175 const gin::GinEmbedder ginEmbedder; | 175 const gin::GinEmbedder ginEmbedder; |
176 | 176 |
177 DomTemplateFunction domTemplateFunction; | 177 DomTemplateFunction domTemplateFunction; |
178 const RefObjectFunction refObjectFunction; | 178 const RefObjectFunction refObjectFunction; |
179 const DerefObjectFunction derefObjectFunction; | 179 const DerefObjectFunction derefObjectFunction; |
180 const TraceFunction traceFunction; | 180 const TraceFunction traceFunction; |
181 const ToActiveDOMObjectFunction toActiveDOMObjectFunction; | 181 const ToActiveDOMObjectFunction toActiveDOMObjectFunction; |
182 const ResolveWrapperReachabilityFunction visitDOMWrapperFunction; | 182 const ResolveWrapperReachabilityFunction visitDOMWrapperFunction; |
183 InstallConditionallyEnabledMethodsFunction installConditionallyEnabledMethod
sFunction; | 183 PreparePrototypeObjectFunction preparePrototypeObjectFunction; |
184 const InstallConditionallyEnabledPropertiesFunction installConditionallyEnab
ledPropertiesFunction; | 184 const InstallConditionallyEnabledPropertiesFunction installConditionallyEnab
ledPropertiesFunction; |
185 const char* const interfaceName; | 185 const char* const interfaceName; |
186 const WrapperTypeInfo* parentClass; | 186 const WrapperTypeInfo* parentClass; |
187 const unsigned wrapperTypePrototype : 1; // WrapperTypePrototype | 187 const unsigned wrapperTypePrototype : 1; // WrapperTypePrototype |
188 const unsigned wrapperClassId : 2; // WrapperClassId | 188 const unsigned wrapperClassId : 2; // WrapperClassId |
189 const unsigned eventTargetInheritance : 1; // EventTargetInheritance | 189 const unsigned eventTargetInheritance : 1; // EventTargetInheritance |
190 const unsigned lifetime : 1; // Lifetime | 190 const unsigned lifetime : 1; // Lifetime |
191 const unsigned gcType : 2; // GCType | 191 const unsigned gcType : 2; // GCType |
192 }; | 192 }; |
193 | 193 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 243 } |
244 | 244 |
245 inline void releaseObject(v8::Global<v8::Object>& wrapper) | 245 inline void releaseObject(v8::Global<v8::Object>& wrapper) |
246 { | 246 { |
247 toWrapperTypeInfo(wrapper)->derefObject(toScriptWrappable(wrapper)); | 247 toWrapperTypeInfo(wrapper)->derefObject(toScriptWrappable(wrapper)); |
248 } | 248 } |
249 | 249 |
250 } // namespace blink | 250 } // namespace blink |
251 | 251 |
252 #endif // WrapperTypeInfo_h | 252 #endif // WrapperTypeInfo_h |
OLD | NEW |