winealsa: Add critical section names for debugging.
[wine/gsoc_dplay.git] / dlls / msxml3 / factory.c
blobf825879d808556dbc07715c27f55b0b64fe4f590
1 /*
2 * MSXML Class Factory
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2005 Mike McCormack
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define COBJMACROS
24 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "msxml2.h"
31 #include "wine/debug.h"
33 #include "msxml_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
37 typedef HRESULT (*fnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
39 /******************************************************************************
40 * MSXML ClassFactory
42 typedef struct _xmlcf
44 const struct IClassFactoryVtbl *lpVtbl;
45 fnCreateInstance pfnCreateInstance;
46 } xmlcf;
48 static inline xmlcf *impl_from_IClassFactory( IClassFactory *iface )
50 return (xmlcf *)((char*)iface - FIELD_OFFSET(xmlcf, lpVtbl));
53 static HRESULT WINAPI xmlcf_QueryInterface(
54 IClassFactory *iface,
55 REFIID riid,
56 LPVOID *ppobj )
58 if (IsEqualGUID(riid, &IID_IUnknown) ||
59 IsEqualGUID(riid, &IID_IClassFactory))
61 IClassFactory_AddRef( iface );
62 *ppobj = iface;
63 return S_OK;
66 return E_NOINTERFACE;
69 static ULONG WINAPI xmlcf_AddRef(
70 IClassFactory *iface )
72 return 2;
75 static ULONG WINAPI xmlcf_Release(
76 IClassFactory *iface )
78 return 1;
81 static HRESULT WINAPI xmlcf_CreateInstance(
82 IClassFactory *iface,
83 LPUNKNOWN pOuter,
84 REFIID riid,
85 LPVOID *ppobj )
87 xmlcf *This = impl_from_IClassFactory( iface );
88 HRESULT r;
89 IUnknown *punk;
91 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
93 *ppobj = NULL;
95 if (pOuter)
96 return CLASS_E_NOAGGREGATION;
98 r = This->pfnCreateInstance( pOuter, (LPVOID*) &punk );
99 if (FAILED(r))
100 return r;
102 r = IUnknown_QueryInterface( punk, riid, ppobj );
103 if (FAILED(r))
104 return r;
105 IUnknown_Release( punk );
106 return r;
109 static HRESULT WINAPI xmlcf_LockServer(
110 IClassFactory *iface,
111 BOOL dolock)
113 FIXME("(%p)->(%d),stub!\n",iface,dolock);
114 return S_OK;
117 const struct IClassFactoryVtbl xmlcf_vtbl =
119 xmlcf_QueryInterface,
120 xmlcf_AddRef,
121 xmlcf_Release,
122 xmlcf_CreateInstance,
123 xmlcf_LockServer
126 static xmlcf domdoccf = { &xmlcf_vtbl, DOMDocument_create };
128 /******************************************************************
129 * DllGetClassObject (MSXML3.@)
131 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
133 IClassFactory *cf = NULL;
135 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv );
137 if( IsEqualGUID( rclsid, &CLSID_DOMDocument ) )
138 cf = (IClassFactory*) &domdoccf.lpVtbl;
140 if ( !cf )
141 return CLASS_E_CLASSNOTAVAILABLE;
143 return IClassFactory_QueryInterface( cf, iid, ppv );