static void search_by_ullmann(struct State * state, struct Query * query, struct Target * target){ int k; // Idea for optimization //show(state->mat, query->len, target->n_bits); if(state->depth == state->height - 1){ //printf("FOUND!\n"); state_push_result(state); //show(state->mat, query->len, target->n_bits); }else{ for(k = 0 ; k < target->n_bits ; k++){ if(has_bit(state->mat, state->depth + 1, k, target->n_bytes)){ state_push(state); state_clear_bits(state->mat, state->depth, k, target->n_bytes, query->len); //show(state->mat, query->len, target->n_bits); refine(state, query, target); //show(state->mat, query->len, target->n_bits); if(state_is_valid(state) == TRUE){ //show(state->mat, query->len, target->n_bits); search_by_ullmann(state, query, target); } state_pop(state); } } } }
static void parse_requires (ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { RequiresInfo *req_info; const gchar *library = NULL; const gchar *version = NULL; gchar **split; gint i, version_major = 0, version_minor = 0; gint line_number, char_number; g_markup_parse_context_get_position (data->ctx, &line_number, &char_number); for (i = 0; names[i] != NULL; i++) { if (strcmp (names[i], "lib") == 0) library = values[i]; else if (strcmp (names[i], "version") == 0) version = values[i]; else error_invalid_attribute (data, element_name, names[i], error); } if (!library || !version) { error_missing_attribute (data, element_name, version ? "lib" : "version", error); return; } if (!(split = g_strsplit (version, ".", 2)) || !split[0] || !split[1]) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_VALUE, "%s:%d:%d <%s> attribute has malformed value \"%s\"", data->filename, line_number, char_number, "version", version); return; } version_major = g_ascii_strtoll (split[0], NULL, 10); version_minor = g_ascii_strtoll (split[1], NULL, 10); g_strfreev (split); req_info = g_slice_new0 (RequiresInfo); req_info->library = g_strdup (library); req_info->major = version_major; req_info->minor = version_minor; state_push (data, req_info); req_info->tag.name = element_name; }
func() { int i, j, k; char *p1, *p2; i = int_spop(); int_stop += i; p_spush( p2 ); int_spush( j ); int_stop += k; state_push( 123 ); }
// returns !=0 on error int filler_start(void) {int i; if(pregetinitflist()) return 1; state_init(); for(i=0;i<nw;i++) words[i].commit=-1; // flag word uncommitted state_push(); for(i=0;i<ne;i++) entries[i].upd=entries[i].flbm!=(1LL<<nl)-1; for(i=0;i<nw;i++) words[i].upd=1; winit=0; clueorderindex=0; phase=10; return 0; }
// phase 12: try one possibility at the current critical entry static int searchtry(void) {char c; int e; static clock_t ct0=0,ct1; e=sent[sdep]; if(sposs[sdep][spp[sdep]]=='\0') {entries[e].ch=' ';return 13;} // none left: backtrack c=sposs[sdep][spp[sdep]++]; // get letter to try // sdepsp();printf(":%c:",c);fflush(stdout); state_push(); entries[e].upd=1;entries[e].flbm=1LL<<chartol[(int)c]; // fix feasible list entries[e].ch=c; ct1=clock(); if(ct1-ct0>CLOCKS_PER_SEC*3||ct1-ct0<0) {progress();ct0=clock();} // update display every three seconds or so return 14; // update internal data from new entry }
static void parse_requires (ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { RequiresInfo *req_info; const gchar *library = NULL; const gchar *version = NULL; gchar **split; gint version_major = 0; gint version_minor = 0; if (!g_markup_collect_attributes (element_name, names, values, error, G_MARKUP_COLLECT_STRING, "lib", &library, G_MARKUP_COLLECT_STRING, "version", &version, G_MARKUP_COLLECT_INVALID)) { _gtk_builder_prefix_error (data->builder, data->ctx, error); return; } if (!(split = g_strsplit (version, ".", 2)) || !split[0] || !split[1]) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_VALUE, "'version' attribute has malformed value '%s'", version); _gtk_builder_prefix_error (data->builder, data->ctx, error); return; } version_major = g_ascii_strtoll (split[0], NULL, 10); version_minor = g_ascii_strtoll (split[1], NULL, 10); g_strfreev (split); req_info = g_slice_new0 (RequiresInfo); req_info->library = g_strdup (library); req_info->major = version_major; req_info->minor = version_minor; state_push (data, req_info); req_info->tag.name = element_name; }
static void parse_child (ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { ObjectInfo* object_info; ChildInfo *child_info; const gchar *type = NULL; const gchar *internal_child = NULL; object_info = state_peek_info (data, ObjectInfo); if (!object_info || !(strcmp (object_info->tag.name, "object") == 0 || strcmp (object_info->tag.name, "template") == 0)) { error_invalid_tag (data, element_name, NULL, error); return; } if (!g_markup_collect_attributes (element_name, names, values, error, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "type", &type, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "internal-child", &internal_child, G_MARKUP_COLLECT_INVALID)) { _gtk_builder_prefix_error (data->builder, data->ctx, error); return; } child_info = g_slice_new0 (ChildInfo); child_info->tag.name = element_name; child_info->type = g_strdup (type); child_info->internal_child = g_strdup (internal_child); child_info->parent = (CommonInfo*)object_info; state_push (data, child_info); object_info->object = builder_construct (data, object_info, error); }
static void parse_child (ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { ObjectInfo* object_info; ChildInfo *child_info; guint i; object_info = state_peek_info (data, ObjectInfo); if (!object_info || !(strcmp (object_info->tag.name, "object") == 0 || strcmp (object_info->tag.name, "template") == 0)) { error_invalid_tag (data, element_name, NULL, error); return; } child_info = g_slice_new0 (ChildInfo); state_push (data, child_info); child_info->tag.name = element_name; for (i = 0; names[i]; i++) { if (strcmp (names[i], "type") == 0) child_info->type = g_strdup (values[i]); else if (strcmp (names[i], "internal-child") == 0) child_info->internal_child = g_strdup (values[i]); else error_invalid_attribute (data, element_name, names[i], error); } child_info->parent = (CommonInfo*)object_info; object_info->object = builder_construct (data, object_info, error); }
static void parse_signal (ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { SignalInfo *info; const gchar *name; const gchar *handler = NULL; const gchar *object = NULL; gboolean after = FALSE; gboolean swapped = -1; ObjectInfo *object_info; guint id = 0; GQuark detail = 0; object_info = state_peek_info (data, ObjectInfo); if (!object_info || !(strcmp (object_info->tag.name, "object") == 0 || strcmp (object_info->tag.name, "template") == 0)) { error_invalid_tag (data, element_name, NULL, error); return; } if (!g_markup_collect_attributes (element_name, names, values, error, G_MARKUP_COLLECT_STRING, "name", &name, G_MARKUP_COLLECT_STRING, "handler", &handler, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "object", &object, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "last_modification_time", NULL, G_MARKUP_COLLECT_BOOLEAN|G_MARKUP_COLLECT_OPTIONAL, "after", &after, G_MARKUP_COLLECT_TRISTATE|G_MARKUP_COLLECT_OPTIONAL, "swapped", &swapped, G_MARKUP_COLLECT_INVALID)) { _gtk_builder_prefix_error (data->builder, data->ctx, error); return; } if (!g_signal_parse_name (name, object_info->type, &id, &detail, FALSE)) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_SIGNAL, "Invalid signal '%s' for type '%s'", name, g_type_name (object_info->type)); _gtk_builder_prefix_error (data->builder, data->ctx, error); return; } /* Swapped defaults to FALSE except when object is set */ if (swapped == -1) { if (object) swapped = TRUE; else swapped = FALSE; } info = g_slice_new0 (SignalInfo); info->id = id; info->detail = detail; info->handler = g_strdup (handler); if (after) info->flags |= G_CONNECT_AFTER; if (swapped) info->flags |= G_CONNECT_SWAPPED; info->connect_object_name = g_strdup (object); state_push (data, info); info->tag.name = element_name; }
static void parse_property (ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { PropertyInfo *info; const gchar *name = NULL; const gchar *context = NULL; const gchar *bind_source = NULL; const gchar *bind_property = NULL; const gchar *bind_flags_str = NULL; GBindingFlags bind_flags = G_BINDING_DEFAULT; gboolean translatable = FALSE; ObjectInfo *object_info; GParamSpec *pspec = NULL; gint line, col; object_info = state_peek_info (data, ObjectInfo); if (!object_info || !(strcmp (object_info->tag.name, "object") == 0 || strcmp (object_info->tag.name, "template") == 0)) { error_invalid_tag (data, element_name, NULL, error); return; } if (!g_markup_collect_attributes (element_name, names, values, error, G_MARKUP_COLLECT_STRING, "name", &name, G_MARKUP_COLLECT_BOOLEAN|G_MARKUP_COLLECT_OPTIONAL, "translatable", &translatable, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "comments", NULL, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "context", &context, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-source", &bind_source, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-property", &bind_property, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-flags", &bind_flags_str, G_MARKUP_COLLECT_INVALID)) { _gtk_builder_prefix_error (data->builder, data->ctx, error); return; } pspec = g_object_class_find_property (object_info->oclass, name); if (!pspec) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_PROPERTY, "Invalid property: %s.%s", g_type_name (object_info->type), name); _gtk_builder_prefix_error (data->builder, data->ctx, error); return; } if (bind_flags_str) { if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, NULL, bind_flags_str, &bind_flags, error)) { _gtk_builder_prefix_error (data->builder, data->ctx, error); return; } } g_markup_parse_context_get_position (data->ctx, &line, &col); if (bind_source && bind_property) { BindingInfo *binfo; binfo = g_slice_new (BindingInfo); binfo->target = NULL; binfo->target_pspec = pspec; binfo->source = g_strdup (bind_source); binfo->source_property = g_strdup (bind_property); binfo->flags = bind_flags; binfo->line = line; binfo->col = col; object_info->bindings = g_slist_prepend (object_info->bindings, binfo); } else if (bind_source || bind_property) { error_missing_attribute (data, element_name, (bind_source) ? "bind-property" : "bind-source", error); return; } info = g_slice_new (PropertyInfo); info->tag.name = element_name; info->pspec = pspec; info->text = g_string_new (""); info->translatable = translatable; info->bound = (bind_source && bind_property); info->context = g_strdup (context); info->line = line; info->col = col; state_push (data, info); }
static void parse_template (GMarkupParseContext *context, ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { ObjectInfo *object_info; const gchar *object_class = NULL; const gchar *parent_class = NULL; gint line; GType template_type; GType parsed_type; template_type = _gtk_builder_get_template_type (data->builder); if (!g_markup_collect_attributes (element_name, names, values, error, G_MARKUP_COLLECT_STRING, "class", &object_class, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "parent", &parent_class, G_MARKUP_COLLECT_INVALID)) { _gtk_builder_prefix_error (data->builder, data->ctx, error); return; } if (template_type == 0) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_UNHANDLED_TAG, "Not expecting to handle a template (class '%s', parent '%s')", object_class, parent_class ? parent_class : "GtkWidget"); _gtk_builder_prefix_error (data->builder, context, error); return; } else if (state_peek (data) != NULL) { error_invalid_tag (data, "template", NULL, error); return; } parsed_type = g_type_from_name (object_class); if (template_type != parsed_type) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_TEMPLATE_MISMATCH, "Parsed template definition for type '%s', expected type '%s'", object_class, g_type_name (template_type)); _gtk_builder_prefix_error (data->builder, context, error); return; } if (parent_class) { GType parent_type = g_type_from_name (parent_class); GType expected_type = g_type_parent (parsed_type); if (parent_type == G_TYPE_INVALID) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_VALUE, "Invalid template parent type '%s'", parent_class); _gtk_builder_prefix_error (data->builder, context, error); return; } if (parent_type != expected_type) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_TEMPLATE_MISMATCH, "Template parent type '%s' does not match instance parent type '%s'.", parent_class, g_type_name (expected_type)); _gtk_builder_prefix_error (data->builder, context, error); return; } } ++data->cur_object_level; object_info = g_slice_new0 (ObjectInfo); object_info->tag.name = element_name; object_info->type = parsed_type; object_info->oclass = g_type_class_ref (parsed_type); object_info->id = g_strdup (object_class); object_info->object = gtk_builder_get_object (data->builder, object_class); state_push (data, object_info); line = GPOINTER_TO_INT (g_hash_table_lookup (data->object_ids, object_class)); if (line != 0) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_DUPLICATE_ID, "Duplicate object ID '%s' (previously on line %d)", object_class, line); _gtk_builder_prefix_error (data->builder, context, error); return; } g_markup_parse_context_get_position (context, &line, NULL); g_hash_table_insert (data->object_ids, g_strdup (object_class), GINT_TO_POINTER (line)); }
static void parse_object (GMarkupParseContext *context, ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { ObjectInfo *object_info; ChildInfo* child_info; GType object_type = G_TYPE_INVALID; const gchar *object_class = NULL; const gchar *constructor = NULL; const gchar *type_func = NULL; const gchar *object_id = NULL; gchar *internal_id = NULL; gint line; child_info = state_peek_info (data, ChildInfo); if (child_info && strcmp (child_info->tag.name, "object") == 0) { error_invalid_tag (data, element_name, NULL, error); return; } if (!g_markup_collect_attributes (element_name, names, values, error, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "class", &object_class, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "constructor", &constructor, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "type-func", &type_func, G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "id", &object_id, G_MARKUP_COLLECT_INVALID)) { _gtk_builder_prefix_error (data->builder, data->ctx, error); return; } if (type_func) { /* Call the GType function, and return the GType, it's guaranteed afterwards * that g_type_from_name on the name will return our GType */ object_type = _get_type_by_symbol (type_func); if (object_type == G_TYPE_INVALID) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION, "Invalid type function '%s'", type_func); _gtk_builder_prefix_error (data->builder, context, error); return; } } else if (object_class) { object_type = gtk_builder_get_type_from_name (data->builder, object_class); if (object_type == G_TYPE_INVALID) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_VALUE, "Invalid object type '%s'", object_class); _gtk_builder_prefix_error (data->builder, context, error); return; } } else { error_missing_attribute (data, element_name, "class", error); return; } if (!object_id) { internal_id = g_strdup_printf ("___object_%d___", ++data->object_counter); object_id = internal_id; } ++data->cur_object_level; /* check if we reached a requested object (if it is specified) */ if (data->requested_objects && !data->inside_requested_object) { if (is_requested_object (object_id, data)) { data->requested_object_level = data->cur_object_level; GTK_NOTE (BUILDER, g_message ("requested object \"%s\" found at level %d", object_id, data->requested_object_level)); data->inside_requested_object = TRUE; } else { g_free (internal_id); return; } } object_info = g_slice_new0 (ObjectInfo); object_info->tag.name = element_name; object_info->type = object_type; object_info->oclass = g_type_class_ref (object_type); object_info->id = (internal_id) ? internal_id : g_strdup (object_id); object_info->constructor = g_strdup (constructor); object_info->parent = (CommonInfo*)child_info; state_push (data, object_info); line = GPOINTER_TO_INT (g_hash_table_lookup (data->object_ids, object_id)); if (line != 0) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_DUPLICATE_ID, "Duplicate object ID '%s' (previously on line %d)", object_id, line); _gtk_builder_prefix_error (data->builder, context, error); return; } g_markup_parse_context_get_position (context, &line, NULL); g_hash_table_insert (data->object_ids, g_strdup (object_id), GINT_TO_POINTER (line)); }
static void parse_signal (ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { SignalInfo *info; gchar *name = NULL; gchar *handler = NULL; gchar *object = NULL; gboolean after = FALSE; gboolean swapped = FALSE; gboolean swapped_set = FALSE; ObjectInfo *object_info; int i; object_info = state_peek_info (data, ObjectInfo); if (!object_info || strcmp (object_info->tag.name, "object") != 0) { error_invalid_tag (data, element_name, NULL, error); return; } for (i = 0; names[i] != NULL; i++) { if (strcmp (names[i], "name") == 0) name = g_strdup (values[i]); else if (strcmp (names[i], "handler") == 0) handler = g_strdup (values[i]); else if (strcmp (names[i], "after") == 0) { if (!_gtk_builder_boolean_from_string (values[i], &after, error)) return; } else if (strcmp (names[i], "swapped") == 0) { if (!_gtk_builder_boolean_from_string (values[i], &swapped, error)) return; swapped_set = TRUE; } else if (strcmp (names[i], "object") == 0) object = g_strdup (values[i]); else if (strcmp (names[i], "last_modification_time") == 0) /* parse but ignore */ ; else { error_invalid_attribute (data, element_name, names[i], error); return; } } if (!name) { error_missing_attribute (data, element_name, "name", error); return; } else if (!handler) { error_missing_attribute (data, element_name, "handler", error); return; } /* Swapped defaults to FALSE except when object is set */ if (object && !swapped_set) swapped = TRUE; info = g_slice_new0 (SignalInfo); info->name = name; info->handler = handler; if (after) info->flags |= G_CONNECT_AFTER; if (swapped) info->flags |= G_CONNECT_SWAPPED; info->connect_object_name = object; state_push (data, info); info->tag.name = element_name; }
static void parse_property (ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { PropertyInfo *info; gchar *name = NULL; gchar *context = NULL; gboolean translatable = FALSE; ObjectInfo *object_info; int i; object_info = state_peek_info (data, ObjectInfo); if (!object_info || strcmp (object_info->tag.name, "object") != 0) { error_invalid_tag (data, element_name, NULL, error); return; } for (i = 0; names[i] != NULL; i++) { if (strcmp (names[i], "name") == 0) name = g_strdelimit (g_strdup (values[i]), "_", '-'); else if (strcmp (names[i], "translatable") == 0) { if (!_gtk_builder_boolean_from_string (values[i], &translatable, error)) return; } else if (strcmp (names[i], "comments") == 0) { /* do nothing, comments are for translators */ } else if (strcmp (names[i], "context") == 0) { context = g_strdup (values[i]); } else { error_invalid_attribute (data, element_name, names[i], error); return; } } if (!name) { error_missing_attribute (data, element_name, "name", error); return; } info = g_slice_new0 (PropertyInfo); info->name = name; info->translatable = translatable; info->context = context; info->text = g_string_new (""); state_push (data, info); info->tag.name = element_name; }
static void parse_object (GMarkupParseContext *context, ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { ObjectInfo *object_info; ChildInfo* child_info; int i; gchar *object_class = NULL; gchar *object_id = NULL; gchar *constructor = NULL; gint line, line2; child_info = state_peek_info (data, ChildInfo); if (child_info && strcmp (child_info->tag.name, "object") == 0) { error_invalid_tag (data, element_name, NULL, error); return; } for (i = 0; names[i] != NULL; i++) { if (strcmp (names[i], "class") == 0) object_class = g_strdup (values[i]); else if (strcmp (names[i], "id") == 0) object_id = g_strdup (values[i]); else if (strcmp (names[i], "constructor") == 0) constructor = g_strdup (values[i]); else if (strcmp (names[i], "type-func") == 0) { /* Call the GType function, and return the name of the GType, * it's guaranteed afterwards that g_type_from_name on the name * will return our GType */ object_class = _get_type_by_symbol (values[i]); if (!object_class) { g_markup_parse_context_get_position (context, &line, NULL); g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION, _("Invalid type function on line %d: '%s'"), line, values[i]); return; } } else { error_invalid_attribute (data, element_name, names[i], error); return; } } if (!object_class) { error_missing_attribute (data, element_name, "class", error); return; } if (!object_id) { error_missing_attribute (data, element_name, "id", error); return; } ++data->cur_object_level; /* check if we reached a requested object (if it is specified) */ if (data->requested_objects && !data->inside_requested_object) { if (is_requested_object (object_id, data)) { data->requested_object_level = data->cur_object_level; GTK_NOTE (BUILDER, g_print ("requested object \"%s\" found at level %d\n", object_id, data->requested_object_level)); data->inside_requested_object = TRUE; } else { g_free (object_class); g_free (object_id); g_free (constructor); return; } } object_info = g_slice_new0 (ObjectInfo); object_info->class_name = object_class; object_info->id = object_id; object_info->constructor = constructor; state_push (data, object_info); object_info->tag.name = element_name; if (child_info) object_info->parent = (CommonInfo*)child_info; g_markup_parse_context_get_position (context, &line, NULL); line2 = GPOINTER_TO_INT (g_hash_table_lookup (data->object_ids, object_id)); if (line2 != 0) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_DUPLICATE_ID, _("Duplicate object id '%s' on line %d (previously on line %d)"), object_id, line, line2); return; } g_hash_table_insert (data->object_ids, g_strdup (object_id), GINT_TO_POINTER (line)); }
static void parse_template (GMarkupParseContext *context, ParserData *data, const gchar *element_name, const gchar **names, const gchar **values, GError **error) { ObjectInfo *object_info; int i; gchar *object_class = NULL; gint line, line2; GType template_type = _gtk_builder_get_template_type (data->builder); GType parsed_type; if (template_type == 0) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_UNHANDLED_TAG, "Encountered template definition but not parsing a template."); return; } else if (state_peek (data) != NULL) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_UNHANDLED_TAG, "Encountered template definition that is not at the top level."); return; } for (i = 0; names[i] != NULL; i++) { if (strcmp (names[i], "class") == 0) object_class = g_strdup (values[i]); else if (strcmp (names[i], "parent") == 0) /* Ignore 'parent' attribute, however it's needed by Glade */; else { error_invalid_attribute (data, element_name, names[i], error); return; } } if (!object_class) { error_missing_attribute (data, element_name, "class", error); return; } parsed_type = g_type_from_name (object_class); if (template_type != parsed_type) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_TEMPLATE_MISMATCH, "Parsed template definition for type `%s', expected type `%s'.", object_class, g_type_name (template_type)); return; } ++data->cur_object_level; object_info = g_slice_new0 (ObjectInfo); object_info->class_name = object_class; object_info->id = g_strdup (object_class); object_info->object = gtk_builder_get_object (data->builder, object_class); state_push (data, object_info); object_info->tag.name = element_name; g_markup_parse_context_get_position (context, &line, NULL); line2 = GPOINTER_TO_INT (g_hash_table_lookup (data->object_ids, object_class)); if (line2 != 0) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_DUPLICATE_ID, _("Duplicate object ID '%s' on line %d (previously on line %d)"), object_class, line, line2); return; } g_hash_table_insert (data->object_ids, g_strdup (object_class), GINT_TO_POINTER (line)); }