Changeset 49
- Timestamp:
- Feb 11, 2012, 2:47:53 PM (12 years ago)
- Location:
- trunk/Utilities/MaxMindGeoLite
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Utilities/MaxMindGeoLite/Location.h
r48 r49 262 262 }; 263 263 264 //////////////////////////////////////////////////// 265 // CDispatchExT 266 // 267 // TODO: IDispatch methods should take care of IID argument 268 269 template <typename T> 270 class ATL_NO_VTABLE CDispatchExT : 271 public IDispatchEx 272 { 273 public: 274 275 //////////////////////////////////////////////////////// 276 // CDispatchData 277 278 class CDispatchData 279 { 280 public: 281 IID m_InterfaceIdentifier; 282 IDispatch* m_pDispatch; 283 284 public: 285 // CDispatchData 286 CDispatchData() throw() : 287 m_InterfaceIdentifier(IID_NULL), 288 m_pDispatch(NULL) 289 { 290 } 291 CDispatchData(IDispatchEx* pDispatchEx, const IID& InterfaceIdentifier) 292 { 293 CComPtr<IDispatch> pDispatch; 294 __C(pDispatchEx->QueryInterface(InterfaceIdentifier, (VOID**) &pDispatch)); 295 m_InterfaceIdentifier = InterfaceIdentifier; 296 m_pDispatch = pDispatch; 297 } 298 }; 299 300 private: 301 CRoArrayT<CDispatchData> m_DispatchDataArray; 302 303 public: 304 // CDispatchExT 305 VOID ResetDispatchInterfaceIdentifiers() throw() 306 { 307 m_DispatchDataArray.RemoveAll(); 308 } 309 VOID SetDispatchInterfaceIdentifiers(const IID* pInterfaceIdentifiers, SIZE_T nInterfaceIdentifierCount) 310 { 311 _A(m_DispatchDataArray.IsEmpty()); 312 for(SIZE_T nIndex = 0; nIndex < nInterfaceIdentifierCount; nIndex++) 313 _W(m_DispatchDataArray.Add(CDispatchData(this, pInterfaceIdentifiers[nIndex])) >= 0); 314 } 315 VOID SetDispatchInterfaceIdentifiers(const IID& InterfaceIdentifier) 316 { 317 SetDispatchInterfaceIdentifiers(&InterfaceIdentifier, 1); 318 } 319 VOID SetDispatchInterfaceIdentifiers(SIZE_T nInterfaceIdentifierCount, ...) 320 { 321 _A(nInterfaceIdentifierCount); 322 va_list Arguments; 323 va_start(Arguments, nInterfaceIdentifierCount); 324 CTempBufferT<IID> pInterfaceIdentifiers(nInterfaceIdentifierCount); 325 for(SIZE_T nIndex = 0; nIndex < nInterfaceIdentifierCount; nIndex++) 326 pInterfaceIdentifiers[nIndex] = *va_arg(Arguments, IID*); 327 va_end(Arguments); 328 SetDispatchInterfaceIdentifiers(pInterfaceIdentifiers, nInterfaceIdentifierCount); 329 } 330 IDispatch* GetDispatch(DISPID nDispIdentifier) const throw() 331 { 332 const SIZE_T nDispatchIndex = (UINT) (nDispIdentifier >> 12); 333 _A(nDispatchIndex < m_DispatchDataArray.GetCount()); 334 return m_DispatchDataArray[nDispatchIndex].m_pDispatch; 335 } 336 337 // IDispatchEx 338 STDMETHOD(GetDispID)(BSTR sName, DWORD nFlags, DISPID* pid) throw() 339 { 340 _Z4(atlTraceCOM, 4, _T("this 0x%p, sName \"%s\", nFlags 0x%x\n"), static_cast<T*>(this), CString(sName), nFlags); 341 _ATLTRY 342 { 343 __D(pid, E_POINTER); 344 nFlags; 345 OLECHAR* ppszNames[] = { const_cast<OLECHAR*>(sName), }; 346 const LCID nLocaleIdentifier = GetThreadLocale(); 347 *pid = -1; 348 HRESULT nResult = DISP_E_UNKNOWNNAME; 349 for(SIZE_T nIndex = 0; nIndex < m_DispatchDataArray.GetCount(); nIndex++) 350 { 351 DISPID nDispatchDispIdentifier; 352 const HRESULT nDispatchResult = m_DispatchDataArray[nIndex].m_pDispatch->GetIDsOfNames(IID_NULL, ppszNames, DIM(ppszNames), nLocaleIdentifier, &nDispatchDispIdentifier); 353 if(SUCCEEDED(nDispatchResult)) 354 { 355 _A(!(nDispatchDispIdentifier & ~0x0FFF)); 356 *pid = (DISPID) (nIndex << 12) + nDispatchDispIdentifier; 357 nResult = nDispatchResult; 358 break; 359 } 360 } 361 _Z4(atlTraceGeneral, 4, _T("nResult 0x%08x, *pid %d\n"), nResult, *pid); 362 return nResult; 363 } 364 _ATLCATCH(Exception) 365 { 366 _C(Exception); 367 } 368 return E_NOTIMPL; 369 } 370 STDMETHOD(InvokeEx)(DISPID id, LCID nLocaleIdentifier, WORD nFlags, DISPPARAMS* pdp, VARIANT* pvarRes, EXCEPINFO* pei, IServiceProvider* pServiceProvider) throw() 371 { 372 _Z4(atlTraceCOM, 4, _T("this 0x%p, id %d, nLocaleIdentifier %d, nFlags 0x%x\n"), static_cast<T*>(this), id, nLocaleIdentifier, nFlags); 373 _ATLTRY 374 { 375 pServiceProvider; 376 UINT nErroneousArgument; 377 _A((id & ~0xFFFF) == 0); 378 const HRESULT nResult = GetDispatch(id)->Invoke(id & 0x0FFF, IID_NULL, nLocaleIdentifier, nFlags, pdp, pvarRes, pei, &nErroneousArgument); 379 _Z4(atlTraceGeneral, 4, _T("nResult 0x%08x\n"), nResult); 380 return nResult; 381 } 382 _ATLCATCH(Exception) 383 { 384 _C(Exception); 385 } 386 return E_NOTIMPL; 387 } 388 STDMETHOD(DeleteMemberByName)(BSTR sName, DWORD nFlags) throw() 389 { 390 _Z4(atlTraceCOM, 4, _T("this 0x%p, sName \"%s\", nFlags 0x%x\n"), static_cast<T*>(this), CString(sName), nFlags); 391 return E_NOTIMPL; 392 } 393 STDMETHOD(DeleteMemberByDispID)(DISPID id) throw() 394 { 395 _Z4(atlTraceCOM, 4, _T("this 0x%p, id %d\n"), static_cast<T*>(this), id); 396 return E_NOTIMPL; 397 } 398 STDMETHOD(GetMemberProperties)(DISPID id, DWORD nFlagMask, DWORD* pnFlags) throw() 399 { 400 _Z4(atlTraceCOM, 4, _T("this 0x%p, id %d, nFlagMask 0x%x\n"), static_cast<T*>(this), id, nFlagMask); 401 return E_NOTIMPL; 402 } 403 STDMETHOD(GetMemberName)(DISPID id, BSTR* psName) throw() 404 { 405 _Z4(atlTraceCOM, 4, _T("this 0x%p, id %d\n"), static_cast<T*>(this), id); 406 return E_NOTIMPL; 407 } 408 STDMETHOD(GetNextDispID)(DWORD nFlags, DISPID id, DISPID* pid) throw() 409 { 410 _Z4(atlTraceCOM, 4, _T("this 0x%p, nFlags 0x%x, id %d\n"), static_cast<T*>(this), nFlags, id); 411 return E_NOTIMPL; 412 } 413 STDMETHOD(GetNameSpaceParent)(IUnknown** ppunk) throw() 414 { 415 _Z4(atlTraceCOM, 4, _T("this 0x%p\n"), static_cast<T*>(this)); 416 return E_NOTIMPL; 417 } 418 419 // IDispatch 420 STDMETHOD(GetTypeInfoCount)(UINT* pnCount) throw() 421 { 422 _Z4(atlTraceCOM, 4, _T("this 0x%p\n"), static_cast<T*>(this)); 423 _ATLTRY 424 { 425 const HRESULT nResult = GetDispatch(0)->GetTypeInfoCount(pnCount); 426 _Z4(atlTraceGeneral, 4, _T("nResult 0x%08x\n"), nResult); 427 return nResult; 428 } 429 _ATLCATCH(Exception) 430 { 431 _C(Exception); 432 } 433 return E_NOTIMPL; 434 } 435 STDMETHOD(GetTypeInfo)(UINT nIndex, LCID nLocaleIdentifier, ITypeInfo** ppTypeInfo) throw() 436 { 437 _Z4(atlTraceCOM, 4, _T("this 0x%p, nIndex %d, nLocaleIdentifier %d\n"), static_cast<T*>(this), nIndex, nLocaleIdentifier); 438 _ATLTRY 439 { 440 const HRESULT nResult = GetDispatch(0)->GetTypeInfo(nIndex, nLocaleIdentifier, ppTypeInfo); 441 _Z4(atlTraceGeneral, 4, _T("nResult 0x%08x\n"), nResult); 442 return nResult; 443 } 444 _ATLCATCH(Exception) 445 { 446 _C(Exception); 447 } 448 return E_NOTIMPL; 449 } 450 STDMETHOD(GetIDsOfNames)(REFIID InterfaceIdentifier, LPOLESTR* ppszNames, UINT nNameCount, LCID nLocaleIdentifier, DISPID* rgDispId) throw() 451 { 452 _Z4(atlTraceCOM, 4, _T("this 0x%p, nNameCount %d, nLocaleIdentifier %d\n"), static_cast<T*>(this), nNameCount, nLocaleIdentifier); 453 _ATLTRY 454 { 455 const HRESULT nResult = GetDispatch(0)->GetIDsOfNames(InterfaceIdentifier, ppszNames, nNameCount, nLocaleIdentifier, rgDispId); 456 _Z4(atlTraceGeneral, 4, _T("nResult 0x%08x\n"), nResult); 457 return nResult; 458 } 459 _ATLCATCH(Exception) 460 { 461 _C(Exception); 462 } 463 return E_NOTIMPL; 464 } 465 STDMETHOD(Invoke)(DISPID dispIdMember, REFIID InterfaceIdentifier, LCID nLocaleIdentifier, WORD nFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) throw() 466 { 467 _Z4(atlTraceCOM, 4, _T("this 0x%p, dispIdMember %d, nLocaleIdentifier %d, nFlags 0x%x\n"), static_cast<T*>(this), dispIdMember, nLocaleIdentifier, nFlags); 468 _ATLTRY 469 { 470 const HRESULT nResult = GetDispatch(0)->Invoke(dispIdMember, InterfaceIdentifier, nLocaleIdentifier, nFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); 471 _Z4(atlTraceGeneral, 4, _T("nResult 0x%08x\n"), nResult); 472 return nResult; 473 } 474 _ATLCATCH(Exception) 475 { 476 _C(Exception); 477 } 478 return E_NOTIMPL; 479 } 480 }; 481 264 482 //////////////////////////////////////////////////////////// 265 483 // CLocations … … 558 776 public CComObjectRootEx<CComMultiThreadModelNoCS>, 559 777 public CComCoClass<CLazyLocations, &__uuidof(LazyLocations)>, 560 public IDispatchImpl<ILazyLocations> 778 public IDispatchImpl<ILazyLocations>, 779 public IDispatchImpl<ILocations>, 780 public CDispatchExT<CLazyLocations> 561 781 { 562 782 typedef CThreadT<CLazyLocations> CThread; … … 573 793 BEGIN_COM_MAP(CLazyLocations) 574 794 COM_INTERFACE_ENTRY(ILazyLocations) 575 COM_INTERFACE_ENTRY_IID(__uuidof(IDispatch), ILazyLocations)576 795 COM_INTERFACE_ENTRY(ILocations) 796 COM_INTERFACE_ENTRY_IID(__uuidof(IDispatch), ILocations) 797 COM_INTERFACE_ENTRY(IDispatchEx) 577 798 COM_INTERFACE_ENTRY_AGGREGATE(__uuidof(IMarshal), m_FreeThreadedMarshaler) 578 799 END_COM_MAP() … … 636 857 _ATLTRY 637 858 { 859 SetDispatchInterfaceIdentifiers(2, &__uuidof(ILazyLocations), &__uuidof(ILocations)); 638 860 CRoCriticalSectionLock ThreadLock(m_ThreadCriticalSection); 639 861 CObjectPtr<CThread> pThread; -
trunk/Utilities/MaxMindGeoLite/MaxMindGeoLite.idl
r48 r49 47 47 pointer_default(unique) 48 48 ] 49 interface ILazyLocations : I Locations49 interface ILazyLocations : IDispatch 50 50 { 51 51 [propget, id(1)] HRESULT Initialized([out, retval] VARIANT_BOOL* pbInitialized); -
trunk/Utilities/MaxMindGeoLite/MaxMindGeoLite_i.c
r48 r49 7 7 8 8 /* File created by MIDL compiler version 7.00.0555 */ 9 /* at Sun Feb 12 00: 21:0020129 /* at Sun Feb 12 00:46:15 2012 10 10 */ 11 11 /* Compiler settings for MaxMindGeoLite.idl: -
trunk/Utilities/MaxMindGeoLite/MaxMindGeoLite_i.h
r48 r49 5 5 6 6 /* File created by MIDL compiler version 7.00.0555 */ 7 /* at Sun Feb 12 00: 21:0020127 /* at Sun Feb 12 00:46:15 2012 8 8 */ 9 9 /* Compiler settings for MaxMindGeoLite.idl: … … 435 435 436 436 MIDL_INTERFACE("34BF53BB-D4C8-4002-A0EC-5BA70FE7ACA3") 437 ILazyLocations : public I Locations437 ILazyLocations : public IDispatch 438 438 { 439 439 public: … … 490 490 /* [out] */ UINT *puArgErr); 491 491 492 /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Item )(493 ILazyLocations * This,494 /* [in] */ VARIANT vIndex,495 /* [retval][out] */ ILocation **ppLocation);496 497 492 /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Initialized )( 498 493 ILazyLocations * This, … … 533 528 #define ILazyLocations_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ 534 529 ( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) ) 535 536 537 #define ILazyLocations_get_Item(This,vIndex,ppLocation) \538 ( (This)->lpVtbl -> get_Item(This,vIndex,ppLocation) )539 530 540 531 -
trunk/Utilities/MaxMindGeoLite/MaxMindGeoLite_p.c
r48 r49 5 5 6 6 /* File created by MIDL compiler version 7.00.0555 */ 7 /* at Sun Feb 12 00: 21:0020127 /* at Sun Feb 12 00:46:15 2012 8 8 */ 9 9 /* Compiler settings for MaxMindGeoLite.idl: … … 407 407 0x6c, /* Old Flags: object, Oi2 */ 408 408 /* 332 */ NdrFcLong( 0x0 ), /* 0 */ 409 /* 336 */ NdrFcShort( 0x 8 ), /* 8*/409 /* 336 */ NdrFcShort( 0x7 ), /* 7 */ 410 410 /* 338 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ 411 411 /* 340 */ NdrFcShort( 0x0 ), /* 0 */ … … 1375 1375 (unsigned short) -1, 1376 1376 (unsigned short) -1, 1377 288,1378 1377 330 1379 1378 }; … … 1400 1399 0, 1401 1400 0}; 1402 CINTERFACE_PROXY_VTABLE( 9) _ILazyLocationsProxyVtbl =1401 CINTERFACE_PROXY_VTABLE(8) _ILazyLocationsProxyVtbl = 1403 1402 { 1404 1403 &ILazyLocations_ProxyInfo, … … 1411 1410 0 /* IDispatch::GetIDsOfNames */ , 1412 1411 0 /* IDispatch_Invoke_Proxy */ , 1413 (void *) (INT_PTR) -1 /* ILocations::get_Item */ ,1414 1412 (void *) (INT_PTR) -1 /* ILazyLocations::get_Initialized */ 1415 1413 }; … … 1422 1420 STUB_FORWARDING_FUNCTION, 1423 1421 STUB_FORWARDING_FUNCTION, 1424 NdrStubCall2,1425 1422 NdrStubCall2 1426 1423 }; … … 1430 1427 &IID_ILazyLocations, 1431 1428 &ILazyLocations_ServerInfo, 1432 9,1429 8, 1433 1430 &ILazyLocations_table[-3], 1434 1431 CStdStubBuffer_DELEGATING_METHODS -
trunk/Utilities/MaxMindGeoLite/Script/LazyTest.js
r48 r49 9 9 locations = new ActiveXObject("AlaxInfo.MaxMindGeoLite.LazyLocations"); 10 10 11 elapsedTime = 0; 11 12 for(; ; ) { 12 13 if(locations.Initialized) 13 14 break; 14 WScript.Echo("Initializing ...");15 WScript.Echo("Initializing (" + elapsedTime + " seconds) ..."); 15 16 //EchoLocation("alax.info", locations.Item("alax.info")); 16 17 WScript.Sleep(5000); 18 elapsedTime += 5; 17 19 } 18 20
Note: See TracChangeset
for help on using the changeset viewer.