コード例 #1
0
ファイル: PyIType.cpp プロジェクト: malrsrch/pywin32
PyObject *PyITypeInfo::GetRefTypeInfo(HREFTYPE href)
{
	ITypeInfo *pti;
	ITypeInfo *pMyTypeInfo = GetI(this);
	if (pMyTypeInfo==NULL) return NULL;
	PY_INTERFACE_PRECALL;
	SCODE sc = pMyTypeInfo->GetRefTypeInfo(href, &pti);
	PY_INTERFACE_POSTCALL;
	if (FAILED(sc))
		return PyCom_BuildPyException(sc, pMyTypeInfo, IID_ITypeInfo);
	return new PyITypeInfo(pti);
}
コード例 #2
0
ファイル: TypeInfo.cpp プロジェクト: enebo/racob
JNIEXPORT jobject JNICALL Java_org_racob_com_TypeInfo_getRefTypeInfo
  (JNIEnv *env, jobject obj, jint pointer, jint reftype) {
   ITypeInfo *typeInfo = (ITypeInfo *) pointer;
   ITypeInfo *newTypeInfo = NULL;
   HRESULT hr = typeInfo->GetRefTypeInfo(reftype, &newTypeInfo);
   if (!SUCCEEDED(hr)) {
      ThrowComFail(env, "getRefTypeInfo failed", hr);
      return NULL;
   }

   return makeTypeInfo(env, newTypeInfo);
}
コード例 #3
0
CLSID tCOMUtil::FindCLSID(ITypeInfo* interface_typeinfo)
{
  ITypeLib* ptypelib    = NULL;
  ITypeInfo* ptypeinfo  = NULL;
  long count            = 0;
  IID iid               = IID_NULL;
  TYPEATTR* ptypeattr   = NULL;
  TYPEKIND tkind;
  bool found            = false;
  CLSID clsid           = IID_NULL;

  // gets IID
  interface_typeinfo->GetTypeAttr(&ptypeattr);

  iid = ptypeattr->guid;
  interface_typeinfo->ReleaseTypeAttr(ptypeattr);
  ptypeattr = NULL;

  // Gets type library
  interface_typeinfo->GetContainingTypeLib(&ptypelib, NULL);

  // iterates looking for IID inside some coclass
  count = ptypelib->GetTypeInfoCount();

  while(count-- && !found)
  {
    ptypelib->GetTypeInfoType(count, &tkind);

    if(tkind != TKIND_COCLASS)
      continue;

    // look inside
    ptypelib->GetTypeInfo(count, &ptypeinfo);

    // gets counts and clsid
    ptypeinfo->GetTypeAttr(&ptypeattr);
    long ifaces_count   = ptypeattr->cImplTypes;
    clsid = ptypeattr->guid;

    ptypeinfo->ReleaseTypeAttr(ptypeattr);
    ptypeattr = NULL;

    TYPEFLAGS typeflags;
    HREFTYPE RefType;
    ITypeInfo* piface_typeinfo = NULL;

    while(ifaces_count-- && !found)
    {
      ptypeinfo->GetRefTypeOfImplType(ifaces_count, &RefType);
      ptypeinfo->GetRefTypeInfo(RefType, &piface_typeinfo);
      piface_typeinfo->GetTypeAttr(&ptypeattr);

      if(IsEqualIID(ptypeattr->guid, iid))
      {
        found = true;
      }

      piface_typeinfo->ReleaseTypeAttr(ptypeattr);
      ptypeattr = NULL;

      COM_RELEASE(piface_typeinfo);
    }

    COM_RELEASE(ptypeinfo);
  }

  COM_RELEASE(ptypelib);

  return clsid;
}
コード例 #4
0
ファイル: tree.cpp プロジェクト: jetlive/skiaming
BOOL CTreeItem::ExpandTypeInfo( HTREEITEM hitem )
{
	ASSERT(m_pTree) ;
	ASSERT(hitem) ;

	CTreeItem*  pNewItem = NULL ;
	HRESULT         hr = S_OK ;
	TV_INSERTSTRUCT tvis ;
	CString         strError = "Enumerating TypeInfo" ;
	TYPEATTR*       pattr = NULL ;
	ITypeInfo*      pti = GetTypeInfo() ;
	ASSERT(pti) ;
	BOOL            fExpand = FALSE ;

	tvis.hParent = hitem  ;
	tvis.hInsertAfter = TVI_LAST ;
	tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN ;
	tvis.item.iImage = typeUnknown ;
	tvis.item.iSelectedImage = tvis.item.iImage + 1 ;

	TRY
	{
		ENSURE(pti);
		hr = pti->GetTypeAttr(&pattr) ;
		if FAILED(hr)
		{
			strError.Format(_T("ITypeInfo::GetTypeAttr() failed"), hr ) ;
			AfxThrowMemoryException() ;
		}

		switch(pattr->typekind)
		{
		// typedef [attributes] enum [tag] {
		//      enumlist
		// } enumname;
		//
		// "typedef enum enumname"
		case TKIND_ENUM:
			fExpand = ExpandVars( hitem ) ;
		break ;

		// typedef [attributes]
		//  struct [tag] {
		//      memberlist
		//  } structname;
		//
		// "typedef struct structname"
		case TKIND_RECORD:
			fExpand = ExpandVars( hitem ) ;
		break ;

		// [attributes]
		//  module modulename {
		//      elementlist
		// };
		case TKIND_MODULE:
			if (pattr->cVars)
			{
				// Add "Constants" folder
				//
				#pragma warning (suppress: 6211)
				#pragma warning (suppress: 6014)
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeProperties ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cVars ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Constants") ;
				tvis.item.iImage = typeConstants ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
			if (pattr->cFuncs)
			{
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeMethods ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cFuncs ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Functions") ;
				tvis.item.iImage = typeMethods ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
		break ;

		// [attributes]
		//  interface interfacename  [:baseinterface] {
		//      functionlist
		// };
		case TKIND_INTERFACE:
			fExpand = ExpandFuncs( hitem) ;
			if (pattr->cImplTypes)
			{
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeImplTypes ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.pszText = _T("Inherited Interfaces") ;
				tvis.item.iImage = typeInterface ;
				tvis.item.cChildren = pattr->cImplTypes ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.iSelectedImage = tvis.item.iImage ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
		break ;

		// [attributes]
		//  dispinterface intfname {
		//      interface interfacename
		// };
		case TKIND_DISPATCH :
			if (pattr->cVars)
			{
				// Add "Constants" folder
				//
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeConstants ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cVars ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Constants") ;
				tvis.item.iImage = typeConstants ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;

				// Add "Properties" folder
				//
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeProperties ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cVars ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Properties") ;
				tvis.item.iImage = typeProperties ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			 }
			if (pattr->cFuncs)
			{
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeMethods ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.cChildren = pattr->cFuncs ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.pszText = _T("Methods") ;
				tvis.item.iImage = typeMethods ;
				tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
			if (pattr->cImplTypes)
			{
				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->m_Type = typeImplTypes ;
				pNewItem->SetTypeInfo(pti) ;
				pti->AddRef() ;
				tvis.item.pszText = _T("Inherited Interfaces") ;
				tvis.item.iImage = typeInterface ;
				tvis.item.cChildren = pattr->cImplTypes ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.iSelectedImage = tvis.item.iImage ;
				m_pTree->InsertItem( &tvis ) ;
				fExpand = TRUE ;
			}
		break ;

		// [attributes]
		//  coclass classname {
		//      [attributes2] [interface | dispinterface] interfacename;
		//      ...
		// };
		case TKIND_COCLASS:
			fExpand = ExpandImplTypes( hitem ) ;
		break ;

		// typedef [attributes] basetype aliasname;
		case TKIND_ALIAS:
			if (pattr->tdescAlias.vt == VT_USERDEFINED)
			{
				ITypeInfo* ptiRefType = NULL ;

				#pragma warning (suppress: 6246)
				HRESULT hr = pti->GetRefTypeInfo( pattr->tdescAlias.hreftype, &ptiRefType ) ;
				if (FAILED(hr))
					AfxThrowOleException( hr ) ;

				pNewItem = new CTreeItem(m_pTree) ;
				pNewItem->SetTypeInfo( ptiRefType ) ;
				pNewItem->m_Type = TypeKindToItemType( pNewItem->GetTypeKind() ) ;
				tvis.item.iImage = TypeKindToItemType( pNewItem->GetTypeKind() ) ;
				tvis.item.cChildren = 1 ;
				tvis.item.lParam = (LPARAM)pNewItem ;
				tvis.item.iSelectedImage = tvis.item.iImage ;
				CString sName;
				pNewItem->GetName(sName, TRUE );
				tvis.item.pszText = sName.GetBuffer(0) ;
				m_pTree->InsertItem( &tvis ) ;
				sName.ReleaseBuffer();
				fExpand = TRUE ;
			}
		break ;

		// typedef [attributes] union [tag] {
		//      memberlist
		// } unionname;
		case TKIND_UNION:
			fExpand = ExpandVars( hitem ) ;
		break ;

		default:
		break ;
		}

		if (pattr)
			pti->ReleaseTypeAttr( pattr ) ;
	}
	CATCH(CException, pException)
	{
		ErrorMessage( strError, hr ) ;
		if (pNewItem)
			delete pNewItem ;

		if (pattr)
			pti->ReleaseTypeAttr( pattr ) ;

		return FALSE ;
	}