Exemplo n.º 1
0
static void skk_map_file_load_map (SkkMapFile* self, GeeMap* map, JsonObject* object) {
	JsonObject* _tmp0_;
	GList* _tmp1_ = NULL;
	GList* keys;
	GList* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (map != NULL);
	g_return_if_fail (object != NULL);
	_tmp0_ = object;
	_tmp1_ = json_object_get_members (_tmp0_);
	keys = _tmp1_;
	_tmp2_ = keys;
	{
		GList* key_collection = NULL;
		GList* key_it = NULL;
		key_collection = _tmp2_;
		for (key_it = key_collection; key_it != NULL; key_it = key_it->next) {
			const gchar* key = NULL;
			key = (const gchar*) key_it->data;
			{
				JsonObject* _tmp3_;
				const gchar* _tmp4_;
				JsonNode* _tmp5_ = NULL;
				JsonNode* _tmp6_;
				JsonNode* value;
				JsonNode* _tmp7_;
				JsonNodeType _tmp8_ = 0;
				_tmp3_ = object;
				_tmp4_ = key;
				_tmp5_ = json_object_get_member (_tmp3_, _tmp4_);
				_tmp6_ = __vala_JsonNode_copy0 (_tmp5_);
				value = _tmp6_;
				_tmp7_ = value;
				_tmp8_ = json_node_get_node_type (_tmp7_);
				if (_tmp8_ == JSON_NODE_NULL) {
					GeeMap* _tmp9_;
					const gchar* _tmp10_;
					_tmp9_ = map;
					_tmp10_ = key;
					gee_map_unset (_tmp9_, _tmp10_, NULL);
				} else {
					GeeMap* _tmp11_;
					const gchar* _tmp12_;
					JsonNode* _tmp13_;
					_tmp11_ = map;
					_tmp12_ = key;
					_tmp13_ = value;
					gee_map_set (_tmp11_, _tmp12_, _tmp13_);
				}
				__vala_JsonNode_free0 (value);
			}
		}
	}
	_g_list_free0 (keys);
}
Exemplo n.º 2
0
void preferences_load (Preferences* self) {
	IBusConfig* _tmp0_;
	GVariant* _tmp1_ = NULL;
	GVariant* _tmp2_;
	GVariant* values;
	GVariant* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->config;
	_tmp1_ = ibus_config_get_values (_tmp0_, "engine/skk");
	_tmp2_ = _g_variant_ref0 (_tmp1_);
	values = _tmp2_;
	_tmp3_ = values;
	if (_tmp3_ != NULL) {
		GVariant* _tmp4_;
		GVariantIter* _tmp5_ = NULL;
		GVariantIter* iter;
		GVariant* entry;
		_tmp4_ = values;
		_tmp5_ = g_variant_iter_new (_tmp4_);
		iter = _tmp5_;
		entry = NULL;
		while (TRUE) {
			GVariantIter* _tmp6_;
			GVariant* _tmp7_ = NULL;
			GVariant* _tmp8_;
			gchar* name = NULL;
			GVariant* value = NULL;
			GVariant* _tmp9_;
			GeeMap* _tmp10_;
			const gchar* _tmp11_;
			GVariant* _tmp12_;
			_tmp6_ = iter;
			_tmp7_ = g_variant_iter_next_value (_tmp6_);
			_g_variant_unref0 (entry);
			entry = _tmp7_;
			_tmp8_ = entry;
			if (!(_tmp8_ != NULL)) {
				break;
			}
			_tmp9_ = entry;
			g_variant_get (_tmp9_, "{sv}", &name, &value, NULL);
			_tmp10_ = self->priv->current;
			_tmp11_ = name;
			_tmp12_ = value;
			gee_map_set (_tmp10_, _tmp11_, _tmp12_);
			_g_variant_unref0 (value);
			_g_free0 (name);
		}
		_g_variant_unref0 (entry);
		_g_variant_iter_free0 (iter);
	}
	_g_variant_unref0 (values);
}
Exemplo n.º 3
0
void preferences_set (Preferences* self, const gchar* name, GVariant* value) {
	GeeMap* _tmp0_;
	const gchar* _tmp1_;
	GVariant* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (value != NULL);
	_tmp0_ = self->priv->current;
	_tmp1_ = name;
	_tmp2_ = value;
	gee_map_set (_tmp0_, _tmp1_, _tmp2_);
}
Exemplo n.º 4
0
GtkMateThemeSetting* gtk_mate_theme_setting_create_from_plist (PListDict* dict) {
	GtkMateThemeSetting* tsetting;
	PListNode* nm;
	PListNode* _tmp2;
	GeeHashMap* _tmp5;
	PListDict* pd;
	GtkMateThemeSetting* _tmp9;
	g_return_val_if_fail (dict != NULL, NULL);
	tsetting = g_object_ref_sink (gtk_mate_theme_setting_new ());
	nm = plist_dict_get (dict, "name");
	if (nm != NULL) {
		char* _tmp1;
		const char* _tmp0;
		_tmp1 = NULL;
		_tmp0 = NULL;
		tsetting->name = (_tmp1 = (_tmp0 = PLIST_STRING (nm)->str, (_tmp0 == NULL) ? NULL : g_strdup (_tmp0)), tsetting->name = (g_free (tsetting->name), NULL), _tmp1);
	}
	_tmp2 = NULL;
	nm = (_tmp2 = plist_dict_get (dict, "scope"), (nm == NULL) ? NULL : (nm = (g_object_unref (nm), NULL)), _tmp2);
	if (nm != NULL) {
		char* _tmp4;
		const char* _tmp3;
		_tmp4 = NULL;
		_tmp3 = NULL;
		tsetting->selector = (_tmp4 = (_tmp3 = PLIST_STRING (nm)->str, (_tmp3 == NULL) ? NULL : g_strdup (_tmp3)), tsetting->selector = (g_free (tsetting->selector), NULL), _tmp4);
	}
	_tmp5 = NULL;
	tsetting->settings = (_tmp5 = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, g_str_hash, g_str_equal, g_direct_equal), (tsetting->settings == NULL) ? NULL : (tsetting->settings = (g_object_unref (tsetting->settings), NULL)), _tmp5);
	pd = PLIST_DICT (plist_dict_get (dict, "settings"));
	{
		GeeSet* _tmp6;
		GeeIterator* _tmp7;
		GeeIterator* _key_it;
		_tmp6 = NULL;
		_tmp7 = NULL;
		_key_it = (_tmp7 = gee_iterable_iterator ((GeeIterable*) (_tmp6 = gee_map_get_keys ((GeeMap*) pd->map))), (_tmp6 == NULL) ? NULL : (_tmp6 = (g_object_unref (_tmp6), NULL)), _tmp7);
		while (gee_iterator_next (_key_it)) {
			char* key;
			PListString* _tmp8;
			key = (char*) gee_iterator_get (_key_it);
			_tmp8 = NULL;
			gee_map_set ((GeeMap*) tsetting->settings, key, (_tmp8 = PLIST_STRING ((PListNode*) gee_map_get ((GeeMap*) pd->map, key)))->str);
			(_tmp8 == NULL) ? NULL : (_tmp8 = (g_object_unref (_tmp8), NULL));
			key = (g_free (key), NULL);
		}
		(_key_it == NULL) ? NULL : (_key_it = (g_object_unref (_key_it), NULL));
	}
	_tmp9 = NULL;
	return (_tmp9 = tsetting, (nm == NULL) ? NULL : (nm = (g_object_unref (nm), NULL)), (pd == NULL) ? NULL : (pd = (g_object_unref (pd), NULL)), _tmp9);
}
Exemplo n.º 5
0
GeeHashMap* gtk_mate_pattern_make_captures_from_plist (PListDict* pd) {
	PListDict* pcd;
	PListString* ns;
	GeeHashMap* captures;
	GeeHashMap* _tmp5;
	if (pd == NULL) {
		return gee_hash_map_new (G_TYPE_INT, NULL, NULL, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, g_direct_hash, g_direct_equal, g_direct_equal);
	}
	pcd = NULL;
	ns = NULL;
	captures = gee_hash_map_new (G_TYPE_INT, NULL, NULL, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, g_direct_hash, g_direct_equal, g_direct_equal);
	{
		gint _tmp1;
		char** s_capnum_collection;
		int s_capnum_collection_length1;
		int s_capnum_it;
		s_capnum_collection = plist_dict_keys (pd, &_tmp1);
		s_capnum_collection_length1 = _tmp1;
		for (s_capnum_it = 0; s_capnum_it < _tmp1; s_capnum_it = s_capnum_it + 1) {
			const char* _tmp4;
			char* s_capnum;
			_tmp4 = NULL;
			s_capnum = (_tmp4 = s_capnum_collection[s_capnum_it], (_tmp4 == NULL) ? NULL : g_strdup (_tmp4));
			{
				gint capnum;
				PListDict* _tmp2;
				PListString* _tmp3;
				capnum = atoi (s_capnum);
				_tmp2 = NULL;
				pcd = (_tmp2 = PLIST_DICT (plist_dict_get (pd, s_capnum)), (pcd == NULL) ? NULL : (pcd = (g_object_unref (pcd), NULL)), _tmp2);
				_tmp3 = NULL;
				ns = (_tmp3 = PLIST_STRING (plist_dict_get (pcd, "name")), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp3);
				/* stdout.printf("capture: %d, %s\n", capnum, ns.str);*/
				gee_map_set ((GeeMap*) captures, GINT_TO_POINTER (capnum), ns->str);
				s_capnum = (g_free (s_capnum), NULL);
			}
		}
		s_capnum_collection = (_vala_array_free (s_capnum_collection, s_capnum_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp5 = NULL;
	return (_tmp5 = captures, (pcd == NULL) ? NULL : (pcd = (g_object_unref (pcd), NULL)), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp5);
}
Exemplo n.º 6
0
static void preferences_value_changed_cb (Preferences* self, IBusConfig* config, const gchar* section, const gchar* name, GVariant* value) {
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (config != NULL);
	g_return_if_fail (section != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (value != NULL);
	_tmp0_ = section;
	if (g_strcmp0 (_tmp0_, "engine/skk") == 0) {
		GeeMap* _tmp1_;
		const gchar* _tmp2_;
		GVariant* _tmp3_;
		const gchar* _tmp4_;
		GVariant* _tmp5_;
		_tmp1_ = self->priv->current;
		_tmp2_ = name;
		_tmp3_ = value;
		gee_map_set (_tmp1_, _tmp2_, _tmp3_);
		_tmp4_ = name;
		_tmp5_ = value;
		g_signal_emit_by_name (self, "value-changed", _tmp4_, _tmp5_);
	}
}
Exemplo n.º 7
0
/* TODO make this return multiple themes if they are identical
 (see 13.5 of Textmate manual)*/
GtkMateThemeSetting* gtk_mate_theme_settings_for_scope (GtkMateTheme* self, GtkMateScope* scope, gboolean inner, GtkMateThemeSetting* exclude_setting) {
	char* scope_name;
	GtkMateThemeSetting* cached;
	OnigMatch* current_m;
	OnigMatch* m;
	GtkMateThemeSetting* current;
	GtkMateThemeSetting* _tmp14;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (scope != NULL, NULL);
	scope_name = gtk_mate_scope_hierarchy_names (scope, inner);
	/*stdout.printf("  finding settings for '%s'\n", scope_name);*/
	cached = NULL;
	if (gee_map_contains ((GeeMap*) self->cached_setting_for_scopes, scope_name)) {
		GtkMateThemeSetting* _tmp0;
		GtkMateThemeSetting* _tmp1;
		_tmp0 = NULL;
		cached = (_tmp0 = (GtkMateThemeSetting*) gee_map_get ((GeeMap*) self->cached_setting_for_scopes, scope_name), (cached == NULL) ? NULL : (cached = (g_object_unref (cached), NULL)), _tmp0);
		_tmp1 = NULL;
		return (_tmp1 = cached, scope_name = (g_free (scope_name), NULL), _tmp1);
	}
	current_m = NULL;
	m = NULL;
	current = NULL;
	{
		GeeIterator* _setting_it;
		_setting_it = gee_iterable_iterator ((GeeIterable*) self->settings);
		while (gee_iterator_next (_setting_it)) {
			GtkMateThemeSetting* setting;
			gboolean _tmp2;
			setting = (GtkMateThemeSetting*) gee_iterator_get (_setting_it);
			_tmp2 = FALSE;
			if (setting == exclude_setting) {
				_tmp2 = exclude_setting != NULL;
			} else {
				_tmp2 = FALSE;
			}
			if (_tmp2) {
			} else {
				OnigMatch* _tmp5;
				gboolean _tmp4;
				OnigMatch* _tmp3;
				/*stdout.printf("    setting '%s' excluded due to parent\n", exclude_setting.name);*/
				_tmp5 = NULL;
				_tmp3 = NULL;
				if ((_tmp4 = gtk_mate_theme_setting_match (setting, scope_name, &_tmp3), m = (_tmp5 = _tmp3, (m == NULL) ? NULL : (m = (g_object_unref (m), NULL)), _tmp5), _tmp4)) {
					/*stdout.printf("    setting '%s' matches selector '%s'\n", setting.name, setting.selector); */
					if (current == NULL) {
						GtkMateThemeSetting* _tmp7;
						GtkMateThemeSetting* _tmp6;
						OnigMatch* _tmp9;
						OnigMatch* _tmp8;
						_tmp7 = NULL;
						_tmp6 = NULL;
						current = (_tmp7 = (_tmp6 = setting, (_tmp6 == NULL) ? NULL : g_object_ref (_tmp6)), (current == NULL) ? NULL : (current = (g_object_unref (current), NULL)), _tmp7);
						_tmp9 = NULL;
						_tmp8 = NULL;
						current_m = (_tmp9 = (_tmp8 = m, (_tmp8 == NULL) ? NULL : g_object_ref (_tmp8)), (current_m == NULL) ? NULL : (current_m = (g_object_unref (current_m), NULL)), _tmp9);
					} else {
						if (gtk_mate_matcher_compare_match (scope_name, current_m, m) < 0) {
							GtkMateThemeSetting* _tmp11;
							GtkMateThemeSetting* _tmp10;
							OnigMatch* _tmp13;
							OnigMatch* _tmp12;
							_tmp11 = NULL;
							_tmp10 = NULL;
							current = (_tmp11 = (_tmp10 = setting, (_tmp10 == NULL) ? NULL : g_object_ref (_tmp10)), (current == NULL) ? NULL : (current = (g_object_unref (current), NULL)), _tmp11);
							_tmp13 = NULL;
							_tmp12 = NULL;
							current_m = (_tmp13 = (_tmp12 = m, (_tmp12 == NULL) ? NULL : g_object_ref (_tmp12)), (current_m == NULL) ? NULL : (current_m = (g_object_unref (current_m), NULL)), _tmp13);
						}
					}
				}
			}
			(setting == NULL) ? NULL : (setting = (g_object_unref (setting), NULL));
		}
		(_setting_it == NULL) ? NULL : (_setting_it = (g_object_unref (_setting_it), NULL));
	}
	/*if (current == null) {
	stdout.printf("none match\n");
	}
	else {
	stdout.printf("    best: '%s'\n", current.name);
	}*/
	gee_map_set ((GeeMap*) self->cached_setting_for_scopes, scope_name, current);
	_tmp14 = NULL;
	return (_tmp14 = current, scope_name = (g_free (scope_name), NULL), (cached == NULL) ? NULL : (cached = (g_object_unref (cached), NULL)), (current_m == NULL) ? NULL : (current_m = (g_object_unref (current_m), NULL)), (m == NULL) ? NULL : (m = (g_object_unref (m), NULL)), _tmp14);
}
Exemplo n.º 8
0
GtkMateTheme* gtk_mate_theme_create_from_plist (PListDict* dict) {
	GtkMateTheme* theme;
	PListNode* nm;
	PListNode* _tmp2;
	GeeHashMap* _tmp5;
	GeeArrayList* _tmp6;
	PListArray* na;
	GtkMateTheme* _tmp14;
	g_return_val_if_fail (dict != NULL, NULL);
	theme = g_object_ref_sink (gtk_mate_theme_new ());
	theme->is_initialized = FALSE;
	nm = plist_dict_get (dict, "name");
	if (nm != NULL) {
		char* _tmp1;
		const char* _tmp0;
		_tmp1 = NULL;
		_tmp0 = NULL;
		theme->name = (_tmp1 = (_tmp0 = PLIST_STRING (nm)->str, (_tmp0 == NULL) ? NULL : g_strdup (_tmp0)), theme->name = (g_free (theme->name), NULL), _tmp1);
	}
	_tmp2 = NULL;
	nm = (_tmp2 = plist_dict_get (dict, "author"), (nm == NULL) ? NULL : (nm = (g_object_unref (nm), NULL)), _tmp2);
	if (nm != NULL) {
		char* _tmp4;
		const char* _tmp3;
		_tmp4 = NULL;
		_tmp3 = NULL;
		theme->author = (_tmp4 = (_tmp3 = PLIST_STRING (nm)->str, (_tmp3 == NULL) ? NULL : g_strdup (_tmp3)), theme->author = (g_free (theme->author), NULL), _tmp4);
	}
	_tmp5 = NULL;
	theme->global_settings = (_tmp5 = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, g_str_hash, g_str_equal, g_direct_equal), (theme->global_settings == NULL) ? NULL : (theme->global_settings = (g_object_unref (theme->global_settings), NULL)), _tmp5);
	_tmp6 = NULL;
	theme->settings = (_tmp6 = gee_array_list_new (GTK_MATE_TYPE_THEME_SETTING, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_direct_equal), (theme->settings == NULL) ? NULL : (theme->settings = (g_object_unref (theme->settings), NULL)), _tmp6);
	na = PLIST_ARRAY (plist_dict_get (dict, "settings"));
	{
		GeeIterator* _nn_it;
		_nn_it = gee_iterable_iterator ((GeeIterable*) na->array);
		while (gee_iterator_next (_nn_it)) {
			PListNode* nn;
			PListDict* _tmp7;
			PListDict* nd;
			PListNode* _tmp8;
			gboolean _tmp9;
			nn = (PListNode*) gee_iterator_get (_nn_it);
			_tmp7 = NULL;
			nd = (_tmp7 = PLIST_DICT (nn), (_tmp7 == NULL) ? NULL : g_object_ref (_tmp7));
			_tmp8 = NULL;
			if ((_tmp9 = (_tmp8 = plist_dict_get (nd, "scope")) == NULL, (_tmp8 == NULL) ? NULL : (_tmp8 = (g_object_unref (_tmp8), NULL)), _tmp9)) {
				PListDict* gsd;
				gsd = PLIST_DICT (plist_dict_get (nd, "settings"));
				{
					gint _tmp10;
					char** key_collection;
					int key_collection_length1;
					int key_it;
					key_collection = plist_dict_keys (gsd, &_tmp10);
					key_collection_length1 = _tmp10;
					for (key_it = 0; key_it < _tmp10; key_it = key_it + 1) {
						const char* _tmp12;
						char* key;
						_tmp12 = NULL;
						key = (_tmp12 = key_collection[key_it], (_tmp12 == NULL) ? NULL : g_strdup (_tmp12));
						{
							PListString* _tmp11;
							_tmp11 = NULL;
							gee_map_set ((GeeMap*) theme->global_settings, key, (_tmp11 = PLIST_STRING (plist_dict_get (gsd, key)))->str);
							(_tmp11 == NULL) ? NULL : (_tmp11 = (g_object_unref (_tmp11), NULL));
							key = (g_free (key), NULL);
						}
					}
					key_collection = (_vala_array_free (key_collection, key_collection_length1, (GDestroyNotify) g_free), NULL);
				}
				(gsd == NULL) ? NULL : (gsd = (g_object_unref (gsd), NULL));
			} else {
				GtkMateThemeSetting* _tmp13;
				_tmp13 = NULL;
				gee_collection_add ((GeeCollection*) theme->settings, _tmp13 = gtk_mate_theme_setting_create_from_plist (nd));
				(_tmp13 == NULL) ? NULL : (_tmp13 = (g_object_unref (_tmp13), NULL));
			}
			(nn == NULL) ? NULL : (nn = (g_object_unref (nn), NULL));
			(nd == NULL) ? NULL : (nd = (g_object_unref (nd), NULL));
		}
		(_nn_it == NULL) ? NULL : (_nn_it = (g_object_unref (_nn_it), NULL));
	}
	_tmp14 = NULL;
	return (_tmp14 = theme, (nm == NULL) ? NULL : (nm = (g_object_unref (nm), NULL)), (na == NULL) ? NULL : (na = (g_object_unref (na), NULL)), _tmp14);
}
Exemplo n.º 9
0
static void skk_map_file_load (SkkMapFile* self, const gchar* rule, const gchar* type, const gchar* name, GeeSet* included, GError** error) {
	const gchar* _tmp0_;
	SkkRuleMetadata* _tmp1_ = NULL;
	SkkRuleMetadata* metadata;
	SkkRuleMetadata* _tmp2_;
	SkkRuleMetadata* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_ = NULL;
	gchar* _tmp12_;
	gchar* filename;
	const gchar* _tmp13_;
	gboolean _tmp14_ = FALSE;
	JsonParser* _tmp17_;
	JsonParser* parser;
	JsonParser* _tmp30_;
	JsonNode* _tmp31_ = NULL;
	JsonNode* _tmp32_;
	JsonNode* root;
	JsonNode* _tmp33_;
	JsonNodeType _tmp34_ = 0;
	JsonNode* _tmp36_;
	JsonObject* _tmp37_ = NULL;
	JsonObject* _tmp38_;
	JsonObject* object;
	JsonNode* member = NULL;
	JsonObject* _tmp39_;
	gboolean _tmp40_ = FALSE;
	JsonObject* _tmp83_;
	gboolean _tmp84_ = FALSE;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (rule != NULL);
	g_return_if_fail (type != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (included != NULL);
	_tmp0_ = rule;
	_tmp1_ = skk_rule_find_rule (_tmp0_);
	metadata = _tmp1_;
	_tmp2_ = metadata;
	if (_tmp2_ == NULL) {
		const gchar* _tmp3_;
		GError* _tmp4_;
		_tmp3_ = rule;
		_tmp4_ = g_error_new (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "can't find rule %s", _tmp3_);
		_inner_error_ = _tmp4_;
		if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) {
			g_propagate_error (error, _inner_error_);
			_skk_rule_metadata_free0 (metadata);
			return;
		} else {
			_skk_rule_metadata_free0 (metadata);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp5_ = metadata;
	_tmp6_ = (*_tmp5_).base_dir;
	_tmp7_ = type;
	_tmp8_ = name;
	_tmp9_ = g_strconcat (_tmp8_, ".json", NULL);
	_tmp10_ = _tmp9_;
	_tmp11_ = g_build_filename (_tmp6_, _tmp7_, _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	_g_free0 (_tmp10_);
	filename = _tmp12_;
	_tmp13_ = filename;
	_tmp14_ = g_file_test (_tmp13_, G_FILE_TEST_EXISTS);
	if (!_tmp14_) {
		const gchar* _tmp15_;
		GError* _tmp16_;
		_tmp15_ = filename;
		_tmp16_ = g_error_new (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "no such file %s", _tmp15_);
		_inner_error_ = _tmp16_;
		if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) {
			g_propagate_error (error, _inner_error_);
			_g_free0 (filename);
			_skk_rule_metadata_free0 (metadata);
			return;
		} else {
			_g_free0 (filename);
			_skk_rule_metadata_free0 (metadata);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp17_ = json_parser_new ();
	parser = _tmp17_;
	{
		JsonParser* _tmp18_;
		const gchar* _tmp19_;
		gboolean _tmp20_ = FALSE;
		gboolean _tmp21_;
		_tmp18_ = parser;
		_tmp19_ = filename;
		_tmp20_ = json_parser_load_from_file (_tmp18_, _tmp19_, &_inner_error_);
		_tmp21_ = _tmp20_;
		if (_inner_error_ != NULL) {
			goto __catch28_g_error;
		}
		if (!_tmp21_) {
			GError* _tmp22_;
			_tmp22_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "");
			_inner_error_ = _tmp22_;
			goto __catch28_g_error;
		}
	}
	goto __finally28;
	__catch28_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp23_;
		GError* _tmp24_;
		const gchar* _tmp25_;
		gchar* _tmp26_ = NULL;
		gchar* _tmp27_;
		GError* _tmp28_;
		GError* _tmp29_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp23_ = filename;
		_tmp24_ = e;
		_tmp25_ = _tmp24_->message;
		_tmp26_ = g_strdup_printf ("can't load %s: %s", _tmp23_, _tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, _tmp27_);
		_tmp29_ = _tmp28_;
		_g_free0 (_tmp27_);
		_inner_error_ = _tmp29_;
		_g_error_free0 (e);
		goto __finally28;
	}
	__finally28:
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) {
			g_propagate_error (error, _inner_error_);
			_g_object_unref0 (parser);
			_g_free0 (filename);
			_skk_rule_metadata_free0 (metadata);
			return;
		} else {
			_g_object_unref0 (parser);
			_g_free0 (filename);
			_skk_rule_metadata_free0 (metadata);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp30_ = parser;
	_tmp31_ = json_parser_get_root (_tmp30_);
	_tmp32_ = __vala_JsonNode_copy0 (_tmp31_);
	root = _tmp32_;
	_tmp33_ = root;
	_tmp34_ = json_node_get_node_type (_tmp33_);
	if (_tmp34_ != JSON_NODE_OBJECT) {
		GError* _tmp35_;
		_tmp35_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "root element must be an object");
		_inner_error_ = _tmp35_;
		if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) {
			g_propagate_error (error, _inner_error_);
			__vala_JsonNode_free0 (root);
			_g_object_unref0 (parser);
			_g_free0 (filename);
			_skk_rule_metadata_free0 (metadata);
			return;
		} else {
			__vala_JsonNode_free0 (root);
			_g_object_unref0 (parser);
			_g_free0 (filename);
			_skk_rule_metadata_free0 (metadata);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp36_ = root;
	_tmp37_ = json_node_get_object (_tmp36_);
	_tmp38_ = __vala_JsonObject_copy0 (_tmp37_);
	object = _tmp38_;
	_tmp39_ = object;
	_tmp40_ = json_object_has_member (_tmp39_, "include");
	if (_tmp40_) {
		JsonObject* _tmp41_;
		JsonNode* _tmp42_ = NULL;
		JsonNode* _tmp43_;
		JsonNode* _tmp44_;
		JsonNodeType _tmp45_ = 0;
		JsonNode* _tmp47_;
		JsonArray* _tmp48_ = NULL;
		JsonArray* _tmp49_;
		JsonArray* include;
		JsonArray* _tmp50_;
		GList* _tmp51_ = NULL;
		GList* elements;
		GList* _tmp52_;
		_tmp41_ = object;
		_tmp42_ = json_object_get_member (_tmp41_, "include");
		_tmp43_ = __vala_JsonNode_copy0 (_tmp42_);
		__vala_JsonNode_free0 (member);
		member = _tmp43_;
		_tmp44_ = member;
		_tmp45_ = json_node_get_node_type (_tmp44_);
		if (_tmp45_ != JSON_NODE_ARRAY) {
			GError* _tmp46_;
			_tmp46_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "\"include\" element must be an array");
			_inner_error_ = _tmp46_;
			if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) {
				g_propagate_error (error, _inner_error_);
				__vala_JsonNode_free0 (member);
				__vala_JsonObject_free0 (object);
				__vala_JsonNode_free0 (root);
				_g_object_unref0 (parser);
				_g_free0 (filename);
				_skk_rule_metadata_free0 (metadata);
				return;
			} else {
				__vala_JsonNode_free0 (member);
				__vala_JsonObject_free0 (object);
				__vala_JsonNode_free0 (root);
				_g_object_unref0 (parser);
				_g_free0 (filename);
				_skk_rule_metadata_free0 (metadata);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
		_tmp47_ = member;
		_tmp48_ = json_node_get_array (_tmp47_);
		_tmp49_ = __vala_JsonArray_copy0 (_tmp48_);
		include = _tmp49_;
		_tmp50_ = include;
		_tmp51_ = json_array_get_elements (_tmp50_);
		elements = _tmp51_;
		_tmp52_ = elements;
		{
			GList* element_collection = NULL;
			GList* element_it = NULL;
			element_collection = _tmp52_;
			for (element_it = element_collection; element_it != NULL; element_it = element_it->next) {
				JsonNode* element = NULL;
				element = (JsonNode*) element_it->data;
				{
					JsonNode* _tmp53_;
					const gchar* _tmp54_ = NULL;
					gchar* _tmp55_;
					gchar* parent;
					GeeSet* _tmp56_;
					const gchar* _tmp57_;
					gboolean _tmp58_ = FALSE;
					const gchar* _tmp61_;
					gint _tmp62_ = 0;
					gint index;
					gint _tmp63_;
					GeeSet* _tmp81_;
					const gchar* _tmp82_;
					_tmp53_ = element;
					_tmp54_ = json_node_get_string (_tmp53_);
					_tmp55_ = g_strdup (_tmp54_);
					parent = _tmp55_;
					_tmp56_ = included;
					_tmp57_ = parent;
					_tmp58_ = gee_collection_contains ((GeeCollection*) _tmp56_, _tmp57_);
					if (_tmp58_) {
						const gchar* _tmp59_;
						GError* _tmp60_;
						_tmp59_ = parent;
						_tmp60_ = g_error_new (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "found circular include of %s", _tmp59_);
						_inner_error_ = _tmp60_;
						if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) {
							g_propagate_error (error, _inner_error_);
							_g_free0 (parent);
							_g_list_free0 (elements);
							__vala_JsonArray_free0 (include);
							__vala_JsonNode_free0 (member);
							__vala_JsonObject_free0 (object);
							__vala_JsonNode_free0 (root);
							_g_object_unref0 (parser);
							_g_free0 (filename);
							_skk_rule_metadata_free0 (metadata);
							return;
						} else {
							_g_free0 (parent);
							_g_list_free0 (elements);
							__vala_JsonArray_free0 (include);
							__vala_JsonNode_free0 (member);
							__vala_JsonObject_free0 (object);
							__vala_JsonNode_free0 (root);
							_g_object_unref0 (parser);
							_g_free0 (filename);
							_skk_rule_metadata_free0 (metadata);
							g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
							g_clear_error (&_inner_error_);
							return;
						}
					}
					_tmp61_ = parent;
					_tmp62_ = string_index_of (_tmp61_, "/", 0);
					index = _tmp62_;
					_tmp63_ = index;
					if (_tmp63_ < 0) {
						const gchar* _tmp64_;
						const gchar* _tmp65_;
						const gchar* _tmp66_;
						GeeSet* _tmp67_;
						_tmp64_ = rule;
						_tmp65_ = type;
						_tmp66_ = parent;
						_tmp67_ = included;
						skk_map_file_load (self, _tmp64_, _tmp65_, _tmp66_, _tmp67_, &_inner_error_);
						if (_inner_error_ != NULL) {
							if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) {
								g_propagate_error (error, _inner_error_);
								_g_free0 (parent);
								_g_list_free0 (elements);
								__vala_JsonArray_free0 (include);
								__vala_JsonNode_free0 (member);
								__vala_JsonObject_free0 (object);
								__vala_JsonNode_free0 (root);
								_g_object_unref0 (parser);
								_g_free0 (filename);
								_skk_rule_metadata_free0 (metadata);
								return;
							} else {
								_g_free0 (parent);
								_g_list_free0 (elements);
								__vala_JsonArray_free0 (include);
								__vala_JsonNode_free0 (member);
								__vala_JsonObject_free0 (object);
								__vala_JsonNode_free0 (root);
								_g_object_unref0 (parser);
								_g_free0 (filename);
								_skk_rule_metadata_free0 (metadata);
								g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
								g_clear_error (&_inner_error_);
								return;
							}
						}
					} else {
						const gchar* _tmp68_;
						gint _tmp69_;
						gchar* _tmp70_ = NULL;
						gchar* _tmp71_;
						const gchar* _tmp72_;
						const gchar* _tmp73_;
						gint _tmp74_;
						const gchar* _tmp75_;
						gint _tmp76_;
						gint _tmp77_;
						gchar* _tmp78_ = NULL;
						gchar* _tmp79_;
						GeeSet* _tmp80_;
						_tmp68_ = parent;
						_tmp69_ = index;
						_tmp70_ = string_slice (_tmp68_, (glong) 0, (glong) _tmp69_);
						_tmp71_ = _tmp70_;
						_tmp72_ = type;
						_tmp73_ = parent;
						_tmp74_ = index;
						_tmp75_ = parent;
						_tmp76_ = strlen (_tmp75_);
						_tmp77_ = _tmp76_;
						_tmp78_ = string_slice (_tmp73_, (glong) (_tmp74_ + 1), (glong) _tmp77_);
						_tmp79_ = _tmp78_;
						_tmp80_ = included;
						skk_map_file_load (self, _tmp71_, _tmp72_, _tmp79_, _tmp80_, &_inner_error_);
						_g_free0 (_tmp79_);
						_g_free0 (_tmp71_);
						if (_inner_error_ != NULL) {
							if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) {
								g_propagate_error (error, _inner_error_);
								_g_free0 (parent);
								_g_list_free0 (elements);
								__vala_JsonArray_free0 (include);
								__vala_JsonNode_free0 (member);
								__vala_JsonObject_free0 (object);
								__vala_JsonNode_free0 (root);
								_g_object_unref0 (parser);
								_g_free0 (filename);
								_skk_rule_metadata_free0 (metadata);
								return;
							} else {
								_g_free0 (parent);
								_g_list_free0 (elements);
								__vala_JsonArray_free0 (include);
								__vala_JsonNode_free0 (member);
								__vala_JsonObject_free0 (object);
								__vala_JsonNode_free0 (root);
								_g_object_unref0 (parser);
								_g_free0 (filename);
								_skk_rule_metadata_free0 (metadata);
								g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
								g_clear_error (&_inner_error_);
								return;
							}
						}
					}
					_tmp81_ = included;
					_tmp82_ = parent;
					gee_collection_add ((GeeCollection*) _tmp81_, _tmp82_);
					_g_free0 (parent);
				}
			}
		}
		_g_list_free0 (elements);
		__vala_JsonArray_free0 (include);
	}
	_tmp83_ = object;
	_tmp84_ = json_object_has_member (_tmp83_, "define");
	if (_tmp84_) {
		JsonObject* _tmp85_;
		JsonNode* _tmp86_ = NULL;
		JsonNode* _tmp87_;
		JsonNode* _tmp88_;
		JsonNodeType _tmp89_ = 0;
		JsonNode* _tmp91_;
		JsonObject* _tmp92_ = NULL;
		JsonObject* _tmp93_;
		JsonObject* define;
		JsonObject* _tmp94_;
		GList* _tmp95_ = NULL;
		GList* keys;
		GList* _tmp96_;
		_tmp85_ = object;
		_tmp86_ = json_object_get_member (_tmp85_, "define");
		_tmp87_ = __vala_JsonNode_copy0 (_tmp86_);
		__vala_JsonNode_free0 (member);
		member = _tmp87_;
		_tmp88_ = member;
		_tmp89_ = json_node_get_node_type (_tmp88_);
		if (_tmp89_ != JSON_NODE_OBJECT) {
			GError* _tmp90_;
			_tmp90_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "\"define\" element must be an object");
			_inner_error_ = _tmp90_;
			if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) {
				g_propagate_error (error, _inner_error_);
				__vala_JsonNode_free0 (member);
				__vala_JsonObject_free0 (object);
				__vala_JsonNode_free0 (root);
				_g_object_unref0 (parser);
				_g_free0 (filename);
				_skk_rule_metadata_free0 (metadata);
				return;
			} else {
				__vala_JsonNode_free0 (member);
				__vala_JsonObject_free0 (object);
				__vala_JsonNode_free0 (root);
				_g_object_unref0 (parser);
				_g_free0 (filename);
				_skk_rule_metadata_free0 (metadata);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
		_tmp91_ = member;
		_tmp92_ = json_node_get_object (_tmp91_);
		_tmp93_ = __vala_JsonObject_copy0 (_tmp92_);
		define = _tmp93_;
		_tmp94_ = define;
		_tmp95_ = json_object_get_members (_tmp94_);
		keys = _tmp95_;
		_tmp96_ = keys;
		{
			GList* key_collection = NULL;
			GList* key_it = NULL;
			key_collection = _tmp96_;
			for (key_it = key_collection; key_it != NULL; key_it = key_it->next) {
				const gchar* key = NULL;
				key = (const gchar*) key_it->data;
				{
					GeeMap* _tmp97_;
					const gchar* _tmp98_;
					gboolean _tmp99_ = FALSE;
					JsonObject* _tmp104_;
					const gchar* _tmp105_;
					JsonNode* _tmp106_ = NULL;
					JsonNode* _tmp107_;
					JsonNode* _tmp108_;
					JsonNodeType _tmp109_ = 0;
					GeeMap* _tmp111_;
					const gchar* _tmp112_;
					gpointer _tmp113_ = NULL;
					GeeMap* _tmp114_;
					JsonNode* _tmp115_;
					JsonObject* _tmp116_ = NULL;
					_tmp97_ = self->priv->maps;
					_tmp98_ = key;
					_tmp99_ = gee_map_has_key (_tmp97_, _tmp98_);
					if (!_tmp99_) {
						GeeHashMap* _tmp100_;
						GeeHashMap* map;
						GeeMap* _tmp101_;
						const gchar* _tmp102_;
						GeeHashMap* _tmp103_;
						_tmp100_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, json_node_get_type (), (GBoxedCopyFunc) _vala_JsonNode_copy, _vala_JsonNode_free, NULL, NULL, NULL);
						map = _tmp100_;
						_tmp101_ = self->priv->maps;
						_tmp102_ = key;
						_tmp103_ = map;
						gee_map_set (_tmp101_, _tmp102_, (GeeMap*) _tmp103_);
						_g_object_unref0 (map);
					}
					_tmp104_ = define;
					_tmp105_ = key;
					_tmp106_ = json_object_get_member (_tmp104_, _tmp105_);
					_tmp107_ = __vala_JsonNode_copy0 (_tmp106_);
					__vala_JsonNode_free0 (member);
					member = _tmp107_;
					_tmp108_ = member;
					_tmp109_ = json_node_get_node_type (_tmp108_);
					if (_tmp109_ != JSON_NODE_OBJECT) {
						GError* _tmp110_;
						_tmp110_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "map element must be an object");
						_inner_error_ = _tmp110_;
						if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) {
							g_propagate_error (error, _inner_error_);
							_g_list_free0 (keys);
							__vala_JsonObject_free0 (define);
							__vala_JsonNode_free0 (member);
							__vala_JsonObject_free0 (object);
							__vala_JsonNode_free0 (root);
							_g_object_unref0 (parser);
							_g_free0 (filename);
							_skk_rule_metadata_free0 (metadata);
							return;
						} else {
							_g_list_free0 (keys);
							__vala_JsonObject_free0 (define);
							__vala_JsonNode_free0 (member);
							__vala_JsonObject_free0 (object);
							__vala_JsonNode_free0 (root);
							_g_object_unref0 (parser);
							_g_free0 (filename);
							_skk_rule_metadata_free0 (metadata);
							g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
							g_clear_error (&_inner_error_);
							return;
						}
					}
					_tmp111_ = self->priv->maps;
					_tmp112_ = key;
					_tmp113_ = gee_map_get (_tmp111_, _tmp112_);
					_tmp114_ = (GeeMap*) _tmp113_;
					_tmp115_ = member;
					_tmp116_ = json_node_get_object (_tmp115_);
					skk_map_file_load_map (self, _tmp114_, _tmp116_);
					_g_object_unref0 (_tmp114_);
				}
			}
		}
		_g_list_free0 (keys);
		__vala_JsonObject_free0 (define);
	}
	__vala_JsonNode_free0 (member);
	__vala_JsonObject_free0 (object);
	__vala_JsonNode_free0 (root);
	_g_object_unref0 (parser);
	_g_free0 (filename);
	_skk_rule_metadata_free0 (metadata);
}
Exemplo n.º 10
0
/* Loads the properties of the grammar that are required
 for parsing. Loads patterns into memory, and sets
 up possible patterns.*/
