Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/plugin/passthroughapp/ProtocolCF.inl

Issue 29332980: Issue #1484 - Use the currently distributed version of PassthroughAPP unaltered
Patch Set: use OnStartEx() instead of OnStart() Created Dec. 23, 2015, 3:18 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2007 Igor Tandetnik
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef PASSTHROUGHAPP_PROTOCOLCF_INL 1 #ifndef PASSTHROUGHAPP_PROTOCOLCF_INL
16 #define PASSTHROUGHAPP_PROTOCOLCF_INL 2 #define PASSTHROUGHAPP_PROTOCOLCF_INL
17 3
18 #if _MSC_VER > 1000 4 #if _MSC_VER > 1000
19 #pragma once 5 #pragma once
20 #endif // _MSC_VER > 1000 6 #endif // _MSC_VER > 1000
21 7
22 #ifndef PASSTHROUGHAPP_PROTOCOLCF_H 8 #ifndef PASSTHROUGHAPP_PROTOCOLCF_H
23 #error ProtocolCF.inl requires ProtocolCF.h to be included first 9 » #error ProtocolCF.inl requires ProtocolCF.h to be included first
24 #endif 10 #endif
25 11
26 #include "PassthroughObject.h" 12 #include "PassthroughObject.h"
27 13
28
29 namespace PassthroughAPP 14 namespace PassthroughAPP
30 { 15 {
31 16
32 // ===== CComClassFactoryProtocol ===== 17 // ===== CComClassFactoryProtocol =====
33 18
34 inline STDMETHODIMP CComClassFactoryProtocol::CreateInstance( 19 inline STDMETHODIMP CComClassFactoryProtocol::CreateInstance(
35 IUnknown* punkOuter, REFIID riid, void** ppvObj) 20 IUnknown* punkOuter, REFIID riid, void** ppvObj)
36 { 21 {
37 ATLASSERT(ppvObj != 0); 22 ATLASSERT(ppvObj != 0);
38 if (!ppvObj) 23 if (!ppvObj)
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 148 }
164 149
165 HRESULT hr = E_OUTOFMEMORY; 150 HRESULT hr = E_OUTOFMEMORY;
166 void* pv = static_cast<void*>(CreatorClass::CreateInstance); 151 void* pv = static_cast<void*>(CreatorClass::CreateInstance);
167 FactoryComObject* p = 0; 152 FactoryComObject* p = 0;
168 ATLTRY(p = new FactoryComObject(pv)) 153 ATLTRY(p = new FactoryComObject(pv))
169 if (p != NULL) 154 if (p != NULL)
170 { 155 {
171 p->SetVoid(pv); 156 p->SetVoid(pv);
172 p->InternalFinalConstructAddRef(); 157 p->InternalFinalConstructAddRef();
173 #if _ATL_VER >= 0x800 158 » » // MG: Updated to conform to more recent ATL version.
174 hr = p->_AtlInitialConstruct(); 159 hr = p->_AtlInitialConstruct();
175 if (SUCCEEDED(hr)) 160 if (SUCCEEDED(hr))
176 #endif
177 hr = p->FinalConstruct(); 161 hr = p->FinalConstruct();
178 #if _ATL_VER >= 0x800
179 if (SUCCEEDED(hr)) 162 if (SUCCEEDED(hr))
180 hr = p->_AtlFinalConstruct(); 163 hr = p->_AtlFinalConstruct();
181 #endif
182 p->InternalFinalConstructRelease(); 164 p->InternalFinalConstructRelease();
183 if (FAILED(hr)) 165 if (FAILED(hr))
184 { 166 {
185 delete p; 167 delete p;
186 p = 0; 168 p = 0;
187 } 169 }
188 } 170 }
189 *ppObj = p; 171 *ppObj = p;
190 return hr; 172 return hr;
191 } 173 }
192 174
193 template <class Factory, class Protocol, class FactoryComObject> 175 template <class Factory, class Protocol, class FactoryComObject>
194 inline HRESULT CMetaFactory<Factory, Protocol, FactoryComObject>:: 176 inline HRESULT CMetaFactory<Factory, Protocol, FactoryComObject>::
195 CreateInstance(IClassFactory* pTargetCF, IClassFactory** ppCF) 177 CreateInstance(IClassFactory* pTargetCF, IClassFactory** ppCF)
196 { 178 {
197 if (!ppCF) 179 if (!ppCF)
198 { 180 {
199 return E_POINTER; 181 return E_POINTER;
200 } 182 }
201 *ppCF = 0; 183 *ppCF = 0;
202 184
203 Factory* pObj = 0; 185 Factory* pObj = 0;
204 HRESULT hr = CreateInstance(&pObj); 186 HRESULT hr = CreateInstance(&pObj);
205 ATLASSERT(SUCCEEDED(hr) && pObj != 0); 187 ATLASSERT(SUCCEEDED(hr) && pObj != 0);
206 if (SUCCEEDED(hr)) 188 if (SUCCEEDED(hr))
207 { 189 {
208 pObj->_AtlInitialConstruct();
209 pObj->AddRef(); 190 pObj->AddRef();
210 191
211 hr = pObj->SetTargetClassFactory(pTargetCF); 192 hr = pObj->SetTargetClassFactory(pTargetCF);
212 ATLASSERT(SUCCEEDED(hr)); 193 ATLASSERT(SUCCEEDED(hr));
213 194
214 if (SUCCEEDED(hr)) 195 if (SUCCEEDED(hr))
215 { 196 {
216 hr = pObj->QueryInterface(IID_IClassFactory, 197 hr = pObj->QueryInterface(IID_IClassFactory,
217 reinterpret_cast<void**>(ppCF)); 198 reinterpret_cast<void**>(ppCF));
218 ATLASSERT(SUCCEEDED(hr) && *ppCF != 0); 199 ATLASSERT(SUCCEEDED(hr) && *ppCF != 0);
(...skipping 12 matching lines...) Expand all
231 { 212 {
232 return E_POINTER; 213 return E_POINTER;
233 } 214 }
234 *ppCF = 0; 215 *ppCF = 0;
235 216
236 Factory* pObj = 0; 217 Factory* pObj = 0;
237 HRESULT hr = CreateInstance(&pObj); 218 HRESULT hr = CreateInstance(&pObj);
238 ATLASSERT(SUCCEEDED(hr) && pObj != 0); 219 ATLASSERT(SUCCEEDED(hr) && pObj != 0);
239 if (SUCCEEDED(hr)) 220 if (SUCCEEDED(hr))
240 { 221 {
241 //pObj->_AtlInitialConstruct();
242 pObj->AddRef(); 222 pObj->AddRef();
243 223
244 hr = pObj->SetTargetCLSID(clsidTarget); 224 hr = pObj->SetTargetCLSID(clsidTarget);
245 ATLASSERT(SUCCEEDED(hr)); 225 ATLASSERT(SUCCEEDED(hr));
246 226
247 if (SUCCEEDED(hr)) 227 if (SUCCEEDED(hr))
248 { 228 {
249 hr = pObj->QueryInterface(IID_IClassFactory, 229 hr = pObj->QueryInterface(IID_IClassFactory,
250 reinterpret_cast<void**>(ppCF)); 230 reinterpret_cast<void**>(ppCF));
251 ATLASSERT(SUCCEEDED(hr) && *ppCF != 0); 231 ATLASSERT(SUCCEEDED(hr) && *ppCF != 0);
252 } 232 }
253 233
254 pObj->Release(); 234 pObj->Release();
255 } 235 }
256 return hr; 236 return hr;
257 } 237 }
258 238
259 } // end namespace PassthroughAPP 239 } // end namespace PassthroughAPP
260 240
261 #endif // PASSTHROUGHAPP_PROTOCOLCF_INL 241 #endif // PASSTHROUGHAPP_PROTOCOLCF_INL
OLDNEW

Powered by Google App Engine
This is Rietveld