Hi Nikolay,
On 2/14/11 9:04 PM, Nikolay Sivov wrote:
Basic put_input() method for IXSLProcessor
+ IXMLDOMNode *old_input = This->input; + HRESULT hr;
- FIXME("(%p): stub\n", This); - return E_NOTIMPL; + TRACE("(%p)->(type=%d)\n", This, V_VT(&input)); + + /* try IXMLDOMNode directly first */ + if (V_VT(&input) == VT_UNKNOWN) + hr = IUnknown_QueryInterface(V_UNKNOWN(&input),&IID_IXMLDOMNode, (void**)&This->input); + else if (V_VT(&input) == VT_DISPATCH) + hr = IDispatch_QueryInterface(V_DISPATCH(&input),&IID_IXMLDOMNode, (void**)&This->input); + + if (hr != S_OK) + { + IXMLDOMDocument *doc; + + hr = DOMDocument_create(&CLSID_DOMDocument, NULL, (void**)&doc); + if (hr == S_OK) + { + hr = IXMLDOMDocument_QueryInterface(doc,&IID_IXMLDOMNode, (void**)&This->input); + IXMLDOMDocument_Release(doc); + } + } + + if (hr == S_OK&& old_input) IXMLDOMNode_Release(old_input);
Failure of QueryInterface call will set This->input to NULL (you probably want it not changed and even if not, that's a leak). It's probably better idea to have local pointer to the new input instead of old one and change it once you know the function will succeed.
Jacek