Dylan Smith : d3dxof: Factor out parse template loops into a function.
Alexandre Julliard
julliard at winehq.org
Thu Jun 9 11:47:39 CDT 2011
Module: wine
Branch: master
Commit: 80705f5a91cd7b9e2483fb8625c5b5323fe50334
URL: http://source.winehq.org/git/wine.git/?a=commit;h=80705f5a91cd7b9e2483fb8625c5b5323fe50334
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Wed Jun 8 15:39:05 2011 -0400
d3dxof: Factor out parse template loops into a function.
---
dlls/d3dxof/d3dxof.c | 51 +++++++----------------------------------
dlls/d3dxof/d3dxof_private.h | 4 +--
dlls/d3dxof/parsing.c | 25 ++++++++++++++++++--
3 files changed, 32 insertions(+), 48 deletions(-)
diff --git a/dlls/d3dxof/d3dxof.c b/dlls/d3dxof/d3dxof.c
index 031f780..b353020 100644
--- a/dlls/d3dxof/d3dxof.c
+++ b/dlls/d3dxof/d3dxof.c
@@ -225,20 +225,9 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
if (FAILED(hr))
goto error;
- while (object->buf.rem_bytes && is_template_available(&object->buf))
- {
- if (!parse_template(&object->buf))
- {
- WARN("Template is not correct\n");
- hr = DXFILEERR_BADVALUE;
- goto error;
- }
- else
- {
- TRACE("Template successfully parsed:\n");
- if (TRACE_ON(d3dxof))
- dump_template(This->xtemplates, &This->xtemplates[This->nb_xtemplates - 1]);
- }
+ if (!parse_templates(&object->buf)) {
+ hr = DXFILEERR_BADVALUE;
+ goto error;
}
if (TRACE_ON(d3dxof))
@@ -299,20 +288,9 @@ static HRESULT WINAPI IDirectXFileImpl_RegisterTemplates(IDirectXFile* iface, LP
if (FAILED(hr))
goto cleanup;
- while (buf.rem_bytes && is_template_available(&buf))
- {
- if (!parse_template(&buf))
- {
- WARN("Template is not correct\n");
- hr = DXFILEERR_BADVALUE;
- goto cleanup;
- }
- else
- {
- TRACE("Template successfully parsed:\n");
- if (TRACE_ON(d3dxof))
- dump_template(This->xtemplates, &This->xtemplates[This->nb_xtemplates - 1]);
- }
+ if (!parse_templates(&buf)) {
+ hr = DXFILEERR_BADVALUE;
+ goto cleanup;
}
if (TRACE_ON(d3dxof))
@@ -970,20 +948,9 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileE
}
/* Check if there are templates defined before the object */
- while (This->buf.rem_bytes && is_template_available(&This->buf))
- {
- if (!parse_template(&This->buf))
- {
- WARN("Template is not correct\n");
- hr = DXFILEERR_BADVALUE;
- goto error;
- }
- else
- {
- TRACE("Template successfully parsed:\n");
- if (TRACE_ON(d3dxof))
- dump_template(This->pDirectXFile->xtemplates, &This->pDirectXFile->xtemplates[This->pDirectXFile->nb_xtemplates - 1]);
- }
+ if (!parse_templates(&This->buf)) {
+ hr = DXFILEERR_BADVALUE;
+ goto error;
}
if (!This->buf.rem_bytes)
diff --git a/dlls/d3dxof/d3dxof_private.h b/dlls/d3dxof/d3dxof_private.h
index 15dca52..40870ac 100644
--- a/dlls/d3dxof/d3dxof_private.h
+++ b/dlls/d3dxof/d3dxof_private.h
@@ -164,10 +164,8 @@ HRESULT IDirectXFileImpl_Create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HID
BOOL read_bytes(parse_buffer * buf, LPVOID data, DWORD size) DECLSPEC_HIDDEN;
HRESULT parse_header(parse_buffer *buf, BYTE **decomp_buffer_ptr) DECLSPEC_HIDDEN;
-BOOL parse_template(parse_buffer * buf) DECLSPEC_HIDDEN;
-void dump_template(xtemplate* templates_array, xtemplate* ptemplate) DECLSPEC_HIDDEN;
-BOOL is_template_available(parse_buffer * buf) DECLSPEC_HIDDEN;
BOOL parse_object(parse_buffer * buf) DECLSPEC_HIDDEN;
+BOOL parse_templates(parse_buffer * buf) DECLSPEC_HIDDEN;
int mszip_decompress(int inlen, int outlen, char* inbuffer, char* outbuffer) DECLSPEC_HIDDEN;
diff --git a/dlls/d3dxof/parsing.c b/dlls/d3dxof/parsing.c
index 7682dfe..4d72219 100644
--- a/dlls/d3dxof/parsing.c
+++ b/dlls/d3dxof/parsing.c
@@ -125,7 +125,7 @@ static const char* get_primitive_string(WORD token)
return NULL;
}
-void dump_template(xtemplate* templates_array, xtemplate* ptemplate)
+static void dump_template(xtemplate* templates_array, xtemplate* ptemplate)
{
int j, k;
GUID* clsid;
@@ -858,7 +858,7 @@ static WORD check_TOKEN(parse_buffer * buf)
return buf->current_token;
}
-BOOL is_template_available(parse_buffer * buf)
+static BOOL is_template_available(parse_buffer * buf)
{
return check_TOKEN(buf) == TOKEN_TEMPLATE;
}
@@ -1076,7 +1076,7 @@ static void go_to_next_definition(parse_buffer * buf)
}
}
-BOOL parse_template(parse_buffer * buf)
+static BOOL parse_template(parse_buffer * buf)
{
if (get_TOKEN(buf) != TOKEN_TEMPLATE)
return FALSE;
@@ -1104,6 +1104,25 @@ BOOL parse_template(parse_buffer * buf)
return TRUE;
}
+BOOL parse_templates(parse_buffer * buf)
+{
+ while (buf->rem_bytes && is_template_available(buf))
+ {
+ if (!parse_template(buf))
+ {
+ WARN("Template is not correct\n");
+ return FALSE;
+ }
+ else
+ {
+ TRACE("Template successfully parsed:\n");
+ if (TRACE_ON(d3dxof_parsing))
+ dump_template(buf->pdxf->xtemplates, &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates - 1]);
+ }
+ }
+ return TRUE;
+}
+
static BOOL check_buffer(parse_buffer * buf, ULONG size)
{
if ((buf->cur_pos_data + size) > buf->capacity)
More information about the wine-cvs
mailing list