OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
typelib.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectComponents
3// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4/// \file
5/// TServedObject implementation and OLE Type library generation
6//----------------------------------------------------------------------------
7#include <ocf/pch.h>
8#include <ocf/appdesc.h>
9#include <ocf/occtrl.h>
10#include <owl/filename.h>
11
12#define OLE_TYPELIB_FILE L"stdole32.tlb"
13
14namespace ocf {
15
16using namespace owl;
17
18//____________________________________________________________________________
19//
20// TypeLibrary generation
21//____________________________________________________________________________
22
23/// local class to hold ICreateTypeLib interface pointers for each class
24
25struct TOleCreateInfo {
26 int FuncCount;
27 int VarCount;
28 int ImplCount;
29 TYPEKIND TypeKind;
30 ITypeInfo* OurTypeInfo; // our type info implementation
31 ITypeInfo* OleTypeInfo; // type info obtained from ICreatTypeInfo
32 ICreateTypeInfo* CreateInfo; // interface obtained from ICreateTypeLib
33 TOleCreateInfo() : OurTypeInfo(0), OleTypeInfo(0), CreateInfo(0) {}
34 ~TOleCreateInfo();
35};
36
37TOleCreateInfo::~TOleCreateInfo()
38{
39 if (OurTypeInfo)
40 OurTypeInfo->Release();
41 if (OleTypeInfo)
42 OleTypeInfo->Release();
43 if (CreateInfo)
44 CreateInfo->Release();
45}
46
47struct TOleCreateList {
48 int Count;
49 ITypeLib* TypeLib;
50 LPCTSTR FileName;
51 TOleCreateInfo* List;
52 ITypeLib* OleLib;
53 ITypeComp* OleComp;
54 ITypeInfo* OleInfo;
55 ICreateTypeLib* CreateLib;
56 TLIBATTR * LibAttr;
57 TYPEATTR * TypeAttr;
58 ITypeInfo* AttrTypeInfo; // valid only when TypeAttr!=0, not refcnt'd
59 TBSTR* FuncNames; // temporary transfer of BSTR name arrays
60
61 TOleCreateList(ITypeLib* typeLib, LPCTSTR fileName);
62 void FixupTypeDescRef(int typeIndex, TYPEDESC & typeDesc);
63 void Close(LPCTSTR helpDir);
64 void Clear();
65 ~TOleCreateList() {Clear();}
66};
67
68TOleCreateList::TOleCreateList(ITypeLib* typeLib, LPCTSTR fileName)
69:
70 TypeLib(typeLib),
71 FileName(fileName),
72 OleLib(0), OleComp(0), OleInfo(0),
73 CreateLib(0), TypeAttr(0), LibAttr(0), List(0), FuncNames(0)
74{
78 ulong helpId;
79 TypeLib->AddRef();
80 OLECALL(::LoadTypeLib(OLE_TYPELIB_FILE, &OleLib), _T("Load stdole.tlb"));
81 OLECALL(OleLib->GetTypeComp(&OleComp), _T("GetTypeComp"));
82 ITypeComp* tempComp; // required as reference arg, but always set to 0
83 OLECALL(
84 OleComp->BindType(
85 const_cast<LPOLESTR>(OleText("IDispatch")),
86 ::LHashValOfName(0, OleText("IDispatch")),
87 &OleInfo,
89 ),
90 _T("BindType"));
91 OLECALL(TypeLib->GetLibAttr(&LibAttr), _T("GetLibAttr"));
92 OLECALL(TypeLib->GetDocumentation(-1, libName, libDoc, &helpId, helpFile),
93 _T("GetDocumentation for library"));
94 OLECALL(::CreateTypeLib(LibAttr->syskind, OleStr((LPTSTR)FileName), &CreateLib), _T("CreateTypeLib"));
95 OLECALL(CreateLib->SetGuid(LibAttr->guid), _T("Set TypeLib GUID"));
96 OLECALL(CreateLib->SetLcid(LibAttr->lcid), _T("Set TypeLib language"));
97 OLECALL(CreateLib->SetLibFlags(LibAttr->wLibFlags), _T("Set TypeLib flags"));
98 if (!!libName)
99 OLECALL(CreateLib->SetName(libName), _T("Set TypeLib name"));
100 if (!!libDoc)
101 OLECALL(CreateLib->SetDocString(libDoc), _T("Set TypeLib doc"));
102 if (!!helpFile)
103 {
104 OLECALL(CreateLib->SetHelpFileName(helpFile), _T("SetHelpFileName"));
105 OLECALL(CreateLib->SetHelpContext(helpId), _T("HelpContext"));
106 }
107 OLECALL(CreateLib->SetVersion(LibAttr->wMajorVerNum,
108 LibAttr->wMinorVerNum), _T("Set TypeLib version"));
109 // allocate all ITypeInfo's upfront to force consistent references
110 Count = TypeLib->GetTypeInfoCount();
111 List = new TOleCreateInfo[Count];
112 for (int nInfo = 0; nInfo < Count; nInfo++) {
113 TOleCreateInfo& info = List[nInfo];
115 OLECALL(TypeLib->GetTypeInfo(nInfo, &AttrTypeInfo), _T("GetTypeInfo"));
116 info.OurTypeInfo = AttrTypeInfo;
117 OLECALL(info.OurTypeInfo->GetTypeAttr(&TypeAttr), _T("GetTypeAttr"));
118 OLECALL(TypeLib->GetDocumentation(nInfo,libName,libDoc,&helpId,helpFile),
119 _T("GetDocumentation for TypeInfo"));
120 OLECALL(CreateLib->CreateTypeInfo(libName, TypeAttr->typekind, &newInfo),
121 _T("Create CreateTypeInfo"));
122 info.CreateInfo = newInfo;
123 OLECALL(newInfo->QueryInterface(IID_ITypeInfo,
124 (void **)&info.OleTypeInfo), _T("QueryInterface for ITypeInfo"));
125 if (!!libDoc)
126 OLECALL(newInfo->SetDocString(libDoc), _T("Set TypeInfo doc"));
127 OLECALL(newInfo->SetHelpContext(helpId), _T("SetHelpContext"));
128 OLECALL(newInfo->SetVersion(TypeAttr->wMajorVerNum,
129 TypeAttr->wMinorVerNum),_T("Set TypeInfo version"));
130 OLECALL(newInfo->SetGuid(TypeAttr->guid), _T("SetTypeInfo GUID"));
131 OLECALL(newInfo->SetTypeFlags(TypeAttr->wTypeFlags), _T("SetTypeFlags"));
132 if (TypeAttr->typekind == TKIND_DISPATCH) {
134 OLECALL(newInfo->AddRefTypeInfo(OleInfo, &hreftype), _T("AddRefTypeInfo"));
135 OLECALL(newInfo->AddImplType(0, hreftype), _T("AddImplType"));
136 }
137 info.TypeKind = TypeAttr->typekind;
138 info.FuncCount = TypeAttr->cFuncs;
139 info.VarCount = TypeAttr->cVars;
140 info.ImplCount = TypeAttr->cImplTypes;
141 info.OurTypeInfo->ReleaseTypeAttr(TypeAttr), TypeAttr = 0;
142 }
143}
144
145void TOleCreateList::Close(LPCTSTR helpDir)
146{
147 OLECALL(CreateLib->SaveAllChanges(), _T("Write and close TypeLib file"));
148 CreateLib->Release();
149 CreateLib = 0;
151 OleStr((LPTSTR)FileName),
153 _T("Register type library"));
154}
155
156void TOleCreateList::Clear()
157{
158 delete[] List; // releases all interface pointers
159 delete[] FuncNames; // in case exception thrown while in use
160 if (LibAttr)
161 TypeLib->ReleaseTLibAttr(LibAttr);
162 if (TypeAttr)
163 AttrTypeInfo->ReleaseTypeAttr(TypeAttr);
164 if (OleInfo)
165 OleInfo->Release();
166 if (OleComp)
167 OleComp->Release();
168 if (OleLib)
169 OleLib->Release();
170 if (CreateLib)
171 CreateLib->Release();
172 TypeLib->Release(); // finally release typelib called at constructor
173}
174
175void
176TOleCreateList::FixupTypeDescRef(int typeIndex, TYPEDESC & typeDesc)
177{
178 if (typeDesc.vt == VT_USERDEFINED) {
179 ITypeInfo* refInfo;
180 OLECALL(List[typeIndex].OurTypeInfo->GetRefTypeInfo(typeDesc.hreftype,
181 &refInfo), _T("GetRefTypeInfo"));
182 refInfo->Release(); // ok to release here, we're only using its pointer
183 for (int nInfo = 0; nInfo < Count; nInfo++) {
184 if (List[nInfo].OurTypeInfo == refInfo) {
185 OLECALL(List[typeIndex].CreateInfo->AddRefTypeInfo(List[nInfo].OleTypeInfo,
186 &typeDesc.hreftype), _T("AddRefTypeInfo"));
187 return;
188 }
189 }
190 OLECALL(HR_TYPE_ELEMENTNOTFOUND, _T("Unknown reference type"));
191 }
192}
193
194void
196{
200 ulong helpId;
201 FUNCDESC * funcDesc = 0;
202 VARDESC * varDesc = 0;
203 TOleCreateList typeList(new TTypeLibrary(*this, lang), file);
204 for (int nInfo = 0; nInfo < typeList.Count; nInfo++) {
205 TOleCreateInfo& curInfo = typeList.List[nInfo];
206 ITypeInfo* typeInfo = curInfo.OurTypeInfo;
207 ICreateTypeInfo* newInfo = curInfo.CreateInfo;
208 int index;
209 for (index = 0; index < curInfo.FuncCount; index++) {
210 OLECALL(typeInfo->GetFuncDesc(index, &funcDesc), _T("GetFuncDesc"));
211 // Using the GetDocumentation call fails when creating a typelib, so attempt to
212 // use the function GetFuncDocFromIndex to get around this problem
213 servedObject = dynamic_cast<TServedObject*>(typeInfo);
214 if (servedObject)
215 OLECALL(servedObject->GetFuncDocFromIndex(index, libName, libDoc,
216 &helpId, 0), _T("Get method name and doc"));
217 else
218 OLECALL(typeInfo->GetDocumentation(funcDesc->memid, libName, libDoc,
219 &helpId, 0), _T("Get method name and doc"));
220 for (int nArg = funcDesc->cParams; nArg-- >=0; ) {
221 ELEMDESC * elem = nArg < 0 ? &funcDesc->elemdescFunc
222 : &funcDesc->lprgelemdescParam[nArg];
223 typeList.FixupTypeDescRef(nInfo, elem->tdesc);
224 }
225 OLECALL(newInfo->AddFuncDesc(index, funcDesc), _T("AddFuncDesc"));
226 unsigned nNames = funcDesc->cParams + 1;
227 typeList.FuncNames = new TBSTR[nNames];
228 OLECALL(typeInfo->GetNames(funcDesc->memid, (BSTR*)typeList.FuncNames,
229 nNames, &nNames), _T("Get method parameter names"));
230 OLECALL(newInfo->SetFuncAndParamNames(index, (BSTR*)typeList.FuncNames,
231 nNames), _T("Set method parameter names"));
232 delete[] typeList.FuncNames;
233 typeList.FuncNames = 0;
234 if (!!libDoc)
235 OLECALL(newInfo->SetFuncDocString(index, libDoc),_T("Set method doc"));
236 OLECALL(newInfo->SetFuncHelpContext(index, helpId), _T("HelpContext"));
237 typeInfo->ReleaseFuncDesc(funcDesc), funcDesc = 0;
238 }
239 for (index = 0; index < curInfo.VarCount; index++) {
240 OLECALL(typeInfo->GetVarDesc(index, &varDesc), _T("GetVarDesc"));
241 // Using the GetDocumentation call fails when creating a typelib, so attempt to
242 // use the function GetVarDocFromIndex to get around this problem
243 servedObject = dynamic_cast<TServedObject*>(typeInfo);
244 if (servedObject)
245 OLECALL(servedObject->GetVarDocFromIndex(index, libName, libDoc,
246 &helpId, 0), _T("Get propery name and doc"));
247 else
248 OLECALL(typeInfo->GetDocumentation(varDesc->memid, libName, libDoc,
249 &helpId, 0), _T("Get propery name and doc"));
250 typeList.FixupTypeDescRef(nInfo, varDesc->elemdescVar.tdesc);
251 OLECALL(newInfo->AddVarDesc(index, varDesc), _T("AddVarDesc"));
252 OLECALL(newInfo->SetVarName(index, libName),_T("Set property name"));
253 if (!!libDoc)
254 OLECALL(newInfo->SetVarDocString(index, libDoc),_T("Set property doc"));
255 OLECALL(newInfo->SetVarHelpContext(index, helpId), _T("HelpContext"));
256 typeInfo->ReleaseVarDesc(varDesc), varDesc = 0;
257 }
258 if (curInfo.TypeKind == TKIND_COCLASS) {
259 for (index = 0; index < curInfo.ImplCount; index++) {
261 ITypeInfo* refInfo;
262 OLECALL(typeInfo->GetRefTypeOfImplType(index, &hreftype),_T("GetCoClassRef"));
263 OLECALL(typeInfo->GetRefTypeInfo(hreftype, &refInfo), _T("GetCoClassTypeInfo"));
264 refInfo->Release(); // ok to release here, only using its pointer
265 for (int iInfo = 0; iInfo < typeList.Count; iInfo++) {
266 if (typeList.List[iInfo].OurTypeInfo == refInfo) {
267 OLECALL(newInfo->AddRefTypeInfo(typeList.List[iInfo].OleTypeInfo, &hreftype), _T("AddRefTypeInfo"));
268 OLECALL(newInfo->AddImplType(index, hreftype), _T("AddImplType"));
269 int implflags;
270 OLECALL(typeInfo->GetImplTypeFlags(index, &implflags), _T("GetImplTypeFlags"));
271 OLECALL(newInfo->SetImplTypeFlags(index, implflags), _T("SetImplTypeFlags"));
272 }
273 }
274 }
275 }
276 OLECALL(newInfo->LayOut(), _T("Layout typeinfo"));
277 }
278 tstring helpDir = RegInfo.Lookup("helpdir");
279 if (helpDir.empty()){
281 Module->GetModuleFileName(path, sizeof(path));
283 }
284 typeList.Close(helpDir.c_str());
285
286 int iGuid = 0; // first pass for app, second for debug app if present
287 do {
288 _TCHAR buf[80];
289 _tcscpy(buf, _T("CLSID\\"));
290 _tcscat(buf, AppClassId[iGuid]);
291 _tcscat(buf, _T("\\TypeLib"));
292 TRegKey::GetClassesRoot().SetValue(buf,REG_SZ, (uint8*)(LPCTSTR)AppClassId[LibGuidOffset], 0);
293 iGuid ^= DebugGuidOffset; // remains 0 if no debug guid assigned
294 } while (iGuid);
295}
296
297//____________________________________________________________________________
298//
299// TTypeLibrary implementation
300//____________________________________________________________________________
301
303 : AppDesc(appDesc), Lang(lang), RefCnt(0)
304{
305 CoClassFlags = 0;
306 CoClassImplCount = 0;
307 TAutoClass::TAutoClassRef* ref = AppDesc.ClassList;
308 for (int index = 0; index < AppDesc.ClassCount; index++, ref++) {
309 TAutoClass* cls = ref->Class;
310 int implFlags = cls->GetImplTypeFlags();
311 uint16 typeFlags = cls->GetCoClassFlags();
312 if (implFlags != 0 || typeFlags != 0) {
313 CoClassImplCount++;
314 CoClassFlags |= typeFlags;
315 }
316 }
317}
318
320{
321 if (AppDesc.TypeLib == this)
322 AppDesc.TypeLib = 0; // remove pointer to this
323 if (RefCnt > 0)
324 ::CoDisconnectObject(this,0); // should not normally happen
325}
326
327ITypeInfo*
329{
330 ITypeInfo* ifc = new TCoClassInfo(AppDesc, CoClassFlags, CoClassImplCount);
331 ifc->AddRef();
332 return ifc;
333}
334
336TTypeLibrary::QueryInterface(const IID & riid, void * * retIface)
337{
338 if (riid == IID_IUnknown || riid == IID_ITypeLib) {
339 AddRef();
340 *retIface = (IUnknown*)this;
341 return HR_NOERROR;
342 }
343 *retIface = 0;
344 return HR_NOINTERFACE;
345}
346
347unsigned long _IFUNC
348
349TTypeLibrary::AddRef()
350{
351 return ++RefCnt;
352}
353
354unsigned long _IFUNC
355TTypeLibrary::Release()
356{
357 if (--RefCnt != 0)
358 return RefCnt;
359 delete this;
360 return 0;
361}
362
363unsigned int _IFUNC
364TTypeLibrary::GetTypeInfoCount()
365{
366 return AppDesc.GetClassCount() + (CoClassImplCount > 0); // +1 for CoClass
367}
368
370TTypeLibrary::GetTypeInfo(unsigned index, ITypeInfo* * retInfo)
371{
372 if (CoClassImplCount > 0 && index == (uint)AppDesc.GetClassCount()) {
374 }
375 else {
376 TAutoClass* cls = AppDesc.GetAutoClass(index);
377 if (!cls)
379 *retInfo = AppDesc.CreateITypeInfo(*cls);
380 }
381 return HR_NOERROR;
382}
383
385TTypeLibrary::GetTypeInfoType(unsigned index, TYPEKIND * retKind)
386{
387 unsigned int count = AppDesc.GetClassCount();
388 if (index > count)
390 *retKind = (index == count ? TKIND_COCLASS : TKIND_DISPATCH);
391 return HR_NOERROR;
392}
393
395TTypeLibrary::GetTypeInfoOfGuid(const GUID & guid, ITypeInfo* * retInfo)
396{
397 if (AppDesc.AppClassId.GetOffset(guid) == 0) {
399 } else {
400 TAutoClass* cls = AppDesc.GetAutoClass(guid);
401 if (!cls)
403 *retInfo = AppDesc.CreateITypeInfo(*cls);
404 }
405 return HR_NOERROR;
406}
407
409TTypeLibrary::GetLibAttr(TLIBATTR * * retAttr)
410{
412 memset(libAttr, 0, sizeof(TLIBATTR));
413 libAttr->syskind = SYS_WIN32;
414 libAttr->lcid = Lang;
415 AppDesc.GetClassId(0, libAttr->guid);
416 libAttr->wMajorVerNum = AppDesc.GetVersionField(0);
417 libAttr->wMinorVerNum = AppDesc.GetVersionField(1);
418 *retAttr = libAttr;
419 return HR_NOERROR;
420}
421
422void _IFUNC
423TTypeLibrary::ReleaseTLibAttr(TLIBATTR * attr)
424{
425 delete attr;
426}
427
429TTypeLibrary::GetTypeComp(ITypeComp* * /*retComp*/)
430{
431 return HR_TYPE_UNSUPFORMAT;
432}
433
435TTypeLibrary::GetDocumentation(int index, BSTR * retName,
436 BSTR * retDoc,
439{
440 if (retHelpFile)
441 *retHelpFile = TOleAuto::SysAllocString((const OLECHAR *)AppDesc.GetHelpFile(Lang));
442 if (retHelpContext)
443 *retHelpContext = 0;
444 if (index == -1 || index == AppDesc.GetClassCount()) { // library itself
445 if (retName)
446 *retName = TOleAuto::SysAllocString((const OLECHAR *)AppDesc.GetAppName(Lang));
447 if (retDoc)
448 *retDoc = TOleAuto::SysAllocString((const OLECHAR *)AppDesc.GetAppDoc(Lang));
449 if (retHelpContext)
450 *retHelpContext = 0;
451 } else {
452 TAutoClass* cls = AppDesc.GetAutoClass(index);
453 if (!cls)
455 if (retName)
456 *retName = TOleAuto::SysAllocString((const OLECHAR *)cls->GetName(Lang));
457 if (retDoc)
458 *retDoc = TOleAuto::SysAllocString((const OLECHAR *)cls->GetDoc(Lang));
459 if (retHelpContext)
460 *retHelpContext = cls->GetHelpId();
461 }
462 return HR_NOERROR;
463}
464
466TTypeLibrary::IsName(OLECHAR * nameBuf, ulong /*hashVal*/, int * retFound)
467{
468 TAutoClass::TAutoClassRef* ref = AppDesc.ClassList;
469 for (int index = 0; index < AppDesc.ClassCount; index++, ref++) {
470 TAutoClass* cls = ref->Class;
471 // not clear from doc if we should check names of classes as well as members
472 long id;
473 TAutoSymbol* sym = cls->Lookup(OleStr(nameBuf), Lang, asOleType, id);
474 if (sym) {
475 lstrcpyW(nameBuf, OleStr(sym->Name));
476 *retFound = 1;
477 return HR_NOERROR;
478 }
479 }
481}
482
484TTypeLibrary::FindName(OLECHAR * nameBuf, ulong /*lHashVal*/,
485 ITypeInfo* * retInfo, MEMBERID * retId,
486 unsigned short * inoutCount)
487{
488 unsigned short found = 0;
489 TAutoClass::TAutoClassRef* ref = AppDesc.ClassList;
490 for (int index = 0; index < AppDesc.ClassCount && found < *inoutCount;
491 index++, ref++) {
492 TAutoClass* cls = ref->Class;
493 long id;
494 TAutoSymbol* sym = cls->Lookup(OleStr(nameBuf), Lang, asOleType, id);
495 if (sym) {
496 retId[found] = id;
497 retInfo[found] = AppDesc.CreateITypeInfo(*cls);
498 found++;
499 }
500 }
501 *inoutCount = found;
503}
504
505//____________________________________________________________________________
506//
507// TCoClassInfo implementation
508//____________________________________________________________________________
509
511: AppDesc(appDesc), RefCnt(0), TypeFlags(typeFlags), ImplCount(implCount)
512{
513 ImplList = new unsigned[implCount];
514 TAutoClass::TAutoClassRef* ref = AppDesc.ClassList;
515 int iapp = -1;
516 int ievent = -1;
517 Default = -1;
518 DefaultEvent = -1;
519 int iclass = 0;
520 for (int index = 0; iclass < implCount; index++, ref++) {
521 TAutoClass* cls = ref->Class;
522 int implFlags = cls->GetImplTypeFlags();
523 uint16 typeFlags = cls->GetCoClassFlags();
524 if (implFlags || typeFlags) {
526 ievent = iclass;
528 DefaultEvent = iclass;
529 } else {
531 iapp = iclass;
533 Default = iclass;
534 }
535 ImplList[iclass++] = index;
536 }
537 }
538 if (Default == -1)
539 Default = iapp;
540 if (DefaultEvent == -1)
541 DefaultEvent = ievent;
542}
543
545{
546 delete ImplList;
547}
548
550TCoClassInfo::QueryInterface(const IID & riid, void * * retIface)
551{
552 if (riid == IID_IUnknown || riid == IID_ITypeInfo) {
553 AddRef();
554 *retIface = (IUnknown*)this;
555 return HR_NOERROR;
556 }
557 *retIface = 0;
558 return HR_NOINTERFACE;
559}
560
561unsigned long _IFUNC
562
563TCoClassInfo::AddRef()
564{
565 return ++RefCnt;
566}
567
568unsigned long _IFUNC
569TCoClassInfo::Release()
570{
571 if (--RefCnt != 0)
572 return RefCnt;
573 delete this;
574 return 0;
575}
576
578TCoClassInfo::GetTypeAttr(TYPEATTR * * retTypeAttr)
579{
580 TYPEATTR* ta = (TYPEATTR*)new uint8[sizeof(TYPEATTR)];
581 memset(ta, 0, sizeof(TYPEATTR));
582 ta->guid = AppDesc.AppClassId;
583 ta->lcid = AppDesc.GetAppLang();
584 ta->typekind = TKIND_COCLASS;
585 ta->cImplTypes = (unsigned short)ImplCount;
586 ta->wMajorVerNum = AppDesc.GetVersionField(0);
587 ta->wMinorVerNum = AppDesc.GetVersionField(1);
588 ta->wTypeFlags = TypeFlags;
589 *retTypeAttr = ta;
590 return HR_NOERROR;
591}
592
593void _IFUNC
594TCoClassInfo::ReleaseTypeAttr(TYPEATTR * ptypeattr)
595{
596 delete [] (uint8*)ptypeattr;
597}
598
600TCoClassInfo::GetDocumentation(MEMBERID memid,
601 BSTR * retName, BSTR * retDoc,
604{
605 if (retHelpFile)
606 *retHelpFile = TOleAuto::SysAllocString((const OLECHAR *)AppDesc.GetHelpFile(AppDesc.GetAppLang()));
607 if (memid == -1) { // request info on type library itself
608 if (retName)
609 *retName = TOleAuto::SysAllocString((const OLECHAR *)AppDesc.GetAppName(AppDesc.GetAppLang()));
610 if (retDoc)
611 *retDoc = TOleAuto::SysAllocString((const OLECHAR *)AppDesc.GetAppDoc(AppDesc.GetAppLang()));
612 if (retHelpContext)
613 *retHelpContext = 0;
614 } else {
616 }
617 return HR_NOERROR;
618}
619
621TCoClassInfo::CreateInstance(IUnknown* /*punkOuter*/, const IID & /*riid*/,
622 void * * /*ppvObj*/)
623{
625}
626
628TCoClassInfo::GetContainingTypeLib(ITypeLib* * retLib,
629 unsigned int * retIndex)
630{
631 *retLib = AppDesc.GetTypeLibrary();
632 if (retIndex)
633 *retIndex = AppDesc.GetClassCount();
634 return HR_NOERROR;
635}
636
638TCoClassInfo::GetRefTypeInfo(HREFTYPE hreftype, ITypeInfo* * retInfo)
639{
640 TAutoClass* cls = (TAutoClass*)hreftype;
641 if (AppDesc.GetClassIndex(cls) == -1) // validate pointer to avoid crash
643 *retInfo = AppDesc.CreateITypeInfo(*cls);
644 return HR_NOERROR;
645}
646
648TCoClassInfo::GetImplTypeFlags(unsigned int index, int * retflags)
649{
650 TAutoClass* cls = index < (uint)ImplCount ?
651 AppDesc.GetAutoClass(ImplList[index]) : 0;
652 if (!cls)
654 int implFlags = cls->GetImplTypeFlags();
656 if (index == (uint)DefaultEvent)
658 }
659 else {
660 if (index == (uint)Default)
662 }
664 return HR_NOERROR;
665}
666
668TCoClassInfo::GetRefTypeOfImplType(unsigned int index,
670{
671 TAutoClass* cls = index < (uint)ImplCount ?
672 AppDesc.GetAutoClass(ImplList[index]):0;
675}
676
677// The following methods of ITypeInfo are not relevant for a COCLASS typeinfo
678
680TCoClassInfo::GetFuncDesc(unsigned int, FUNCDESC * *)
681{
683}
684
685void _IFUNC
686TCoClassInfo::ReleaseFuncDesc(FUNCDESC *)
687{
688}
689
691TCoClassInfo::GetVarDesc(unsigned int, VARDESC * *)
692{
694}
695
696void _IFUNC
697TCoClassInfo::ReleaseVarDesc(VARDESC *)
698{
699}
700
702TCoClassInfo::GetNames(MEMBERID, BSTR *, unsigned int, unsigned int *)
703{
705}
706
708TCoClassInfo::GetIDsOfNames(OLECHAR * *, uint, MEMBERID *)
709{
711}
712
714TCoClassInfo::Invoke(void *, MEMBERID, unsigned short, DISPPARAMS *,
715 VARIANT *, EXCEPINFO *, unsigned int *)
716{
718}
719
721TCoClassInfo::GetTypeComp(ITypeComp* *)
722{
724}
725
727TCoClassInfo::GetMops(MEMBERID, BSTR *)
728{
730}
731
733TCoClassInfo::GetDllEntry(MEMBERID, INVOKEKIND, BSTR *, BSTR *,
734 unsigned short *)
735{
737}
738
740TCoClassInfo::AddressOfMember(MEMBERID, INVOKEKIND, void * *)
741{
743}
744
745} // OCF namespace
746
747//==============================================================================
748
TAppDescriptor - OLE application descriptor definitions.
bool GetClassId(TAutoClass *cls, GUID &retId)
Retrieves the GUID of the specified TAutoClass instance.
Definition appdesc.cpp:489
TAutoClass * GetAutoClass(unsigned index)
Returns the TAutoClass instance as the specified index.
Definition appdesc.cpp:522
friend class _ICLASS TTypeLibrary
Definition appdesc.h:194
void WriteTypeLibrary(owl::TLangId lang, LPCTSTR file)
Definition typelib.cpp:195
LPCTSTR GetAppDoc(owl::TLangId lang)
Definition appdesc.h:111
ITypeLib * GetTypeLibrary()
Returns the 'ITypeLib' interface pointer describing the objects exposed by this instance of 'TAppDesc...
Definition appdesc.cpp:574
LPCTSTR GetAppName(owl::TLangId lang)
Definition appdesc.h:110
owl::uint16 GetVersionField(owl::uint field)
Returns version as a whole number.
Definition appdesc.cpp:379
owl::TLangId GetAppLang()
Definition appdesc.h:103
LPCTSTR GetHelpFile(owl::TLangId lang)
Definition appdesc.h:112
ITypeInfo * CreateITypeInfo(TAutoClass &cls)
Definition appdesc.cpp:696
TBaseClassId AppClassId
Definition appdesc.h:136
int GetClassIndex(TAutoClass *cls)
Returns the index of a 'TAutoClass' instance.
Definition appdesc.cpp:473
int GetOffset(const GUID &guid)
Definition oleutil.cpp:168
TCoClassInfo(TAppDescriptor &appDesc, owl::uint16 typeFlags, int implCount)
Definition typelib.cpp:510
OLE object exposed for automated access of internal object.
Definition autodefs.h:972
TTypeLibrary(TAppDescriptor &appDesc, owl::TLangId lang)
Definition typelib.cpp:302
ITypeInfo * CreateCoClassInfo()
Definition typelib.cpp:328
The TFileName class constructs filenames.
Definition filename.h:37
@ Device
Logical device or sharename.
Definition filename.h:127
@ Path
Directory path to the file.
Definition filename.h:128
@ Server
Server name.
Definition filename.h:126
const tchar * GetParts(uint p) const
Reassembles any logical subset of filename parts.
Definition filename.cpp:759
static BSTR SysAllocString(const OLECHAR *)
Definition module.cpp:1256
static auto GetClassesRoot() -> TRegKey &
Special predefined root key used by shell and OLE applications (HKEY_CLASSES_ROOT).
Definition registry.cpp:32
LPCTSTR Lookup(LPCSTR key, TLangId lang=TLocaleString::UserDefaultLangId)
Performs the lookup of the TRegItems using a key (an item name such as progid) and returns the value ...
Definition regheap.cpp:58
System string (BSTR) encapsulation.
Definition string.h:33
#define _tcscat
Definition cygwin.h:83
#define _tcscpy
Definition cygwin.h:79
#define _MAX_PATH
Definition cygwin.h:97
#define _T(x)
Definition cygwin.h:51
int GetModuleFileName(TCHAR *buff, int maxChars) const
Returns the expanded file name (path and file name) of the file from which this module was loaded.
Definition module.h:1271
Include for OC, gets common headers when precompiled headers are enabled.
Object Component Framework (COM encapsulation)
Definition appdesc.h:22
@ asOleType
method or property exposed for OLE
Definition autodefs.h:299
owl::TSysStr TBSTR
BASIC global string encapsulation.
Definition oleutil.h:40
class _ICLASS TCoClassInfo
Definition appdesc.h:31
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long ulong
Definition number.h:26
unsigned char uint8
Definition number.h:32
owl::uint16 TLangId
Holds a language ID, a predefined number that represents a base language and dialect.
Definition lclstrng.h:26
unsigned short uint16
Definition number.h:33
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
Definition of TOcControl class - Proxy object representing a control in.
#define HR_NOINTERFACE
Definition defs.h:79
#define HR_TYPE_WRONGTYPEKIND
Definition defs.h:101
#define HR_TYPE_ELEMENTNOTFOUND
Definition defs.h:103
#define HR_TYPE_LIBNOTREGISTERED
Definition defs.h:102
#define HR_TYPE_UNSUPFORMAT
Definition defs.h:104
#define HR_NOERROR
Definition defs.h:73
#define OLECALL(func, msg)
Definition except.h:78
#define _IFUNC
Definition oleutil.h:28
#define OleText(s)
Definition string.h:129
#define OleStr(s)
Definition string.h:128
#define OLE_TYPELIB_FILE
Definition typelib.cpp:12