d3dxof: Implement IDirectXFileDataImpl_GetNextObject.

This commit is contained in:
Christian Costa 2008-09-22 20:27:09 +02:00 committed by Alexandre Julliard
parent e8754b8ea6
commit 8002b79087
2 changed files with 33 additions and 15 deletions

View File

@ -161,7 +161,7 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
DWORD size; DWORD size;
HANDLE hFile = INVALID_HANDLE_VALUE; HANDLE hFile = INVALID_HANDLE_VALUE;
FIXME("(%p/%p)->(%p,%x,%p) partial stub!\n", This, iface, pvSource, dwLoadOptions, ppEnumObj); TRACE("(%p/%p)->(%p,%x,%p)\n", This, iface, pvSource, dwLoadOptions, ppEnumObj);
if (!ppEnumObj) if (!ppEnumObj)
return DXFILEERR_BADVALUE; return DXFILEERR_BADVALUE;
@ -1393,14 +1393,25 @@ static HRESULT WINAPI IDirectXFileDataImpl_GetType(IDirectXFileData* iface, cons
static HRESULT WINAPI IDirectXFileDataImpl_GetNextObject(IDirectXFileData* iface, LPDIRECTXFILEOBJECT* ppChildObj) static HRESULT WINAPI IDirectXFileDataImpl_GetNextObject(IDirectXFileData* iface, LPDIRECTXFILEOBJECT* ppChildObj)
{ {
HRESULT hr;
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface; IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
IDirectXFileDataImpl *object;
FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppChildObj); TRACE("(%p/%p)->(%p)\n", This, iface, ppChildObj);
if (This->cur_enum_object >= This->pobj->nb_childs) if (This->cur_enum_object >= This->pobj->nb_childs)
return DXFILEERR_NOMOREOBJECTS; return DXFILEERR_NOMOREOBJECTS;
return DXFILEERR_BADVALUE; hr = IDirectXFileDataImpl_Create(&object);
if (hr != S_OK)
return DXFILEERR_BADVALUE;
object->pobj = This->pobj->childs[This->cur_enum_object++];
object->cur_enum_object = 0;
*ppChildObj = (LPDIRECTXFILEOBJECT)object;
return DXFILE_OK;
} }
static HRESULT WINAPI IDirectXFileDataImpl_AddDataObject(IDirectXFileData* iface, LPDIRECTXFILEDATA pDataObj) static HRESULT WINAPI IDirectXFileDataImpl_AddDataObject(IDirectXFileData* iface, LPDIRECTXFILEDATA pDataObj)
@ -1751,6 +1762,8 @@ static BOOL parse_object_parts(parse_buffer * buf, BOOL allow_optional)
if (allow_optional) if (allow_optional)
{ {
buf->pxo->size = buf->cur_pdata - buf->pxo->pdata;
/* Skip trailing semicolon */ /* Skip trailing semicolon */
while (check_TOKEN(buf) == TOKEN_SEMICOLON) while (check_TOKEN(buf) == TOKEN_SEMICOLON)
get_TOKEN(buf); get_TOKEN(buf);
@ -1767,6 +1780,9 @@ static BOOL parse_object_parts(parse_buffer * buf, BOOL allow_optional)
} }
else if (check_TOKEN(buf) == TOKEN_NAME) else if (check_TOKEN(buf) == TOKEN_NAME)
{ {
xobject* pxo = buf->pxo;
buf->pxo = buf->pxo->childs[buf->pxo->nb_childs] = &buf->pxo_tab[buf->cur_subobject++];
TRACE("Enter optional %s\n", (char*)buf->value); TRACE("Enter optional %s\n", (char*)buf->value);
buf->level++; buf->level++;
if (!parse_object(buf)) if (!parse_object(buf))
@ -1775,6 +1791,8 @@ static BOOL parse_object_parts(parse_buffer * buf, BOOL allow_optional)
return FALSE; return FALSE;
} }
buf->level--; buf->level--;
buf->pxo = pxo;
buf->pxo->nb_childs++;
} }
else else
break; break;
@ -1788,6 +1806,8 @@ static BOOL parse_object(parse_buffer * buf)
{ {
int i; int i;
buf->pxo->pdata = buf->cur_pdata;
if (get_TOKEN(buf) != TOKEN_NAME) if (get_TOKEN(buf) != TOKEN_NAME)
return FALSE; return FALSE;
@ -1849,10 +1869,9 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileE
IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface; IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface;
IDirectXFileDataImpl* object; IDirectXFileDataImpl* object;
HRESULT hr; HRESULT hr;
LPBYTE pdata;
FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppDataObj); TRACE("(%p/%p)->(%p)\n", This, iface, ppDataObj);
/*printf("%d\n", This->buf.rem_bytes);*/
if (!This->buf.rem_bytes) if (!This->buf.rem_bytes)
return DXFILEERR_NOMOREOBJECTS; return DXFILEERR_NOMOREOBJECTS;
@ -1861,20 +1880,19 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileE
if (!SUCCEEDED(hr)) if (!SUCCEEDED(hr))
return hr; return hr;
This->buf.pxo = &This->xobjects[This->nb_xobjects][This->buf.cur_subobject]; This->buf.pxo_tab = &This->xobjects[This->nb_xobjects][0];
TRACE("Start %d %d\n", This->nb_xobjects, This->buf.cur_subobject); This->buf.cur_subobject = 0;
This->buf.pxo = &This->buf.pxo_tab[This->buf.cur_subobject++];
This->buf.pxo->pdata = HeapAlloc(GetProcessHeap(), 0, MAX_DATA_SIZE); pdata = HeapAlloc(GetProcessHeap(), 0, MAX_DATA_SIZE);
if (!This->buf.pxo->pdata) if (!pdata)
{ {
WARN("Out of memory\n"); WARN("Out of memory\n");
return DXFILEERR_BADALLOC; return DXFILEERR_BADALLOC;
} }
This->buf.cur_pdata = This->buf.pxo->pdata; This->buf.cur_pdata = pdata;
This->buf.level = 0; This->buf.level = 0;
This->buf.pxo->pdata = This->buf.cur_pdata;
if (!parse_object(&This->buf)) if (!parse_object(&This->buf))
{ {
TRACE("Object is not correct\n"); TRACE("Object is not correct\n");
@ -1882,9 +1900,8 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileE
return DXFILEERR_PARSEERROR; return DXFILEERR_PARSEERROR;
} }
This->buf.pxo->size = This->buf.cur_pdata - This->buf.pxo->pdata;
object->pobj = This->buf.pxo; object->pobj = This->buf.pxo;
object->cur_enum_object = 0;
*ppDataObj = (LPDIRECTXFILEDATA)object; *ppDataObj = (LPDIRECTXFILEDATA)object;

View File

@ -120,6 +120,7 @@ typedef struct {
ULONG cur_subobject; ULONG cur_subobject;
LPBYTE cur_pdata; LPBYTE cur_pdata;
BYTE value[100]; BYTE value[100];
xobject* pxo_tab;
IDirectXFileImpl* pdxf; IDirectXFileImpl* pdxf;
xobject* pxo; xobject* pxo;
xtemplate* pxt[MAX_SUBOBJECTS]; xtemplate* pxt[MAX_SUBOBJECTS];