Qt 4.8
Classes | Public Functions | Private Types | Private Functions | Properties | Friends | List of all members
MetaObjectGenerator Class Reference

Classes

struct  Method
 
struct  Property
 

Public Functions

void addClassInfo (const char *key, const char *value)
 
QMetaObjectmetaObject (const QMetaObject *parentObject, const QByteArray &className=QByteArray())
 
 MetaObjectGenerator (QAxBase *ax, QAxBasePrivate *dptr)
 
 MetaObjectGenerator (ITypeLib *typelib, ITypeInfo *typeinfo)
 
void readClassInfo ()
 
void readEnumInfo ()
 
void readEventInfo ()
 
void readEventInterface (ITypeInfo *eventinfo, IConnectionPoint *cpoint)
 
void readFuncsInfo (ITypeInfo *typeinfo, ushort nFuncs)
 
void readInterfaceInfo ()
 
void readVarsInfo (ITypeInfo *typeinfo, ushort nVars)
 
 ~MetaObjectGenerator ()
 

Private Types

enum  MemberFlags {
  AccessPrivate = 0x00, AccessProtected = 0x01, AccessPublic = 0x02, MemberMethod = 0x00,
  MemberSignal = 0x04, MemberSlot = 0x08, MemberCompatibility = 0x10, MemberCloned = 0x20,
  MemberScriptable = 0x40
}
 
enum  ProperyFlags {
  Invalid = 0x00000000, Readable = 0x00000001, Writable = 0x00000002, Resettable = 0x00000004,
  EnumOrFlag = 0x00000008, StdCppSet = 0x00000100, Designable = 0x00001000, ResolveDesignable = 0x00002000,
  Scriptable = 0x00004000, ResolveScriptable = 0x00008000, Stored = 0x00010000, ResolveStored = 0x00020000,
  Editable = 0x00040000, ResolveEditable = 0x00080000, User = 0x00100000, ResolveUser = 0x00200000,
  RequestingEdit = 0x00400000, Bindable = 0x00800000
}
 

Private Functions

void addChangedSignal (const QByteArray &function, const QByteArray &type, int memid)
 
void addEnumValue (const QByteArray &enumname, const QByteArray &key, int value)
 
void addProperty (const QByteArray &type, const QByteArray &name, uint flags)
 
void addSetterSlot (const QByteArray &property)
 
void addSignal (const QByteArray &prototype, const QByteArray &parameters)
 
void addSlot (const QByteArray &type, const QByteArray &prototype, const QByteArray &parameters, int flags=QMetaMethod::Public)
 
QByteArray createPrototype (FUNCDESC *funcdesc, ITypeInfo *typeinfo, const QList< QByteArray > &names, QByteArray &type, QList< QByteArray > &parameters)
 
QByteArray guessTypes (const TYPEDESC &tdesc, ITypeInfo *info, const QByteArray &function)
 
bool hasClassInfo (const char *key)
 
bool hasEnum (const QByteArray &enumname)
 
bool hasProperty (const QByteArray &name)
 
bool hasSignal (const QByteArray &prototype)
 
bool hasSlot (const QByteArray &prototype)
 
void init ()
 
QList< QByteArrayparamList (const QByteArray &proto)
 
QByteArray propertyType (const QByteArray &name)
 
QByteArray replacePrototype (const QByteArray &prototype)
 
QByteArray replaceType (const QByteArray &type)
 
QMetaObjecttryCache ()
 
QByteArray usertypeToString (const TYPEDESC &tdesc, ITypeInfo *info, const QByteArray &function)
 

Properties

QString cacheKey
 
ITypeInfo * classInfo
 
QMap< QByteArray, QByteArrayclassinfo_list
 
QByteArray current_typelib
 
QAxBasePrivated
 
QByteArray debugInfo
 
IDispatch * disp
 
ITypeInfo * dispInfo
 
QMap< QByteArray, QList< QPair< QByteArray, int > > > enum_list
 
QUuid iid_propNotifySink
 
QSettings iidnames
 
QMap< QByteArray, Propertyproperty_list
 
QMap< QByteArray, Methodsignal_list
 
QMap< QByteArray, Methodslot_list
 
QAxBasethat
 
ITypeLib * typelib
 

Friends

QMetaObjectqax_readClassInfo (ITypeLib *typeLib, ITypeInfo *classInfo, const QMetaObject *parentObject)
 

Detailed Description

Definition at line 1493 of file qaxbase.cpp.

Enumerations

◆ MemberFlags

Enumerator
AccessPrivate 
AccessProtected 
AccessPublic 
MemberMethod 
MemberSignal 
MemberSlot 
MemberCompatibility 
MemberCloned 
MemberScriptable 

Definition at line 1550 of file qaxbase.cpp.

◆ ProperyFlags

Enumerator
Invalid 
Readable 
Writable 
Resettable 
EnumOrFlag 
StdCppSet 
Designable 
ResolveDesignable 
Scriptable 
ResolveScriptable 
Stored 
ResolveStored 
Editable 
ResolveEditable 
User 
ResolveUser 
RequestingEdit 
Bindable 

Definition at line 1528 of file qaxbase.cpp.

1528  {
1529  Invalid = 0x00000000,
1530  Readable = 0x00000001,
1531  Writable = 0x00000002,
1532  Resettable = 0x00000004,
1533  EnumOrFlag = 0x00000008,
1534  StdCppSet = 0x00000100,
1535 // Override = 0x00000200,
1536  Designable = 0x00001000,
1537  ResolveDesignable = 0x00002000,
1538  Scriptable = 0x00004000,
1539  ResolveScriptable = 0x00008000,
1540  Stored = 0x00010000,
1541  ResolveStored = 0x00020000,
1542  Editable = 0x00040000,
1543  ResolveEditable = 0x00080000,
1544  User = 0x00100000,
1545  ResolveUser = 0x00200000,
1546  // And our own - don't use the upper byte, as it's used for the property type
1547  RequestingEdit = 0x00400000,
1548  Bindable = 0x00800000
1549  };

Constructors and Destructors

◆ MetaObjectGenerator() [1/2]

MetaObjectGenerator::MetaObjectGenerator ( QAxBase ax,
QAxBasePrivate dptr 
)

Definition at line 1839 of file qaxbase.cpp.

