d3dxof: Enable retrieving a particular member in GetData + tests.
This commit is contained in:
parent
f87191815d
commit
d581f1bf7d
|
@ -616,12 +616,23 @@ static HRESULT WINAPI IDirectXFileDataImpl_GetData(IDirectXFileData* iface, LPCS
|
|||
|
||||
if (szMember)
|
||||
{
|
||||
FIXME("Specifying a member is not supported yet!\n");
|
||||
return DXFILEERR_BADVALUE;
|
||||
int i;
|
||||
for (i = 0; i < This->pobj->nb_members; i++)
|
||||
if (!strcmp(This->pobj->members[i].name, szMember))
|
||||
break;
|
||||
if (i == This->pobj->nb_members)
|
||||
{
|
||||
WARN("Unknown member '%s'\n", szMember);
|
||||
return DXFILEERR_BADDATAREFERENCE;
|
||||
}
|
||||
|
||||
*pcbSize = This->pobj->members[i].size;
|
||||
*ppvData = This->pobj->root->pdata + This->pobj->members[i].start;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pcbSize = This->pobj->size;
|
||||
*ppvData = This->pobj->root->pdata + This->pobj->pos_data;
|
||||
}
|
||||
|
||||
return DXFILE_OK;
|
||||
}
|
||||
|
|
|
@ -1149,6 +1149,8 @@ static BOOL parse_object_members_list(parse_buffer * buf)
|
|||
int i;
|
||||
xtemplate* pt = buf->pxt[buf->level];
|
||||
|
||||
buf->pxo->nb_members = pt->nb_members;
|
||||
|
||||
for (i = 0; i < pt->nb_members; i++)
|
||||
{
|
||||
int k;
|
||||
|
@ -1295,6 +1297,7 @@ static BOOL parse_object_members_list(parse_buffer * buf)
|
|||
if ((token != TOKEN_SEMICOLON) && (token != TOKEN_COMMA))
|
||||
return FALSE;
|
||||
}
|
||||
buf->pxo->members[i].size = buf->cur_pos_data - buf->pxo->members[i].start;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -204,12 +204,38 @@ static void test_CreateEnumObject(void)
|
|||
hr = IDirectXFileEnumObject_GetNextDataObject(lpdxfeo, &lpdxfd);
|
||||
ok(hr == DXFILE_OK, "IDirectXFileEnumObject_GetNextDataObject: %x\n", hr);
|
||||
|
||||
/* Get all data (szMember == NULL) */
|
||||
hr = IDirectXFileData_GetData(lpdxfd, NULL, &size, (void**)&pdata);
|
||||
ok(hr == DXFILE_OK, "IDirectXFileData_GetData: %x\n", hr);
|
||||
|
||||
ok(size == 8, "Retrieved data size is wrong\n");
|
||||
ok(size == 8, "Retrieved data size is wrong (%u instead of 8)\n", size);
|
||||
ok((*((WORD*)pdata) == 1) && (*((WORD*)(pdata+2)) == 2) && (*((DWORD*)(pdata+4)) == 3), "Retrieved data is wrong\n");
|
||||
|
||||
/* Get only "major" member (szMember == "major") */
|
||||
hr = IDirectXFileData_GetData(lpdxfd, "major", &size, (void**)&pdata);
|
||||
ok(hr == DXFILE_OK, "IDirectXFileData_GetData: %x\n", hr);
|
||||
|
||||
ok(size == 2, "Retrieved data size is wrong (%u instead of 2)\n", size);
|
||||
ok(*((WORD*)pdata) == 1, "Retrieved data is wrong (%u instead of 1)\n", *((WORD*)pdata));
|
||||
|
||||
/* Get only "minor" member (szMember == "minor") */
|
||||
hr = IDirectXFileData_GetData(lpdxfd, "minor", &size, (void**)&pdata);
|
||||
ok(hr == DXFILE_OK, "IDirectXFileData_GetData: %x\n", hr);
|
||||
|
||||
ok(size == 2, "Retrieved data size is wrong (%u instead of 2)\n", size);
|
||||
ok(*((WORD*)pdata) == 2, "Retrieved data is wrong (%u instead of 2)\n", *((WORD*)pdata));
|
||||
|
||||
/* Get only "flags" member (szMember == "flags") */
|
||||
hr = IDirectXFileData_GetData(lpdxfd, "flags", &size, (void**)&pdata);
|
||||
ok(hr == DXFILE_OK, "IDirectXFileData_GetData: %x\n", hr);
|
||||
|
||||
ok(size == 4, "Retrieved data size is wrong (%u instead of 4)\n", size);
|
||||
ok(*((WORD*)pdata) == 3, "Retrieved data is wrong (%u instead of 3)\n", *((WORD*)pdata));
|
||||
|
||||
/* Try to get not existing member (szMember == "unknown") */
|
||||
hr = IDirectXFileData_GetData(lpdxfd, "unknow", &size, (void**)&pdata);
|
||||
ok(hr == DXFILEERR_BADDATAREFERENCE, "IDirectXFileData_GetData: %x\n", hr);
|
||||
|
||||
ref = IDirectXFileEnumObject_Release(lpdxfeo);
|
||||
ok(ref == 0, "Got refcount %d, expected 0\n", ref);
|
||||
|
||||
|
|
Loading…
Reference in New Issue