void gtk_mate_grammar_init_for_use (GtkMateGrammar* self) {
	PListNode* fsm;
	PListNode* ftm;
	GeeArrayList* _tmp2;
	GeeArrayList* _tmp3;
	PListNode* ps;
	GtkMatePattern* pattern;
	GeeHashMap* _tmp5;
	PListDict* pd;
	PListDict* pd1;
	PListNode* pa1;
	g_return_if_fail (self != NULL);
	if (self->loaded) {
		return;
	}
	self->loaded = TRUE;
	/*stdout.printf("initializing grammar for use: %s\n", name);*/
	fsm = plist_dict_get (self->priv->_plist, "foldingStartMarker");
	if (fsm != NULL) {
		OnigRx* _tmp0;
		_tmp0 = NULL;
		self->folding_start_marker = (_tmp0 = onig_rx_make1 (PLIST_STRING (fsm)->str), (self->folding_start_marker == NULL) ? NULL : (self->folding_start_marker = (g_object_unref (self->folding_start_marker), NULL)), _tmp0);
	}
	ftm = plist_dict_get (self->priv->_plist, "foldingStopMarker");
	if (ftm != NULL) {
		OnigRx* _tmp1;
		_tmp1 = NULL;
		self->folding_stop_marker = (_tmp1 = onig_rx_make1 (PLIST_STRING (ftm)->str), (self->folding_stop_marker == NULL) ? NULL : (self->folding_stop_marker = (g_object_unref (self->folding_stop_marker), NULL)), _tmp1);
	}
	_tmp2 = NULL;
	self->all_patterns = (_tmp2 = gee_array_list_new (GTK_MATE_TYPE_PATTERN, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_direct_equal), (self->all_patterns == NULL) ? NULL : (self->all_patterns = (g_object_unref (self->all_patterns), NULL)), _tmp2);
	/* stdout.printf("getting patterns\n");*/
	_tmp3 = NULL;
	self->patterns = (_tmp3 = gee_array_list_new (GTK_MATE_TYPE_PATTERN, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_direct_equal), (self->patterns == NULL) ? NULL : (self->patterns = (g_object_unref (self->patterns), NULL)), _tmp3);
	ps = plist_dict_get (self->priv->_plist, "patterns");
	pattern = NULL;
	if (ps != NULL) {
		{
			GeeIterator* _p_it;
			_p_it = gee_iterable_iterator ((GeeIterable*) PLIST_ARRAY (ps)->array);
			while (gee_iterator_next (_p_it)) {
				PListNode* p;
				GtkMatePattern* _tmp4;
				p = (PListNode*) gee_iterator_get (_p_it);
				_tmp4 = NULL;
				pattern = (_tmp4 = gtk_mate_pattern_create_from_plist (self->all_patterns, PLIST_DICT (p)), (pattern == NULL) ? NULL : (pattern = (g_object_unref (pattern), NULL)), _tmp4);
				gtk_mate_pattern_set_grammar (pattern, self);
				if (pattern != NULL) {
					gee_collection_add ((GeeCollection*) self->patterns, pattern);
				}
				(p == NULL) ? NULL : (p = (g_object_unref (p), NULL));
			}
			(_p_it == NULL) ? NULL : (_p_it = (g_object_unref (_p_it), NULL));
		}
	}
	/* stdout.printf("getting repository\n");*/
	_tmp5 = NULL;
	self->repository = (_tmp5 = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, GEE_TYPE_ARRAY_LIST, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_str_hash, g_str_equal, g_direct_equal), (self->repository == NULL) ? NULL : (self->repository = (g_object_unref (self->repository), NULL)), _tmp5);
	pd = PLIST_DICT (plist_dict_get (self->priv->_plist, "repository"));
	pd1 = NULL;
	pa1 = NULL;
	if (pd != NULL) {
		{
			GeeSet* _tmp6;
			GeeIterator* _tmp7;
			GeeIterator* _key_it;
			_tmp6 = NULL;
			_tmp7 = NULL;
			_key_it = (_tmp7 = gee_iterable_iterator ((GeeIterable*) (_tmp6 = gee_map_get_keys ((GeeMap*) pd->map))), (_tmp6 == NULL) ? NULL : (_tmp6 = (g_object_unref (_tmp6), NULL)), _tmp7);
			while (gee_iterator_next (_key_it)) {
				char* key;
				GeeArrayList* repo_array;
				PListDict* _tmp8;
				gboolean _tmp9;
				PListNode* _tmp10;
				gboolean _tmp11;
				key = (char*) gee_iterator_get (_key_it);
				/* stdout.printf("convert repo name: %s\n", key);*/
				repo_array = gee_array_list_new (GTK_MATE_TYPE_PATTERN, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_direct_equal);
				_tmp8 = NULL;
				pd1 = (_tmp8 = PLIST_DICT (plist_dict_get (pd, key)), (pd1 == NULL) ? NULL : (pd1 = (g_object_unref (pd1), NULL)), _tmp8);
				_tmp9 = FALSE;
				_tmp10 = NULL;
				if ((_tmp11 = (_tmp10 = plist_dict_get (pd1, "begin")) != NULL, (_tmp10 == NULL) ? NULL : (_tmp10 = (g_object_unref (_tmp10), NULL)), _tmp11)) {
					_tmp9 = TRUE;
				} else {
					PListNode* _tmp12;
					_tmp12 = NULL;
					_tmp9 = (_tmp12 = plist_dict_get (pd1, "match")) != NULL;
					(_tmp12 == NULL) ? NULL : (_tmp12 = (g_object_unref (_tmp12), NULL));
				}
				/* repository name can go straight to a pattern*/
				if (_tmp9) {
					GtkMatePattern* _tmp13;
					_tmp13 = NULL;
					pattern = (_tmp13 = gtk_mate_pattern_create_from_plist (self->all_patterns, PLIST_DICT (pd1)), (pattern == NULL) ? NULL : (pattern = (g_object_unref (pattern), NULL)), _tmp13);
					gtk_mate_pattern_set_grammar (pattern, self);
					if (pattern != NULL) {
						gee_collection_add ((GeeCollection*) repo_array, pattern);
					}
				} else {
					PListNode* _tmp14;
					_tmp14 = NULL;
					if ((pa1 = (_tmp14 = plist_dict_get (pd1, "patterns"), (pa1 == NULL) ? NULL : (pa1 = (g_object_unref (pa1), NULL)), _tmp14)) != NULL) {
						{
							GeeIterator* _ps1_it;
							_ps1_it = gee_iterable_iterator ((GeeIterable*) PLIST_ARRAY (pa1)->array);
							while (gee_iterator_next (_ps1_it)) {
								PListNode* ps1;
								GtkMatePattern* _tmp15;
								ps1 = (PListNode*) gee_iterator_get (_ps1_it);
								_tmp15 = NULL;
								pattern = (_tmp15 = gtk_mate_pattern_create_from_plist (self->all_patterns, PLIST_DICT (ps1)), (pattern == NULL) ? NULL : (pattern = (g_object_unref (pattern), NULL)), _tmp15);
								gtk_mate_pattern_set_grammar (pattern, self);
								if (pattern != NULL) {
									gee_collection_add ((GeeCollection*) repo_array, pattern);
								}
								(ps1 == NULL) ? NULL : (ps1 = (g_object_unref (ps1), NULL));
							}
							(_ps1_it == NULL) ? NULL : (_ps1_it = (g_object_unref (_ps1_it), NULL));
						}
					}
				}
				gee_map_set ((GeeMap*) self->repository, key, repo_array);
				key = (g_free (key), NULL);
				(repo_array == NULL) ? NULL : (repo_array = (g_object_unref (repo_array), NULL));
			}
			(_key_it == NULL) ? NULL : (_key_it = (g_object_unref (_key_it), NULL));
		}
	}
	/* stdout.printf("all_patterns: %d\n", all_patterns.size);*/
	{
		GeeIterator* _p_it;
		/* stdout.printf("all_patterns: %d\n", all_patterns.size);*/
		_p_it = gee_iterable_iterator ((GeeIterable*) self->all_patterns);
		/* stdout.printf("all_patterns: %d\n", all_patterns.size);*/
		while (gee_iterator_next (_p_it)) {
			GtkMatePattern* p;
			/* stdout.printf("all_patterns: %d\n", all_patterns.size);*/
			p = (GtkMatePattern*) gee_iterator_get (_p_it);
			if (GTK_MATE_IS_DOUBLE_PATTERN (p)) {
				gtk_mate_pattern_replace_include_patterns (GTK_MATE_DOUBLE_PATTERN (p)->patterns, self);
			}
			(p == NULL) ? NULL : (p = (g_object_unref (p), NULL));
		}
		(_p_it == NULL) ? NULL : (_p_it = (g_object_unref (_p_it), NULL));
	}
	gtk_mate_pattern_replace_include_patterns (self->patterns, self);
	(fsm == NULL) ? NULL : (fsm = (g_object_unref (fsm), NULL));
	(ftm == NULL) ? NULL : (ftm = (g_object_unref (ftm), NULL));
	(ps == NULL) ? NULL : (ps = (g_object_unref (ps), NULL));
	(pattern == NULL) ? NULL : (pattern = (g_object_unref (pattern), NULL));
	(pd == NULL) ? NULL : (pd = (g_object_unref (pd), NULL));
	(pd1 == NULL) ? NULL : (pd1 = (g_object_unref (pd1), NULL));
	(pa1 == NULL) ? NULL : (pa1 = (g_object_unref (pa1), NULL));
}
Exemplo n.º 11
0
Preferences* preferences_construct (GType object_type, IBusConfig* config) {
	Preferences * self = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* dictionaries;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	GeeMap* _tmp4_;
	gint _tmp5_ = 0;
	gpointer* _tmp6_ = NULL;
	gchar** _tmp7_;
	gint _tmp7__length1;
	GVariant* _tmp8_;
	GVariant* _tmp9_;
	GeeMap* _tmp10_;
	GVariant* _tmp11_;
	GVariant* _tmp12_;
	GeeMap* _tmp13_;
	GVariant* _tmp14_;
	GVariant* _tmp15_;
	GeeMap* _tmp16_;
	GVariant* _tmp17_;
	GVariant* _tmp18_;
	GeeMap* _tmp19_;
	GVariant* _tmp20_;
	GVariant* _tmp21_;
	GeeMap* _tmp22_;
	GVariant* _tmp23_;
	GVariant* _tmp24_;
	GeeMap* _tmp25_;
	GVariant* _tmp26_;
	GVariant* _tmp27_;
	GeeMap* _tmp28_;
	GVariant* _tmp29_;
	GVariant* _tmp30_;
	GeeMap* _tmp31_;
	GVariant* _tmp32_;
	GVariant* _tmp33_;
	IBusConfig* _tmp34_;
	IBusConfig* _tmp35_;
	IBusConfig* _tmp36_;
	g_return_val_if_fail (config != NULL, NULL);
	self = (Preferences*) g_object_new (object_type, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
	dictionaries = _tmp0_;
	_tmp1_ = g_get_user_config_dir ();
	_tmp2_ = g_strdup_printf ("type=file,file=%s/ibus-skk/user.dict,mode=readwrite", _tmp1_);
	_tmp3_ = _tmp2_;
	gee_abstract_collection_add ((GeeAbstractCollection*) dictionaries, _tmp3_);
	_g_free0 (_tmp3_);
	gee_abstract_collection_add ((GeeAbstractCollection*) dictionaries, "type=file,file=/usr/share/skk/SKK-JISYO.L,mode=readonly");
	gee_abstract_collection_add ((GeeAbstractCollection*) dictionaries, "type=server,host=localhost,port=1178");
	_tmp4_ = self->priv->_default;
	_tmp6_ = gee_abstract_collection_to_array ((GeeAbstractCollection*) dictionaries, &_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp7__length1 = _tmp5_;
	_tmp8_ = g_variant_new_strv (_tmp7_, _tmp5_);
	_tmp9_ = g_variant_ref_sink (_tmp8_);
	gee_map_set (_tmp4_, "dictionaries", _tmp9_);
	_g_variant_unref0 (_tmp9_);
	_tmp7_ = (_vala_array_free (_tmp7_, _tmp7__length1, (GDestroyNotify) g_free), NULL);
	_tmp10_ = self->priv->_default;
	_tmp11_ = g_variant_new_strv (PREFERENCES_AUTO_START_HENKAN_KEYWORDS, G_N_ELEMENTS (PREFERENCES_AUTO_START_HENKAN_KEYWORDS));
	_tmp12_ = g_variant_ref_sink (_tmp11_);
	gee_map_set (_tmp10_, "auto_start_henkan_keywords", _tmp12_);
	_g_variant_unref0 (_tmp12_);
	_tmp13_ = self->priv->_default;
	_tmp14_ = g_variant_new_int32 ((gint32) SKK_PERIOD_STYLE_JA_JA);
	_tmp15_ = g_variant_ref_sink (_tmp14_);
	gee_map_set (_tmp13_, "period_style", _tmp15_);
	_g_variant_unref0 (_tmp15_);
	_tmp16_ = self->priv->_default;
	_tmp17_ = g_variant_new_int32 ((gint32) 7);
	_tmp18_ = g_variant_ref_sink (_tmp17_);
	gee_map_set (_tmp16_, "page_size", _tmp18_);
	_g_variant_unref0 (_tmp18_);
	_tmp19_ = self->priv->_default;
	_tmp20_ = g_variant_new_int32 ((gint32) 4);
	_tmp21_ = g_variant_ref_sink (_tmp20_);
	gee_map_set (_tmp19_, "pagination_start", _tmp21_);
	_g_variant_unref0 (_tmp21_);
	_tmp22_ = self->priv->_default;
	_tmp23_ = g_variant_new_boolean (TRUE);
	_tmp24_ = g_variant_ref_sink (_tmp23_);
	gee_map_set (_tmp22_, "show_annotation", _tmp24_);
	_g_variant_unref0 (_tmp24_);
	_tmp25_ = self->priv->_default;
	_tmp26_ = g_variant_new_int32 ((gint32) SKK_INPUT_MODE_HIRAGANA);
	_tmp27_ = g_variant_ref_sink (_tmp26_);
	gee_map_set (_tmp25_, "initial_input_mode", _tmp27_);
	_g_variant_unref0 (_tmp27_);
	_tmp28_ = self->priv->_default;
	_tmp29_ = g_variant_new_boolean (FALSE);
	_tmp30_ = g_variant_ref_sink (_tmp29_);
	gee_map_set (_tmp28_, "egg_like_newline", _tmp30_);
	_g_variant_unref0 (_tmp30_);
	_tmp31_ = self->priv->_default;
	_tmp32_ = g_variant_new_string ("default");
	_tmp33_ = g_variant_ref_sink (_tmp32_);
	gee_map_set (_tmp31_, "typing_rule", _tmp33_);
	_g_variant_unref0 (_tmp33_);
	_tmp34_ = config;
	_tmp35_ = _g_object_ref0 (_tmp34_);
	_g_object_unref0 (self->priv->config);
	self->priv->config = _tmp35_;
	preferences_load (self);
	_tmp36_ = config;
	g_signal_connect_object (_tmp36_, "value-changed", (GCallback) _preferences_value_changed_cb_ibus_config_value_changed, self, 0);
	_g_object_unref0 (dictionaries);
	return self;
}