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

Side by Side Diff: Source/bindings/v8/WrapperTypeInfo.h

Issue 26792002: Reland: Reland: Implement new Blink IDL attribute [SetReference] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: mark NodeFilter Dependent Created 7 years, 1 month 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) 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 enum WrapperWorldType { 53 enum WrapperWorldType {
54 MainWorld, 54 MainWorld,
55 IsolatedWorld, 55 IsolatedWorld,
56 WorkerWorld 56 WorkerWorld
57 }; 57 };
58 58
59 typedef v8::Handle<v8::FunctionTemplate> (*GetTemplateFunction)(v8::Isolate* , WrapperWorldType); 59 typedef v8::Handle<v8::FunctionTemplate> (*GetTemplateFunction)(v8::Isolate* , WrapperWorldType);
60 typedef void (*DerefObjectFunction)(void*); 60 typedef void (*DerefObjectFunction)(void*);
61 typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Handle<v8::Object> ); 61 typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Handle<v8::Object> );
62 typedef EventTarget* (*ToEventTargetFunction)(v8::Handle<v8::Object>); 62 typedef EventTarget* (*ToEventTargetFunction)(v8::Handle<v8::Object>);
63 typedef void* (*OpaqueRootForGC)(void*, v8::Isolate*); 63 typedef void (*ResolveWrapperReachabilityFunction)(void*, const v8::Persiste nt<v8::Object>&, v8::Isolate*);
64 typedef void (*InstallPerContextEnabledPrototypePropertiesFunction)(v8::Hand le<v8::Object>, v8::Isolate*); 64 typedef void (*InstallPerContextEnabledPrototypePropertiesFunction)(v8::Hand le<v8::Object>, v8::Isolate*);
65 65
66 enum WrapperTypePrototype { 66 enum WrapperTypePrototype {
67 WrapperTypeObjectPrototype, 67 WrapperTypeObjectPrototype,
68 WrapperTypeErrorPrototype 68 WrapperTypeErrorPrototype
69 }; 69 };
70 70
71 inline void setObjectGroup(void* object, const v8::Persistent<v8::Object>& w rapper, v8::Isolate* isolate)
72 {
73 isolate->SetObjectGroupId(wrapper, v8::UniqueId(reinterpret_cast<intptr_ t>(object)));
74 }
75
71 // This struct provides a way to store a bunch of information that is helpfu l when unwrapping 76 // This struct provides a way to store a bunch of information that is helpfu l when unwrapping
72 // v8 objects. Each v8 bindings class has exactly one static WrapperTypeInfo member, so 77 // v8 objects. Each v8 bindings class has exactly one static WrapperTypeInfo member, so
73 // comparing pointers is a safe way to determine if types match. 78 // comparing pointers is a safe way to determine if types match.
74 struct WrapperTypeInfo { 79 struct WrapperTypeInfo {
75 80
76 static const WrapperTypeInfo* unwrap(v8::Handle<v8::Value> typeInfoWrapp er) 81 static const WrapperTypeInfo* unwrap(v8::Handle<v8::Value> typeInfoWrapp er)
77 { 82 {
78 return reinterpret_cast<const WrapperTypeInfo*>(v8::External::Cast(* typeInfoWrapper)->Value()); 83 return reinterpret_cast<const WrapperTypeInfo*>(v8::External::Cast(* typeInfoWrapper)->Value());
79 } 84 }
80 85
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return toActiveDOMObjectFunction(object); 120 return toActiveDOMObjectFunction(object);
116 } 121 }
117 122
118 EventTarget* toEventTarget(v8::Handle<v8::Object> object) const 123 EventTarget* toEventTarget(v8::Handle<v8::Object> object) const
119 { 124 {
120 if (!toEventTargetFunction) 125 if (!toEventTargetFunction)
121 return 0; 126 return 0;
122 return toEventTargetFunction(object); 127 return toEventTargetFunction(object);
123 } 128 }
124 129
125 void* opaqueRootForGC(void* object, v8::Isolate* isolate) const 130 void resolveWrapperReachability(void* object, const v8::Persistent<v8::O bject>& wrapper, v8::Isolate* isolate) const
126 { 131 {
127 if (!opaqueRootForGCFunction) 132 if (!resolveWrapperReachabilityFunction)
128 return object; 133 setObjectGroup(object, wrapper, isolate);
129 return opaqueRootForGCFunction(object, isolate); 134 else
135 resolveWrapperReachabilityFunction(object, wrapper, isolate);
130 } 136 }
131 137
132 const GetTemplateFunction getTemplateFunction; 138 const GetTemplateFunction getTemplateFunction;
133 const DerefObjectFunction derefObjectFunction; 139 const DerefObjectFunction derefObjectFunction;
134 const ToActiveDOMObjectFunction toActiveDOMObjectFunction; 140 const ToActiveDOMObjectFunction toActiveDOMObjectFunction;
135 const ToEventTargetFunction toEventTargetFunction; 141 const ToEventTargetFunction toEventTargetFunction;
136 const OpaqueRootForGC opaqueRootForGCFunction; 142 const ResolveWrapperReachabilityFunction resolveWrapperReachabilityFunct ion;
137 const InstallPerContextEnabledPrototypePropertiesFunction installPerCont extEnabledPrototypePropertiesFunction; 143 const InstallPerContextEnabledPrototypePropertiesFunction installPerCont extEnabledPrototypePropertiesFunction;
138 const WrapperTypeInfo* parentClass; 144 const WrapperTypeInfo* parentClass;
139 const WrapperTypePrototype wrapperTypePrototype; 145 const WrapperTypePrototype wrapperTypePrototype;
140 }; 146 };
141 147
142 template<typename T, int offset> 148 template<typename T, int offset>
143 inline T* getInternalField(const v8::Persistent<v8::Object>& persistent) 149 inline T* getInternalField(const v8::Persistent<v8::Object>& persistent)
144 { 150 {
145 // This would be unsafe, but InternalFieldCount and GetAlignedPointerFro mInternalField are guaranteed not to allocate 151 // This would be unsafe, but InternalFieldCount and GetAlignedPointerFro mInternalField are guaranteed not to allocate
146 const v8::Handle<v8::Object>& object = reinterpret_cast<const v8::Handle <v8::Object>&>(persistent); 152 const v8::Handle<v8::Object>& object = reinterpret_cast<const v8::Handle <v8::Object>&>(persistent);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return configuration; 210 return configuration;
205 } 211 }
206 212
207 template<class ElementType> 213 template<class ElementType>
208 class WrapperTypeTraits { 214 class WrapperTypeTraits {
209 // specialized classes have thier own functions, which are generated by binding generator. 215 // specialized classes have thier own functions, which are generated by binding generator.
210 }; 216 };
211 } 217 }
212 218
213 #endif // WrapperTypeInfo_h 219 #endif // WrapperTypeInfo_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8GCController.cpp ('k') | Source/bindings/v8/custom/V8NodeIteratorCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698