Ejemplo n.º 1
0
tLuaCOM::~tLuaCOM()
{
  releaseConnections();

  // frees funcinfos
  {
    long counter = 0;

    while(pFuncInfo[counter].name != NULL &&
      counter < MAX_FUNCINFOS)
    {
      free(pFuncInfo[counter].name);
      pFuncInfo[counter].name = NULL;

      ReleaseFuncDesc(pFuncInfo[counter].propget);
      ReleaseFuncDesc(pFuncInfo[counter].propput);
      ReleaseFuncDesc(pFuncInfo[counter].func);

      counter++;
    }
  }

  delete typehandler;
  typehandler = NULL;

  COM_RELEASE(ptcomp);
  COM_RELEASE(plib_tcomp);
  COM_RELEASE(ptinfo);
  COM_RELEASE(pdisp);

  tUtil::log_verbose("tLuaCOM", "%.4d:destroyed", ID);
}
Ejemplo n.º 2
0
/*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  Method:   tLuaCOMConnPointContainer
              ::tLuaCOMConnPointContainer

  Summary:  Constructor for the tLuaCOMConnPointContainer interface
            instantiation.

  Args:     COBall* pBackObj,
              Back pointer to the parent outer object.
            IUnknown* pUnkOuter
              Pointer to the outer Unknown.  For delegation.

  Modifies: pBackObj, pUnkOuter.

  Returns:  void
M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
tLuaCOMConnPointContainer::tLuaCOMConnPointContainer(lua_State* p_L,
                                                     IUnknown* p_pUnkOuter)
{
  HRESULT hr = S_OK;
  ITypeInfo *events_typeinfo = NULL;

  CHECKPARAM(p_L); CHECKPARAM(p_pUnkOuter);

  // stores pointers
  pUnkOuter = p_pUnkOuter;
  L = p_L;

  // creates connection point for source interface
  IProvideClassInfo2 *ci2  = NULL;

  hr = pUnkOuter->QueryInterface(IID_IProvideClassInfo2, (void **) &ci2); 
  CHK_COM_CODE(hr);

  IID iid;

  hr = ci2->GetGUID(GUIDKIND_DEFAULT_SOURCE_DISP_IID, &iid);
  CHK_COM_CODE(hr);

  ITypeInfo *coclassinfo = NULL;

  hr = ci2->GetClassInfo(&coclassinfo);
  CHK_COM_CODE(hr);  

  events_typeinfo = tCOMUtil::GetDefaultInterfaceTypeInfo(coclassinfo, true);
  CHK_LCOM_ERR(events_typeinfo, "No default source typeinfo.");

  COM_RELEASE(ci2);
  COM_RELEASE(coclassinfo);

  max_connection_points = 1;
  connection_points = new tLuaCOMConnPoint*[max_connection_points];
  CHKMALLOC(connection_points);

  connection_points[0] = new tLuaCOMConnPoint(L, p_pUnkOuter);
  CHKMALLOC(connection_points[0]);

  connection_points[0]->AddRef();
  
  num_connection_points = 1;

  hr = connection_points[0]->Init(iid, events_typeinfo);
  CHK_COM_CODE(hr);  

  default_connection = connection_points[0];

  return;
}
Ejemplo n.º 3
0
/*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  Method:   tLuaCOMConnPoint::Unadvise

  Summary:  The Unadvise member method of this IConnPoint interface
            implementation. Called by clients to disconnect a connection
            of their sink to this connection point. The connection is
            identified by the dwCookie argument (obtained by a previous
            Advise call). Uses the CThreaded OwnThis mechanism to provide
            mutually exclusive access by multiple threads.

  Args:     DWORD dwCookie
              Connection key that was obtained by a previous Advise call.

  Modifies: .

  Returns:  HRESULT
              Standard result code. NOERROR for success.
M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
STDMETHODIMP tLuaCOMConnPoint::Unadvise(
               DWORD dwCookie)
{
  HRESULT hr = NOERROR;
  UINT uiSlot;

  if (0 != dwCookie)
  {
      hr = FindSlot(dwCookie, &uiSlot);
      if (SUCCEEDED(hr))
      {
        // Release the sink interface.
        COM_RELEASE(paConnections[uiSlot].pUnk);
        sinks[uiSlot]->Unlock();
        sinks[uiSlot] = NULL;

        // Mark the array entry as empty.
        paConnections[uiSlot].dwCookie = 0;

        // Decrement the number of live connections.
        cConnections--;
      }

  }
  else
    hr = E_INVALIDARG;

  return hr;
}
Ejemplo n.º 4
0
tLuaCOM * tLuaCOM::CreateLuaCOM(lua_State* L,
                                IDispatch * pdisp,
                                const CLSID& coclass,
                                ITypeInfo* typeinfo,
                                bool untyped
                                )
{
  HRESULT hr = S_OK;

  CHECKPARAM(pdisp && L);
  CHECKPARAM(!untyped || !typeinfo);

  if(!untyped)
  {
    if(!typeinfo)
      typeinfo = tCOMUtil::GetDispatchTypeInfo(pdisp); 
    else
      typeinfo->AddRef();
  }

  tLuaCOM *lcom = 
    new tLuaCOM(L, pdisp, typeinfo, coclass);

  COM_RELEASE(typeinfo);

  // We have one reference (the pointer), so we lock the object
  lcom->Lock();

  return lcom;
}
Ejemplo n.º 5
0
CLSID tLuaCOM::GetCLSID()
{
  HRESULT hr = S_OK;

  if(clsid != IID_NULL)
    return clsid;

  // tries to find the CLSID using IProvideClassInfo
  ITypeInfo* coclassinfo = tCOMUtil::GetCoClassTypeInfo(pdisp);

  if(coclassinfo)
  {
    clsid = tCOMUtil::GetCLSID(coclassinfo);
    COM_RELEASE(coclassinfo);

    if(clsid != IID_NULL)
      return clsid;
  }

  // Now searches the type library seeking the coclass to which
  // this interface belongs

  clsid = tCOMUtil::FindCLSID(ptinfo);

  return clsid;
}
Ejemplo n.º 6
0
void HistoryDlg::getContextMenu(xpr_bool_t sRightClick)
{
    HistoryDisp *sHistoryDisp = getCurHistoryDisp();
    if (sHistoryDisp == XPR_NULL)
        return;

    CPoint sCursorPoint;
    GetCursorPos(&sCursorPoint);

    HTREEITEM sTreeItem = XPR_NULL;

    if (sRightClick == XPR_TRUE)
    {
        CPoint sHitTestPoint(sCursorPoint);
        mTreeCtrl.ScreenToClient(&sHitTestPoint);

        sTreeItem = mTreeCtrl.HitTest(sHitTestPoint);
    }
    else
    {
        sTreeItem = mTreeCtrl.GetSelectedItem();

        CRect sRect;
        mTreeCtrl.GetItemRect(sTreeItem, sRect, XPR_TRUE);
        mTreeCtrl.ClientToScreen(&sRect);
        if (!(sRect.left < sCursorPoint.x && sCursorPoint.x < sRect.right) || !(sRect.top < sCursorPoint.y && sRect.bottom < sCursorPoint.y))
        {
            sCursorPoint.x = sRect.left + (sRect.right-sRect.left)/2;
            sCursorPoint.y = sRect.bottom;
        }
    }

    if (sTreeItem == XPR_NULL)
        return;

    xpr_uint_t sIndex = getItemIndex(sTreeItem);
    if (FXFILE_STL_IS_INDEXABLE(sIndex, *sHistoryDisp->mHistoryDeque) == XPR_FALSE)
        return;

    HistoryDeque::const_reverse_iterator sReverseIterator = sHistoryDisp->mHistoryDeque->rbegin() + sIndex;
    if (sReverseIterator == sHistoryDisp->mHistoryDeque->rend())
        return;

    LPITEMIDLIST sFullPidl = *sReverseIterator;
    if (sFullPidl == XPR_NULL)
        return;

    xpr_bool_t    sResult;
    LPSHELLFOLDER sShellFolder = XPR_NULL;
    LPCITEMIDLIST sPidl        = XPR_NULL;

    sResult = fxfile::base::Pidl::getSimplePidl(sFullPidl, sShellFolder, sPidl);
    if (XPR_IS_TRUE(sResult) && sShellFolder != XPR_NULL && sPidl != XPR_NULL)
    {
        xpr_uint_t nFlags = TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON;
        ContextMenu::trackItemMenu(sShellFolder, &sPidl, 1, &sCursorPoint, nFlags, m_hWnd, CMF_EXPLORE);
    }

    COM_RELEASE(sShellFolder);
}
Ejemplo n.º 7
0
tLuaCOMConnPointContainer::~tLuaCOMConnPointContainer(void)
{
  while(num_connection_points--)
  {
    COM_RELEASE(connection_points[num_connection_points]);
  }

  delete[] connection_points;
  return;
}
Ejemplo n.º 8
0
xpr_bool_t ShellEnumerator::enumerate(HWND aHwnd, LPSHELLFOLDER aShellFolder, xpr_sint_t aListType, xpr_sint_t aAttributes)
{
    DWORD   sFlags = 0;
    HRESULT sComResult;

    switch (aListType)
    {
    case ListTypeAll:        sFlags = SHCONTF_FOLDERS | SHCONTF_NONFOLDERS; break;
    case ListTypeOnlyFile:   sFlags = SHCONTF_NONFOLDERS;                   break;
    case ListTypeOnlyFolder: sFlags = SHCONTF_FOLDERS;                      break;
    }

    if (XPR_TEST_BITS(aAttributes, AttributeHidden))
    {
        sFlags |= SHCONTF_INCLUDEHIDDEN;
    }

    if (XPR_TEST_BITS(aAttributes, AttributeSystem))
    {
        sFlags |= SHCONTF_STORAGE;
    }

    LPENUMIDLIST sEnumIdList = XPR_NULL;

    sComResult = aShellFolder->EnumObjects(aHwnd, sFlags, &sEnumIdList);

    if (FAILED(sComResult))
    {
        if (XPR_IS_NOT_NULL(sEnumIdList))
        {
            COM_RELEASE(sEnumIdList);
        }

        return XPR_FALSE;
    }

    COM_RELEASE(mEnumIdList);

    mEnumIdList = sEnumIdList;

    return XPR_TRUE;
}
Ejemplo n.º 9
0
/**
* CABT::destroyTree
* @date Modified Apr 17, 2006
*/
void CABT::destroyTree(SABTNode* pNode)
{
	ACEASSERT(pNode);

	// Save subtrees
	SABTNode* pLeft = pNode->m_pLeft, *pRight = pNode->m_pRight;

	// Deallocate node
	COM_RELEASE(pNode->m_pVB);
	delete pNode;

	// Continue down the tree.
	if(pLeft) destroyTree(pLeft);
	if(pRight) destroyTree(pRight);
}
Ejemplo n.º 10
0
bool AngelCore::AngelSubSystem::RenderManager::ShutDown()
{
	COM_RELEASE(AngelSubSystemResources::GraphicDeviceResources::Device);
	COM_RELEASE(AngelSubSystemResources::GraphicDeviceResources::DeviceContext);
	COM_RELEASE(AngelSubSystemResources::GraphicDeviceResources::SwapChain);
	COM_RELEASE(AngelSubSystemResources::GraphicDeviceResources::DepthStencilView);
	COM_RELEASE(AngelSubSystemResources::GraphicDeviceResources::DXGIAdaptor);
	COM_RELEASE(AngelSubSystemResources::GraphicDeviceResources::DXGIFactory);
	return true;
}
Ejemplo n.º 11
0
xpr_bool_t Pidl::getName(LPCITEMIDLIST aFullPidl, DWORD aFlags, xpr::string &aName)
{
    xpr_bool_t    sResult      = XPR_FALSE;
    LPSHELLFOLDER sShellFolder = XPR_NULL;
    LPCITEMIDLIST sPidl        = XPR_NULL;

    sResult = getSimplePidl(aFullPidl, sShellFolder, sPidl);
    if (XPR_IS_TRUE(sResult))
    {
        sResult = getName(sShellFolder, sPidl, aFlags, aName);
    }

    COM_RELEASE(sShellFolder);

    return sResult;
}
Ejemplo n.º 12
0
xpr_bool_t Pidl::getAttributes(LPCITEMIDLIST aFullPidl, xpr_ulong_t &aAttributes)
{
    xpr_bool_t    sResult      = XPR_FALSE;
    LPSHELLFOLDER sShellFolder = XPR_NULL;
    LPCITEMIDLIST sPidl        = XPR_NULL;

    sResult = getSimplePidl(aFullPidl, sShellFolder, sPidl);
    if (XPR_IS_TRUE(sResult))
    {
        return getAttributes(sShellFolder, sPidl, aAttributes);
    }

    COM_RELEASE(sShellFolder);

    return sResult;
}
Ejemplo n.º 13
0
xpr_bool_t Pidl::getInfotip(LPSHELLFOLDER aShellFolder, LPCITEMIDLIST aPidl, xpr::string &aInfotip)
{
    xpr_bool_t  sResult    = XPR_FALSE;
    IQueryInfo *sQueryInfo = XPR_NULL;
    HRESULT     sComResult;

    sComResult = aShellFolder->GetUIObjectOf(
        XPR_NULL,
        1,
        (LPCITEMIDLIST *)&aPidl,
        IID_IQueryInfo,
        0,
        (LPVOID *)&sQueryInfo);

    if (SUCCEEDED(sComResult) && XPR_IS_NOT_NULL(sQueryInfo))
    {
        xpr_wchar_t *sWideInfotip = XPR_NULL;

        sComResult = sQueryInfo->GetInfoTip(SHGDN_INFOLDER, &sWideInfotip);
        if (SUCCEEDED(sComResult) && XPR_IS_NOT_NULL(sWideInfotip))
        {
            xpr_size_t sInfotipLen = wcslen(sWideInfotip);
            if (sInfotipLen != 0)
            {
                aInfotip.clear();
                aInfotip.reserve(sInfotipLen + 1);

                xpr_tchar_t *sInfotip = (xpr_tchar_t *)aInfotip.c_str();

                xpr_size_t sInputBytes = sInfotipLen * sizeof(xpr_wchar_t);
                xpr_size_t sOutputBytes = sInfotipLen * sizeof(xpr_tchar_t);
                XPR_UTF16_TO_TCS(sWideInfotip, &sInputBytes, sInfotip, &sOutputBytes);
                sInfotip[sOutputBytes / sizeof(xpr_tchar_t)] = 0;

                aInfotip.update();

                sResult = XPR_TRUE;
            }
        }

        COM_FREE(sWideInfotip);
    }

    COM_RELEASE(sQueryInfo);

    return sResult;
}
Ejemplo n.º 14
0
/*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  Method:   tLuaCOMEnumConnPoints::~tLuaCOMEnumConnPoints

  Summary:  tLuaCOMEnumConnPoints Destructor.

  Args:     void

  Modifies: paConnPts.

  Returns:  void
M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
tLuaCOMEnumConnPoints::~tLuaCOMEnumConnPoints(void)
{
  if (NULL != paConnPts)
  {
    UINT i;

    // Release all the connection point interface pointers.
    for (i=0; i<cConnPts; i++)
      if (NULL != paConnPts[i])
        COM_RELEASE(paConnPts[i]);

    // Delete the array of interface pointers.
    delete [] paConnPts;
  }

  return;
}
Ejemplo n.º 15
0
// IShellFolder + PIDL -> full qualified PIDL
LPITEMIDLIST Pidl::getFullPidl(LPSHELLFOLDER aShellFolder, LPCITEMIDLIST aSimplePidl)
{
    if (XPR_IS_NULL(aShellFolder) || XPR_IS_NULL(aSimplePidl))
    {
        return XPR_NULL;
    }

    LPITEMIDLIST  sFullPidl   = XPR_NULL;
    IDataObject  *sDataObject = XPR_NULL;
    HRESULT       sComResult;

    sComResult = aShellFolder->GetUIObjectOf(0, 1, &aSimplePidl, IID_IDataObject, 0, (LPVOID *)&sDataObject);
    if (SUCCEEDED(sComResult))
    {
        FORMATETC sFormatEtc = {0};
        sFormatEtc.cfFormat = RegisterClipboardFormat(CFSTR_SHELLIDLIST);
        sFormatEtc.ptd      = XPR_NULL;
        sFormatEtc.dwAspect = DVASPECT_CONTENT;
        sFormatEtc.lindex   = -1;
        sFormatEtc.tymed    = TYMED_HGLOBAL;

        STGMEDIUM sStgMedium = {0,};
        sComResult = sDataObject->GetData(&sFormatEtc, &sStgMedium);

        if (SUCCEEDED(sComResult))
        {
            LPIDA sPida = (LPIDA)::GlobalLock(sStgMedium.hGlobal);

            LPCITEMIDLIST sFolderPidl = (LPCITEMIDLIST)((xpr_byte_t *)sPida + sPida->aoffset[0]);
            LPCITEMIDLIST sChildPidl  = (LPCITEMIDLIST)((xpr_byte_t *)sPida + sPida->aoffset[1]);

            sFullPidl = concat(sFolderPidl, sChildPidl);

            ::GlobalUnlock(sStgMedium.hGlobal);

            if (XPR_IS_NOT_NULL(sStgMedium.pUnkForRelease))
            {
                ::ReleaseStgMedium(&sStgMedium);
            }
        }

        COM_RELEASE(sDataObject);
    }

    return sFullPidl;
}
Ejemplo n.º 16
0
ITypeInfo * tLuaCOM::GetDefaultEventsInterface()
{
  CLSID clsid = GetCLSID();

  if(clsid == IID_NULL)
    return NULL;
  
  ITypeInfo* coclassinfo = tCOMUtil::GetCoClassTypeInfo(pdisp, clsid);

  if(!coclassinfo)
    return NULL;
  
  ITypeInfo *ptinfo = tCOMUtil::GetDefaultInterfaceTypeInfo(coclassinfo, true);
  COM_RELEASE(coclassinfo);

  return ptinfo;
}
Ejemplo n.º 17
0
// full qualified PIDL -> IShellFolder
xpr_bool_t Pidl::getShellFolder(LPCITEMIDLIST aFullPidl, LPSHELLFOLDER &aShellFolder)
{
    XPR_ASSERT(aFullPidl != XPR_NULL);

    xpr_bool_t    sResult            = XPR_FALSE;
    LPSHELLFOLDER sParentShellFolder = XPR_NULL;
    LPCITEMIDLIST sPidl              = XPR_NULL;

    if (getSimplePidl(aFullPidl, sParentShellFolder, sPidl) == XPR_FALSE)
    {
        return XPR_FALSE;
    }

    sResult = getShellFolder(sParentShellFolder, sPidl, aShellFolder);

    COM_RELEASE(sParentShellFolder);

    return sResult;
}
Ejemplo n.º 18
0
void ColumnSetCommand::execute(CommandContext &aContext)
{
    FXFILE_COMMAND_DECLARE_CTRL;

    if (sExplorerCtrl != XPR_NULL)
    {
        LPSHELLFOLDER2 sShellFolder2 = XPR_NULL;
        ColumnDataList sColumnList;
        sExplorerCtrl->getColumnDataList(sShellFolder2, sColumnList);

        xpr_sint_t sAvgCharWidth = ShellColumnManager::getAvgCharWidth(sExplorerCtrl);

        ColumnSetDlg sDlg;
        sDlg.setShellFolder2(sShellFolder2);
        sDlg.setAvgCharWidth(sAvgCharWidth);
        sDlg.setColumnList(sColumnList);
        xpr_sintptr_t sId = sDlg.DoModal();
        if (sId == IDOK)
        {
            ColumnDataList sUseColumnList;
            sDlg.getUseColumnList(sUseColumnList);

            xpr_sint_t i;
            xpr_sint_t sViewCount;
            ExplorerCtrl *sAllExplorerCtrl;

            sViewCount = sMainFrame->getViewCount();

            for (i = 0; i < sViewCount; ++i)
            {
                sAllExplorerCtrl = sMainFrame->getExplorerCtrl(i);
                if (XPR_IS_NOT_NULL(sAllExplorerCtrl))
                {
                    sAllExplorerCtrl->setColumnDataList(sUseColumnList);
                }
            }

            clear(sUseColumnList);
        }

        COM_RELEASE(sShellFolder2);
    }
}
Ejemplo n.º 19
0
	IDirect3DTexture9 * TextureCache::_addTex( uint fmt, uint w, uint h, uint c, const unsigned char * pixel, uint _usage )
	{
		uint usage = _usage;
		uint pool = D3DPOOL_MANAGED;

		if ( usage & D3DUSAGE_DYNAMIC ) // The resource will be a render target. D3DUSAGE_RENDERTARGET can only be used with D3DPOOL_DEFAULT. 
		{
			pool = D3DPOOL_DEFAULT;
			
		}
		if ( usage & D3DUSAGE_RENDERTARGET ) // The resource will be a render target. D3DUSAGE_RENDERTARGET can only be used with D3DPOOL_DEFAULT. 
		{
			pool = D3DPOOL_DEFAULT;
			
		}
		else // no usage
		{
			usage |= D3DUSAGE_AUTOGENMIPMAP;
		}

		//printf( "%s %s %x\n", __FUNCTION__, ("nil"), fmt);

		IDirect3DTexture9 * tx = createTexture( w, h, getPixelFormat(fmt), usage, pool );
		if ( ! tx ) 
		{
			printf( __FUNCTION__ " ERROR : could not create tex \n" );
			return 0;
		}
		if ( pixel )
		{
			IDirect3DSurface9 *surf = 0;
			HRESULT hr = tx->GetSurfaceLevel( 0, & surf );
			E_TRACE(hr);

			uint r = SurfaceHelper::copyToSurface( w, h, c, pixel, surf );

			COM_RELEASE( surf );
		}
		return tx;
	}
Ejemplo n.º 20
0
//
// Tries to find a constant in the type library and
// pushes its value to Lua
//
bool tLuaCOM::getConstant(lua_State* L, const char* name)
{
  if(plib_tcomp == NULL)
    return false;

  HRESULT hr = S_OK;
  BINDPTR bindptr;
  DESCKIND desckind;
  BSTR wName;
  ITypeInfo *info = NULL;
  bool result = false;

  unsigned int dumb = 0;

  wName = tUtil::string2bstr(name);

  unsigned long lhashval = LHashValOfName(LOCALE_SYSTEM_DEFAULT, wName);

  hr = plib_tcomp->Bind(wName, lhashval, INVOKE_PROPERTYGET,
    &info, &desckind, &bindptr);

  SysFreeString(wName);

  if(SUCCEEDED(hr) 
    && desckind == DESCKIND_VARDESC 
    && bindptr.lpvardesc->varkind == VAR_CONST)
  {
    typehandler->com2lua(L, *bindptr.lpvardesc->lpvarValue);
    result = true;
  }
  else
    result = false;

  COM_RELEASE(info);

  return result;
}
Ejemplo n.º 21
0
ITypeInfo *tCOMUtil::GetCoClassTypeInfo(IDispatch* pdisp, CLSID clsid)
{
  CHECKPARAM(pdisp);

  ITypeInfo* typeinfo = NULL;
  ITypeLib* typelib = NULL;
  HRESULT hr = S_OK;

  {
    unsigned int typeinfocount = 0;

    hr = pdisp->GetTypeInfoCount(&typeinfocount);

    if(FAILED(hr) || typeinfocount == 0)
      return NULL;
  }

  hr = pdisp->GetTypeInfo(0, 0, &typeinfo);

  if(FAILED(hr))
    return NULL;

  {
    unsigned int dumb_index = -1;
    hr = typeinfo->GetContainingTypeLib(&typelib, &dumb_index);
    COM_RELEASE(typeinfo);
  }

  if(FAILED(hr))
    return NULL;

  ITypeInfo* coclasstypeinfo = tCOMUtil::GetCoClassTypeInfo(typelib, clsid);
  typelib->Release();

  return coclasstypeinfo;
}
Ejemplo n.º 22
0
ITypeInfo *tCOMUtil::GetDispatchTypeInfo(IDispatch* pdisp)
{
  ITypeInfo* typeinfo = NULL;

  HRESULT hr = pdisp->GetTypeInfo(0, LOCALE_SYSTEM_DEFAULT, &typeinfo);

  if(FAILED(hr))
    return NULL;

  TYPEATTR *ptypeattr = NULL;

  typeinfo->GetTypeAttr(&ptypeattr);

  TYPEKIND typekind = ptypeattr->typekind;

  if(typekind == TKIND_DISPATCH)
  {
    typeinfo->ReleaseTypeAttr(ptypeattr);
    return typeinfo;
  }

  // tries to find another description of the same
  // interface in the typelib with TKIND_DISPATCH

  ITypeLib *ptypelib = NULL;
  unsigned int dumb = 0;
  IID iid = ptypeattr->guid;

  hr = typeinfo->GetContainingTypeLib(&ptypelib, &dumb);

  typeinfo->ReleaseTypeAttr(ptypeattr);

  // if there's no containing type lib, we have to
  // trust this one is the right type info
  if(FAILED(hr))
    return typeinfo;

  // obtem a typeinfo do iid fornecido
  // caso haja uma implementacao dispinterface,
  // esta' e' que sera' retornada (segundo
  // documentacao do ActiveX

  ITypeInfo* typeinfo_guid = NULL;

  hr = ptypelib->GetTypeInfoOfGuid(iid, &typeinfo_guid);

  if(FAILED(hr))
  {
    ptypelib->Release();
    return typeinfo;
  }

  // verifica se e' dispinterface
  TYPEATTR *ptypeattr_iface = NULL;

  hr = typeinfo_guid->GetTypeAttr(&ptypeattr_iface);
  TYPEKIND typekind_iface = ptypeattr_iface->typekind;
  typeinfo_guid->ReleaseTypeAttr(ptypeattr_iface);

  if(typekind_iface == TKIND_DISPATCH)
  {
    // releases original type information
    COM_RELEASE(typeinfo);

    return typeinfo_guid;
  }
  else
  {
    COM_RELEASE(typeinfo_guid);
    
    // returns original type info
    return typeinfo;
  }
}
Ejemplo n.º 23
0
void CAnimationInstance::CleanUp(void)
{
	COM_RELEASE( m_pAnimationController);	
}
Ejemplo n.º 24
0
tLuaCOMEnumerator::~tLuaCOMEnumerator()
{
  COM_RELEASE(pEV);
  delete typehandler;
}
Ejemplo n.º 25
0
int tLuaCOMEnumerator::callCOMmethod(lua_State* L, const char *name, int first_param, int num_params)
{
  HRESULT hr = S_OK;

  // Next method
  if(strcmp(name, "Next") == 0)
  {
    VARIANT* pVar = NULL;
    unsigned long num_elements = 1, counter = 0;
    ULONG fetched = 0;


    if(num_params > 0)
    {
      num_elements = (unsigned long) lua_tonumber(L, first_param);
    }

    pVar = new VARIANT[num_elements];

    for(counter = 0; counter <  num_elements; counter++)
      VariantInit(&pVar[counter]);


    hr = pEV->Next(num_elements, pVar, &fetched);
    
    for(counter = 0; counter < fetched; counter++)
    {
      typehandler->com2lua(L, pVar[counter]);
      typehandler->releaseVariant(&pVar[counter]);
    }

    for(counter = 0; counter <  num_elements; counter++)
	  VariantClear(&pVar[counter]);

    delete[] pVar;

	pVar = NULL;

    return fetched;
  }

  if(strcmp(name, "Reset") == 0)
  {
    hr = pEV->Reset();
    CHK_LCOM_ERR(hr == S_OK, "Unable to reset enumeration.");
    
    return 0;
  }

  if(strcmp(name, "Skip") == 0)
  {
    CHK_LCOM_ERR(num_params > 0, "Not enough parameters.");

    unsigned long num_elements = (unsigned long) lua_tonumber(L, first_param);

    hr = pEV->Skip(num_elements);

    luaCompat_pushBool(L, hr == S_OK);

    return 1;
  }

  if(strcmp(name, "Clone") == 0)
  {
    IEnumVARIANT* p_newEV = NULL;

    hr = pEV->Clone(&p_newEV);
    CHK_COM_CODE(hr);

    tLuaCOMEnumerator* enumerator = new tLuaCOMEnumerator(p_newEV);
    
    COM_RELEASE(p_newEV);

    enumerator->push(L);

    return 1;
  }



  return 0;
}
Ejemplo n.º 26
0
/**
* CBitmapFont::~CBitmapFont
* @date Modified Mar 28, 2006
*/
CBitmapFont::~CBitmapFont(void)
{
	COM_RELEASE(m_poTexture);
}
Ejemplo n.º 27
0
/**
* CActor::~CActor
* @date Modified Mar 07, 2006
*/
CActor::~CActor(void)
{
	COM_RELEASE(m_pMesh);
}
Ejemplo n.º 28
0
void AngelCore::AngelSubSystem::RenderManager::OnResize()
{
	if (AngelSubSystemResources::GraphicDeviceResources::GetSwapChain())
	{
		COM_RELEASE(AngelSubSystemResources::GraphicDeviceResources::RenderTargetView);
		COM_RELEASE(AngelSubSystemResources::GraphicDeviceResources::DepthStencilView);

		HR(AngelSubSystemResources::GraphicDeviceResources::SwapChain->ResizeBuffers(2,
			0,
			800,
			DXGI_FORMAT_B8G8R8A8_UNORM, 0));
		DXGI_SWAP_CHAIN_DESC1 descswap;
		AngelSubSystemResources::GraphicDeviceResources::SwapChain->GetDesc1(&descswap);

		

		Microsoft::WRL::ComPtr<ID3D11Texture2D> backBuffer;
		HR(AngelSubSystemResources::GraphicDeviceResources::SwapChain->
			GetBuffer(0, IID_PPV_ARGS(&backBuffer)));

		HR(AngelSubSystemResources::GraphicDeviceResources::Device->CreateRenderTargetView(backBuffer.Get(),
			nullptr,
			AngelSubSystemResources::GraphicDeviceResources::RenderTargetView.GetAddressOf()));

		COM_RELEASE(backBuffer);

		backBuffer = nullptr;

		UINT sampleLevel = 0;
		UINT sampleCount = AngelSubSystemResources::GraphicDeviceResources::GetSampleCount(); // You set this
		HR(AngelSubSystemResources::GraphicDeviceResources::Device->
			CheckMultisampleQualityLevels(DXGI_FORMAT_B8G8R8A8_UNORM
				, sampleCount, &sampleLevel));

		Microsoft::WRL::ComPtr<ID3D11Texture2D> depthTexture;
		D3D11_TEXTURE2D_DESC desc;
		desc.ArraySize = 1;
		desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
		desc.CPUAccessFlags = 0;
		desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
		desc.Height = descswap.Height;
		desc.MipLevels = 1;
		desc.MiscFlags = 0;
		desc.SampleDesc.Count = sampleCount;
		desc.SampleDesc.Quality = sampleLevel-1;
		desc.Usage = D3D11_USAGE_DEFAULT;
		desc.Width = descswap.Width;

		HR(AngelSubSystemResources::GraphicDeviceResources::Device->CreateTexture2D(&desc, nullptr, depthTexture.GetAddressOf()));

		HR(AngelSubSystemResources::GraphicDeviceResources::Device->CreateDepthStencilView(depthTexture.Get()
			, nullptr, AngelSubSystemResources::GraphicDeviceResources::DepthStencilView.GetAddressOf()));

		COM_RELEASE(depthTexture);

		depthTexture = nullptr;

		D3D11_VIEWPORT view;
		view.Height = static_cast<FLOAT>(AngelSubSystemResources::WindowProperties::GetHeight());
		view.Width = static_cast<FLOAT>(AngelSubSystemResources::WindowProperties::GetWidth());
		view.MaxDepth = 1.0f;
		view.MinDepth = 0.0f;
		view.TopLeftX = 0.0f;
		view.TopLeftY = 0.0f;

		AngelSubSystemResources::GraphicDeviceResources::DeviceContext->RSSetViewports(1, &view);

		//AngelCore::AngelRendering::PostProcess::GetInstance()->DestroyInstance();
		AngelCore::AngelRendering::PostProcess::GetInstance()->Initialize(
			AngelSubSystemResources::GraphicDeviceResources::Device.Get());

		AngelLog::WriteLogMessage("AngelWindow Resized Successfully");
	}
}
Ejemplo n.º 29
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;
}
Ejemplo n.º 30
0
tLuaCOM::tLuaCOM(lua_State* L,
                 IDispatch *pdisp_arg,
                 ITypeInfo *ptinfo_arg,
                 CLSID coclass
                 )
{
  HRESULT hr = S_OK;

  // initialization
  plib_tcomp              = NULL;
  ptcomp                  = NULL;
  clsid                   = IID_NULL;
  lock_count              = 0;
  conn_point              = NULL;

  pdisp = pdisp_arg;
  pdisp->AddRef(); 

  ptinfo = ptinfo_arg;

  if(ptinfo)
  {
    // gets ITypeComp interface. If it's not
    // available, frees typeinfo, as we only
    // use ITypeComp

    hr = ptinfo->GetTypeComp(&ptcomp);

    if(SUCCEEDED(hr))
    {
      ptinfo->AddRef();

      // tries to get typecomp for type library
      // (useful to bind to constants)

      ITypeLib* ptlib = NULL;
      unsigned int dumb = 0;

      hr = ptinfo->GetContainingTypeLib(&ptlib, &dumb);

      if(SUCCEEDED(hr))
      {
        //ptlib->GetTypeComp(&plib_tcomp);
        COM_RELEASE(ptlib);
        COM_RELEASE(plib_tcomp);
      }
    }
    else
      COM_RELEASE(ptinfo);  // BUG!!!
  }

  typehandler = new tLuaCOMTypeHandler(ptinfo_arg);

  // cleans FuncInfo array
  int i;
  for(i = 0; i < MAX_FUNCINFOS; i++)
    pFuncInfo[i].name = NULL;

  ID = tLuaCOM::NEXT_ID++;

#ifdef VERBOSE
  {
    char msg[100];
    lua_Debug ar;

    if(lua_getstack(L, 1, &ar))
    {
      lua_getinfo(L, "lnS", &ar);

      sprintf(msg, "%.4d:created:LUAINFO=(%s,%d,%s,%s)", ID, ar.short_src,
        ar.currentline, ar.name, ar.what);
    }
    else if(lua_getstack(L, 0, &ar))
    {
      lua_getinfo(L, "lnS", &ar);
      sprintf(msg, "%.4d:created:LUAINFO=(%s,%d,%s,%s)", ID, ar.short_src,
        ar.currentline, ar.name, ar.what);
    }
    else
    {
      sprintf(msg, "%.4d:created:LUAINFO=(not available)", ID);
    }

    tUtil::log_verbose("tLuaCOM",msg);
  }
#endif
}