msvcr120: Add fegetexceptflag.
[wine/zf.git] / dlls / dmscript / script.c
blob80c5273a710eb2099ad424e233832ecb4e0592f1
1 /* IDirectMusicScript
3 * Copyright (C) 2003-2004 Rok Mandeljc
4 * Copyright (C) 2003-2004 Raphael Junqueira
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <stdio.h>
24 #include "dmscript_private.h"
25 #include "dmobject.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(dmscript);
28 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
31 /*****************************************************************************
32 * IDirectMusicScriptImpl implementation
34 typedef struct IDirectMusicScriptImpl {
35 IDirectMusicScript IDirectMusicScript_iface;
36 struct dmobject dmobj;
37 LONG ref;
38 IDirectMusicPerformance *pPerformance;
39 DMUS_IO_SCRIPT_HEADER *pHeader;
40 DMUS_IO_VERSION *pVersion;
41 WCHAR *pwzLanguage;
42 WCHAR *pwzSource;
43 } IDirectMusicScriptImpl;
45 static inline IDirectMusicScriptImpl *impl_from_IDirectMusicScript(IDirectMusicScript *iface)
47 return CONTAINING_RECORD(iface, IDirectMusicScriptImpl, IDirectMusicScript_iface);
50 static HRESULT WINAPI IDirectMusicScriptImpl_QueryInterface(IDirectMusicScript *iface, REFIID riid,
51 void **ret_iface)
53 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
55 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
57 *ret_iface = NULL;
59 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicScript))
60 *ret_iface = iface;
61 else if (IsEqualIID(riid, &IID_IDirectMusicObject))
62 *ret_iface = &This->dmobj.IDirectMusicObject_iface;
63 else if (IsEqualIID(riid, &IID_IPersistStream))
64 *ret_iface = &This->dmobj.IPersistStream_iface;
65 else {
66 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
67 return E_NOINTERFACE;
70 IUnknown_AddRef((IUnknown*)*ret_iface);
71 return S_OK;
74 static ULONG WINAPI IDirectMusicScriptImpl_AddRef(IDirectMusicScript *iface)
76 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
77 LONG ref = InterlockedIncrement(&This->ref);
79 TRACE("(%p) ref=%d\n", This, ref);
81 return ref;
84 static ULONG WINAPI IDirectMusicScriptImpl_Release(IDirectMusicScript *iface)
86 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
87 LONG ref = InterlockedDecrement(&This->ref);
89 TRACE("(%p) ref=%d\n", This, ref);
91 if (!ref) {
92 HeapFree(GetProcessHeap(), 0, This->pHeader);
93 HeapFree(GetProcessHeap(), 0, This->pVersion);
94 HeapFree(GetProcessHeap(), 0, This->pwzLanguage);
95 HeapFree(GetProcessHeap(), 0, This->pwzSource);
96 HeapFree(GetProcessHeap(), 0, This);
97 DMSCRIPT_UnlockModule();
100 return ref;
103 static HRESULT WINAPI IDirectMusicScriptImpl_Init(IDirectMusicScript *iface,
104 IDirectMusicPerformance *pPerformance, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
106 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
107 FIXME("(%p, %p, %p): stub\n", This, pPerformance, pErrorInfo);
108 This->pPerformance = pPerformance;
109 return S_OK;
112 static HRESULT WINAPI IDirectMusicScriptImpl_CallRoutine(IDirectMusicScript *iface,
113 WCHAR *pwszRoutineName, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
115 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
116 FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszRoutineName), pErrorInfo);
117 /*return E_NOTIMPL;*/
118 return S_OK;
119 /*return E_FAIL;*/
122 static HRESULT WINAPI IDirectMusicScriptImpl_SetVariableVariant(IDirectMusicScript *iface,
123 WCHAR *pwszVariableName, VARIANT varValue, BOOL fSetRef, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
125 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
126 FIXME("(%p, %s, FIXME, %d, %p): stub\n", This, debugstr_w(pwszVariableName),/* varValue,*/ fSetRef, pErrorInfo);
127 return S_OK;
130 static HRESULT WINAPI IDirectMusicScriptImpl_GetVariableVariant(IDirectMusicScript *iface,
131 WCHAR *pwszVariableName, VARIANT *pvarValue, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
133 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
134 FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), pvarValue, pErrorInfo);
135 return S_OK;
138 static HRESULT WINAPI IDirectMusicScriptImpl_SetVariableNumber(IDirectMusicScript *iface,
139 WCHAR *pwszVariableName, LONG lValue, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
141 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
142 FIXME("(%p, %s, %i, %p): stub\n", This, debugstr_w(pwszVariableName), lValue, pErrorInfo);
143 return S_OK;
146 static HRESULT WINAPI IDirectMusicScriptImpl_GetVariableNumber(IDirectMusicScript *iface,
147 WCHAR *pwszVariableName, LONG *plValue, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
149 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
150 FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), plValue, pErrorInfo);
151 return S_OK;
154 static HRESULT WINAPI IDirectMusicScriptImpl_SetVariableObject(IDirectMusicScript *iface,
155 WCHAR *pwszVariableName, IUnknown *punkValue, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
157 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
158 FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), punkValue, pErrorInfo);
159 return S_OK;
162 static HRESULT WINAPI IDirectMusicScriptImpl_GetVariableObject(IDirectMusicScript *iface,
163 WCHAR *pwszVariableName, REFIID riid, void **ppv, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
165 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
166 FIXME("(%p, %s, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), debugstr_dmguid(riid), ppv, pErrorInfo);
167 return S_OK;
170 static HRESULT WINAPI IDirectMusicScriptImpl_EnumRoutine(IDirectMusicScript *iface, DWORD dwIndex,
171 WCHAR *pwszName)
173 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
174 FIXME("(%p, %d, %p): stub\n", This, dwIndex, pwszName);
175 return S_OK;
178 static HRESULT WINAPI IDirectMusicScriptImpl_EnumVariable(IDirectMusicScript *iface, DWORD dwIndex,
179 WCHAR *pwszName)
181 IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
182 FIXME("(%p, %d, %p): stub\n", This, dwIndex, pwszName);
183 return S_OK;
186 static const IDirectMusicScriptVtbl dmscript_vtbl = {
187 IDirectMusicScriptImpl_QueryInterface,
188 IDirectMusicScriptImpl_AddRef,
189 IDirectMusicScriptImpl_Release,
190 IDirectMusicScriptImpl_Init,
191 IDirectMusicScriptImpl_CallRoutine,
192 IDirectMusicScriptImpl_SetVariableVariant,
193 IDirectMusicScriptImpl_GetVariableVariant,
194 IDirectMusicScriptImpl_SetVariableNumber,
195 IDirectMusicScriptImpl_GetVariableNumber,
196 IDirectMusicScriptImpl_SetVariableObject,
197 IDirectMusicScriptImpl_GetVariableObject,
198 IDirectMusicScriptImpl_EnumRoutine,
199 IDirectMusicScriptImpl_EnumVariable
202 static HRESULT WINAPI script_IDirectMusicObject_ParseDescriptor(IDirectMusicObject *iface,
203 IStream *stream, DMUS_OBJECTDESC *desc)
205 struct chunk_entry riff = {0};
206 HRESULT hr;
208 TRACE("(%p, %p, %p)\n", iface, stream, desc);
210 if (!stream || !desc)
211 return E_POINTER;
213 if ((hr = stream_get_chunk(stream, &riff)) != S_OK)
214 return hr;
215 if (riff.id != FOURCC_RIFF || riff.type != DMUS_FOURCC_SCRIPT_FORM) {
216 TRACE("loading failed: unexpected %s\n", debugstr_chunk(&riff));
217 stream_skip_chunk(stream, &riff);
218 return DMUS_E_SCRIPT_INVALID_FILE;
221 hr = dmobj_parsedescriptor(stream, &riff, desc,
222 DMUS_OBJ_OBJECT|DMUS_OBJ_NAME|DMUS_OBJ_NAME_INAM|DMUS_OBJ_CATEGORY|DMUS_OBJ_VERSION);
223 if (FAILED(hr))
224 return hr;
226 if (desc->dwValidData) {
227 desc->guidClass = CLSID_DirectMusicScript;
228 desc->dwValidData |= DMUS_OBJ_CLASS;
231 TRACE("returning descriptor:\n");
232 dump_DMUS_OBJECTDESC(desc);
233 return S_OK;
236 static const IDirectMusicObjectVtbl dmobject_vtbl = {
237 dmobj_IDirectMusicObject_QueryInterface,
238 dmobj_IDirectMusicObject_AddRef,
239 dmobj_IDirectMusicObject_Release,
240 dmobj_IDirectMusicObject_GetDescriptor,
241 dmobj_IDirectMusicObject_SetDescriptor,
242 script_IDirectMusicObject_ParseDescriptor
245 /* IDirectMusicScriptImpl IPersistStream part: */
246 static inline IDirectMusicScriptImpl *impl_from_IPersistStream(IPersistStream *iface)
248 return CONTAINING_RECORD(iface, IDirectMusicScriptImpl, dmobj.IPersistStream_iface);
251 static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pStm)
253 IDirectMusicScriptImpl *This = impl_from_IPersistStream(iface);
254 DMUS_PRIVATE_CHUNK Chunk;
255 DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
256 LARGE_INTEGER liMove; /* used when skipping chunks */
257 LPDIRECTMUSICGETLOADER pGetLoader = NULL;
258 LPDIRECTMUSICLOADER pLoader = NULL;
260 FIXME("(%p, %p): Loading not implemented yet\n", This, pStm);
261 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
262 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
263 switch (Chunk.fccID) {
264 case FOURCC_RIFF: {
265 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
266 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
267 StreamSize = Chunk.dwSize - sizeof(FOURCC);
268 StreamCount = 0;
269 switch (Chunk.fccID) {
270 case DMUS_FOURCC_SCRIPT_FORM: {
271 TRACE_(dmfile)(": script form\n");
272 do {
273 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
274 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
275 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
276 switch (Chunk.fccID) {
277 case DMUS_FOURCC_SCRIPT_CHUNK: {
278 TRACE_(dmfile)(": script header chunk\n");
279 This->pHeader = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
280 IStream_Read (pStm, This->pHeader, Chunk.dwSize, NULL);
281 break;
283 case DMUS_FOURCC_SCRIPTVERSION_CHUNK: {
284 TRACE_(dmfile)(": script version chunk\n");
285 This->pVersion = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
286 IStream_Read (pStm, This->pVersion, Chunk.dwSize, NULL);
287 TRACE_(dmfile)("version: 0x%08x.0x%08x\n", This->pVersion->dwVersionMS, This->pVersion->dwVersionLS);
288 break;
290 case DMUS_FOURCC_SCRIPTLANGUAGE_CHUNK: {
291 TRACE_(dmfile)(": script language chunk\n");
292 This->pwzLanguage = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
293 IStream_Read (pStm, This->pwzLanguage, Chunk.dwSize, NULL);
294 TRACE_(dmfile)("using language: %s\n", debugstr_w(This->pwzLanguage));
295 break;
297 case DMUS_FOURCC_SCRIPTSOURCE_CHUNK: {
298 TRACE_(dmfile)(": script source chunk\n");
299 This->pwzSource = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
300 IStream_Read (pStm, This->pwzSource, Chunk.dwSize, NULL);
301 if (TRACE_ON(dmscript)) {
302 int count = WideCharToMultiByte(CP_ACP, 0, This->pwzSource, -1, NULL, 0, NULL, NULL);
303 LPSTR str = HeapAlloc(GetProcessHeap (), 0, count);
304 WideCharToMultiByte(CP_ACP, 0, This->pwzSource, -1, str, count, NULL, NULL);
305 str[count-1] = '\n';
306 TRACE("source:\n");
307 fwrite( str, 1, count, stderr );
308 HeapFree(GetProcessHeap(), 0, str);
310 break;
312 case DMUS_FOURCC_GUID_CHUNK: {
313 TRACE_(dmfile)(": GUID chunk\n");
314 This->dmobj.desc.dwValidData |= DMUS_OBJ_OBJECT;
315 IStream_Read (pStm, &This->dmobj.desc.guidObject, Chunk.dwSize, NULL);
316 break;
318 case DMUS_FOURCC_VERSION_CHUNK: {
319 TRACE_(dmfile)(": version chunk\n");
320 This->dmobj.desc.dwValidData |= DMUS_OBJ_VERSION;
321 IStream_Read (pStm, &This->dmobj.desc.vVersion, Chunk.dwSize, NULL);
322 break;
324 case DMUS_FOURCC_CATEGORY_CHUNK: {
325 TRACE_(dmfile)(": category chunk\n");
326 This->dmobj.desc.dwValidData |= DMUS_OBJ_CATEGORY;
327 IStream_Read (pStm, This->dmobj.desc.wszCategory, Chunk.dwSize, NULL);
328 break;
330 case FOURCC_RIFF: {
331 IDirectMusicObject* pObject = NULL;
332 DMUS_OBJECTDESC desc;
334 ZeroMemory (&desc, sizeof(DMUS_OBJECTDESC));
335 desc.dwSize = sizeof(DMUS_OBJECTDESC);
336 desc.dwValidData = DMUS_OBJ_STREAM | DMUS_OBJ_CLASS;
337 desc.guidClass = CLSID_DirectMusicContainer;
338 desc.pStream = NULL;
339 IStream_Clone (pStm, &desc.pStream);
341 liMove.QuadPart = 0;
342 liMove.QuadPart -= (sizeof(FOURCC) + sizeof(DWORD));
343 IStream_Seek (desc.pStream, liMove, STREAM_SEEK_CUR, NULL);
345 IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader);
346 IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader);
347 IDirectMusicGetLoader_Release (pGetLoader);
349 if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader, &desc, &IID_IDirectMusicObject, (LPVOID*) &pObject))) {
350 IDirectMusicObject_Release (pObject);
351 } else {
352 ERR_(dmfile)("Error on GetObject while trying to load Scrip SubContainer\n");
355 IDirectMusicLoader_Release (pLoader); pLoader = NULL; /* release loader */
356 IStream_Release(desc.pStream); desc.pStream = NULL; /* release cloned stream */
358 liMove.QuadPart = Chunk.dwSize;
359 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
361 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
362 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
363 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
364 ListCount[0] = 0;
366 switch (Chunk.fccID) {
367 default: {
368 TRACE_(dmfile)(": unknown (skipping)\n");
369 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
370 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
371 break;
375 break;
377 case FOURCC_LIST: {
378 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
379 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
380 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
381 ListCount[0] = 0;
382 switch (Chunk.fccID) {
383 case DMUS_FOURCC_UNFO_LIST: {
384 TRACE_(dmfile)(": UNFO list\n");
385 do {
386 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
387 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
388 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
389 switch (Chunk.fccID) {
390 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
391 (though strings seem to be valid unicode) */
392 case mmioFOURCC('I','N','A','M'):
393 case DMUS_FOURCC_UNAM_CHUNK: {
394 TRACE_(dmfile)(": name chunk\n");
395 This->dmobj.desc.dwValidData |= DMUS_OBJ_NAME;
396 IStream_Read (pStm, This->dmobj.desc.wszName, Chunk.dwSize, NULL);
397 break;
399 case mmioFOURCC('I','A','R','T'):
400 case DMUS_FOURCC_UART_CHUNK: {
401 TRACE_(dmfile)(": artist chunk (ignored)\n");
402 liMove.QuadPart = Chunk.dwSize;
403 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
404 break;
406 case mmioFOURCC('I','C','O','P'):
407 case DMUS_FOURCC_UCOP_CHUNK: {
408 TRACE_(dmfile)(": copyright chunk (ignored)\n");
409 liMove.QuadPart = Chunk.dwSize;
410 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
411 break;
413 case mmioFOURCC('I','S','B','J'):
414 case DMUS_FOURCC_USBJ_CHUNK: {
415 TRACE_(dmfile)(": subject chunk (ignored)\n");
416 liMove.QuadPart = Chunk.dwSize;
417 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
418 break;
420 case mmioFOURCC('I','C','M','T'):
421 case DMUS_FOURCC_UCMT_CHUNK: {
422 TRACE_(dmfile)(": comment chunk (ignored)\n");
423 liMove.QuadPart = Chunk.dwSize;
424 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
425 break;
427 default: {
428 TRACE_(dmfile)(": unknown sub-chunk (irrelevant & skipping)\n");
429 liMove.QuadPart = Chunk.dwSize;
430 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
431 break;
434 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
435 } while (ListCount[0] < ListSize[0]);
436 break;
438 default: {
439 TRACE_(dmfile)(": unknown (skipping)\n");
440 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
441 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
442 break;
445 break;
447 default: {
448 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
449 liMove.QuadPart = Chunk.dwSize;
450 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
451 break;
454 TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
455 } while (StreamCount < StreamSize);
456 break;
458 default: {
459 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
460 liMove.QuadPart = StreamSize;
461 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
462 return E_FAIL;
465 TRACE_(dmfile)(": reading finished\n");
466 break;
468 default: {
469 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
470 liMove.QuadPart = Chunk.dwSize;
471 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
472 return E_FAIL;
476 return S_OK;
479 static const IPersistStreamVtbl persiststream_vtbl = {
480 dmobj_IPersistStream_QueryInterface,
481 dmobj_IPersistStream_AddRef,
482 dmobj_IPersistStream_Release,
483 unimpl_IPersistStream_GetClassID,
484 unimpl_IPersistStream_IsDirty,
485 IPersistStreamImpl_Load,
486 unimpl_IPersistStream_Save,
487 unimpl_IPersistStream_GetSizeMax
490 /* for ClassFactory */
491 HRESULT WINAPI DMUSIC_CreateDirectMusicScriptImpl(REFIID lpcGUID, void **ppobj, IUnknown *pUnkOuter)
493 IDirectMusicScriptImpl *obj;
494 HRESULT hr;
496 *ppobj = NULL;
498 if (pUnkOuter)
499 return CLASS_E_NOAGGREGATION;
501 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicScriptImpl));
502 if (!obj)
503 return E_OUTOFMEMORY;
505 obj->IDirectMusicScript_iface.lpVtbl = &dmscript_vtbl;
506 obj->ref = 1;
507 dmobject_init(&obj->dmobj, &CLSID_DirectMusicScript, (IUnknown*)&obj->IDirectMusicScript_iface);
508 obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
509 obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
511 DMSCRIPT_LockModule();
512 hr = IDirectMusicScript_QueryInterface(&obj->IDirectMusicScript_iface, lpcGUID, ppobj);
513 IDirectMusicScript_Release(&obj->IDirectMusicScript_iface);
515 return hr;