// @pymethod |PyIDirectSoundCaptureBuffer|GetFormat|Retrieves the current format of the sound capture buffer as a WAVEFORMATEX object. PyObject *PyIDirectSoundCaptureBuffer::GetFormat(PyObject *self, PyObject *args) { IDirectSoundCaptureBuffer *pIDSCB = GetI(self); if ( pIDSCB == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetFormat") ) return NULL; HRESULT hr; PyWAVEFORMATEX *wfx = new PyWAVEFORMATEX(); PY_INTERFACE_PRECALL; // We don't support getting more than standard wave headers hr = pIDSCB->GetFormat(&wfx->m_wfx, sizeof(WAVEFORMATEX), NULL); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("GetFormat", hr); return NULL; } Py_INCREF(wfx); return wfx; }
// @pymethod |PyIShellLink|SetIDList|Sets the list of item identifiers for a shell link object. PyObject *PyIShellLink::SetIDList(PyObject *self, PyObject *args) { IShellLink *pISL = GetI(self); if ( pISL == NULL ) return NULL; LPITEMIDLIST pidl; PyObject *obpidl; if ( !PyArg_ParseTuple(args, "O:SetIDList", &obpidl) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsPIDL( obpidl, &pidl )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISL->SetIDList( pidl ); PY_INTERFACE_POSTCALL; PyObject_FreePIDL(pidl); if ( FAILED(hr) ) return OleSetOleError(hr); Py_INCREF(Py_None); return Py_None; }
// @pymethod int|PyITransferSource|RemoveItem|Deletes an item without recycling // @rdesc Returns the HRESULT of the operation PyObject *PyITransferSource::RemoveItem(PyObject *self, PyObject *args) { ITransferSource *pITS = GetI(self); if ( pITS == NULL ) return NULL; // @pyparm <o PyIShellItem>|Source||The item to be deleted TRANSFER_SOURCE_FLAGS flags; // @pyparm int|flags||Combination of shellcon.TSF_* flags PyObject *obpsiSource; IShellItem * psiSource; if ( !PyArg_ParseTuple(args, "Oi:RemoveItem", &obpsiSource, &flags) ) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiSource, IID_IShellItem, (void **)&psiSource, FALSE)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pITS->RemoveItem( psiSource, flags ); psiSource->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pITS, IID_ITransferSource ); return PyInt_FromLong(hr); }
// @pymethod |PyIPersistFile|Load|Opens the specified file and initializes an object from the file contents. PyObject *PyIPersistFile::Load(PyObject *self, PyObject *args) { IPersistFile *pIPF = GetI(self); if ( pIPF == NULL ) return NULL; // @pyparm str|FileName||Absolute path of the file to open // @pyparm int|Mode|STGM_READ|Specifies the access mode from the STGM enumeration. PyObject *obFileName; TmpWCHAR FileName; DWORD dwMode = STGM_READ; if ( !PyArg_ParseTuple(args, "O|l:Load", &obFileName, &dwMode) ) return NULL; if (!PyWinObject_AsWCHAR(obFileName, &FileName)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIPF->Load(FileName, dwMode ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile); Py_INCREF(Py_None); return Py_None; }
PyObject *PyIGlobalInterfaceTable::RevokeInterfaceFromGlobal(PyObject *self, PyObject *args) { DWORD dwCookie; HRESULT hr; IGlobalInterfaceTable *pIGIT = GetI(self); if ( pIGIT == NULL ) { return NULL; } if (!PyArg_ParseTuple(args, "l:RevokeInterfaceFromGlobal", &dwCookie) ) { return NULL; } PY_INTERFACE_PRECALL; hr = pIGIT->RevokeInterfaceFromGlobal( dwCookie ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) { return PyCom_BuildPyException(hr, pIGIT, IID_IGlobalInterfaceTable ); } Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyICreateTypeInfo|SetGuid|Description of SetGuid. PyObject *PyICreateTypeInfo::SetGuid(PyObject *self, PyObject *args) { ICreateTypeInfo *pICTI = GetI(self); if ( pICTI == NULL ) return NULL; // @pyparm <o PyIID>|guid||Description for guid PyObject *obguid; IID guid; if ( !PyArg_ParseTuple(args, "O:SetGuid", &obguid) ) return NULL; BOOL bPythonIsHappy = TRUE; if (!PyWinObject_AsIID(obguid, &guid)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pICTI->SetGuid( guid ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pICTI, IID_ICreateTypeInfo); Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyIFileOperation|RenameItem|Adds a rename to the operation sequence PyObject *PyIFileOperation::RenameItem(PyObject *self, PyObject *args) { IFileOperation *pIFO = GetI(self); if ( pIFO == NULL ) return NULL; // @pyparm <o PyIShellItem>|Item||The item to be renamed // @pyparm str|NewName||The new name // @pyparm <o PyGFileOperationProgressSink>|Sink|None|Progress sink for this operation only. PyObject *obItem, *obNewName, *obSink = Py_None; IShellItem * pItem; TmpWCHAR NewName; IFileOperationProgressSink * pSink; if ( !PyArg_ParseTuple(args, "OO|O:RenameItem", &obItem, &obNewName, &obSink)) return NULL; if (!PyWinObject_AsWCHAR(obNewName, &NewName, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obItem, IID_IShellItem, (void **)&pItem, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obSink, IID_IFileOperationProgressSink, (void **)&pSink, TRUE)) { PYCOM_RELEASE(pItem); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIFO->RenameItem(pItem, NewName, pSink); pItem->Release(); if (pSink) pSink->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIFO, IID_IFileOperation ); Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyIDirectSound|Initialize|Description of Initialize. PyObject *PyIDirectSound::Initialize(PyObject *self, PyObject *args) { PyObject *obGUID; IDirectSound *pIDS = GetI(self); if ( pIDS == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "|O:Initialize", &obGUID) ) // @pyparm <o PyIID>|guid||Globally unique identifier (GUID) specifying the sound driver to which this DirectSound object binds. Pass None to select the primary sound driver. return NULL; GUID guid; LPGUID pguid = NULL; if (!obGUID && obGUID != Py_None) { if (!PyWinObject_AsIID(obGUID, &guid)) return NULL; pguid = &guid; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDS->Initialize(pguid); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("Initialize", hr); return NULL; } Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyIDebugExpression|Start|Description of Start. PyObject *PyIDebugExpression::Start(PyObject *self, PyObject *args) { IDebugExpression *pIDE = GetI(self); if ( pIDE == NULL ) return NULL; // @pyparm <o PyIDebugExpressionCallBack>|pdecb||Description for pdecb PyObject *obpdecb; IDebugExpressionCallBack *pdecb; if ( !PyArg_ParseTuple(args, "O:Start", &obpdecb) ) return NULL; BOOL bPythonIsHappy = TRUE; if (!PyCom_InterfaceFromPyInstanceOrObject(obpdecb, IID_IDebugExpressionCallBack, (void **)&pdecb, FALSE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; PY_INTERFACE_PRECALL; HRESULT hr = pIDE->Start( pdecb ); pdecb->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return SetPythonCOMError(self,hr); Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyIInternetSecurityManager|MapUrlToZone|Description of MapUrlToZone. PyObject *PyIInternetSecurityManager::MapUrlToZone(PyObject *self, PyObject *args) { IInternetSecurityManager *pIISM = GetI(self); if ( pIISM == NULL ) return NULL; // @pyparm <o unicode>|pwszUrl||Description for pwszUrl // @pyparm int|dwFlags||Description for dwFlags PyObject *obpwszUrl; LPWSTR pwszUrl; DWORD pdwZone; DWORD dwFlags; if (!PyArg_ParseTuple(args, "Ol:MapUrlToZone", &obpwszUrl, &dwFlags)) return NULL; if (!PyWinObject_AsBstr(obpwszUrl, &pwszUrl)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIISM->MapUrlToZone( pwszUrl, &pdwZone, dwFlags ); SysFreeString(pwszUrl); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIISM, IID_IInternetSecurityManager ); return PyInt_FromLong(pdwZone); }
// @pymethod |PyIDirectSound|SetSpeakerConfig|The SetSpeakerConfig method specifies the speaker configuration of the DirectSound object. PyObject *PyIDirectSound::SetSpeakerConfig(PyObject *self, PyObject *args) { DWORD config; IDirectSound *pIDS = GetI(self); if ( pIDS == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "i:SetSpeakerConfig", &config) ) // @pyparm int|dwSpeakerConfig||Speaker configuration of the specified DirectSound object. See the DSSPEAKER constants. return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDS->SetSpeakerConfig(config); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("SetSpeakerConfig", hr); return NULL; } Py_INCREF(Py_None); return Py_None; }
// @pymethod <o PyOLEMENUGROUPWIDTHS>|PyIShellBrowser|InsertMenusSB|Updates a composite menu with container's options PyObject *PyIShellBrowser::InsertMenusSB(PyObject *self, PyObject *args) { IShellBrowser *pISB = GetI(self); if ( pISB == NULL ) return NULL; OLEMENUGROUPWIDTHS menuWidths; PyObject *obMenuWidths, *obhmenuShared; HMENU hmenuShared; if ( !PyArg_ParseTuple(args, "OO:InsertMenusSB", &obhmenuShared, // @pyparm <o PyHANDLE>|hmenuShared||Newly created menu that contains no items &obMenuWidths)) // @pyparm <o PyOLEMENUGROUPWIDTHS>|lpMenuWidths||Tuple of 6 ints. Items 0,2,and 4 are updated when the tuple is returned. return NULL; if (!PyWinObject_AsHANDLE(obhmenuShared, (HANDLE *)&hmenuShared)) return NULL; if (!PyObject_AsOLEMENUGROUPWIDTHS( obMenuWidths, &menuWidths)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISB->InsertMenusSB( hmenuShared, &menuWidths ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); return PyObject_FromOLEMENUGROUPWIDTHS(&menuWidths); }
// @pymethod |PyIShellBrowser|BrowseObject|Navigates to a different location PyObject *PyIShellBrowser::BrowseObject(PyObject *self, PyObject *args) { IShellBrowser *pISB = GetI(self); if ( pISB == NULL ) return NULL; PyObject *obpidl; LPITEMIDLIST pidl; UINT wFlags; if ( !PyArg_ParseTuple(args, "OI:BrowseObject", &obpidl, // @pyparm <o PyIDL>|pidl||Item id list that specifies the new browse location, can be None &wFlags)) // @pyparm int|wFlags||Combination of shellcon.SBSP_* flags return NULL; if (!PyObject_AsPIDL(obpidl, &pidl, TRUE)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISB->BrowseObject( pidl, wFlags ); PyObject_FreePIDL(pidl); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyIShellBrowser|TranslateAcceleratorSB|Translates keystrokes used as menu item activators PyObject *PyIShellBrowser::TranslateAcceleratorSB(PyObject *self, PyObject *args) { IShellBrowser *pISB = GetI(self); if ( pISB == NULL ) return NULL; MSG msg; PyObject *obpmsg; WORD wID; if (!PyArg_ParseTuple(args, "OH:TranslateAcceleratorSB", &obpmsg, // @pyparm <o PyMSG>|pmsg||Keystroke message to be translated &wID)) // @pyparm int|wID||Menu command id for the keystroke return NULL; if (!PyObject_AsMSG(obpmsg, &msg)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISB->TranslateAcceleratorSB( &msg, wID ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); Py_INCREF(Py_None); return Py_None; }
// @pymethod dict|PyIServerSecurity|QueryBlanket|Retrieves security settings specified by the client PyObject *PyIServerSecurity::QueryBlanket(PyObject *self, PyObject *args) { IServerSecurity *pISS = GetI(self); if ( pISS == NULL ) return NULL; // In many methods using pPrivs, it may be a variety of different structs // but for this particular one it's just WCHAR* containing client name void *pPrivs; DWORD AuthnSvc; DWORD AuthzSvc; WCHAR *ServerPrincipalName; DWORD AuthnLevel; DWORD ImpLevel; DWORD Capabilities = 0; // @pyparm int|Capabilities|0|Can be EOAC_MAKE_FULLSIC for SChannel provider if ( !PyArg_ParseTuple(args, "|k:QueryBlanket", &Capabilities)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISS->QueryBlanket( &AuthnSvc, &AuthzSvc, &ServerPrincipalName, &AuthnLevel, &ImpLevel, &pPrivs, &Capabilities); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISS, IID_IServerSecurity ); PyObject *pyretval = Py_BuildValue("{s:k, s:k, s:N, s:k, s:k, s:N, s:k}", "AuthnSvc", AuthnSvc, "AuthzSvc", AuthzSvc, "ServerPrincipalName", PyWinObject_FromWCHAR(ServerPrincipalName), "AuthnLevel", AuthnLevel, "ImpLevel", ImpLevel, "ClientName", PyWinObject_FromWCHAR((WCHAR *)pPrivs), "Capabilities", Capabilities); CoTaskMemFree(ServerPrincipalName); return pyretval; }
// // TODO: I don't support passing in a FULLPROPSEC array yet // PyObject *PyIFilter::Init(PyObject *self, PyObject *args) { IFilter *pIF = GetI(self); if ( pIF == NULL ) return NULL; const FULLPROPSPEC * aAttributes=NULL; ULONG cAttributes=0; ULONG grfFlags=0; ULONG flags = 0; if ( !PyArg_ParseTuple(args, "l:Init", &grfFlags) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIF->Init( grfFlags, cAttributes, aAttributes, &flags ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIF, IID_IFilter ); return Py_BuildValue("l", flags); }
// @pymethod |PyIShellLibrary|AddFolder|Includes a folder PyObject *PyIShellLibrary::AddFolder(PyObject *self, PyObject *args) { IShellLibrary *pISL = GetI(self); if ( pISL == NULL ) return NULL; IShellItem *Location; PyObject *obLocation; // @pyparm <o PyIShellItem>|Location||Shell item interface representing the folder if ( !PyArg_ParseTuple(args, "O:AddFolder", &obLocation)) return NULL; if (!PyCom_InterfaceFromPyObject(obLocation, IID_IShellItem, (void **)&Location, FALSE)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISL->AddFolder(Location); Location->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary ); Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyIShellItemResources|GetResourceDescription|Description of GetResourceDescription. PyObject *PyIShellItemResources::GetResourceDescription(PyObject *self, PyObject *args) { IShellItemResources *pISIR = GetI(self); if ( pISIR == NULL ) return NULL; SHELL_ITEM_RESOURCE sir; PyObject *obpcsir; // @pyparm <o PySHELL_ITEM_RESOURCE>|pcsir||Description for pcsir LPWSTR pszDescription; if ( !PyArg_ParseTuple(args, "O:GetResourceDescription", &obpcsir)) return NULL; if (!PyWinObject_AsSHELL_ITEM_RESOURCE( obpcsir, &sir )) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISIR->GetResourceDescription(&sir, &pszDescription ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISIR, IID_IShellItemResources ); PyObject *ret = PyWinObject_FromWCHAR(pszDescription); CoTaskMemFree(pszDescription); // ??? Docs don't specify how it should be freed ??? return ret; }
// @pymethod <o PyIPropertyDescription>|PyIPropertySystem|GetPropertyDescription|Returns an interface used to describe a property PyObject *PyIPropertySystem::GetPropertyDescription(PyObject *self, PyObject *args) { IPropertySystem *pIPS = GetI(self); if ( pIPS == NULL ) return NULL; PROPERTYKEY key; IID riid = IID_IPropertyDescription; void *ret; // @pyparm <o PyPROPERTYKEY>|Key||Fmtid and propertyid that uniquely identifies a property // @pyparm <o PyIID>|riid|IID_IPropertyDescription|The interface to return if ( !PyArg_ParseTuple(args, "O&|O&:GetPropertyDescription", PyWinObject_AsPROPERTYKEY, &key, PyWinObject_AsIID, &riid)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIPS->GetPropertyDescription(key, riid, &ret); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPS, IID_IPropertySystem ); return PyCom_PyObjectFromIUnknown((IUnknown *)ret, riid); }
// @pymethod interface|PyIShellItemResources|CreateResource|Description of CreateResource. PyObject *PyIShellItemResources::CreateResource(PyObject *self, PyObject *args) { IShellItemResources *pISIR = GetI(self); if ( pISIR == NULL ) return NULL; SHELL_ITEM_RESOURCE sir; PyObject *obpcsir; // @pyparm <o PySHELL_ITEM_RESOURCE>|sir||Resource identifier // @pyparm <o PyIID>|riid||The interface to return void *pv; IID riid; if ( !PyArg_ParseTuple(args, "OO&:CreateResource", &obpcsir, PyWinObject_AsIID, &riid)) return NULL; if (!PyWinObject_AsSHELL_ITEM_RESOURCE( obpcsir, &sir )) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISIR->CreateResource(&sir, riid, &pv ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISIR, IID_IShellItemResources ); return PyCom_PyObjectFromIUnknown((IUnknown *)pv, riid, FALSE); }
// @pymethod |PyIFileOperation|DeleteItems|Adds multiple delete operations to the configuration PyObject *PyIFileOperation::DeleteItems(PyObject *self, PyObject *args) { IFileOperation *pIFO = GetI(self); if ( pIFO == NULL ) return NULL; // @pyparm <o PyIUnknown>|Items||<o PyIShellItemArray>, <o PyIDataObject>, or <o PyIEnumShellItems> containing the items to be deleted PyObject *obItems; IUnknown * pItems; if ( !PyArg_ParseTuple(args, "O:DeleteItems", &obItems) ) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obItems, IID_IUnknown, (void **)&pItems, FALSE)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIFO->DeleteItems(pItems); pItems->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIFO, IID_IFileOperation ); Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyIShellLink|SetArguments|Sets the command-line arguments associated with a shell link object. PyObject *PyIShellLink::SetArguments(PyObject *self, PyObject *args) { IShellLink *pISL = GetI(self); if ( pISL == NULL ) return NULL; PyObject *obArgs; // @pyparm string|args||The new arguments. if ( !PyArg_ParseTuple(args, "O:SetArguments", &obArgs) ) return NULL; TCHAR *pszArgs; if (!PyWinObject_AsTCHAR(obArgs, &pszArgs)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISL->SetArguments( pszArgs ); PY_INTERFACE_POSTCALL; PyWinObject_FreeTCHAR(pszArgs); if ( FAILED(hr) ) return OleSetOleError(hr); Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyIPersistFile|Save|Saves the object into the specified file. PyObject *PyIPersistFile::Save(PyObject *self, PyObject *args) { IPersistFile *pIPF = GetI(self); if ( pIPF == NULL ) return NULL; // @pyparm str|FileName||absolute path of the file where the object is saved. // @pyparm int|fRemember||Specifies whether the file is to be the current working file or not. PyObject *obFileName; TmpWCHAR FileName; BOOL fRemember; if ( !PyArg_ParseTuple(args, "Oi:Save", &obFileName, &fRemember) ) return NULL; if (!PyWinObject_AsWCHAR(obFileName, &FileName, TRUE)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIPF->Save(FileName, fRemember ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile); Py_INCREF(Py_None); return Py_None; }
// @pymethod <o PyIShellItem>|PyITransferSource|ApplyPropertiesToItem|Changes an item's properties as specified by <om PyITransferSource::SetProperties> PyObject *PyITransferSource::ApplyPropertiesToItem(PyObject *self, PyObject *args) { ITransferSource *pITS = GetI(self); if ( pITS == NULL ) return NULL; // @pyparm <o PyIShellItem>|Source||Item whose properties are to be changed PyObject *obpsiSource; IShellItem * psiSource; IShellItem * ppsiNew; if ( !PyArg_ParseTuple(args, "O:ApplyPropertiesToItem", &obpsiSource) ) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiSource, IID_IShellItem, (void **)&psiSource, FALSE)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pITS->ApplyPropertiesToItem( psiSource, &ppsiNew ); psiSource->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pITS, IID_ITransferSource ); return PyCom_PyObjectFromIUnknown(ppsiNew, IID_IShellItem, FALSE); }
// @pymethod |PyINameSpaceTreeControl|GetNextItem|Description of GetNextItem. PyObject *PyINameSpaceTreeControl::GetNextItem(PyObject *self, PyObject *args) { INameSpaceTreeControl *pINSTC = GetI(self); if ( pINSTC == NULL ) return NULL; // @pyparm <o PyIShellItem>|psi||Description for psi // @pyparm int|nstcgi||Description for nstcgi PyObject *obpsi; IShellItem * psi; long nstcgi; IShellItem * ppsiNext; if ( !PyArg_ParseTuple(args, "Ol:GetNextItem", &obpsi, &nstcgi) ) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsi, IID_IShellItem, (void **)&psi, TRUE /* bNoneOK */)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pINSTC->GetNextItem( psi, (NSTCGNI)nstcgi, &ppsiNext ); if (psi) psi->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pINSTC, IID_INameSpaceTreeControl ); return PyCom_PyObjectFromIUnknown(ppsiNext, IID_IShellItem, FALSE); }
static PyObject *Get(PyObject *self, PyObject *args) { nsIVariant *pI = GetI(self); if (pI==NULL) return NULL; if (!PyArg_ParseTuple(args, ":Get")) return NULL; return PyObject_FromVariant((Py_nsISupports *)self, pI); }
// A method added for Python performance if you really need // it. Allows you to fetch a block of objects in one // hit, allowing the loop to remain implemented in C. static PyObject *PyFetchBlock(PyObject *self, PyObject *args) { PyObject *obIID = NULL; int n_wanted; int n_fetched = 0; if (!PyArg_ParseTuple(args, "i|O:FetchBlock", &n_wanted, &obIID)) return NULL; nsIID iid(NS_GET_IID(nsISupports)); if (obIID != NULL && !Py_nsIID::IIDFromPyObject(obIID, &iid)) return NULL; nsIEnumerator *pI = GetI(self); if (pI==NULL) return NULL; // We want to fetch with the thread-lock released, // but this means we can not append to the PyList nsISupports **fetched = new nsISupports*[n_wanted]; if (fetched==nsnull) { PyErr_NoMemory(); return NULL; } memset(fetched, 0, sizeof(nsISupports *) * n_wanted); nsresult r = NS_OK; Py_BEGIN_ALLOW_THREADS; for (;n_fetched<n_wanted;) { nsISupports *pNew; r = pI->CurrentItem(&pNew); if (NS_FAILED(r)) { r = 0; // Normal enum end break; } if (obIID) { nsISupports *temp; r = pNew->QueryInterface(iid, (void **)&temp); pNew->Release(); if ( NS_FAILED(r) ) { break; } pNew = temp; } fetched[n_fetched] = pNew; n_fetched++; // must increment before breaking out. if (NS_FAILED(pI->Next())) break; // not an error condition. } Py_END_ALLOW_THREADS; PyObject *ret; if (NS_SUCCEEDED(r)) { ret = PyList_New(n_fetched); if (ret) for (int i=0;i<n_fetched;i++) { PyObject *new_ob = Py_nsISupports::PyObjectFromInterface(fetched[i], iid, PR_FALSE); PyList_SET_ITEM(ret, i, new_ob); } } else ret = PyXPCOM_BuildPyException(r); if ( ret == NULL ) { // Free the objects we consumed. for (int i=0;i<n_fetched;i++) fetched[i]->Release(); } delete [] fetched; return ret; }
PyObject *PyITypeComp::Bind(OLECHAR* s,unsigned short w) { return ITypeCompBind(GetI(this),s,w); }
// find the suffix array SA of s[0..n-1] in {1..K}^n // require s[n]=s[n+1]=s[n+2]=0, n>=2 void suffixArray(int* s, int* SA, int n, int K) { int n0=(n+2)/3, n1=(n+1)/3, n2=n/3, n02=n0+n2; int* s12 = new int[n02 + 3]; s12[n02]= s12[n02+1]= s12[n02+2]=0; int* SA12 = new int[n02 + 3]; SA12[n02]=SA12[n02+1]=SA12[n02+2]=0; int* s0 = new int[n0]; int* SA0 = new int[n0]; // generate positions of mod 1 and mod 2 suffixes // the "+(n0-n1)" adds a dummy mod 1 suffix if n%3 == 1 for (int i=0, j=0; i < n+(n0-n1); i++) if (i%3 != 0) s12[j++] = i; // lsb radix sort the mod 1 and mod 2 triples radixPass(s12 , SA12, s+2, n02, K); radixPass(SA12, s12 , s+1, n02, K); radixPass(s12 , SA12, s , n02, K); // find lexicographic names of triples int name = 0, c0 = -1, c1 = -1, c2 = -1; for (int i = 0; i < n02; i++) { if (s[SA12[i]] != c0 || s[SA12[i]+1] != c1 || s[SA12[i]+2] != c2) { name++; c0 = s[SA12[i]]; c1 = s[SA12[i]+1]; c2 = s[SA12[i]+2]; } if (SA12[i] % 3 == 1) { s12[SA12[i]/3] = name; } // left half else { s12[SA12[i]/3 + n0] = name; } // right half } // recurse if names are not yet unique if (name < n02) { suffixArray(s12, SA12, n02, name); // store unique names in s12 using the suffix array for (int i = 0; i < n02; i++) s12[SA12[i]] = i + 1; } else // generate the suffix array of s12 directly for (int i = 0; i < n02; i++) SA12[s12[i] - 1] = i; // stably sort the mod 0 suffixes from SA12 by their first character for (int i=0, j=0; i < n02; i++) if (SA12[i] < n0) s0[j++] = 3*SA12[i]; radixPass(s0, SA0, s, n0, K); // merge sorted SA0 suffixes and sorted SA12 suffixes for (int p=0, t=n0-n1, k=0; k < n; k++) { #define GetI() (SA12[t] < n0 ? SA12[t] * 3 + 1 : (SA12[t] - n0) * 3 + 2) int i = GetI(); // pos of current offset 12 suffix int j = SA0[p]; // pos of current offset 0 suffix if (SA12[t] < n0 ? leq(s[i], s12[SA12[t] + n0], s[j], s12[j/3]) : leq(s[i],s[i+1],s12[SA12[t]-n0+1], s[j],s[j+1],s12[j/3+n0])) { // suffix from SA12 is smaller SA[k] = i; t++; if (t == n02) { // done --- only SA0 suffixes left for (k++; p < n0; p++, k++) SA[k] = SA0[p]; } } else { SA[k] = j; p++; if (p == n0) { // done --- only SA12 suffixes left for (k++; t < n02; t++, k++) SA[k] = GetI(); } } } delete [] s12; delete [] SA12; delete [] SA0; delete [] s0; }
void HMap::Paint(){ double v1[3], v2[3], v3[3]; glPushMatrix(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glShadeModel(GL_SMOOTH); float colorBlue[] = { 1.0f, 1.0f, 1.0f, 1.0f }; float colorBlue2[] = { 1.0f, 1.0f, 1.0f, 1.0f }; glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, colorBlue); //glMaterialfv(GL_FRONT, GL_SPECULAR, colorBlue2); glEnable(GL_COLOR_MATERIAL); for (int x = 1; x < SizeX-1; x++) { glBegin(GL_QUAD_STRIP); for (int z = 1; z < SizeY; z++) { v2[0] = -(abs(GetI(x,z)))+(abs(GetI(x+1, z))); v1[0] = v2[0]; v1[1] = -1.0f; v1[2] = v2[0]; v2[1] = sqrt(v1[0]*v1[0]+1+v1[0]*v1[0]); v1[0] /= v2[1]; v1[1] /= v2[1]; v1[2] /= v2[1]; glColor3f(abs(GetI(x,z)/cs),abs(GetI(x,z)/cs),abs(GetI(x,z)/cs*2)); glVertex3f( x, (abs(ss*GetI(x,z))) , z ); glVertex3f( x+1, (abs(ss*GetI(x+1,z))) , z ); glNormal3f(v1[0],v1[2],v1[3]); } glEnd(); } glPopMatrix(); glColor3f(1.0f,1.0f,1.0f); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //Border line glDisable(GL_LIGHTING); glLineWidth(2.5); glColor3f(1.0, 1.0, 1.0); glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glBegin(GL_LINE_STRIP); glVertex3f(0.0, 0.0, 0.0); glVertex3f(SizeX, 0, 0); glVertex3f(SizeX, 0, SizeY); glVertex3f(0, 0, SizeY); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, Height, 0.0); glVertex3f(SizeX, Height, 0.0); glVertex3f(SizeX, Height, SizeY); glVertex3f(0, Height, SizeY); glVertex3f(0.0, Height, 0.0); glEnd(); glEnable(GL_LIGHTING); }