4 * Copyright 2008 Christian Costa
6 * This file contains the (internal) driver registration functions,
7 * driver enumeration APIs and DirectDraw creation functions.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/debug.h"
32 #include "d3dxof_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(d3dxof);
40 #define TOKEN_STRING 2
41 #define TOKEN_INTEGER 3
43 #define TOKEN_INTEGER_LIST 6
44 #define TOKEN_FLOAT_LIST 7
45 #define TOKEN_OBRACE 10
46 #define TOKEN_CBRACE 11
47 #define TOKEN_OPAREN 12
48 #define TOKEN_CPAREN 13
49 #define TOKEN_OBRACKET 14
50 #define TOKEN_CBRACKET 15
51 #define TOKEN_OANGLE 16
52 #define TOKEN_CANGLE 17
54 #define TOKEN_COMMA 19
55 #define TOKEN_SEMICOLON 20
56 #define TOKEN_TEMPLATE 31
58 #define TOKEN_DWORD 41
59 #define TOKEN_FLOAT 42
60 #define TOKEN_DOUBLE 43
62 #define TOKEN_UCHAR 45
63 #define TOKEN_SWORD 46
64 #define TOKEN_SDWORD 47
66 #define TOKEN_LPSTR 49
67 #define TOKEN_UNICODE 50
68 #define TOKEN_CSTRING 51
69 #define TOKEN_ARRAY 52
71 #define CLSIDFMT "<%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X>"
73 static const char* get_primitive_string(WORD token)
107 void dump_template(xtemplate* templates_array, xtemplate* ptemplate)
112 clsid = &ptemplate->class_id;
114 DPRINTF("template %s\n", ptemplate->name);
116 DPRINTF(CLSIDFMT "\n", clsid->Data1, clsid->Data2, clsid->Data3, clsid->Data4[0],
117 clsid->Data4[1], clsid->Data4[2], clsid->Data4[3], clsid->Data4[4], clsid->Data4[5], clsid->Data4[6], clsid->Data4[7]);
118 for (j = 0; j < ptemplate->nb_members; j++)
120 if (ptemplate->members[j].nb_dims)
122 if (ptemplate->members[j].type == TOKEN_NAME)
123 DPRINTF("%s ", templates_array[ptemplate->members[j].idx_template].name);
125 DPRINTF("%s ", get_primitive_string(ptemplate->members[j].type));
126 DPRINTF("%s", ptemplate->members[j].name);
127 for (k = 0; k < ptemplate->members[j].nb_dims; k++)
129 if (ptemplate->members[j].dim_fixed[k])
130 DPRINTF("[%d]", ptemplate->members[j].dim_value[k]);
132 DPRINTF("[%s]", ptemplate->members[ptemplate->members[j].dim_value[k]].name);
138 else if (ptemplate->nb_childs)
140 DPRINTF("[%s", ptemplate->childs[0]);
141 for (j = 1; j < ptemplate->nb_childs; j++)
142 DPRINTF(",%s", ptemplate->childs[j]);
148 BOOL read_bytes(parse_buffer * buf, LPVOID data, DWORD size)
150 if (buf->rem_bytes < size)
152 memcpy(data, buf->buffer, size);
154 buf->rem_bytes -= size;
158 static void rewind_bytes(parse_buffer * buf, DWORD size)
161 buf->rem_bytes += size;
164 static void dump_TOKEN(WORD token)
166 #define DUMP_TOKEN(t) case t: TRACE(#t "\n"); break
169 DUMP_TOKEN(TOKEN_NAME);
170 DUMP_TOKEN(TOKEN_STRING);
171 DUMP_TOKEN(TOKEN_INTEGER);
172 DUMP_TOKEN(TOKEN_GUID);
173 DUMP_TOKEN(TOKEN_INTEGER_LIST);
174 DUMP_TOKEN(TOKEN_FLOAT_LIST);
175 DUMP_TOKEN(TOKEN_OBRACE);
176 DUMP_TOKEN(TOKEN_CBRACE);
177 DUMP_TOKEN(TOKEN_OPAREN);
178 DUMP_TOKEN(TOKEN_CPAREN);
179 DUMP_TOKEN(TOKEN_OBRACKET);
180 DUMP_TOKEN(TOKEN_CBRACKET);
181 DUMP_TOKEN(TOKEN_OANGLE);
182 DUMP_TOKEN(TOKEN_CANGLE);
183 DUMP_TOKEN(TOKEN_DOT);
184 DUMP_TOKEN(TOKEN_COMMA);
185 DUMP_TOKEN(TOKEN_SEMICOLON);
186 DUMP_TOKEN(TOKEN_TEMPLATE);
187 DUMP_TOKEN(TOKEN_WORD);
188 DUMP_TOKEN(TOKEN_DWORD);
189 DUMP_TOKEN(TOKEN_FLOAT);
190 DUMP_TOKEN(TOKEN_DOUBLE);
191 DUMP_TOKEN(TOKEN_CHAR);
192 DUMP_TOKEN(TOKEN_UCHAR);
193 DUMP_TOKEN(TOKEN_SWORD);
194 DUMP_TOKEN(TOKEN_SDWORD);
195 DUMP_TOKEN(TOKEN_VOID);
196 DUMP_TOKEN(TOKEN_LPSTR);
197 DUMP_TOKEN(TOKEN_UNICODE);
198 DUMP_TOKEN(TOKEN_CSTRING);
199 DUMP_TOKEN(TOKEN_ARRAY);
202 TRACE("Unknown token %d\n", token);
208 static BOOL is_space(char c)
222 static BOOL is_operator(char c)
241 static inline BOOL is_separator(char c)
243 return is_space(c) || is_operator(c);
246 static WORD get_operator_token(char c)
255 return TOKEN_OBRACKET;
257 return TOKEN_CBRACKET;
269 return TOKEN_SEMICOLON;
274 static BOOL is_keyword(parse_buffer* buf, const char* keyword)
276 char tmp[9]; /* template keyword size + 1 */
277 DWORD len = strlen(keyword);
278 read_bytes(buf, tmp, len+1);
279 if (!strncasecmp(tmp, keyword,len) && is_separator(tmp[len]))
281 rewind_bytes(buf, 1);
284 rewind_bytes(buf, len+1);
288 static WORD get_keyword_token(parse_buffer* buf)
290 if (is_keyword(buf, "template"))
291 return TOKEN_TEMPLATE;
292 if (is_keyword(buf, "WORD"))
294 if (is_keyword(buf, "DWORD"))
296 if (is_keyword(buf, "FLOAT"))
298 if (is_keyword(buf, "DOUBLE"))
300 if (is_keyword(buf, "CHAR"))
302 if (is_keyword(buf, "UCHAR"))
304 if (is_keyword(buf, "SWORD"))
306 if (is_keyword(buf, "SDWORD"))
308 if (is_keyword(buf, "VOID"))
310 if (is_keyword(buf, "STRING"))
312 if (is_keyword(buf, "UNICODE"))
313 return TOKEN_UNICODE;
314 if (is_keyword(buf, "CSTRING"))
315 return TOKEN_CSTRING;
316 if (is_keyword(buf, "array"))
322 static BOOL is_guid(parse_buffer* buf)
330 if (*buf->buffer != '<')
333 while (*(buf->buffer+pos) != '>')
335 tmp[pos] = *(buf->buffer+pos);
340 if (pos != 38 /* <+36+> */)
342 TRACE("Wrong guid %s (%d)\n", tmp, pos);
346 buf->rem_bytes -= pos;
348 ret = sscanf(tmp, CLSIDFMT, &class_id.Data1, tab, tab+1, tab+2, tab+3, tab+4, tab+5, tab+6, tab+7, tab+8, tab+9);
351 TRACE("Wrong guid %s (%d)\n", tmp, pos);
354 TRACE("Found guid %s (%d)\n", tmp, pos);
356 class_id.Data2 = tab[0];
357 class_id.Data3 = tab[1];
358 class_id.Data4[0] = tab[2];
359 class_id.Data4[1] = tab[3];
360 class_id.Data4[2] = tab[4];
361 class_id.Data4[3] = tab[5];
362 class_id.Data4[4] = tab[6];
363 class_id.Data4[5] = tab[7];
364 class_id.Data4[6] = tab[8];
365 class_id.Data4[7] = tab[9];
367 *(GUID*)buf->value = class_id;
372 static BOOL is_name(parse_buffer* buf)
378 while (!is_separator(c = *(buf->buffer+pos)))
380 if (!(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')) || (c == '_') || (c == '-')))
388 TRACE("Wrong name %s\n", tmp);
393 buf->rem_bytes -= pos;
395 TRACE("Found name %s\n", tmp);
396 strcpy((char*)buf->value, tmp);
401 static BOOL is_float(parse_buffer* buf)
409 while (!is_separator(c = *(buf->buffer+pos)))
411 if (!((!pos && (c == '-')) || ((c >= '0') && (c <= '9')) || (!dot && (c == '.'))))
420 buf->rem_bytes -= pos;
422 sscanf(tmp, "%f", &decimal);
424 TRACE("Found float %s - %f\n", tmp, decimal);
426 *(float*)buf->value = decimal;
431 static BOOL is_integer(parse_buffer* buf)
438 while (!is_separator(c = *(buf->buffer+pos)))
440 if (!((c >= '0') && (c <= '9')))
447 buf->rem_bytes -= pos;
449 sscanf(tmp, "%d", &integer);
451 TRACE("Found integer %s - %d\n", tmp, integer);
453 *(DWORD*)buf->value = integer;
458 static BOOL is_string(parse_buffer* buf)
465 if (*buf->buffer != '"')
468 while (!is_separator(c = *(buf->buffer+pos+1)) && (pos < 31))
481 TRACE("Wrong string %s\n", tmp);
485 buf->buffer += pos + 2;
486 buf->rem_bytes -= pos + 2;
488 TRACE("Found string %s\n", tmp);
489 strcpy((char*)buf->value, tmp);
494 static WORD parse_TOKEN(parse_buffer * buf)
503 if (!read_bytes(buf, &c, 1))
505 /*TRACE("char = '%c'\n", is_space(c) ? ' ' : c);*/
506 if ((c == '#') || (c == '/'))
508 /* Handle comment (# or //) */
511 if (!read_bytes(buf, &c, 1))
519 if (!read_bytes(buf, &c, 1))
526 if (is_operator(c) && (c != '<'))
528 token = get_operator_token(c);
538 rewind_bytes(buf, 1);
540 if ((token = get_keyword_token(buf)))
550 token = TOKEN_INTEGER;
569 FIXME("Unrecognize element\n");
581 if (!read_bytes(buf, &token, 2))
584 /* Convert integer and float list into separate elements */
585 if (token == TOKEN_INTEGER_LIST)
587 if (!read_bytes(buf, &nb_elem, 4))
589 token = TOKEN_INTEGER;
591 TRACE("Integer list (TOKEN_INTEGER_LIST) of size %d\n", nb_elem);
593 else if (token == TOKEN_FLOAT_LIST)
595 if (!read_bytes(buf, &nb_elem, 4))
599 TRACE("Float list (TOKEN_FLOAT_LIST) of size %d\n", nb_elem);
605 token = is_float ? TOKEN_FLOAT : TOKEN_INTEGER;
610 if (!read_bytes(buf, &integer, 4))
613 *(DWORD*)buf->value = integer;
626 if (!read_bytes(buf, &count, 4))
628 if (!read_bytes(buf, strname, count))
631 /*TRACE("name = %s\n", strname);*/
633 strcpy((char*)buf->value, strname);
640 if (!read_bytes(buf, &integer, 4))
642 /*TRACE("integer = %ld\n", integer);*/
644 *(DWORD*)buf->value = integer;
652 if (!read_bytes(buf, &class_id, 16))
654 sprintf(strguid, CLSIDFMT, class_id.Data1, class_id.Data2, class_id.Data3, class_id.Data4[0],
655 class_id.Data4[1], class_id.Data4[2], class_id.Data4[3], class_id.Data4[4], class_id.Data4[5],
656 class_id.Data4[6], class_id.Data4[7]);
657 /*TRACE("guid = {%s}\n", strguid);*/
659 *(GUID*)buf->value = class_id;
667 if (!read_bytes(buf, &count, 4))
669 if (!read_bytes(buf, strname, count))
672 if (!read_bytes(buf, &tmp_token, 2))
674 if ((tmp_token != TOKEN_COMMA) && (tmp_token != TOKEN_SEMICOLON))
675 ERR("No comma or semicolon (got %d)\n", tmp_token);
676 /*TRACE("name = %s\n", strname);*/
678 strcpy((char*)buf->value, strname);
692 case TOKEN_SEMICOLON:
718 static WORD get_TOKEN(parse_buffer * buf)
720 if (buf->token_present)
722 buf->token_present = FALSE;
723 return buf->current_token;
726 buf->current_token = parse_TOKEN(buf);
728 return buf->current_token;
731 static WORD check_TOKEN(parse_buffer * buf)
733 if (buf->token_present)
734 return buf->current_token;
736 buf->current_token = parse_TOKEN(buf);
737 buf->token_present = TRUE;
739 return buf->current_token;
742 BOOL is_template_available(parse_buffer * buf)
744 return check_TOKEN(buf) == TOKEN_TEMPLATE;
747 static inline BOOL is_primitive_type(WORD token)
772 static BOOL parse_template_option_info(parse_buffer * buf)
774 xtemplate* cur_template = &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates];
776 if (check_TOKEN(buf) == TOKEN_DOT)
779 if (get_TOKEN(buf) != TOKEN_DOT)
781 if (get_TOKEN(buf) != TOKEN_DOT)
783 cur_template->open = TRUE;
789 if (get_TOKEN(buf) != TOKEN_NAME)
791 strcpy(cur_template->childs[cur_template->nb_childs], (char*)buf->value);
792 if (check_TOKEN(buf) == TOKEN_GUID)
794 cur_template->nb_childs++;
795 if (check_TOKEN(buf) != TOKEN_COMMA)
799 cur_template->open = FALSE;
805 static BOOL parse_template_members_list(parse_buffer * buf)
814 cur_member = &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[idx_member];
816 if (check_TOKEN(buf) == TOKEN_ARRAY)
822 if (check_TOKEN(buf) == TOKEN_NAME)
824 cur_member->type = get_TOKEN(buf);
825 cur_member->idx_template = 0;
826 while (cur_member->idx_template < buf->pdxf->nb_xtemplates)
828 if (!strcasecmp((char*)buf->value, buf->pdxf->xtemplates[cur_member->idx_template].name))
830 cur_member->idx_template++;
832 if (cur_member->idx_template == buf->pdxf->nb_xtemplates)
834 ERR("Reference to a nonexistent template '%s'\n", (char*)buf->value);
838 else if (is_primitive_type(check_TOKEN(buf)))
839 cur_member->type = get_TOKEN(buf);
843 if (get_TOKEN(buf) != TOKEN_NAME)
845 strcpy(cur_member->name, (char*)buf->value);
849 while (check_TOKEN(buf) == TOKEN_OBRACKET)
851 if (nb_dims >= MAX_ARRAY_DIM)
853 FIXME("Too many dimensions (%d) for multi-dimensional array\n", nb_dims + 1);
857 if (check_TOKEN(buf) == TOKEN_INTEGER)
860 cur_member->dim_fixed[nb_dims] = TRUE;
861 cur_member->dim_value[nb_dims] = *(DWORD*)buf->value;
866 if (get_TOKEN(buf) != TOKEN_NAME)
868 for (i = 0; i < idx_member; i++)
870 if (!strcmp((char*)buf->value, buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].name))
872 if (buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].nb_dims)
874 ERR("Array cannot be used to specify variable array size\n");
877 if (buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].type != TOKEN_DWORD)
879 FIXME("Only DWORD supported to specify variable array size\n");
887 ERR("Reference to unknown member %s\n", (char*)buf->value);
890 cur_member->dim_fixed[nb_dims] = FALSE;
891 cur_member->dim_value[nb_dims] = i;
893 if (get_TOKEN(buf) != TOKEN_CBRACKET)
899 cur_member->nb_dims = nb_dims;
901 if (get_TOKEN(buf) != TOKEN_SEMICOLON)
907 buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].nb_members = idx_member;
912 static BOOL parse_template_parts(parse_buffer * buf)
914 if (!parse_template_members_list(buf))
916 if (check_TOKEN(buf) == TOKEN_OBRACKET)
919 if (!parse_template_option_info(buf))
921 if (get_TOKEN(buf) != TOKEN_CBRACKET)
928 static void go_to_next_definition(parse_buffer * buf)
931 while (buf->rem_bytes)
933 read_bytes(buf, &c, 1);
934 if ((c == '#') || (c == '/'))
936 /* Handle comment (# or //) */
939 if (!read_bytes(buf, &c, 1))
947 if (!read_bytes(buf, &c, 1))
952 else if (!is_space(c))
954 rewind_bytes(buf, 1);
960 BOOL parse_template(parse_buffer * buf)
962 if (get_TOKEN(buf) != TOKEN_TEMPLATE)
964 if (get_TOKEN(buf) != TOKEN_NAME)
966 strcpy(buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].name, (char*)buf->value);
967 if (get_TOKEN(buf) != TOKEN_OBRACE)
969 if (get_TOKEN(buf) != TOKEN_GUID)
971 buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].class_id = *(GUID*)buf->value;
972 if (!parse_template_parts(buf))
974 if (get_TOKEN(buf) != TOKEN_CBRACE)
978 /* Go to the next template */
979 go_to_next_definition(buf);
982 TRACE("%d - %s - %s\n", buf->pdxf->nb_xtemplates, buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].name, debugstr_guid(&buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].class_id));
983 buf->pdxf->nb_xtemplates++;
988 static BOOL parse_object_parts(parse_buffer * buf, BOOL allow_optional);
989 static BOOL parse_object_members_list(parse_buffer * buf)
993 xtemplate* pt = buf->pxt[buf->level];
994 DWORD last_dword = 0;
996 for (i = 0; i < pt->nb_members; i++)
1001 buf->pxo->members[i].name = pt->members[i].name;
1002 buf->pxo->members[i].start = buf->cur_pdata;
1004 for (k = 0; k < pt->members[i].nb_dims; k++)
1006 if (pt->members[i].dim_fixed[k])
1007 nb_elems *= pt->members[i].dim_value[k];
1009 nb_elems *= *(DWORD*)buf->pxo->members[pt->members[i].dim_value[k]].start;
1012 TRACE("Elements to consider: %d\n", nb_elems);
1014 for (k = 0; k < nb_elems; k++)
1018 token = check_TOKEN(buf);
1019 if (token == TOKEN_COMMA)
1025 /* Allow comma omission */
1026 if (!((token == TOKEN_FLOAT) || (token == TOKEN_INTEGER)))
1031 if (pt->members[i].type == TOKEN_NAME)
1035 TRACE("Found sub-object %s\n", buf->pdxf->xtemplates[pt->members[i].idx_template].name);
1037 /* To do template lookup */
1038 for (j = 0; j < buf->pdxf->nb_xtemplates; j++)
1040 if (!strcasecmp(buf->pdxf->xtemplates[pt->members[i].idx_template].name, buf->pdxf->xtemplates[j].name))
1042 buf->pxt[buf->level] = &buf->pdxf->xtemplates[j];
1046 if (j == buf->pdxf->nb_xtemplates)
1048 ERR("Unknown template %s\n", (char*)buf->value);
1052 TRACE("Enter %s\n", buf->pdxf->xtemplates[pt->members[i].idx_template].name);
1053 if (!parse_object_parts(buf, FALSE))
1062 token = check_TOKEN(buf);
1063 if (token == TOKEN_INTEGER)
1066 last_dword = *(DWORD*)buf->value;
1067 TRACE("%s = %d\n", pt->members[i].name, *(DWORD*)buf->value);
1068 /* Assume larger size */
1069 if ((buf->cur_pdata - buf->pdata + 4) > MAX_DATA_SIZE)
1071 FIXME("Buffer too small\n");
1074 if (pt->members[i].type == TOKEN_WORD)
1076 *(((WORD*)(buf->cur_pdata))) = (WORD)(*(DWORD*)buf->value);
1077 buf->cur_pdata += 2;
1079 else if (pt->members[i].type == TOKEN_DWORD)
1081 *(((DWORD*)(buf->cur_pdata))) = (DWORD)(*(DWORD*)buf->value);
1082 buf->cur_pdata += 4;
1086 FIXME("Token %d not supported\n", pt->members[i].type);
1090 else if (token == TOKEN_FLOAT)
1093 TRACE("%s = %f\n", pt->members[i].name, *(float*)buf->value);
1094 /* Assume larger size */
1095 if ((buf->cur_pdata - buf->pdata + 4) > MAX_DATA_SIZE)
1097 FIXME("Buffer too small\n");
1100 if (pt->members[i].type == TOKEN_FLOAT)
1102 *(((float*)(buf->cur_pdata))) = (float)(*(float*)buf->value);
1103 buf->cur_pdata += 4;
1107 FIXME("Token %d not supported\n", pt->members[i].type);
1111 else if (token == TOKEN_LPSTR)
1114 TRACE("%s = %s\n", pt->members[i].name, (char*)buf->value);
1115 /* Assume larger size */
1116 if ((buf->cur_pdata - buf->pdata + 4) > MAX_DATA_SIZE)
1118 FIXME("Buffer too small\n");
1121 if (pt->members[i].type == TOKEN_LPSTR)
1123 int len = strlen((char*)buf->value) + 1;
1124 if ((buf->cur_pstrings - buf->pstrings + len) > MAX_STRINGS_BUFFER)
1126 FIXME("Buffer too small %p %p %d\n", buf->cur_pstrings, buf->pstrings, len);
1129 strcpy((char*)buf->cur_pstrings, (char*)buf->value);
1130 *(((LPCSTR*)(buf->cur_pdata))) = (char*)buf->cur_pstrings;
1131 buf->cur_pstrings += len;
1132 buf->cur_pdata += 4;
1136 FIXME("Token %d not supported\n", pt->members[i].type);
1142 FIXME("Unexpected token %d\n", token);
1148 if (buf->txt && (check_TOKEN(buf) != TOKEN_CBRACE))
1150 token = get_TOKEN(buf);
1151 if ((token != TOKEN_SEMICOLON) && (token != TOKEN_COMMA))
1153 /* Allow comma instead of semicolon in some specific cases */
1154 if (!((token == TOKEN_COMMA) && ((i+1) < pt->nb_members) && (pt->members[i].type == pt->members[i+1].type)
1155 && (!pt->members[i].nb_dims) && (!pt->members[i+1].nb_dims)))
1164 static BOOL parse_object_parts(parse_buffer * buf, BOOL allow_optional)
1166 if (!parse_object_members_list(buf))
1171 buf->pxo->size = buf->cur_pdata - buf->pxo->pdata;
1173 /* Skip trailing semicolon */
1174 while (check_TOKEN(buf) == TOKEN_SEMICOLON)
1179 if (check_TOKEN(buf) == TOKEN_OBRACE)
1183 if (get_TOKEN(buf) != TOKEN_NAME)
1185 if (get_TOKEN(buf) != TOKEN_CBRACE)
1187 TRACE("Found optional reference %s\n", (char*)buf->value);
1188 for (i = 0; i < buf->nb_pxo_globals; i++)
1190 for (j = 0; j < (buf->pxo_globals[i])[0].nb_subobjects; j++)
1192 if (!strcmp((buf->pxo_globals[i])[j].name, (char*)buf->value))
1197 if (i == buf->nb_pxo_globals)
1199 ERR("Reference to unknown object %s\n", (char*)buf->value);
1202 buf->pxo->childs[buf->pxo->nb_childs] = &buf->pxo_tab[buf->cur_subobject++];
1203 buf->pxo->childs[buf->pxo->nb_childs]->ptarget = &(buf->pxo_globals[i])[j];
1204 buf->pxo->nb_childs++;
1206 else if (check_TOKEN(buf) == TOKEN_NAME)
1208 xobject* pxo = buf->pxo;
1209 buf->pxo = buf->pxo->childs[buf->pxo->nb_childs] = &buf->pxo_tab[buf->cur_subobject++];
1211 TRACE("Enter optional %s\n", (char*)buf->value);
1213 if (!parse_object(buf))
1220 buf->pxo->nb_childs++;
1227 if (buf->pxo->nb_childs > MAX_CHILDS)
1229 FIXME("Too many childs %d\n", buf->pxo->nb_childs);
1236 BOOL parse_object(parse_buffer * buf)
1240 buf->pxo->pdata = buf->cur_pdata;
1241 buf->pxo->ptarget = NULL;
1243 if (get_TOKEN(buf) != TOKEN_NAME)
1246 /* To do template lookup */
1247 for (i = 0; i < buf->pdxf->nb_xtemplates; i++)
1249 if (!strcasecmp((char*)buf->value, buf->pdxf->xtemplates[i].name))
1251 buf->pxt[buf->level] = &buf->pdxf->xtemplates[i];
1252 memcpy(&buf->pxo->type, &buf->pdxf->xtemplates[i].class_id, 16);
1256 if (i == buf->pdxf->nb_xtemplates)
1258 ERR("Unknown template %s\n", (char*)buf->value);
1262 if (check_TOKEN(buf) == TOKEN_NAME)
1265 strcpy(buf->pxo->name, (char*)buf->value);
1268 buf->pxo->name[0] = 0;
1270 if (get_TOKEN(buf) != TOKEN_OBRACE)
1272 if (check_TOKEN(buf) == TOKEN_GUID)
1275 memcpy(&buf->pxo->class_id, buf->value, 16);
1278 memset(&buf->pxo->class_id, 0, 16);
1280 if (!parse_object_parts(buf, TRUE))
1282 if (get_TOKEN(buf) != TOKEN_CBRACE)
1287 /* Go to the next object */
1288 go_to_next_definition(buf);