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

Side by Side Diff: Source/bindings/tests/results/V8TestInterfacePython.h

Issue 82693003: IDL compiler: [CustomToV8] interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased, remove excess files Created 7 years 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 static inline TestInterfacePythonImplementation* fromInternalPointer(void* o bject) 64 static inline TestInterfacePythonImplementation* fromInternalPointer(void* o bject)
65 { 65 {
66 return static_cast<TestInterfacePythonImplementation*>(object); 66 return static_cast<TestInterfacePythonImplementation*>(object);
67 } 67 }
68 static void installPerContextEnabledProperties(v8::Handle<v8::Object>, TestI nterfacePythonImplementation*, v8::Isolate*) { } 68 static void installPerContextEnabledProperties(v8::Handle<v8::Object>, TestI nterfacePythonImplementation*, v8::Isolate*) { }
69 static void installPerContextEnabledMethods(v8::Handle<v8::Object>, v8::Isol ate*) { } 69 static void installPerContextEnabledMethods(v8::Handle<v8::Object>, v8::Isol ate*) { }
70 70
71 private: 71 private:
72 friend v8::Handle<v8::Object> wrap(TestInterfacePythonImplementation*, v8::H andle<v8::Object> creationContext, v8::Isolate*);
73 static v8::Handle<v8::Object> createWrapper(PassRefPtr<TestInterfacePythonIm plementation>, v8::Handle<v8::Object> creationContext, v8::Isolate*);
74 }; 72 };
75 73
76 template<> 74 template<>
77 class WrapperTypeTraits<TestInterfacePythonImplementation > { 75 class WrapperTypeTraits<TestInterfacePythonImplementation > {
78 public: 76 public:
79 static const WrapperTypeInfo* wrapperTypeInfo() { return &V8TestInterfacePyt hon::wrapperTypeInfo; } 77 static const WrapperTypeInfo* wrapperTypeInfo() { return &V8TestInterfacePyt hon::wrapperTypeInfo; }
80 }; 78 };
81 79
82 v8::Handle<v8::Object> wrap(TestInterfacePythonImplementation* impl, v8::Handle< v8::Object> creationContext, v8::Isolate*); 80 class TestInterfacePythonImplementation;
81 v8::Handle<v8::Value> toV8(TestInterfacePythonImplementation*, v8::Handle<v8::Ob ject> creationContext, v8::Isolate*);
83 82
84 inline v8::Handle<v8::Value> toV8(TestInterfacePythonImplementation* impl, v8::H andle<v8::Object> creationContext, v8::Isolate* isolate) 83 template<class CallbackInfo>
84 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterfacePyth onImplementation* impl)
85 { 85 {
86 if (UNLIKELY(!impl)) 86 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf o.GetIsolate()));
87 return v8::Null(isolate);
88 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<V8TestInterfacePyth on>(impl, isolate);
89 if (!wrapper.IsEmpty())
90 return wrapper;
91 return wrap(impl, creationContext, isolate);
92 } 87 }
93 88
94 template<typename CallbackInfo> 89 template<class CallbackInfo>
95 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterfacePyth onImplementation* impl)
96 {
97 if (UNLIKELY(!impl)) {
98 v8SetReturnValueNull(callbackInfo);
99 return;
100 }
101 if (DOMDataStore::setReturnValueFromWrapper<V8TestInterfacePython>(callbackI nfo.GetReturnValue(), impl))
102 return;
103 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackI nfo.GetIsolate());
104 v8SetReturnValue(callbackInfo, wrapper);
105 }
106
107 template<typename CallbackInfo>
108 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, TestI nterfacePythonImplementation* impl) 90 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, TestI nterfacePythonImplementation* impl)
109 { 91 {
110 ASSERT(worldType(callbackInfo.GetIsolate()) == MainWorld); 92 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackIn fo.GetIsolate()));
111 if (UNLIKELY(!impl)) {
112 v8SetReturnValueNull(callbackInfo);
113 return;
114 }
115 if (DOMDataStore::setReturnValueFromWrapperForMainWorld<V8TestInterfacePytho n>(callbackInfo.GetReturnValue(), impl))
116 return;
117 v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackIn fo.GetIsolate());
118 v8SetReturnValue(callbackInfo, wrapper);
119 } 93 }
120 94
121 template<class CallbackInfo, class Wrappable> 95 template<class CallbackInfo, class Wrappable>
122 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, TestInterface PythonImplementation* impl, Wrappable* wrappable) 96 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, TestInterface PythonImplementation* impl, Wrappable*)
123 { 97 {
124 if (UNLIKELY(!impl)) { 98 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackIn fo.GetIsolate()));
125 v8SetReturnValueNull(callbackInfo);
126 return;
127 }
128 if (DOMDataStore::setReturnValueFromWrapperFast<V8TestInterfacePython>(callb ackInfo.GetReturnValue(), impl, callbackInfo.Holder(), wrappable))
129 return;
130 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackI nfo.GetIsolate());
131 v8SetReturnValue(callbackInfo, wrapper);
132 } 99 }
133 100
134 inline v8::Handle<v8::Value> toV8(PassRefPtr<TestInterfacePythonImplementation > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 101 inline v8::Handle<v8::Value> toV8(PassRefPtr<TestInterfacePythonImplementation > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
135 { 102 {
136 return toV8(impl.get(), creationContext, isolate); 103 return toV8(impl.get(), creationContext, isolate);
137 } 104 }
138 105
139 template<class CallbackInfo> 106 template<class CallbackInfo>
140 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, PassRefPtr<TestIn terfacePythonImplementation > impl) 107 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, PassRefPtr<TestIn terfacePythonImplementation > impl)
141 { 108 {
142 v8SetReturnValue(callbackInfo, impl.get()); 109 v8SetReturnValue(callbackInfo, impl.get());
143 } 110 }
144 111
145 template<class CallbackInfo> 112 template<class CallbackInfo>
146 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassR efPtr<TestInterfacePythonImplementation > impl) 113 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassR efPtr<TestInterfacePythonImplementation > impl)
147 { 114 {
148 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); 115 v8SetReturnValueForMainWorld(callbackInfo, impl.get());
149 } 116 }
150 117
151 template<class CallbackInfo, class Wrappable> 118 template<class CallbackInfo, class Wrappable>
152 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<Te stInterfacePythonImplementation > impl, Wrappable* wrappable) 119 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<Te stInterfacePythonImplementation > impl, Wrappable* wrappable)
153 { 120 {
154 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); 121 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable);
155 } 122 }
156 123
157 } 124 }
158 #endif // ENABLE(CONDITION) 125 #endif // ENABLE(CONDITION)
159 #endif // V8TestInterfacePython_h 126 #endif // V8TestInterfacePython_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698