1840 : that(ax), d(dptr), disp(0), dispInfo(0), classInfo(0), typelib(0),
1841  iidnames(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes"), QSettings::NativeFormat)
1842 {
1843  init();
1844 }
QAxBasePrivate * d
Definition: qaxbase.cpp:1728
ITypeInfo * classInfo
Definition: qaxbase.cpp:1732
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QSettings iidnames
Definition: qaxbase.cpp:1736
ITypeLib * typelib
Definition: qaxbase.cpp:1733
IDispatch * disp
Definition: qaxbase.cpp:1730
ITypeInfo * dispInfo
Definition: qaxbase.cpp:1731

◆ MetaObjectGenerator() [2/2]

MetaObjectGenerator::MetaObjectGenerator ( ITypeLib *  typelib,
ITypeInfo *  typeinfo 
)

Definition at line 1846 of file qaxbase.cpp.

1847 : that(0), d(0), disp(0), dispInfo(tinfo), classInfo(0), typelib(tlib),
1848  iidnames(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes"), QSettings::NativeFormat)
1849 {
1850  init();
1851 
1852  if (dispInfo)
1853  dispInfo->AddRef();
1854  if (typelib) {
1855  typelib->AddRef();
1856  BSTR bstr;
1857  typelib->GetDocumentation(-1, &bstr, 0, 0, 0);
1859  SysFreeString(bstr);
1860  }
1861  readClassInfo();
1862 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
QAxBasePrivate * d
Definition: qaxbase.cpp:1728
ITypeInfo * classInfo
Definition: qaxbase.cpp:1732
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QSettings iidnames
Definition: qaxbase.cpp:1736
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
ITypeLib * typelib
Definition: qaxbase.cpp:1733
QByteArray current_typelib
Definition: qaxbase.cpp:1734
IDispatch * disp
Definition: qaxbase.cpp:1730
ITypeInfo * dispInfo
Definition: qaxbase.cpp:1731

◆ ~MetaObjectGenerator()

MetaObjectGenerator::~MetaObjectGenerator ( )

Definition at line 1879 of file qaxbase.cpp.

1880 {
1881  if (dispInfo) dispInfo->Release();
1882  if (classInfo) classInfo->Release();
1883  if (typelib) typelib->Release();
1884 }
ITypeInfo * classInfo
Definition: qaxbase.cpp:1732
ITypeLib * typelib
Definition: qaxbase.cpp:1733
ITypeInfo * dispInfo
Definition: qaxbase.cpp:1731

Functions

◆ addChangedSignal()

void MetaObjectGenerator::addChangedSignal ( const QByteArray function,
const QByteArray type,
int  memid 
)
private

Definition at line 2349 of file qaxbase.cpp.

Referenced by readFuncsInfo(), and readVarsInfo().

2350 {
2351  QAxEventSink *eventSink = 0;
2352  if (d) {
2353  eventSink = d->eventSink.value(iid_propNotifySink);
2354  if (!eventSink && d->useEventSink) {
2355  eventSink = new QAxEventSink(that);
2356  d->eventSink.insert(iid_propNotifySink, eventSink);
2357  }
2358  }
2359  // generate changed signal
2360  QByteArray signalName(function);
2361  signalName += "Changed";
2362  QByteArray signalProto = signalName + '(' + replaceType(type) + ')';
2363  if (!hasSignal(signalProto))
2364  addSignal(signalProto, function);
2365  if (eventSink)
2366  eventSink->addProperty(memid, function, signalProto);
2367 }
QAxBasePrivate * d
Definition: qaxbase.cpp:1728
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QHash< QUuid, QAxEventSink * > eventSink
Definition: qaxbase.cpp:592
void addProperty(DISPID propid, const char *name, const char *signal)
Definition: qaxbase.cpp:284
bool hasSignal(const QByteArray &prototype)
Definition: qaxbase.cpp:1641
void addSignal(const QByteArray &prototype, const QByteArray &parameters)
Definition: qaxbase.cpp:1627
uint useEventSink
Definition: qaxbase.cpp:593
QByteArray replaceType(const QByteArray &type)
Definition: qaxbase.cpp:1572

◆ addClassInfo()

void MetaObjectGenerator::addClassInfo ( const char *  key,
const char *  value 
)
inline

Definition at line 1510 of file qaxbase.cpp.

Referenced by metaObject(), qax_readClassInfo(), readClassInfo(), readEventInfo(), and readInterfaceInfo().

1511  {
1512  classinfo_list.insert(key, value);
1513  }
QMap< QByteArray, QByteArray > classinfo_list
Definition: qaxbase.cpp:1611
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
int key

◆ addEnumValue()

void MetaObjectGenerator::addEnumValue ( const QByteArray enumname,
const QByteArray key,
int  value 
)
inlineprivate

Definition at line 1717 of file qaxbase.cpp.

Referenced by readEnumInfo().

1718  {
1719  enum_list[enumname].append(QPair<QByteArray, int>(key, value));
1720  }
QMap< QByteArray, QList< QPair< QByteArray, int > > > enum_list
Definition: qaxbase.cpp:1716

◆ addProperty()

void MetaObjectGenerator::addProperty ( const QByteArray type,
const QByteArray name,
uint  flags 
)
inlineprivate

Definition at line 1674 of file qaxbase.cpp.

Referenced by init(), readFuncsInfo(), and readVarsInfo().

1675  {
1676  QByteArray propertyType(type);
1677  if (propertyType.endsWith('&'))
1678  propertyType.chop(1);
1679 
1680  Property &prop = property_list[name];
1681  if (!propertyType.isEmpty() && propertyType != "HRESULT") {
1682  prop.type = replaceType(propertyType);
1683  if (prop.type != propertyType)
1684  prop.realType = propertyType;
1685  }
1686  if (flags & Writable)
1687  flags |= Stored;
1688  prop.typeId |= flags;
1689  QVariant::Type vartype = QVariant::nameToType(prop.type);
1690  switch(vartype) {
1691  case QVariant::Invalid:
1692  case QVariant::UserType:
1693  if (prop.type == "QVariant") {
1694  prop.typeId |= 0xff << 24;
1695  break;
1696  }
1697  if (QMetaType::type(prop.type) == -1)
1698  qWarning("QAxBase: Unsupported property type: %s", prop.type.data());
1699  break;
1700  default:
1701  prop.typeId |= vartype << 24;
1702  break;
1703  }
1704  }
void chop(int n)
Removes n bytes from the end of the byte array.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
const char * name
Q_CORE_EXPORT void qWarning(const char *,...)
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
static int type(const char *typeName)
Returns a handle to the type called typeName, or 0 if there is no such type.
Definition: qmetatype.cpp:607
QByteArray propertyType(const QByteArray &name)
Definition: qaxbase.cpp:1711
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static Type nameToType(const char *name)
Converts the string representation of the storage type given in name, to its enum representation...
Definition: qvariant.cpp:2026
QMap< QByteArray, Property > property_list
Definition: qaxbase.cpp:1673
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...
QByteArray replaceType(const QByteArray &type)
Definition: qaxbase.cpp:1572

◆ addSetterSlot()

void MetaObjectGenerator::addSetterSlot ( const QByteArray property)
private

Definition at line 2369 of file qaxbase.cpp.

Referenced by readFuncsInfo(), and readVarsInfo().

2370 {
2371  QByteArray set;
2372  QByteArray prototype(property);
2373  if (isupper(prototype.at(0))) {
2374  set = "Set";
2375  } else {
2376  set = "set";
2377  prototype[0] = toupper(prototype[0]);
2378  }
2379  prototype = set + prototype + '(' + propertyType(property) + ')';
2380  if (!hasSlot(prototype))
2381  addSlot(0, prototype, property);
2382 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool hasSlot(const QByteArray &prototype)
Definition: qaxbase.cpp:1661
void addSlot(const QByteArray &type, const QByteArray &prototype, const QByteArray &parameters, int flags=QMetaMethod::Public)
Definition: qaxbase.cpp:1647
QByteArray propertyType(const QByteArray &name)
Definition: qaxbase.cpp:1711
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685
char at(int i) const
Returns the character at index position i in the byte array.
Definition: qbytearray.h:413

◆ addSignal()

void MetaObjectGenerator::addSignal ( const QByteArray prototype,
const QByteArray parameters 
)
inlineprivate

Definition at line 1627 of file qaxbase.cpp.

Referenced by addChangedSignal(), init(), qax_readClassInfo(), and readEventInterface().

1628  {
1629  QByteArray proto(replacePrototype(prototype));
1630 
1631  Method &signal = signal_list[proto];
1632  signal.type = 0;
1633  signal.parameters = parameters;
1634  signal.flags = QMetaMethod::Public | MemberSignal;
1635  if (proto != prototype)
1636  signal.realPrototype = prototype;
1637  }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685
QMap< QByteArray, Method > signal_list
Definition: qaxbase.cpp:1626
QByteArray replacePrototype(const QByteArray &prototype)
Definition: qaxbase.cpp:1588

◆ addSlot()

void MetaObjectGenerator::addSlot ( const QByteArray type,
const QByteArray prototype,
const QByteArray parameters,
int  flags = QMetaMethod::Public 
)
inlineprivate

Definition at line 1647 of file qaxbase.cpp.

Referenced by addSetterSlot(), and readFuncsInfo().

1648  {
1649  QByteArray proto = replacePrototype(prototype);
1650 
1651  Method &slot = slot_list[proto];
1652  slot.type = replaceType(type);
1653  slot.parameters = parameters;
1654  slot.flags = flags | MemberSlot;
1655  if (proto != prototype)
1656  slot.realPrototype = prototype;
1657  }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685
QByteArray replacePrototype(const QByteArray &prototype)
Definition: qaxbase.cpp:1588
QMap< QByteArray, Method > slot_list
Definition: qaxbase.cpp:1646
QByteArray replaceType(const QByteArray &type)
Definition: qaxbase.cpp:1572

◆ createPrototype()

QByteArray MetaObjectGenerator::createPrototype ( FUNCDESC *  funcdesc,
ITypeInfo *  typeinfo,
const QList< QByteArray > &  names,
QByteArray type,
QList< QByteArray > &  parameters 
)
private

Definition at line 2384 of file qaxbase.cpp.

Referenced by readEventInterface(), and readFuncsInfo().

2386 {
2388  QByteArray function(names.at(0));
2389  const QByteArray hresult("HRESULT");
2390  // get function prototype
2391  type = guessTypes(funcdesc->elemdescFunc.tdesc, typeinfo, function);
2392  if ((type.isEmpty() || type == hresult) && funcdesc->invkind == INVOKE_PROPERTYPUT && funcdesc->lprgelemdescParam) {
2393  type = guessTypes(funcdesc->lprgelemdescParam->tdesc, typeinfo, function);
2394  }
2395 
2396  prototype = function + '(';
2397  if (funcdesc->invkind == INVOKE_FUNC && type == hresult)
2398  type = 0;
2399 
2400  int p;
2401  for (p = 1; p < names.count(); ++p) {
2402  // parameter
2403  QByteArray paramName = names.at(p);
2404  bool optional = p > (funcdesc->cParams - funcdesc->cParamsOpt);
2405  TYPEDESC tdesc = funcdesc->lprgelemdescParam[p-1].tdesc;
2406  PARAMDESC pdesc = funcdesc->lprgelemdescParam[p-1].paramdesc;
2407 
2408  QByteArray ptype = guessTypes(tdesc, typeinfo, function);
2409  if (pdesc.wParamFlags & PARAMFLAG_FRETVAL) {
2410  if (ptype.endsWith('&')) {
2411  ptype.truncate(ptype.length() - 1);
2412  } else if (ptype.endsWith("**")) {
2413  ptype.truncate(ptype.length() - 1);
2414  }
2415  type = ptype;
2416  } else {
2417  prototype += ptype;
2418  if (pdesc.wParamFlags & PARAMFLAG_FOUT && !ptype.endsWith('&') && !ptype.endsWith("**"))
2419  prototype += '&';
2420  if (optional || pdesc.wParamFlags & PARAMFLAG_FOPT)
2421  paramName += "=0";
2422  else if (pdesc.wParamFlags & PARAMFLAG_FHASDEFAULT) {
2423  // ### get the value from pdesc.pparamdescex
2424  paramName += "=0";
2425  }
2426  parameters << paramName;
2427  }
2428  if (p < funcdesc->cParams && !(pdesc.wParamFlags & PARAMFLAG_FRETVAL))
2429  prototype += ',';
2430  }
2431 
2432  if (!prototype.isEmpty()) {
2433  if (prototype.endsWith(',')) {
2434  if (funcdesc->invkind == INVOKE_PROPERTYPUT && p == funcdesc->cParams) {
2435  TYPEDESC tdesc = funcdesc->lprgelemdescParam[p-1].tdesc;
2436  QByteArray ptype = guessTypes(tdesc, typeinfo, function);
2437  prototype += ptype;
2438  prototype += ')';
2439  parameters << "rhs";
2440  } else {
2441  prototype[prototype.length()-1] = ')';
2442  }
2443  } else {
2444  prototype += ')';
2445  }
2446  }
2447 
2448  return prototype;
2449 }
void truncate(int pos)
Truncates the byte array at index position pos.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QByteArray guessTypes(const TYPEDESC &tdesc, ITypeInfo *info, const QByteArray &function)
Definition: qaxbase.cpp:1977
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int length() const
Same as size().
Definition: qbytearray.h:356
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...

◆ guessTypes()

QByteArray MetaObjectGenerator::guessTypes ( const TYPEDESC &  tdesc,
ITypeInfo *  info,
const QByteArray function 
)
private

Definition at line 1977 of file qaxbase.cpp.

Referenced by createPrototype(), readVarsInfo(), and usertypeToString().

1978 {
1979  QByteArray str;
1980  switch (tdesc.vt) {
1981  case VT_EMPTY:
1982  case VT_VOID:
1983  break;
1984  case VT_LPWSTR:
1985  str = "wchar_t *";
1986  break;
1987  case VT_BSTR:
1988  str = "QString";
1989  break;
1990  case VT_BOOL:
1991  str = "bool";
1992  break;
1993  case VT_I1:
1994  str = "char";
1995  break;
1996  case VT_I2:
1997  str = "short";
1998  break;
1999  case VT_I4:
2000  case VT_INT:
2001  str = "int";
2002  break;
2003  case VT_I8:
2004  str = "qlonglong";
2005  break;
2006  case VT_UI1:
2007  case VT_UI2:
2008  case VT_UI4:
2009  case VT_UINT:
2010  str = "uint";
2011  break;
2012  case VT_UI8:
2013  str = "qulonglong";
2014  break;
2015  case VT_CY:
2016  str = "qlonglong";
2017  break;
2018  case VT_R4:
2019  str = "float";
2020  break;
2021  case VT_R8:
2022  str = "double";
2023  break;
2024  case VT_DATE:
2025  str = "QDateTime";
2026  break;
2027  case VT_DISPATCH:
2028  str = "IDispatch*";
2029  break;
2030  case VT_VARIANT:
2031  str = "QVariant";
2032  break;
2033  case VT_UNKNOWN:
2034  str = "IUnknown*";
2035  break;
2036  case VT_HRESULT:
2037  str = "HRESULT";
2038  break;
2039  case VT_PTR:
2040  str = guessTypes(*tdesc.lptdesc, info, function);
2041  switch(tdesc.lptdesc->vt) {
2042  case VT_VOID:
2043  str = "void*";
2044  break;
2045  case VT_VARIANT:
2046  case VT_BSTR:
2047  case VT_I1:
2048  case VT_I2:
2049  case VT_I4:
2050  case VT_I8:
2051  case VT_UI1:
2052  case VT_UI2:
2053  case VT_UI4:
2054  case VT_UI8:
2055  case VT_BOOL:
2056  case VT_R4:
2057  case VT_R8:
2058  case VT_INT:
2059  case VT_UINT:
2060  case VT_CY:
2061  str += '&';
2062  break;
2063  case VT_PTR:
2064  if (str == "QFont" || str == "QPixmap") {
2065  str += '&';
2066  break;
2067  } else if (str == "void*") {
2068  str = "void **";
2069  break;
2070  }
2071  // FALLTHROUGH
2072  default:
2073  if (str == "QColor")
2074  str += '&';
2075  else if (str == "QDateTime")
2076  str += '&';
2077  else if (str == "QVariantList")
2078  str += '&';
2079  else if (str == "QByteArray")
2080  str += '&';
2081  else if (str == "QStringList")
2082  str += '&';
2083  else if (!str.isEmpty() && hasEnum(str))
2084  str += '&';
2085  else if (!str.isEmpty() && str != "QFont" && str != "QPixmap" && str != "QVariant")
2086  str += '*';
2087  }
2088  break;
2089  case VT_SAFEARRAY:
2090  switch(tdesc.lpadesc->tdescElem.vt) {
2091  // some shortcuts, and generic support for lists of QVariant-supported types
2092  case VT_UI1:
2093  str = "QByteArray";
2094  break;
2095  case VT_BSTR:
2096  str = "QStringList";
2097  break;
2098  case VT_VARIANT:
2099  str = "QVariantList";
2100  break;
2101  default:
2102  str = guessTypes(tdesc.lpadesc->tdescElem, info, function);
2103  if (!str.isEmpty())
2104  str = "QList<" + str + '>';
2105  break;
2106  }
2107  break;
2108  case VT_CARRAY:
2109  str = guessTypes(tdesc.lpadesc->tdescElem, info, function);
2110  if (!str.isEmpty()) {
2111  for (int index = 0; index < tdesc.lpadesc->cDims; ++index)
2112  str += '[' + QByteArray::number((int)tdesc.lpadesc->rgbounds[index].cElements) + ']';
2113  }
2114  break;
2115  case VT_USERDEFINED:
2116  str = usertypeToString(tdesc, info, function);
2117  break;
2118 
2119  VT_UNHANDLED(FILETIME);
2120  VT_UNHANDLED(BLOB);
2122  VT_UNHANDLED(DECIMAL);
2123  VT_UNHANDLED(LPSTR);
2124  default:
2125  break;
2126  }
2127 
2128  if (tdesc.vt & VT_BYREF)
2129  str += '&';
2130 
2131  str.replace("&*", "**");
2132  return str;
2133 }
bool hasEnum(const QByteArray &enumname)
Definition: qaxbase.cpp:1722
static mach_timebase_info_data_t info
#define VT_UNHANDLED(x)
Definition: qaxbase.cpp:1975
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QByteArray guessTypes(const TYPEDESC &tdesc, ITypeInfo *info, const QByteArray &function)
Definition: qaxbase.cpp:1977
QByteArray usertypeToString(const TYPEDESC &tdesc, ITypeInfo *info, const QByteArray &function)
Definition: qaxbase.cpp:1889
quint16 index
QByteArray & replace(int index, int len, const char *s)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...

◆ hasClassInfo()

bool MetaObjectGenerator::hasClassInfo ( const char *  key)
inlineprivate

Definition at line 1613 of file qaxbase.cpp.

Referenced by readClassInfo().

1614  {
1615  return classinfo_list.contains(key);
1616  }
QMap< QByteArray, QByteArray > classinfo_list
Definition: qaxbase.cpp:1611
int key
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
Definition: qmap.h:553

◆ hasEnum()

bool MetaObjectGenerator::hasEnum ( const QByteArray enumname)
inlineprivate

Definition at line 1722 of file qaxbase.cpp.

Referenced by guessTypes(), readFuncsInfo(), readVarsInfo(), and usertypeToString().

1723  {
1724  return enum_list.contains(enumname);
1725  }
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
Definition: qmap.h:553
QMap< QByteArray, QList< QPair< QByteArray, int > > > enum_list
Definition: qaxbase.cpp:1716

◆ hasProperty()

bool MetaObjectGenerator::hasProperty ( const QByteArray name)
inlineprivate

Definition at line 1706 of file qaxbase.cpp.

Referenced by readFuncsInfo(), and readVarsInfo().

1707  {
1708  return property_list.contains(name);
1709  }
QMap< QByteArray, Property > property_list
Definition: qaxbase.cpp:1673

◆ hasSignal()

bool MetaObjectGenerator::hasSignal ( const QByteArray prototype)
inlineprivate

Definition at line 1641 of file qaxbase.cpp.

Referenced by addChangedSignal(), and readEventInterface().

1642  {
1643  return signal_list.contains(prototype);
1644  }
QMap< QByteArray, Method > signal_list
Definition: qaxbase.cpp:1626

◆ hasSlot()

bool MetaObjectGenerator::hasSlot ( const QByteArray prototype)
inlineprivate

Definition at line 1661 of file qaxbase.cpp.

Referenced by addSetterSlot().

1662  {
1663  return slot_list.contains(prototype);
1664  }
QMap< QByteArray, Method > slot_list
Definition: qaxbase.cpp:1646

◆ init()

void MetaObjectGenerator::init ( )
private

Definition at line 1864 of file qaxbase.cpp.

Referenced by MetaObjectGenerator().

1865 {
1866  if (d)
1867  disp = d->dispatch();
1868 
1869  iid_propNotifySink = IID_IPropertyNotifySink;
1870 
1871  addSignal("signal(QString,int,void*)", "name,argc,argv");
1872  addSignal("exception(int,QString,QString,QString)", "code,source,disc,help");
1873  addSignal("propertyChanged(QString)", "name");
1874  if (d || dispInfo) {
1876  }
1877 }
void addProperty(const QByteArray &type, const QByteArray &name, uint flags)
Definition: qaxbase.cpp:1674
QAxBasePrivate * d
Definition: qaxbase.cpp:1728
void addSignal(const QByteArray &prototype, const QByteArray &parameters)
Definition: qaxbase.cpp:1627
IDispatch * disp
Definition: qaxbase.cpp:1730
IDispatch * dispatch() const
Definition: qaxbase.cpp:580
ITypeInfo * dispInfo
Definition: qaxbase.cpp:1731

◆ metaObject()

QMetaObject * MetaObjectGenerator::metaObject ( const QMetaObject parentObject,
const QByteArray className = QByteArray() 
)

Definition at line 2995 of file qaxbase.cpp.

Referenced by QAxBase::dynamicCallHelper(), QAxBase::internalInvoke(), QAxBase::internalProperty(), QAxBase::metaObject(), QAxBase::propertyBag(), qax_noSuchFunction(), qax_readClassInfo(), qax_readEnumInfo(), qax_readInterfaceInfo(), QAxBase::qt_metacall(), QAxBase::querySubObject(), and QAxBase::setPropertyBag().

2996 {
2997  if (that) {
2998  readClassInfo();
2999  if (typelib) {
3000  BSTR bstr;
3001  typelib->GetDocumentation(-1, &bstr, 0, 0, 0);
3003  SysFreeString(bstr);
3004  }
3005  if (d->tryCache && tryCache())
3006  return d->metaobj;
3007  readEnumInfo();
3009  readEventInfo();
3010  }
3011 
3013 
3014 #ifndef QAX_NO_CLASSINFO
3015  if (!debugInfo.isEmpty() && d->useClassInfo)
3016  addClassInfo("debugInfo", debugInfo);
3017 #endif
3018 
3019  QAxMetaObject *metaobj = new QAxMetaObject;
3020 
3021  // revision + classname + table + zero terminator
3022  uint int_data_size = 1+1+2+2+2+2+1;
3023 
3024  int_data_size += classinfo_list.count() * 2;
3025  int_data_size += signal_list.count() * 5;
3026  int_data_size += slot_list.count() * 5;
3027  int_data_size += property_list.count() * 3;
3028  int_data_size += enum_list.count() * 4;
3029  for (QMap<QByteArray, QList<QPair<QByteArray, int> > >::ConstIterator it = enum_list.begin();
3030  it != enum_list.end(); ++it) {
3031  int_data_size += (*it).count() * 2;
3032  }
3033 
3034  uint *int_data = new uint[int_data_size];
3035  int_data[0] = 1; // revision number
3036  int_data[1] = 0; // classname index
3037  int_data[2] = classinfo_list.count(); // num_classinfo
3038  int_data[3] = 10; // idx_classinfo
3039  int_data[4] = signal_list.count() + slot_list.count(); // num_methods
3040  int_data[5] = int_data[3] + int_data[2] * 2; // idx_signals
3041  int_data[6] = property_list.count(); // num_properties
3042  int_data[7] = int_data[5] + int_data[4] * 5; // idx_properties
3043  int_data[8] = enum_list.count(); // num_enums
3044  int_data[9] = int_data[7] + int_data[6] * 3; // idx_enums
3045  int_data[int_data_size - 1] = 0; // eod;
3046 
3047  char null('\0');
3048  // data + zero-terminator
3049  QByteArray stringdata = that ? QByteArray(that->className()) : className;
3050  stringdata += null;
3051  stringdata.reserve(8192);
3052 
3053  uint offset = int_data[3]; //idx_classinfo
3054 
3055  // each class info in form key\0value\0
3057  QByteArray key(it.key());
3058  QByteArray value(it.value());
3059  int_data[offset++] = stringdata.length();
3060  stringdata += key;
3061  stringdata += null;
3062  int_data[offset++] = stringdata.length();
3063  stringdata += value;
3064  stringdata += null;
3065  }
3066  Q_ASSERT(offset == int_data[5]);
3067 
3068  // each signal in form prototype\0parameters\0type\0tag\0
3071  QByteArray type(it.value().type);
3072  QByteArray parameters(it.value().parameters);
3073  if (!it.value().realPrototype.isEmpty())
3074  metaobj->realPrototype.insert(prototype, it.value().realPrototype);
3075  QByteArray tag;
3076  int flags = it.value().flags;
3077 
3078  int_data[offset++] = stringdata.length();
3079  stringdata += prototype;
3080  stringdata += null;
3081  int_data[offset++] = stringdata.length();
3082  stringdata += parameters;
3083  stringdata += null;
3084  int_data[offset++] = stringdata.length();
3085  stringdata += type;
3086  stringdata += null;
3087  int_data[offset++] = stringdata.length();
3088  stringdata += tag;
3089  stringdata += null;
3090  int_data[offset++] = flags;
3091  }
3092 
3093  // each slot in form prototype\0parameters\0type\0tag\0
3094  for (QMap<QByteArray, Method>::ConstIterator it = slot_list.begin(); it != slot_list.end(); ++it) {
3096  QByteArray type(it.value().type);
3097  QByteArray parameters(it.value().parameters);
3098  if (!it.value().realPrototype.isEmpty())
3099  metaobj->realPrototype.insert(prototype, it.value().realPrototype);
3100  QByteArray tag;
3101  int flags = it.value().flags;
3102 
3103  int_data[offset++] = stringdata.length();
3104  stringdata += prototype;
3105  stringdata += null;
3106  int_data[offset++] = stringdata.length();
3107  stringdata += parameters;
3108  stringdata += null;
3109  int_data[offset++] = stringdata.length();
3110  stringdata += type;
3111  stringdata += null;
3112  int_data[offset++] = stringdata.length();
3113  stringdata += tag;
3114  stringdata += null;
3115  int_data[offset++] = flags;
3116  }
3117  Q_ASSERT(offset == int_data[7]);
3118 
3119  // each property in form name\0type\0
3121  QByteArray name(it.key());
3122  QByteArray type(it.value().type);
3123  QByteArray realType(it.value().realType);
3124  if (!realType.isEmpty() && realType != type)
3125  metaobj->realPrototype.insert(name, realType);
3126  uint flags = it.value().typeId;
3127 
3128  int_data[offset++] = stringdata.length();
3129  stringdata += name;
3130  stringdata += null;
3131  int_data[offset++] = stringdata.length();
3132  stringdata += type;
3133  stringdata += null;
3134  int_data[offset++] = flags;
3135  }
3136  Q_ASSERT(offset == int_data[9]);
3137 
3138  int value_offset = offset + enum_list.count() * 4;
3139  // each enum in form name\0
3140  for (QMap<QByteArray, QList<QPair<QByteArray, int> > >::ConstIterator it = enum_list.begin(); it != enum_list.end(); ++it) {
3141  QByteArray name(it.key());
3142  int flags = 0x0; // 0x1 for flag?
3143  int count = it.value().count();
3144 
3145  int_data[offset++] = stringdata.length();
3146  stringdata += name;
3147  stringdata += null;
3148  int_data[offset++] = flags;
3149  int_data[offset++] = count;
3150  int_data[offset++] = value_offset;
3151  value_offset += count * 2;
3152  }
3153  Q_ASSERT(offset == int_data[9] + enum_list.count() * 4);
3154 
3155  // each enum value in form key\0
3156  for (QMap<QByteArray, QList<QPair<QByteArray, int> > >::ConstIterator it = enum_list.begin(); it != enum_list.end(); ++it) {
3157  for (QList<QPair<QByteArray,int> >::ConstIterator it2 = it.value().begin(); it2 != it.value().end(); ++it2) {
3158  QByteArray key((*it2).first);
3159  int value = (*it2).second;
3160  int_data[offset++] = stringdata.length();
3161  stringdata += key;
3162  stringdata += null;
3163  int_data[offset++] = value;
3164  }
3165  }
3166  Q_ASSERT(offset == int_data_size-1);
3167 
3168  char *string_data = new char[stringdata.length()];
3169  memcpy(string_data, stringdata, stringdata.length());
3170 
3171  // put the metaobject together
3172  metaobj->d.data = int_data;
3173  metaobj->d.extradata = 0;
3174  metaobj->d.stringdata = string_data;
3175  metaobj->d.superdata = parentObject;
3176 
3177  if (d)
3178  d->metaobj = metaobj;
3179 
3180  if (!cacheKey.isEmpty()) {
3181  mo_cache.insert(cacheKey, d->metaobj);
3182  d->cachedMetaObject = true;
3184  QAxEventSink *sink = it.value();
3185  if (sink) {
3186  QUuid ciid = sink->connectionInterface();
3187 
3189  d->metaobj->sigs.insert(ciid, sink->signalMap());
3190  d->metaobj->props.insert(ciid, sink->propertyMap());
3191  d->metaobj->propsigs.insert(ciid, sink->propSignalMap());
3192  }
3193  }
3194  }
3195 
3196  return metaobj;
3197 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
static QHash< QString, QAxMetaObject * > mo_cache
Definition: qaxbase.cpp:183
QMap< QByteArray, QByteArray > realPrototype
Definition: qaxbase.cpp:109
int type
Definition: qmetatype.cpp:239
QAxBasePrivate * d
Definition: qaxbase.cpp:1728
const void * extradata
Definition: qobjectdefs.h:472
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
#define it(className, varName)
void readInterfaceInfo()
Definition: qaxbase.cpp:2707
QMap< QUuid, QMap< DISPID, QByteArray > > props
Definition: qaxbase.cpp:105
QAxMetaObject * metaobj
Definition: qaxbase.cpp:614
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int count(const Key &key) const
Returns the number of items associated with key key.
Definition: qmap.h:539
void addClassInfo(const char *key, const char *value)
Definition: qaxbase.cpp:1510
const char * stringdata
Definition: qobjectdefs.h:470
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QHash< QUuid, QAxEventSink * > eventSink
Definition: qaxbase.cpp:592
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
virtual const char * className() const =0
QMap< QUuid, QMap< DISPID, QByteArray > > sigs
Definition: qaxbase.cpp:101
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const char * name
QMap< QByteArray, QByteArray > classinfo_list
Definition: qaxbase.cpp:1611
unsigned int uint
Definition: qglobal.h:996
uint cachedMetaObject
Definition: qaxbase.cpp:596
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
QMetaObject * tryCache()
Definition: qaxbase.cpp:2959
const uint * data
Definition: qobjectdefs.h:471
QByteArray debugInfo
Definition: qaxbase.cpp:1738
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
Definition: qmap.h:372
int length() const
Same as size().
Definition: qbytearray.h:356
uint useClassInfo
Definition: qaxbase.cpp:595
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685
QMap< DISPID, QByteArray > signalMap() const
Definition: qaxbase.cpp:226
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
Definition: qmap.h:301
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
QMap< QByteArray, Method > signal_list
Definition: qaxbase.cpp:1626
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
int key
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
const QMetaObject * superdata
Definition: qobjectdefs.h:469
struct QMetaObject::@38 d
QMap< DISPID, QByteArray > propertyMap() const
Definition: qaxbase.cpp:230
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
QMap< QByteArray, Method > slot_list
Definition: qaxbase.cpp:1646
QMap< DISPID, QByteArray > propSignalMap() const
Definition: qaxbase.cpp:234
QMap< QByteArray, QList< QPair< QByteArray, int > > > enum_list
Definition: qaxbase.cpp:1716
ITypeLib * typelib
Definition: qaxbase.cpp:1733
QByteArray current_typelib
Definition: qaxbase.cpp:1734
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
QUuid connectionInterface() const
Definition: qaxbase.cpp:222
void reserve(int size)
Attempts to allocate memory for at least size bytes.
Definition: qbytearray.h:449
QMap< QUuid, QMap< DISPID, QByteArray > > propsigs
Definition: qaxbase.cpp:103
The QUuid class stores a Universally Unique Identifier (UUID).
Definition: quuid.h:67
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67
QMap< QByteArray, Property > property_list
Definition: qaxbase.cpp:1673
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
QList< QUuid > connectionInterfaces
Definition: qaxbase.cpp:99

◆ paramList()

QList<QByteArray> MetaObjectGenerator::paramList ( const QByteArray proto)
inlineprivate

Definition at line 1562 of file qaxbase.cpp.

1563  {
1564  QByteArray prototype(proto);
1565  QByteArray parameters = prototype.mid(prototype.indexOf('(') + 1);
1566  parameters.truncate(parameters.length() - 1);
1567 
1568  QList<QByteArray> plist = parameters.split(',');
1569  return plist;
1570  }
void truncate(int pos)
Truncates the byte array at index position pos.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
int length() const
Same as size().
Definition: qbytearray.h:356
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...

◆ propertyType()

QByteArray MetaObjectGenerator::propertyType ( const QByteArray name)
inlineprivate

Definition at line 1711 of file qaxbase.cpp.

Referenced by addSetterSlot().

1712  {
1713  return property_list.value(name).type;
1714  }
QMap< QByteArray, Property > property_list
Definition: qaxbase.cpp:1673

◆ readClassInfo()

void MetaObjectGenerator::readClassInfo ( )

Definition at line 2135 of file qaxbase.cpp.

Referenced by QAxBase::connectNotify(), metaObject(), and MetaObjectGenerator().

2136 {
2137  // Read class information
2138  IProvideClassInfo *provideClassInfo = 0;
2139  if (d)
2140  d->ptr->QueryInterface(IID_IProvideClassInfo, (void**)&provideClassInfo);
2141  if (provideClassInfo) {
2142  provideClassInfo->GetClassInfo(&classInfo);
2143  TYPEATTR *typeattr = 0;
2144  if (classInfo)
2145  classInfo->GetTypeAttr(&typeattr);
2146 
2147  QString coClassID;
2148  if (typeattr) {
2149  QUuid clsid(typeattr->guid);
2150  coClassID = clsid.toString().toUpper();
2151 #ifndef QAX_NO_CLASSINFO
2152  // UUID
2153  if (d->useClassInfo && !hasClassInfo("CoClass")) {
2154  QString coClassIDstr = iidnames.value(QLatin1String("/CLSID/") + coClassID + QLatin1String("/Default"), coClassID).toString();
2155  addClassInfo("CoClass", coClassIDstr.isEmpty() ? coClassID.toLatin1() : coClassIDstr.toLatin1());
2156  QByteArray version = QByteArray::number(typeattr->wMajorVerNum) + '.' + QByteArray::number(typeattr->wMinorVerNum);
2157  if (version != "0.0")
2158  addClassInfo("Version", version);
2159  }
2160 #endif
2161  classInfo->ReleaseTypeAttr(typeattr);
2162  }
2163  provideClassInfo->Release();
2164  provideClassInfo = 0;
2165 
2166  if (d->tryCache && !coClassID.isEmpty())
2167  cacheKey = QString::fromLatin1("%1$%2$%3$%4").arg(coClassID)
2169  }
2170 
2171  UINT index = 0;
2172  if (disp && !dispInfo)
2173  disp->GetTypeInfo(index, LOCALE_USER_DEFAULT, &dispInfo);
2174 
2175  if (dispInfo && !typelib)
2176  dispInfo->GetContainingTypeLib(&typelib, &index);
2177 
2178  if (!typelib) {
2179  QSettings controls(QLatin1String("HKEY_LOCAL_MACHINE\\Software"), QSettings::NativeFormat);
2180  QString tlid = controls.value(QLatin1String("/Classes/CLSID/") + that->control() + QLatin1String("/TypeLib/.")).toString();
2181  QString tlfile;
2182  if (!tlid.isEmpty()) {
2183  controls.beginGroup(QLatin1String("/Classes/TypeLib/") + tlid);
2184  QStringList versions = controls.childGroups();
2185  QStringList::Iterator vit = versions.begin();
2186  while (tlfile.isEmpty() && vit != versions.end()) {
2187  QString version = *vit;
2188  ++vit;
2189  tlfile = controls.value(QLatin1Char('/') + version + QLatin1String("/0/win32/.")).toString();
2190  }
2191  controls.endGroup();
2192  } else {
2193  tlfile = controls.value(QLatin1String("/Classes/CLSID/") + that->control() + QLatin1String("/InprocServer32/.")).toString();
2194  if (tlfile.isEmpty())
2195  tlfile = controls.value(QLatin1String("/Classes/CLSID/") + that->control() + QLatin1String("/LocalServer32/.")).toString();
2196  }
2197  if (!tlfile.isEmpty()) {
2198  LoadTypeLib((OLECHAR*)tlfile.utf16(), &typelib);
2199  if (!typelib) {
2200  tlfile = tlfile.left(tlfile.lastIndexOf(QLatin1Char('.'))) + QLatin1String(".tlb");
2201  LoadTypeLib((OLECHAR*)tlfile.utf16(), &typelib);
2202  }
2203  if (!typelib) {
2204  tlfile = tlfile.left(tlfile.lastIndexOf(QLatin1Char('.'))) + QLatin1String(".olb");
2205  LoadTypeLib((OLECHAR*)tlfile.utf16(), &typelib);
2206  }
2207  }
2208  }
2209 
2210  if (!classInfo && typelib && that)
2211  typelib->GetTypeInfoOfGuid(QUuid(that->control()), &classInfo);
2212 
2213  if (classInfo && !dispInfo) {
2214  TYPEATTR *classAttr;
2215  classInfo->GetTypeAttr(&classAttr);
2216  if (classAttr) {
2217  for (int i = 0; i < classAttr->cImplTypes; ++i) {
2218  int typeFlags = 0;
2219  classInfo->GetImplTypeFlags(i, &typeFlags);
2220  if (typeFlags & IMPLTYPEFLAG_FSOURCE)
2221  continue;
2222 
2223  HREFTYPE hrefType;
2224  if (S_OK == classInfo->GetRefTypeOfImplType(i, &hrefType))
2225  classInfo->GetRefTypeInfo(hrefType, &dispInfo);
2226  if (dispInfo) {
2227  TYPEATTR *ifaceAttr;
2228  dispInfo->GetTypeAttr(&ifaceAttr);
2229  WORD typekind = ifaceAttr->typekind;
2230  dispInfo->ReleaseTypeAttr(ifaceAttr);
2231 
2232  if (typekind & TKIND_DISPATCH) {
2233  break;
2234  } else {
2235  dispInfo->Release();
2236  dispInfo = 0;
2237  }
2238  }
2239  }
2240  classInfo->ReleaseTypeAttr(classAttr);
2241  }
2242  }
2243 
2244  if (!d || !dispInfo || !cacheKey.isEmpty() || !d->tryCache)
2245  return;
2246 
2247  TYPEATTR *typeattr = 0;
2248  dispInfo->GetTypeAttr(&typeattr);
2249 
2250  QString interfaceID;
2251  if (typeattr) {
2252  QUuid iid(typeattr->guid);
2253  interfaceID = iid.toString().toUpper();
2254 
2255  dispInfo->ReleaseTypeAttr(typeattr);
2256  // ### event interfaces!!
2257  if (!interfaceID.isEmpty())
2258  cacheKey = QString::fromLatin1("%1$%2$%3$%4").arg(interfaceID)
2260  }
2261 }
IUnknown * ptr
Definition: qaxbase.cpp:600
bool qax_dispatchEqualsIDispatch
Definition: qaxbase.cpp:1886
QAxBasePrivate * d
Definition: qaxbase.cpp:1728
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for setting key.
Definition: qsettings.cpp:3460
QString control() const
the name of the COM object wrapped by this QAxBase object.
Definition: qaxbase.cpp:1029
ITypeInfo * classInfo
Definition: qaxbase.cpp:1732
The QSettings class provides persistent platform-independent application settings.
Definition: qsettings.h:73
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
void addClassInfo(const char *key, const char *value)
Definition: qaxbase.cpp:1510
QSettings iidnames
Definition: qaxbase.cpp:1736
iterator Iterator
Qt-style synonym for QList::iterator.
Definition: qlist.h:278
bool hasClassInfo(const char *key)
Definition: qaxbase.cpp:1613
static QString toString(Register *reg, int type, bool *ok=0)
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
uint useEventSink
Definition: qaxbase.cpp:593
uint useClassInfo
Definition: qaxbase.cpp:595
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
quint16 index
ITypeLib * typelib
Definition: qaxbase.cpp:1733
IDispatch * disp
Definition: qaxbase.cpp:1730
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QUuid class stores a Universally Unique Identifier (UUID).
Definition: quuid.h:67
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290
ITypeInfo * dispInfo
Definition: qaxbase.cpp:1731

◆ readEnumInfo()

void MetaObjectGenerator::readEnumInfo ( )

Definition at line 2263 of file qaxbase.cpp.

Referenced by QAxBase::connectNotify(), metaObject(), qax_readClassInfo(), qax_readEnumInfo(), and qax_readInterfaceInfo().

2264 {
2265  if (!typelib)
2266  return;
2267 
2268  QUuid libUuid;
2269 
2270  if (d && d->tryCache) {
2271  TLIBATTR *libAttr = 0;
2272  typelib->GetLibAttr(&libAttr);
2273  if (libAttr) {
2274  libUuid = QUuid(libAttr->guid);
2275  typelib->ReleaseTLibAttr(libAttr);
2276  enum_list = enum_cache.value(libUuid);
2277  if (!enum_list.isEmpty())
2278  return;
2279  }
2280  }
2281 
2282  int valueindex = 0;
2283  QSet<QString> clashCheck;
2284  int clashIndex = 0;
2285 
2286  int enum_serial = 0;
2287  UINT index = typelib->GetTypeInfoCount();
2288  for (UINT i = 0; i < index; ++i) {
2289  TYPEKIND typekind;
2290  typelib->GetTypeInfoType(i, &typekind);
2291  if (typekind == TKIND_ENUM) {
2292  // Get the type information for the enum
2293  ITypeInfo *enuminfo = 0;
2294  typelib->GetTypeInfo(i, &enuminfo);
2295  if (!enuminfo)
2296  continue;
2297 
2298  // Get the name of the enumeration
2299  BSTR enumname;
2300  QByteArray enumName;
2301  if (typelib->GetDocumentation(i, &enumname, 0, 0, 0) == S_OK) {
2302  enumName = QString::fromWCharArray(enumname).toLatin1();
2303  SysFreeString(enumname);
2304  } else {
2305  enumName = "enum" + QByteArray::number(++enum_serial);
2306  }
2307 
2308  // Get the attributes of the enum type
2309  TYPEATTR *typeattr = 0;
2310  enuminfo->GetTypeAttr(&typeattr);
2311  if (typeattr) {
2312  // Get all values of the enumeration
2313  for (UINT vd = 0; vd < (UINT)typeattr->cVars; ++vd) {
2314  VARDESC *vardesc = 0;
2315  enuminfo->GetVarDesc(vd, &vardesc);
2316  if (vardesc && vardesc->varkind == VAR_CONST) {
2317  int value = vardesc->lpvarValue->lVal;
2318  int memid = vardesc->memid;
2319  // Get the name of the value
2320  BSTR valuename;
2321  QByteArray valueName;
2322  UINT maxNamesOut;
2323  enuminfo->GetNames(memid, &valuename, 1, &maxNamesOut);
2324  if (maxNamesOut) {
2325  valueName = QString::fromWCharArray(valuename).toLatin1();
2326  SysFreeString(valuename);
2327  } else {
2328  valueName = "value" + QByteArray::number(valueindex++);
2329  }
2330 
2331  if (clashCheck.contains(QString::fromLatin1(valueName)))
2332  valueName += QByteArray::number(++clashIndex);
2333 
2334  clashCheck.insert(QString::fromLatin1(valueName));
2335  addEnumValue(enumName, valueName, value);
2336  }
2337  enuminfo->ReleaseVarDesc(vardesc);
2338  }
2339  }
2340  enuminfo->ReleaseTypeAttr(typeattr);
2341  enuminfo->Release();
2342  }
2343  }
2344 
2345  if (!libUuid.isNull())
2346  enum_cache.insert(libUuid, enum_list);
2347 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
QAxBasePrivate * d
Definition: qaxbase.cpp:1728
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool isNull() const
Returns true if this is the null UUID {00000000-0000-0000-0000-000000000000}; otherwise returns false...
Definition: quuid.cpp:700
bool contains(const T &value) const
Definition: qset.h:91
const_iterator insert(const T &value)
Definition: qset.h:179
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
bool isEmpty() const
Returns true if the map contains no items; otherwise returns false.
Definition: qmap.h:203
QMap< QByteArray, QList< QPair< QByteArray, int > > > enum_list
Definition: qaxbase.cpp:1716
quint16 index
ITypeLib * typelib
Definition: qaxbase.cpp:1733
static QHash< QUuid, QMap< QByteArray, QList< QPair< QByteArray, int > > > > enum_cache
Definition: qaxbase.cpp:184
void addEnumValue(const QByteArray &enumname, const QByteArray &key, int value)
Definition: qaxbase.cpp:1717
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
The QUuid class stores a Universally Unique Identifier (UUID).
Definition: quuid.h:67

◆ readEventInfo()

void MetaObjectGenerator::readEventInfo ( )

Definition at line 2855 of file qaxbase.cpp.

Referenced by metaObject().

2856 {
2857  int event_serial = 0;
2858  IConnectionPointContainer *cpoints = 0;
2859  if (d && d->useEventSink)
2860  d->ptr->QueryInterface(IID_IConnectionPointContainer, (void**)&cpoints);
2861  if (cpoints) {
2862  // Get connection point enumerator
2863  IEnumConnectionPoints *epoints = 0;
2864  cpoints->EnumConnectionPoints(&epoints);
2865  if (epoints) {
2866  ULONG c = 1;
2867  IConnectionPoint *cpoint = 0;
2868  epoints->Reset();
2869  QList<QUuid> cpointlist;
2870  do {
2871  if (cpoint) cpoint->Release();
2872  cpoint = 0;
2873  HRESULT hr = epoints->Next(c, &cpoint, &c);
2874  if (!c || hr != S_OK)
2875  break;
2876 
2877  IID conniid;
2878  cpoint->GetConnectionInterface(&conniid);
2879  // workaround for typelibrary bug of Word.Application
2880  QUuid connuuid(conniid);
2881  if (cpointlist.contains(connuuid))
2882  break;
2883 
2884 #ifndef QAX_NO_CLASSINFO
2885  if (d->useClassInfo) {
2886  QString uuidstr = connuuid.toString().toUpper();
2887  uuidstr = iidnames.value(QLatin1String("/Interface/") + uuidstr + QLatin1String("/Default"), uuidstr).toString();
2888  addClassInfo("Event Interface " + QByteArray::number(++event_serial), uuidstr.toLatin1());
2889  }
2890 #endif
2891 
2892  // get information about type
2893  if (conniid == IID_IPropertyNotifySink) {
2894  // test whether property notify sink has been created already, and advise on it
2896  if (eventSink)
2897  eventSink->advise(cpoint, conniid);
2898  continue;
2899  }
2900 
2901  ITypeInfo *eventinfo = 0;
2902  if (typelib)
2903  typelib->GetTypeInfoOfGuid(conniid, &eventinfo);
2904 
2905  if (eventinfo) {
2906  // avoid recursion (see workaround above)
2907  cpointlist.append(connuuid);
2908 
2909  readEventInterface(eventinfo, cpoint);
2910  eventinfo->Release();
2911  }
2912  } while (c);
2913  if (cpoint) cpoint->Release();
2914  epoints->Release();
2915  } else if (classInfo) { // no enumeration - search source interfaces and ask for those
2916  TYPEATTR *typeattr = 0;
2917  classInfo->GetTypeAttr(&typeattr);
2918  if (typeattr) {
2919  for (int i = 0; i < typeattr->cImplTypes; ++i) {
2920  int flags = 0;
2921  classInfo->GetImplTypeFlags(i, &flags);
2922  if (!(flags & IMPLTYPEFLAG_FSOURCE))
2923  continue;
2924  HREFTYPE reference;
2925  if (S_OK != classInfo->GetRefTypeOfImplType(i, &reference))
2926  continue;
2927  ITypeInfo *eventInfo = 0;
2928  classInfo->GetRefTypeInfo(reference, &eventInfo);
2929  if (!eventInfo)
2930  continue;
2931  TYPEATTR *eventattr = 0;
2932  eventInfo->GetTypeAttr(&eventattr);
2933  if (eventattr) {
2934  IConnectionPoint *cpoint = 0;
2935  cpoints->FindConnectionPoint(eventattr->guid, &cpoint);
2936  if (cpoint) {
2937  if (eventattr->guid == IID_IPropertyNotifySink) {
2938  // test whether property notify sink has been created already, and advise on it
2940  if (eventSink)
2941  eventSink->advise(cpoint, eventattr->guid);
2942  continue;
2943  }
2944 
2945  readEventInterface(eventInfo, cpoint);
2946  cpoint->Release();
2947  }
2948  eventInfo->ReleaseTypeAttr(eventattr);
2949  }
2950  eventInfo->Release();
2951  }
2952  classInfo->ReleaseTypeAttr(typeattr);
2953  }
2954  }
2955  cpoints->Release();
2956  }
2957 }
IUnknown * ptr
Definition: qaxbase.cpp:600
QAxBasePrivate * d
Definition: qaxbase.cpp:1728
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for setting key.
Definition: qsettings.cpp:3460
unsigned char c[8]
Definition: qnumeric_p.h:62
void readEventInterface(ITypeInfo *eventinfo, IConnectionPoint *cpoint)
Definition: qaxbase.cpp:2772
ITypeInfo * classInfo
Definition: qaxbase.cpp:1732
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
void advise(IConnectionPoint *cp, IID iid)
Definition: qaxbase.cpp:240
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
void addClassInfo(const char *key, const char *value)
Definition: qaxbase.cpp:1510
QSettings iidnames
Definition: qaxbase.cpp:1736
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QHash< QUuid, QAxEventSink * > eventSink
Definition: qaxbase.cpp:592
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
uint useEventSink
Definition: qaxbase.cpp:593
uint useClassInfo
Definition: qaxbase.cpp:595
long HRESULT
ITypeLib * typelib
Definition: qaxbase.cpp:1733
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
The QUuid class stores a Universally Unique Identifier (UUID).
Definition: quuid.h:67

◆ readEventInterface()

void MetaObjectGenerator::readEventInterface ( ITypeInfo *  eventinfo,
IConnectionPoint *  cpoint 
)

Definition at line 2772 of file qaxbase.cpp.

Referenced by QAxBase::connectNotify(), qax_readClassInfo(), and readEventInfo().

2773 {
2774  TYPEATTR *eventattr;
2775  eventinfo->GetTypeAttr(&eventattr);
2776  if (!eventattr)
2777  return;
2778  if (eventattr->typekind != TKIND_DISPATCH) {
2779  eventinfo->ReleaseTypeAttr(eventattr);
2780  return;
2781  }
2782 
2783  QAxEventSink *eventSink = 0;
2784  if (d) {
2785  IID conniid;
2786  cpoint->GetConnectionInterface(&conniid);
2787  eventSink = d->eventSink.value(QUuid(conniid));
2788  if (!eventSink) {
2789  eventSink = new QAxEventSink(that);
2790  d->eventSink.insert(QUuid(conniid), eventSink);
2791  eventSink->advise(cpoint, conniid);
2792  }
2793  }
2794 
2795  // get information about all event functions
2796  for (UINT fd = 0; fd < (UINT)eventattr->cFuncs; ++fd) {
2797  FUNCDESC *funcdesc;
2798  eventinfo->GetFuncDesc(fd, &funcdesc);
2799  if (!funcdesc)
2800  break;
2801  if (funcdesc->invkind != INVOKE_FUNC ||
2802  funcdesc->funckind != FUNC_DISPATCH) {
2803  eventinfo->ReleaseTypeAttr(eventattr);
2804  eventinfo->ReleaseFuncDesc(funcdesc);
2805  continue;
2806  }
2807 
2808  QByteArray function;
2810  QList<QByteArray> parameters;
2811 
2812  // parse event function description
2813  BSTR bstrNames[256];
2814  UINT maxNames = 255;
2815  UINT maxNamesOut;
2816  eventinfo->GetNames(funcdesc->memid, (BSTR*)&bstrNames, maxNames, &maxNamesOut);
2817  QList<QByteArray> names;
2818  int p;
2819  for (p = 0; p < (int)maxNamesOut; ++p) {
2820  names << QString::fromWCharArray(bstrNames[p]).toLatin1();
2821  SysFreeString(bstrNames[p]);
2822  }
2823 
2824  // get event function prototype
2825  function = names.at(0);
2826  QByteArray type; // dummy - we don't care about return values for signals
2827  prototype = createPrototype(/*in*/ funcdesc, eventinfo, names, /*out*/type, parameters);
2828  if (!hasSignal(prototype)) {
2829  QByteArray pnames;
2830  for (p = 0; p < parameters.count(); ++p) {
2831  pnames += parameters.at(p);
2832  if (p < parameters.count() - 1)
2833  pnames += ',';
2834  }
2835  addSignal(prototype, pnames);
2836  }
2837  if (eventSink)
2838  eventSink->addSignal(funcdesc->memid, prototype);
2839 
2840 #if 0 // documentation in metaobject would be cool?
2841  // get function documentation
2842  BSTR bstrDocu;
2843  eventinfo->GetDocumentation(funcdesc->memid, 0, &bstrDocu, 0, 0);
2844  QString strDocu = QString::fromWCharArray(bstrDocu);
2845  SysFreeString(bstrDocu);
2846  if (!!strDocu)
2847  desc += '[' + strDocu + ']';
2848  desc += '\n';
2849 #endif
2850  eventinfo->ReleaseFuncDesc(funcdesc);
2851  }
2852  eventinfo->ReleaseTypeAttr(eventattr);
2853 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
int type
Definition: qmetatype.cpp:239
QAxBasePrivate * d
Definition: qaxbase.cpp:1728
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void advise(IConnectionPoint *cp, IID iid)
Definition: qaxbase.cpp:240
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QHash< QUuid, QAxEventSink * > eventSink
Definition: qaxbase.cpp:592
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void addSignal(DISPID memid, const char *name)
Definition: qaxbase.cpp:259
bool hasSignal(const QByteArray &prototype)
Definition: qaxbase.cpp:1641
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
void addSignal(const QByteArray &prototype, const QByteArray &parameters)
Definition: qaxbase.cpp:1627
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685
QByteArray createPrototype(FUNCDESC *funcdesc, ITypeInfo *typeinfo, const QList< QByteArray > &names, QByteArray &type, QList< QByteArray > &parameters)
Definition: qaxbase.cpp:2384
The QUuid class stores a Universally Unique Identifier (UUID).
Definition: quuid.h:67

◆ readFuncsInfo()

void MetaObjectGenerator::readFuncsInfo ( ITypeInfo *  typeinfo,
ushort  nFuncs 
)

Definition at line 2451 of file qaxbase.cpp.

Referenced by qax_readClassInfo(), qax_readInterfaceInfo(), and readInterfaceInfo().

2452 {
2453  if (!nFuncs) {
2454  TYPEATTR *typeattr = 0;
2455  typeinfo->GetTypeAttr(&typeattr);
2456  if (typeattr) {
2457  nFuncs = typeattr->cFuncs;
2458  typeinfo->ReleaseTypeAttr(typeattr);
2459  }
2460  }
2461 
2462  // get information about all functions
2463  for (ushort fd = 0; fd < nFuncs ; ++fd) {
2464  FUNCDESC *funcdesc = 0;
2465  typeinfo->GetFuncDesc(fd, &funcdesc);
2466  if (!funcdesc)
2467  break;
2468 
2469  QByteArray function;
2470  QByteArray type;
2472  QList<QByteArray> parameters;
2473 
2474  // parse function description
2475  BSTR bstrNames[256];
2476  UINT maxNames = 255;
2477  UINT maxNamesOut;
2478  typeinfo->GetNames(funcdesc->memid, (BSTR*)&bstrNames, maxNames, &maxNamesOut);
2479  QList<QByteArray> names;
2480  int p;
2481  for (p = 0; p < (int)maxNamesOut; ++p) {
2482  names << QString::fromWCharArray(bstrNames[p]).toLatin1();
2483  SysFreeString(bstrNames[p]);
2484  }
2485 
2486  // function name
2487  function = names.at(0);
2488  if ((maxNamesOut == 3 && function == "QueryInterface") ||
2489  (maxNamesOut == 1 && function == "AddRef") ||
2490  (maxNamesOut == 1 && function == "Release") ||
2491  (maxNamesOut == 9 && function == "Invoke") ||
2492  (maxNamesOut == 6 && function == "GetIDsOfNames") ||
2493  (maxNamesOut == 2 && function == "GetTypeInfoCount") ||
2494  (maxNamesOut == 4 && function == "GetTypeInfo")) {
2495  typeinfo->ReleaseFuncDesc(funcdesc);
2496  continue;
2497  }
2498 
2499  prototype = createPrototype(/*in*/ funcdesc, typeinfo, names, /*out*/type, parameters);
2500 
2501  // get type of function
2502  switch(funcdesc->invkind) {
2503  case INVOKE_PROPERTYGET: // property
2504  case INVOKE_PROPERTYPUT:
2505  if (funcdesc->cParams - funcdesc->cParamsOpt <= 1) {
2506  bool dontBreak = false;
2507  // getter with non-default-parameters -> fall through to function handling
2508  if (funcdesc->invkind == INVOKE_PROPERTYGET && parameters.count() && funcdesc->cParams - funcdesc->cParamsOpt) {
2509  dontBreak = true;
2510  } else {
2511  uint flags = Readable;
2512  if (funcdesc->invkind != INVOKE_PROPERTYGET)
2513  flags |= Writable;
2514  if (!(funcdesc->wFuncFlags & (FUNCFLAG_FNONBROWSABLE | FUNCFLAG_FHIDDEN)))
2515  flags |= Designable;
2516  if (!(funcdesc->wFuncFlags & FUNCFLAG_FRESTRICTED))
2517  flags |= Scriptable;
2518  if (funcdesc->wFuncFlags & FUNCFLAG_FREQUESTEDIT)
2519  flags |= RequestingEdit;
2520  if (hasEnum(type))
2521  flags |= EnumOrFlag;
2522 
2523  if (funcdesc->wFuncFlags & FUNCFLAG_FBINDABLE && funcdesc->invkind == INVOKE_PROPERTYGET) {
2524  addChangedSignal(function, type, funcdesc->memid);
2525  flags |= Bindable;
2526  }
2527  // Don't generate code for properties without type
2528  if (type.isEmpty())
2529  break;
2530  addProperty(type, function, flags);
2531 
2532  // more parameters -> function handling
2533  if (funcdesc->invkind == INVOKE_PROPERTYGET && funcdesc->cParams)
2534  dontBreak = true;
2535  }
2536 
2537  if (!funcdesc->cParams) {
2538  // don't generate slots for incomplete properties
2539  if (type.isEmpty())
2540  break;
2541 
2542  // Done for getters
2543  if (funcdesc->invkind == INVOKE_PROPERTYGET)
2544  break;
2545 
2546  // generate setter slot
2547  if (funcdesc->invkind == INVOKE_PROPERTYPUT && hasProperty(function)) {
2548  addSetterSlot(function);
2549  break;
2550  }
2551  } else if (funcdesc->invkind == INVOKE_PROPERTYPUT && hasProperty(function)) {
2552  addSetterSlot(function);
2553  // more parameters -> function handling
2554  if (funcdesc->cParams > 1)
2555  dontBreak = true;
2556  }
2557  if (!dontBreak)
2558  break;
2559  }
2560  if (funcdesc->invkind == INVOKE_PROPERTYPUT) {
2561  // remove the typename guessed for property setters
2562  // its done only for setter's with more than one parameter.
2563  if (funcdesc->cParams - funcdesc->cParamsOpt > 1) {
2564  type.clear();
2565  }
2566  QByteArray set;
2567  if (isupper(prototype.at(0))) {
2568  set = "Set";
2569  } else {
2570  set = "set";
2571  prototype[0] = toupper(prototype[0]);
2572  }
2573 
2574  prototype = set + prototype;
2575  }
2576  // FALL THROUGH to support multi-variat properties
2577  case INVOKE_FUNC: // method
2578  {
2579  bool cloned = false;
2580  bool defargs;
2581  do {
2582  QByteArray pnames;
2583  for (p = 0; p < parameters.count(); ++p) {
2584  pnames += parameters.at(p);
2585  if (p < parameters.count() - 1)
2586  pnames += ',';
2587  }
2588  defargs = pnames.contains("=0");
2589  int flags = QMetaMethod::Public;
2590  if (cloned)
2591  flags |= QMetaMethod::Cloned << 4;
2592  cloned |= defargs;
2593  addSlot(type, prototype, pnames.replace("=0", ""), flags);
2594 
2595  if (defargs) {
2596  parameters.takeLast();
2597  int lastParam = prototype.lastIndexOf(',');
2598  if (lastParam == -1)
2599  lastParam = prototype.indexOf('(') + 1;
2600  prototype.truncate(lastParam);
2601  prototype += ')';
2602  }
2603  } while (defargs);
2604  }
2605  break;
2606 
2607  default:
2608  break;
2609  }
2610 #if 0 // documentation in metaobject would be cool?
2611  // get function documentation
2612  BSTR bstrDocu;
2613  info->GetDocumentation(funcdesc->memid, 0, &bstrDocu, 0, 0);
2614  QString strDocu = QString::fromWCharArray(bstrDocu);
2615  SysFreeString(bstrDocu);
2616  if (!!strDocu)
2617  desc += '[' + strDocu + ']';
2618  desc += '\n';
2619 #endif
2620  typeinfo->ReleaseFuncDesc(funcdesc);
2621  }
2622 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
bool hasEnum(const QByteArray &enumname)
Definition: qaxbase.cpp:1722
void addProperty(const QByteArray &type, const QByteArray &name, uint flags)
Definition: qaxbase.cpp:1674
int type
Definition: qmetatype.cpp:239
void truncate(int pos)
Truncates the byte array at index position pos.
static mach_timebase_info_data_t info
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool hasProperty(const QByteArray &name)
Definition: qaxbase.cpp:1706
int lastIndexOf(char c, int from=-1) const
Returns the index position of the last occurrence of character ch in the byte array, searching backward from index position from.
void addSlot(const QByteArray &type, const QByteArray &prototype, const QByteArray &parameters, int flags=QMetaMethod::Public)
Definition: qaxbase.cpp:1647
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
unsigned int uint
Definition: qglobal.h:996
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685
void addSetterSlot(const QByteArray &property)
Definition: qaxbase.cpp:2369
unsigned short ushort
Definition: qglobal.h:995
QByteArray createPrototype(FUNCDESC *funcdesc, ITypeInfo *typeinfo, const QList< QByteArray > &names, QByteArray &type, QList< QByteArray > &parameters)
Definition: qaxbase.cpp:2384
T takeLast()
Removes the last item in the list and returns it.
Definition: qlist.h:492
QByteArray & replace(int index, int len, const char *s)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
char at(int i) const
Returns the character at index position i in the byte array.
Definition: qbytearray.h:413
void clear()
Clears the contents of the byte array and makes it empty.
void addChangedSignal(const QByteArray &function, const QByteArray &type, int memid)
Definition: qaxbase.cpp:2349
QBool contains(char c) const
Returns true if the byte array contains the character ch; otherwise returns false.
Definition: qbytearray.h:525

◆ readInterfaceInfo()

void MetaObjectGenerator::readInterfaceInfo ( )

Definition at line 2707 of file qaxbase.cpp.

Referenced by metaObject().

2708 {
2709  ITypeInfo *typeinfo = dispInfo;
2710  if (!typeinfo)
2711  return;
2712  typeinfo->AddRef();
2713  int interface_serial = 0;
2714  while (typeinfo) {
2715  ushort nFuncs = 0;
2716  ushort nVars = 0;
2717  ushort nImpl = 0;
2718  // get information about type
2719  TYPEATTR *typeattr;
2720  typeinfo->GetTypeAttr(&typeattr);
2721  bool interesting = true;
2722  if (typeattr) {
2723  // get number of functions, variables, and implemented interfaces
2724  nFuncs = typeattr->cFuncs;
2725  nVars = typeattr->cVars;
2726  nImpl = typeattr->cImplTypes;
2727 
2728  if ((typeattr->typekind == TKIND_DISPATCH || typeattr->typekind == TKIND_INTERFACE) &&
2729  (typeattr->guid != IID_IDispatch && typeattr->guid != IID_IUnknown)) {
2730 #ifndef QAX_NO_CLASSINFO
2731  if (d && d->useClassInfo) {
2732  // UUID
2733  QUuid uuid(typeattr->guid);
2734  QString uuidstr = uuid.toString().toUpper();
2735  uuidstr = iidnames.value(QLatin1String("/Interface/") + uuidstr + QLatin1String("/Default"), uuidstr).toString();
2736  addClassInfo("Interface " + QByteArray::number(++interface_serial), uuidstr.toLatin1());
2737  }
2738 #endif
2739  typeinfo->ReleaseTypeAttr(typeattr);
2740  } else {
2741  interesting = false;
2742  typeinfo->ReleaseTypeAttr(typeattr);
2743  }
2744  }
2745 
2746  if (interesting) {
2747  readFuncsInfo(typeinfo, nFuncs);
2748  readVarsInfo(typeinfo, nVars);
2749  }
2750 
2751  if (!nImpl) {
2752  typeinfo->Release();
2753  typeinfo = 0;
2754  break;
2755  }
2756 
2757  // go up one base class
2758  HREFTYPE pRefType;
2759  typeinfo->GetRefTypeOfImplType(0, &pRefType);
2760  ITypeInfo *baseInfo = 0;
2761  typeinfo->GetRefTypeInfo(pRefType, &baseInfo);
2762  typeinfo->Release();
2763  if (typeinfo == baseInfo) { // IUnknown inherits IUnknown ???
2764  baseInfo->Release();
2765  typeinfo = 0;
2766  break;
2767  }
2768  typeinfo = baseInfo;
2769  }
2770 }
QAxBasePrivate * d
Definition: qaxbase.cpp:1728
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for setting key.
Definition: qsettings.cpp:3460
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
void addClassInfo(const char *key, const char *value)
Definition: qaxbase.cpp:1510
QSettings iidnames
Definition: qaxbase.cpp:1736
void readVarsInfo(ITypeInfo *typeinfo, ushort nVars)
Definition: qaxbase.cpp:2624
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
void readFuncsInfo(ITypeInfo *typeinfo, ushort nFuncs)
Definition: qaxbase.cpp:2451
uint useClassInfo
Definition: qaxbase.cpp:595
unsigned short ushort
Definition: qglobal.h:995
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
The QUuid class stores a Universally Unique Identifier (UUID).
Definition: quuid.h:67
ITypeInfo * dispInfo
Definition: qaxbase.cpp:1731

◆ readVarsInfo()

void MetaObjectGenerator::readVarsInfo ( ITypeInfo *  typeinfo,
ushort  nVars 
)

Definition at line 2624 of file qaxbase.cpp.

Referenced by qax_readClassInfo(), qax_readInterfaceInfo(), and readInterfaceInfo().

2625 {
2626  if (!nVars) {
2627  TYPEATTR *typeattr = 0;
2628  typeinfo->GetTypeAttr(&typeattr);
2629  if (typeattr) {
2630  nVars = typeattr->cVars;
2631  typeinfo->ReleaseTypeAttr(typeattr);
2632  }
2633  }
2634 
2635  // get information about all variables
2636  for (ushort vd = 0; vd < nVars; ++vd) {
2637  VARDESC *vardesc;
2638  typeinfo->GetVarDesc(vd, &vardesc);
2639  if (!vardesc)
2640  break;
2641 
2642  // no use if it's not a dispatched variable
2643  if (vardesc->varkind != VAR_DISPATCH) {
2644  typeinfo->ReleaseVarDesc(vardesc);
2645  continue;
2646  }
2647 
2648  // get variable name
2649  BSTR bstrName;
2650  UINT maxNames = 1;
2651  UINT maxNamesOut;
2652  typeinfo->GetNames(vardesc->memid, &bstrName, maxNames, &maxNamesOut);
2653  if (maxNamesOut != 1 || !bstrName) {
2654  typeinfo->ReleaseVarDesc(vardesc);
2655  continue;
2656  }
2657  QByteArray variableType;
2658  QByteArray variableName;
2659  uint flags = 0;
2660 
2661  variableName = QString::fromWCharArray(bstrName).toLatin1();
2662  SysFreeString(bstrName);
2663 
2664  // get variable type
2665  TYPEDESC typedesc = vardesc->elemdescVar.tdesc;
2666  variableType = guessTypes(typedesc, typeinfo, variableName);
2667 
2668  // generate meta property
2669  if (!hasProperty(variableName)) {
2670  flags = Readable;
2671  if (!(vardesc->wVarFlags & VARFLAG_FREADONLY))
2672  flags |= Writable;
2673  if (!(vardesc->wVarFlags & (VARFLAG_FNONBROWSABLE | VARFLAG_FHIDDEN)))
2674  flags |= Designable;
2675  if (!(vardesc->wVarFlags & VARFLAG_FRESTRICTED))
2676  flags |= Scriptable;
2677  if (vardesc->wVarFlags & VARFLAG_FREQUESTEDIT)
2678  flags |= RequestingEdit;
2679  if (hasEnum(variableType))
2680  flags |= EnumOrFlag;
2681 
2682  if (vardesc->wVarFlags & VARFLAG_FBINDABLE) {
2683  addChangedSignal(variableName, variableType, vardesc->memid);
2684  flags |= Bindable;
2685  }
2686  addProperty(variableType, variableName, flags);
2687  }
2688 
2689  // generate a set slot
2690  if (!(vardesc->wVarFlags & VARFLAG_FREADONLY))
2691  addSetterSlot(variableName);
2692 
2693 #if 0 // documentation in metaobject would be cool?
2694  // get function documentation
2695  BSTR bstrDocu;
2696  info->GetDocumentation(vardesc->memid, 0, &bstrDocu, 0, 0);
2697  QString strDocu = QString::fromWCharArray(bstrDocu);
2698  SysFreeString(bstrDocu);
2699  if (!!strDocu)
2700  desc += '[' + strDocu + ']';
2701  desc += '\n';
2702 #endif
2703  typeinfo->ReleaseVarDesc(vardesc);
2704  }
2705 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
bool hasEnum(const QByteArray &enumname)
Definition: qaxbase.cpp:1722
void addProperty(const QByteArray &type, const QByteArray &name, uint flags)
Definition: qaxbase.cpp:1674
static mach_timebase_info_data_t info
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool hasProperty(const QByteArray &name)
Definition: qaxbase.cpp:1706
QByteArray guessTypes(const TYPEDESC &tdesc, ITypeInfo *info, const QByteArray &function)
Definition: qaxbase.cpp:1977
unsigned int uint
Definition: qglobal.h:996
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
void addSetterSlot(const QByteArray &property)
Definition: qaxbase.cpp:2369
unsigned short ushort
Definition: qglobal.h:995
void addChangedSignal(const QByteArray &function, const QByteArray &type, int memid)
Definition: qaxbase.cpp:2349

◆ replacePrototype()

QByteArray MetaObjectGenerator::replacePrototype ( const QByteArray prototype)
inlineprivate

Definition at line 1588 of file qaxbase.cpp.

1589  {
1590  QByteArray proto(prototype);
1591 
1592  QList<QByteArray> plist = paramList(prototype);
1593  for (int p = 0; p < plist.count(); ++p) {
1594  QByteArray param(plist.at(p));
1595  if (param != replaceType(param)) {
1596  int type = 0;
1597  while (type_conversion[type][0]) {
1598  int paren = proto.indexOf('(');
1599  while ((paren = proto.indexOf(type_conversion[type][0])) != -1) {
1600  proto.replace(paren, qstrlen(type_conversion[type][0]), type_conversion[type][1]);
1601  }
1602  ++type;
1603  }
1604  break;
1605  }
1606  }
1607 
1608  return proto;
1609  }
int type
Definition: qmetatype.cpp:239
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
uint qstrlen(const char *str)
Definition: qbytearray.h:79
static const char *const type_conversion[][2]
Definition: qaxbase.cpp:189
QList< QByteArray > paramList(const QByteArray &proto)
Definition: qaxbase.cpp:1562
QByteArray replaceType(const QByteArray &type)
Definition: qaxbase.cpp:1572

◆ replaceType()

QByteArray MetaObjectGenerator::replaceType ( const QByteArray type)
inlineprivate

Definition at line 1572 of file qaxbase.cpp.

Referenced by addChangedSignal().

1573  {
1574  int i = 0;
1575  while (type_conversion[i][0]) {
1576  int len = int(strlen(type_conversion[i][0]));
1577  int ti;
1578  if ((ti = type.indexOf(type_conversion[i][0])) != -1) {
1579  QByteArray rtype(type);
1580  rtype.replace(ti, len, type_conversion[i][1]);
1581  return rtype;
1582  }
1583  ++i;
1584  }
1585  return type;
1586  }
int type
Definition: qmetatype.cpp:239
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
static const char *const type_conversion[][2]
Definition: qaxbase.cpp:189

◆ tryCache()

QMetaObject * MetaObjectGenerator::tryCache ( )
private

Definition at line 2959 of file qaxbase.cpp.

Referenced by metaObject().

2960 {
2961  if (!cacheKey.isEmpty()) {
2962  d->metaobj = mo_cache.value(cacheKey);
2963  if (d->metaobj) {
2964  d->cachedMetaObject = true;
2965 
2966  IConnectionPointContainer *cpoints = 0;
2967  d->ptr->QueryInterface(IID_IConnectionPointContainer, (void**)&cpoints);
2968  if (cpoints) {
2970  while (it != d->metaobj->connectionInterfaces.end()) {
2971  QUuid iid = *it;
2972  ++it;
2973 
2974  IConnectionPoint *cpoint = 0;
2975  cpoints->FindConnectionPoint(iid, &cpoint);
2976  if (cpoint) {
2977  QAxEventSink *sink = new QAxEventSink(that);
2978  sink->advise(cpoint, iid);
2979  d->eventSink.insert(iid, sink);
2980  sink->sigs = d->metaobj->sigs.value(iid);
2981  sink->props = d->metaobj->props.value(iid);
2982  sink->propsigs = d->metaobj->propsigs.value(iid);
2983  cpoint->Release();
2984  }
2985  }
2986  cpoints->Release();
2987  }
2988 
2989  return d->metaobj;
2990  }
2991  }
2992  return 0;
2993 }
static QHash< QString, QAxMetaObject * > mo_cache
Definition: qaxbase.cpp:183
IUnknown * ptr
Definition: qaxbase.cpp:600
QAxBasePrivate * d
Definition: qaxbase.cpp:1728
QMap< DISPID, QByteArray > sigs
Definition: qaxbase.cpp:536
#define it(className, varName)
QMap< QUuid, QMap< DISPID, QByteArray > > props
Definition: qaxbase.cpp:105
QAxMetaObject * metaobj
Definition: qaxbase.cpp:614
void advise(IConnectionPoint *cp, IID iid)
Definition: qaxbase.cpp:240
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QHash< QUuid, QAxEventSink * > eventSink
Definition: qaxbase.cpp:592
QMap< QUuid, QMap< DISPID, QByteArray > > sigs
Definition: qaxbase.cpp:101
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
uint cachedMetaObject
Definition: qaxbase.cpp:596
QMap< DISPID, QByteArray > propsigs
Definition: qaxbase.cpp:537
QMap< DISPID, QByteArray > props
Definition: qaxbase.cpp:538
QMap< QUuid, QMap< DISPID, QByteArray > > propsigs
Definition: qaxbase.cpp:103
The QUuid class stores a Universally Unique Identifier (UUID).
Definition: quuid.h:67
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
QList< QUuid > connectionInterfaces
Definition: qaxbase.cpp:99

◆ usertypeToString()

QByteArray MetaObjectGenerator::usertypeToString ( const TYPEDESC &  tdesc,
ITypeInfo *  info,
const QByteArray function 
)
private

Definition at line 1889 of file qaxbase.cpp.

Referenced by guessTypes().

1890 {
1891  HREFTYPE usertype = tdesc.hreftype;
1892  if (tdesc.vt != VT_USERDEFINED)
1893  return 0;
1894 
1896  ITypeInfo *usertypeinfo = 0;
1897  info->GetRefTypeInfo(usertype, &usertypeinfo);
1898  if (usertypeinfo) {
1899  ITypeLib *usertypelib = 0;
1900  UINT index;
1901  usertypeinfo->GetContainingTypeLib(&usertypelib, &index);
1902  if (usertypelib) {
1903  // get type library name
1904  BSTR typelibname = 0;
1905  usertypelib->GetDocumentation(-1, &typelibname, 0, 0, 0);
1906  QByteArray typeLibName = QString::fromWCharArray(typelibname).toLatin1();
1907  SysFreeString(typelibname);
1908 
1909  // get type name
1910  BSTR usertypename = 0;
1911  usertypelib->GetDocumentation(index, &usertypename, 0, 0, 0);
1912  QByteArray userTypeName = QString::fromWCharArray(usertypename).toLatin1();
1913  SysFreeString(usertypename);
1914 
1915  if (hasEnum(userTypeName)) // known enum?
1916  typeName = userTypeName;
1917  else if (userTypeName == "OLE_COLOR" || userTypeName == "VB_OLE_COLOR")
1918  typeName = "QColor";
1919  else if (userTypeName == "IFontDisp" || userTypeName == "IFontDisp*" || userTypeName == "IFont" || userTypeName == "IFont*")
1920  typeName = "QFont";
1921  else if (userTypeName == "Picture" || userTypeName == "Picture*")
1922  typeName = "QPixmap";
1923 
1924  if (typeName.isEmpty()) {
1925  TYPEATTR *typeattr = 0;
1926  usertypeinfo->GetTypeAttr(&typeattr);
1927  if (typeattr) {
1928  switch(typeattr->typekind) {
1929  case TKIND_ALIAS:
1930  userTypeName = guessTypes(typeattr->tdescAlias, usertypeinfo, function);
1931  break;
1932  case TKIND_DISPATCH:
1933  case TKIND_COCLASS:
1935  userTypeName = "IDispatch";
1936  } else {
1937  if (typeLibName != current_typelib)
1938  userTypeName = typeLibName + "::" + userTypeName;
1939  if (!qax_qualified_usertypes.contains(userTypeName))
1940  qax_qualified_usertypes << userTypeName;
1941  }
1942  break;
1943  case TKIND_ENUM:
1944  if (typeLibName != current_typelib)
1945  userTypeName = typeLibName + "::" + userTypeName;
1946  if (!qax_qualified_usertypes.contains("enum " + userTypeName))
1947  qax_qualified_usertypes << "enum " + userTypeName;
1948  break;
1949  case TKIND_INTERFACE:
1950  if (typeLibName != current_typelib)
1951  userTypeName = typeLibName + "::" + userTypeName;
1952  if (!qax_qualified_usertypes.contains(userTypeName))
1953  qax_qualified_usertypes << userTypeName;
1954  break;
1955  case TKIND_RECORD:
1956  if (!qax_qualified_usertypes.contains("struct " + userTypeName))
1957  qax_qualified_usertypes << "struct "+ userTypeName;
1958  break;
1959  default:
1960  break;
1961  }
1962  }
1963 
1964  usertypeinfo->ReleaseTypeAttr(typeattr);
1965  typeName = userTypeName;
1966  }
1967  usertypelib->Release();
1968  }
1969  usertypeinfo->Release();
1970  }
1971 
1972  return typeName;
1973 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
bool hasEnum(const QByteArray &enumname)
Definition: qaxbase.cpp:1722
bool qax_dispatchEqualsIDispatch
Definition: qaxbase.cpp:1886
static mach_timebase_info_data_t info
QList< QByteArray > qax_qualified_usertypes
Definition: qaxbase.cpp:1887
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QByteArray guessTypes(const TYPEDESC &tdesc, ITypeInfo *info, const QByteArray &function)
Definition: qaxbase.cpp:1977
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
const char * typeName
Definition: qmetatype.cpp:239
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
quint16 index
QByteArray current_typelib
Definition: qaxbase.cpp:1734
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421

Friends and Related Functions

◆ qax_readClassInfo

QMetaObject* qax_readClassInfo ( ITypeLib *  typeLib,
ITypeInfo *  classInfo,
const QMetaObject parentObject 
)
friend

Definition at line 1772 of file qaxbase.cpp.

1773 {
1774  MetaObjectGenerator generator(typeLib, 0);
1775  generator.addSignal("exception(int,QString,QString,QString)", "code,source,disc,help");
1776  generator.addSignal("propertyChanged(QString)", "name");
1777 
1779  BSTR bstr;
1780  if (S_OK != classInfo->GetDocumentation(-1, &bstr, 0, 0, 0))
1781  return 0;
1782 
1783  className = QString::fromWCharArray(bstr);
1784  SysFreeString(bstr);
1785 
1786  generator.readEnumInfo();
1787 
1788  TYPEATTR *typeattr;
1789  classInfo->GetTypeAttr(&typeattr);
1790  if (typeattr) {
1791  int nInterfaces = typeattr->cImplTypes;
1792  classInfo->ReleaseTypeAttr(typeattr);
1793 
1794  for (int index = 0; index < nInterfaces; ++index) {
1795  HREFTYPE refType;
1796  if (S_OK != classInfo->GetRefTypeOfImplType(index, &refType))
1797  continue;
1798 
1799  int flags = 0;
1800  classInfo->GetImplTypeFlags(index, &flags);
1801  if (flags & IMPLTYPEFLAG_FRESTRICTED)
1802  continue;
1803 
1804  ITypeInfo *interfaceInfo = 0;
1805  classInfo->GetRefTypeInfo(refType, &interfaceInfo);
1806  if (!interfaceInfo)
1807  continue;
1808 
1809  interfaceInfo->GetDocumentation(-1, &bstr, 0, 0, 0);
1810  QString interfaceName = QString::fromWCharArray(bstr);
1811  SysFreeString(bstr);
1812  QByteArray key;
1813 
1814  TYPEATTR *typeattr = 0;
1815  interfaceInfo->GetTypeAttr(&typeattr);
1816 
1817  if (flags & IMPLTYPEFLAG_FSOURCE) {
1818  if (typeattr && !(typeattr->wTypeFlags & TYPEFLAG_FHIDDEN))
1819  key = "Event Interface " + QByteArray::number(index);
1820  generator.readEventInterface(interfaceInfo, 0);
1821  } else {
1822  if (typeattr && !(typeattr->wTypeFlags & TYPEFLAG_FHIDDEN))
1823  key = "Interface " + QByteArray::number(index);
1824  generator.readFuncsInfo(interfaceInfo, 0);
1825  generator.readVarsInfo(interfaceInfo, 0);
1826  }
1827  if (!key.isEmpty())
1828  generator.addClassInfo(key.data(), interfaceName.toLatin1());
1829 
1830  if (typeattr)
1831  interfaceInfo->ReleaseTypeAttr(typeattr);
1832  interfaceInfo->Release();
1833  }
1834  }
1835 
1836  return generator.metaObject(parentObject, className.toLatin1());
1837 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
ITypeInfo * classInfo
Definition: qaxbase.cpp:1732
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QString class provides a Unicode character string.
Definition: qstring.h:83
const char * className
Definition: qwizard.cpp:137
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
int key
quint16 index
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...

Properties

◆ cacheKey

QString MetaObjectGenerator::cacheKey
private

Definition at line 1737 of file qaxbase.cpp.

Referenced by metaObject(), readClassInfo(), and tryCache().

◆ classInfo

ITypeInfo* MetaObjectGenerator::classInfo
private

Definition at line 1732 of file qaxbase.cpp.

Referenced by readClassInfo(), readEventInfo(), and ~MetaObjectGenerator().

◆ classinfo_list

QMap<QByteArray, QByteArray> MetaObjectGenerator::classinfo_list
private

Definition at line 1611 of file qaxbase.cpp.

Referenced by metaObject().

◆ current_typelib

QByteArray MetaObjectGenerator::current_typelib
private

Definition at line 1734 of file qaxbase.cpp.

Referenced by metaObject(), MetaObjectGenerator(), and usertypeToString().

◆ d

QAxBasePrivate* MetaObjectGenerator::d
private

◆ debugInfo

QByteArray MetaObjectGenerator::debugInfo
private

Definition at line 1738 of file qaxbase.cpp.

Referenced by metaObject().

◆ disp

IDispatch* MetaObjectGenerator::disp
private

◆ dispInfo

ITypeInfo* MetaObjectGenerator::dispInfo
private

◆ enum_list

QMap<QByteArray, QList<QPair<QByteArray, int> > > MetaObjectGenerator::enum_list
private

Definition at line 1716 of file qaxbase.cpp.

Referenced by metaObject(), and readEnumInfo().

◆ iid_propNotifySink

QUuid MetaObjectGenerator::iid_propNotifySink
private

Definition at line 1740 of file qaxbase.cpp.

Referenced by addChangedSignal(), init(), and readEventInfo().

◆ iidnames

QSettings MetaObjectGenerator::iidnames
private

Definition at line 1736 of file qaxbase.cpp.

Referenced by readClassInfo(), readEventInfo(), and readInterfaceInfo().

◆ property_list

QMap<QByteArray, Property> MetaObjectGenerator::property_list
private

Definition at line 1673 of file qaxbase.cpp.

Referenced by metaObject().

◆ signal_list

QMap<QByteArray, Method> MetaObjectGenerator::signal_list
private

Definition at line 1626 of file qaxbase.cpp.

Referenced by metaObject().

◆ slot_list

QMap<QByteArray, Method> MetaObjectGenerator::slot_list
private

Definition at line 1646 of file qaxbase.cpp.

Referenced by metaObject().

◆ that

QAxBase* MetaObjectGenerator::that
private

◆ typelib

ITypeLib* MetaObjectGenerator::typelib
private

The documentation for this class was generated from the following file: