Example #1
0
GtkMateDoublePattern* gtk_mate_double_pattern_create_from_plist (GeeArrayList* all_patterns, PListDict* pd) {
	PListString* ns;
	GtkMateDoublePattern* pattern;
	PListString* _tmp0;
	PListString* _tmp3;
	char* _tmp5;
	const char* _tmp4;
	OnigRx* _tmp6;
	PListString* _tmp7;
	char* _tmp9;
	const char* _tmp8;
	PListString* _tmp10;
	PListNode* n;
	PListNode* _tmp14;
	PListNode* _tmp16;
	GeeHashMap* _tmp17;
	GeeArrayList* _tmp18;
	PListNode* ps;
	GtkMatePattern* subpattern;
	PListNode* _tmp20;
	gboolean _tmp21;
	gboolean _tmp22;
	GtkMateDoublePattern* _tmp25;
	g_return_val_if_fail (all_patterns != NULL, NULL);
	g_return_val_if_fail (pd != NULL, NULL);
	ns = NULL;
	pattern = g_object_ref_sink (gtk_mate_double_pattern_new ());
	_tmp0 = NULL;
	ns = (_tmp0 = PLIST_STRING (plist_dict_get (pd, "name")), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp0);
	if (ns != NULL) {
		char* _tmp2;
		const char* _tmp1;
		_tmp2 = NULL;
		_tmp1 = NULL;
		((GtkMatePattern*) pattern)->name = (_tmp2 = (_tmp1 = ns->str, (_tmp1 == NULL) ? NULL : g_strdup (_tmp1)), ((GtkMatePattern*) pattern)->name = (g_free (((GtkMatePattern*) pattern)->name), NULL), _tmp2);
	}
	_tmp3 = NULL;
	ns = (_tmp3 = PLIST_STRING (plist_dict_get (pd, "begin")), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp3);
	_tmp5 = NULL;
	_tmp4 = NULL;
	pattern->begin_string = (_tmp5 = (_tmp4 = ns->str, (_tmp4 == NULL) ? NULL : g_strdup (_tmp4)), pattern->begin_string = (g_free (pattern->begin_string), NULL), _tmp5);
	_tmp6 = NULL;
	pattern->begin = (_tmp6 = onig_rx_make1 (ns->str), (pattern->begin == NULL) ? NULL : (pattern->begin = (g_object_unref (pattern->begin), NULL)), _tmp6);
	_tmp7 = NULL;
	ns = (_tmp7 = PLIST_STRING (plist_dict_get (pd, "end")), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp7);
	_tmp9 = NULL;
	_tmp8 = NULL;
	pattern->end_string = (_tmp9 = (_tmp8 = ns->str, (_tmp8 == NULL) ? NULL : g_strdup (_tmp8)), pattern->end_string = (g_free (pattern->end_string), NULL), _tmp9);
	_tmp10 = NULL;
	ns = (_tmp10 = PLIST_STRING (plist_dict_get (pd, "contentName")), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp10);
	if (ns != NULL) {
		char* _tmp12;
		const char* _tmp11;
		_tmp12 = NULL;
		_tmp11 = NULL;
		pattern->content_name = (_tmp12 = (_tmp11 = ns->str, (_tmp11 == NULL) ? NULL : g_strdup (_tmp11)), pattern->content_name = (g_free (pattern->content_name), NULL), _tmp12);
	}
	n = plist_dict_get (pd, "beginCaptures");
	if (n != NULL) {
		GeeHashMap* _tmp13;
		_tmp13 = NULL;
		pattern->begin_captures = (_tmp13 = gtk_mate_pattern_make_captures_from_plist (PLIST_DICT (n)), (pattern->begin_captures == NULL) ? NULL : (pattern->begin_captures = (g_object_unref (pattern->begin_captures), NULL)), _tmp13);
	}
	_tmp14 = NULL;
	n = (_tmp14 = plist_dict_get (pd, "captures"), (n == NULL) ? NULL : (n = (g_object_unref (n), NULL)), _tmp14);
	if (n != NULL) {
		GeeHashMap* _tmp15;
		_tmp15 = NULL;
		pattern->both_captures = (_tmp15 = gtk_mate_pattern_make_captures_from_plist (PLIST_DICT (n)), (pattern->both_captures == NULL) ? NULL : (pattern->both_captures = (g_object_unref (pattern->both_captures), NULL)), _tmp15);
	}
	_tmp16 = NULL;
	n = (_tmp16 = plist_dict_get (pd, "endCaptures"), (n == NULL) ? NULL : (n = (g_object_unref (n), NULL)), _tmp16);
	_tmp17 = NULL;
	pattern->end_captures = (_tmp17 = gtk_mate_pattern_make_captures_from_plist (PLIST_DICT (n)), (pattern->end_captures == NULL) ? NULL : (pattern->end_captures = (g_object_unref (pattern->end_captures), NULL)), _tmp17);
	_tmp18 = NULL;
	pattern->patterns = (_tmp18 = gee_array_list_new (GTK_MATE_TYPE_PATTERN, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_direct_equal), (pattern->patterns == NULL) ? NULL : (pattern->patterns = (g_object_unref (pattern->patterns), NULL)), _tmp18);
	ps = plist_dict_get (pd, "patterns");
	subpattern = 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* _tmp19;
				p = (PListNode*) gee_iterator_get (_p_it);
				_tmp19 = NULL;
				subpattern = (_tmp19 = gtk_mate_pattern_create_from_plist (all_patterns, PLIST_DICT (p)), (subpattern == NULL) ? NULL : (subpattern = (g_object_unref (subpattern), NULL)), _tmp19);
				if (subpattern != NULL) {
					gee_collection_add ((GeeCollection*) pattern->patterns, subpattern);
				}
				(p == NULL) ? NULL : (p = (g_object_unref (p), NULL));
			}
			(_p_it == NULL) ? NULL : (_p_it = (g_object_unref (_p_it), NULL));
		}
	}
	_tmp20 = NULL;
	n = (_tmp20 = plist_dict_get (pd, "disabled"), (n == NULL) ? NULL : (n = (g_object_unref (n), NULL)), _tmp20);
	_tmp21 = FALSE;
	_tmp22 = FALSE;
	if (n != NULL) {
		_tmp22 = PLIST_IS_INTEGER (n);
	} else {
		_tmp22 = FALSE;
	}
	if (_tmp22) {
		_tmp21 = PLIST_INTEGER (n)->value == 1;
	} else {
		_tmp21 = FALSE;
	}
	if (_tmp21) {
		((GtkMatePattern*) pattern)->disabled = TRUE;
	} else {
		gboolean _tmp23;
		gboolean _tmp24;
		_tmp23 = FALSE;
		_tmp24 = FALSE;
		if (n != NULL) {
			_tmp24 = PLIST_IS_STRING (n);
		} else {
			_tmp24 = FALSE;
		}
		if (_tmp24) {
			_tmp23 = _vala_strcmp0 (PLIST_STRING (n)->str, "1") == 0;
		} else {
			_tmp23 = FALSE;
		}
		if (_tmp23) {
			((GtkMatePattern*) pattern)->disabled = TRUE;
		} else {
			((GtkMatePattern*) pattern)->disabled = FALSE;
		}
	}
	gee_collection_add ((GeeCollection*) all_patterns, (GtkMatePattern*) pattern);
	_tmp25 = NULL;
	return (_tmp25 = pattern, (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), (n == NULL) ? NULL : (n = (g_object_unref (n), NULL)), (ps == NULL) ? NULL : (ps = (g_object_unref (ps), NULL)), (subpattern == NULL) ? NULL : (subpattern = (g_object_unref (subpattern), NULL)), _tmp25);
}
Example #2
0
GtkMateSinglePattern* gtk_mate_single_pattern_create_from_plist (GeeArrayList* all_patterns, PListDict* pd) {
	PListString* ns;
	GtkMateSinglePattern* pattern;
	PListString* _tmp0;
	PListString* _tmp3;
	OnigRx* _tmp4;
	PListNode* n;
	GeeHashMap* _tmp5;
	PListNode* _tmp6;
	gboolean _tmp7;
	gboolean _tmp8;
	GtkMateSinglePattern* _tmp11;
	g_return_val_if_fail (all_patterns != NULL, NULL);
	g_return_val_if_fail (pd != NULL, NULL);
	ns = NULL;
	pattern = g_object_ref_sink (gtk_mate_single_pattern_new ());
	_tmp0 = NULL;
	ns = (_tmp0 = PLIST_STRING (plist_dict_get (pd, "name")), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp0);
	if (ns != NULL) {
		char* _tmp2;
		const char* _tmp1;
		_tmp2 = NULL;
		_tmp1 = NULL;
		((GtkMatePattern*) pattern)->name = (_tmp2 = (_tmp1 = ns->str, (_tmp1 == NULL) ? NULL : g_strdup (_tmp1)), ((GtkMatePattern*) pattern)->name = (g_free (((GtkMatePattern*) pattern)->name), NULL), _tmp2);
	}
	/*stdout.printf("sp: %s\n", ((PList.String) pd.get("name")).str);
	else
	stdout.printf("sp: no name\n");*/
	_tmp3 = NULL;
	ns = (_tmp3 = PLIST_STRING (plist_dict_get (pd, "match")), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp3);
	_tmp4 = NULL;
	pattern->match = (_tmp4 = onig_rx_make1 (ns->str), (pattern->match == NULL) ? NULL : (pattern->match = (g_object_unref (pattern->match), NULL)), _tmp4);
	n = plist_dict_get (pd, "captures");
	_tmp5 = NULL;
	pattern->captures = (_tmp5 = gtk_mate_pattern_make_captures_from_plist (PLIST_DICT (n)), (pattern->captures == NULL) ? NULL : (pattern->captures = (g_object_unref (pattern->captures), NULL)), _tmp5);
	_tmp6 = NULL;
	n = (_tmp6 = plist_dict_get (pd, "disabled"), (n == NULL) ? NULL : (n = (g_object_unref (n), NULL)), _tmp6);
	_tmp7 = FALSE;
	_tmp8 = FALSE;
	if (n != NULL) {
		_tmp8 = PLIST_IS_INTEGER (n);
	} else {
		_tmp8 = FALSE;
	}
	if (_tmp8) {
		_tmp7 = PLIST_INTEGER (n)->value == 1;
	} else {
		_tmp7 = FALSE;
	}
	if (_tmp7) {
		((GtkMatePattern*) pattern)->disabled = TRUE;
	} else {
		gboolean _tmp9;
		gboolean _tmp10;
		_tmp9 = FALSE;
		_tmp10 = FALSE;
		if (n != NULL) {
			_tmp10 = PLIST_IS_STRING (n);
		} else {
			_tmp10 = FALSE;
		}
		if (_tmp10) {
			_tmp9 = _vala_strcmp0 (PLIST_STRING (n)->str, "1") == 0;
		} else {
			_tmp9 = FALSE;
		}
		if (_tmp9) {
			((GtkMatePattern*) pattern)->disabled = TRUE;
		} else {
			((GtkMatePattern*) pattern)->disabled = FALSE;
		}
	}
	gee_collection_add ((GeeCollection*) all_patterns, (GtkMatePattern*) pattern);
	_tmp11 = NULL;
	return (_tmp11 = pattern, (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), (n == NULL) ? NULL : (n = (g_object_unref (n), NULL)), _tmp11);
}
Example #3
0
GtkMateDoublePattern* gtk_mate_double_pattern_create_from_plist (GeeArrayList* all_patterns, PListDict* pd) {
	PListString* ns;
	GtkMateDoublePattern* pattern;
	PListString* _tmp0_;
	PListString* _tmp3_;
	char* _tmp5_;
	const char* _tmp4_;
	OnigRx* _tmp6_;
	PListString* _tmp7_;
	char* _tmp9_;
	const char* _tmp8_;
	PListString* _tmp10_;
	PListNode* n;
	PListNode* _tmp14_;
	PListNode* _tmp16_;
	GeeHashMap* _tmp17_;
	GeeArrayList* _tmp18_;
	PListNode* ps;
	GtkMatePattern* subpattern;
	PListNode* _tmp20_;
	gboolean _tmp21_;
	gboolean _tmp22_;
	GtkMateDoublePattern* _tmp25_;
	g_return_val_if_fail (all_patterns != NULL, NULL);
	g_return_val_if_fail (pd != NULL, NULL);
	ns = NULL;
	pattern = g_object_ref_sink (gtk_mate_double_pattern_new ());
	_tmp0_ = NULL;
	ns = (_tmp0_ = PLIST_STRING (plist_dict_get (pd, "name")), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp0_);
	if (ns != NULL) {
		char* _tmp2_;
		const char* _tmp1_;
		_tmp2_ = NULL;
		_tmp1_ = NULL;
		((GtkMatePattern*) pattern)->name = (_tmp2_ = (_tmp1_ = ns->str, (_tmp1_ == NULL) ? NULL : g_strdup (_tmp1_)), ((GtkMatePattern*) pattern)->name = (g_free (((GtkMatePattern*) pattern)->name), NULL), _tmp2_);
	}
	_tmp3_ = NULL;
	ns = (_tmp3_ = PLIST_STRING (plist_dict_get (pd, "begin")), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp3_);
	_tmp5_ = NULL;
	_tmp4_ = NULL;
	pattern->begin_string = (_tmp5_ = (_tmp4_ = ns->str, (_tmp4_ == NULL) ? NULL : g_strdup (_tmp4_)), pattern->begin_string = (g_free (pattern->begin_string), NULL), _tmp5_);
	_tmp6_ = NULL;
	pattern->begin = (_tmp6_ = onig_rx_make1 (ns->str), (pattern->begin == NULL) ? NULL : (pattern->begin = (g_object_unref (pattern->begin), NULL)), _tmp6_);
	_tmp7_ = NULL;
	ns = (_tmp7_ = PLIST_STRING (plist_dict_get (pd, "end")), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp7_);
	_tmp9_ = NULL;
	_tmp8_ = NULL;
	pattern->end_string = (_tmp9_ = (_tmp8_ = ns->str, (_tmp8_ == NULL) ? NULL : g_strdup (_tmp8_)), pattern->end_string = (g_free (pattern->end_string), NULL), _tmp9_);
	_tmp10_ = NULL;
	ns = (_tmp10_ = PLIST_STRING (plist_dict_get (pd, "contentName")), (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), _tmp10_);
	if (ns != NULL) {
		char* _tmp12_;
		const char* _tmp11_;
		_tmp12_ = NULL;
		_tmp11_ = NULL;
		pattern->content_name = (_tmp12_ = (_tmp11_ = ns->str, (_tmp11_ == NULL) ? NULL : g_strdup (_tmp11_)), pattern->content_name = (g_free (pattern->content_name), NULL), _tmp12_);
	}
	n = plist_dict_get (pd, "beginCaptures");
	if (n != NULL) {
		GeeHashMap* _tmp13_;
		_tmp13_ = NULL;
		pattern->begin_captures = (_tmp13_ = gtk_mate_pattern_make_captures_from_plist (PLIST_DICT (n)), (pattern->begin_captures == NULL) ? NULL : (pattern->begin_captures = (g_object_unref (pattern->begin_captures), NULL)), _tmp13_);
	}
	_tmp14_ = NULL;
	n = (_tmp14_ = plist_dict_get (pd, "captures"), (n == NULL) ? NULL : (n = (g_object_unref (n), NULL)), _tmp14_);
	if (n != NULL) {
		GeeHashMap* _tmp15_;
		_tmp15_ = NULL;
		pattern->both_captures = (_tmp15_ = gtk_mate_pattern_make_captures_from_plist (PLIST_DICT (n)), (pattern->both_captures == NULL) ? NULL : (pattern->both_captures = (g_object_unref (pattern->both_captures), NULL)), _tmp15_);
	}
	_tmp16_ = NULL;
	n = (_tmp16_ = plist_dict_get (pd, "endCaptures"), (n == NULL) ? NULL : (n = (g_object_unref (n), NULL)), _tmp16_);
	_tmp17_ = NULL;
	pattern->end_captures = (_tmp17_ = gtk_mate_pattern_make_captures_from_plist (PLIST_DICT (n)), (pattern->end_captures == NULL) ? NULL : (pattern->end_captures = (g_object_unref (pattern->end_captures), NULL)), _tmp17_);
	_tmp18_ = NULL;
	pattern->patterns = (_tmp18_ = gee_array_list_new (GTK_MATE_TYPE_PATTERN, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_direct_equal), (pattern->patterns == NULL) ? NULL : (pattern->patterns = (g_object_unref (pattern->patterns), NULL)), _tmp18_);
	ps = plist_dict_get (pd, "patterns");
	subpattern = 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* _tmp19_;
				p = (PListNode*) gee_iterator_get (_p_it);
				_tmp19_ = NULL;
				subpattern = (_tmp19_ = gtk_mate_pattern_create_from_plist (all_patterns, PLIST_DICT (p)), (subpattern == NULL) ? NULL : (subpattern = (g_object_unref (subpattern), NULL)), _tmp19_);
				if (subpattern != NULL) {
					gee_collection_add ((GeeCollection*) pattern->patterns, subpattern);
				}
				(p == NULL) ? NULL : (p = (g_object_unref (p), NULL));
			}
			(_p_it == NULL) ? NULL : (_p_it = (g_object_unref (_p_it), NULL));
		}
	}
	_tmp20_ = NULL;
	n = (_tmp20_ = plist_dict_get (pd, "disabled"), (n == NULL) ? NULL : (n = (g_object_unref (n), NULL)), _tmp20_);
	_tmp21_ = FALSE;
	_tmp22_ = FALSE;
	if (n != NULL) {
		_tmp22_ = PLIST_IS_INTEGER (n);
	} else {
		_tmp22_ = FALSE;
	}
	if (_tmp22_) {
		_tmp21_ = PLIST_INTEGER (n)->value == 1;
	} else {
		_tmp21_ = FALSE;
	}
	if (_tmp21_) {
		((GtkMatePattern*) pattern)->disabled = TRUE;
	} else {
		gboolean _tmp23_;
		gboolean _tmp24_;
		_tmp23_ = FALSE;
		_tmp24_ = FALSE;
		if (n != NULL) {
			_tmp24_ = PLIST_IS_STRING (n);
		} else {
			_tmp24_ = FALSE;
		}
		if (_tmp24_) {
			_tmp23_ = _vala_strcmp0 (PLIST_STRING (n)->str, "1") == 0;
		} else {
			_tmp23_ = FALSE;
		}
		if (_tmp23_) {
			((GtkMatePattern*) pattern)->disabled = TRUE;
		} else {
			((GtkMatePattern*) pattern)->disabled = FALSE;
		}
	}
	gee_collection_add ((GeeCollection*) all_patterns, (GtkMatePattern*) pattern);
	_tmp25_ = NULL;
	return (_tmp25_ = pattern, (ns == NULL) ? NULL : (ns = (g_object_unref (ns), NULL)), (n == NULL) ? NULL : (n = (g_object_unref (n), NULL)), (ps == NULL) ? NULL : (ps = (g_object_unref (ps), NULL)), (subpattern == NULL) ? NULL : (subpattern = (g_object_unref (subpattern), NULL)), _tmp25_);
}
Example #4
0
GeeArrayList* gtk_mate_matcher_compile (const char* selector_string) {
	GeeArrayList* ms;
	char** _tmp1;
	gint scope_ors1_size;
	gint scope_ors1_length1;
	char** _tmp0;
	char** scope_ors1;
	GeeArrayList* _tmp11;
	g_return_val_if_fail (selector_string != NULL, NULL);
	ms = gee_array_list_new (GTK_MATE_TYPE_MATCHER, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_direct_equal);
	/* FIXME should validate and throw UTF8 error if bad.*/
	_tmp1 = NULL;
	_tmp0 = NULL;
	scope_ors1 = (_tmp1 = _tmp0 = g_strsplit (selector_string, ",", 0), scope_ors1_length1 = _vala_array_length (_tmp0), scope_ors1_size = scope_ors1_length1, _tmp1);
	/*stdout.printf("match: selector: '%s', scope: '%s'\n", selector_string, scope_string);*/
	{
		char** selector_string1_collection;
		int selector_string1_collection_length1;
		int selector_string1_it;
		selector_string1_collection = scope_ors1;
		selector_string1_collection_length1 = scope_ors1_length1;
		for (selector_string1_it = 0; selector_string1_it < scope_ors1_length1; selector_string1_it = selector_string1_it + 1) {
			const char* _tmp10;
			char* selector_string1;
			_tmp10 = NULL;
			selector_string1 = (_tmp10 = selector_string1_collection[selector_string1_it], (_tmp10 == NULL) ? NULL : g_strdup (_tmp10));
			{
				GtkMateMatcher* m;
				GeeArrayList* _tmp2;
				char** _tmp4;
				gint positives_and_negatives_size;
				gint positives_and_negatives_length1;
				char** _tmp3;
				char** positives_and_negatives;
				m = g_object_ref_sink (gtk_mate_matcher_new ());
				_tmp2 = NULL;
				m->neg_rxs = (_tmp2 = gee_array_list_new (ONIG_TYPE_RX, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_direct_equal), (m->neg_rxs == NULL) ? NULL : (m->neg_rxs = (g_object_unref (m->neg_rxs), NULL)), _tmp2);
				_tmp4 = NULL;
				_tmp3 = NULL;
				positives_and_negatives = (_tmp4 = _tmp3 = g_strsplit (selector_string1, " -", 0), positives_and_negatives_length1 = _vala_array_length (_tmp3), positives_and_negatives_size = positives_and_negatives_length1, _tmp4);
				{
					char** sub_selector_string_collection;
					int sub_selector_string_collection_length1;
					int sub_selector_string_it;
					sub_selector_string_collection = positives_and_negatives;
					sub_selector_string_collection_length1 = positives_and_negatives_length1;
					for (sub_selector_string_it = 0; sub_selector_string_it < positives_and_negatives_length1; sub_selector_string_it = sub_selector_string_it + 1) {
						const char* _tmp9;
						char* sub_selector_string;
						_tmp9 = NULL;
						sub_selector_string = (_tmp9 = sub_selector_string_collection[sub_selector_string_it], (_tmp9 == NULL) ? NULL : g_strdup (_tmp9));
						{
							if (m->pos_rx == NULL) {
								char* s1;
								char* s2;
								OnigRx* _tmp7;
								char* _tmp6;
								char* _tmp5;
								s1 = string_helper_gsub (g_strstrip (sub_selector_string), ".", "\\.");
								s2 = string_helper_gsub (s1, " ", ").* .*(");
								/*stdout.printf("positive '%s' -> '%s'\n", selector_string, "("+s2+")");*/
								_tmp7 = NULL;
								_tmp6 = NULL;
								_tmp5 = NULL;
								m->pos_rx = (_tmp7 = onig_rx_make1 (_tmp6 = g_strconcat (_tmp5 = g_strconcat ("(", s2, NULL), ")", NULL)), (m->pos_rx == NULL) ? NULL : (m->pos_rx = (g_object_unref (m->pos_rx), NULL)), _tmp7);
								_tmp6 = (g_free (_tmp6), NULL);
								_tmp5 = (g_free (_tmp5), NULL);
								s1 = (g_free (s1), NULL);
								s2 = (g_free (s2), NULL);
							} else {
								char* s1;
								char* s2;
								OnigRx* _tmp8;
								s1 = string_helper_gsub (g_strstrip (sub_selector_string), ".", "\\.");
								s2 = string_helper_gsub (s1, " ", ".* .*");
								/*stdout.printf("negative '%s' -> '%s'\n", selector_string, s2);*/
								_tmp8 = NULL;
								gee_collection_add ((GeeCollection*) m->neg_rxs, _tmp8 = onig_rx_make1 (s2));
								(_tmp8 == NULL) ? NULL : (_tmp8 = (g_object_unref (_tmp8), NULL));
								s1 = (g_free (s1), NULL);
								s2 = (g_free (s2), NULL);
							}
							sub_selector_string = (g_free (sub_selector_string), NULL);
						}
					}
				}
				gee_collection_add ((GeeCollection*) ms, m);
				selector_string1 = (g_free (selector_string1), NULL);
				(m == NULL) ? NULL : (m = (g_object_unref (m), NULL));
				positives_and_negatives = (_vala_array_free (positives_and_negatives, positives_and_negatives_length1, (GDestroyNotify) g_free), NULL);
			}
		}
	}
	_tmp11 = NULL;
	return (_tmp11 = ms, scope_ors1 = (_vala_array_free (scope_ors1, scope_ors1_length1, (GDestroyNotify) g_free), NULL), _tmp11);
}
Example #5
0
/* Loads the properties that are needed whether or not 
 the grammar ever used.*/
void gtk_mate_grammar_init_for_reference (GtkMateGrammar* self) {
	PListNode* nm;
	PListNode* flm;
	PListNode* ke;
	PListNode* sn;
	PListNode* cm;
	PListNode* filetypes;
	g_return_if_fail (self != NULL);
	nm = plist_dict_get (self->priv->_plist, "name");
	if (nm != NULL) {
		gtk_mate_grammar_set_name (self, PLIST_STRING (nm)->str);
	}
	flm = plist_dict_get (self->priv->_plist, "firstLineMatch");
	if (flm != NULL) {
		OnigRx* _tmp0;
		_tmp0 = NULL;
		self->first_line_match = (_tmp0 = onig_rx_make1 (PLIST_STRING (flm)->str), (self->first_line_match == NULL) ? NULL : (self->first_line_match = (g_object_unref (self->first_line_match), NULL)), _tmp0);
	}
	ke = plist_dict_get (self->priv->_plist, "keyEquivalent");
	if (ke != NULL) {
		char* _tmp2;
		const char* _tmp1;
		_tmp2 = NULL;
		_tmp1 = NULL;
		self->key_equivalent = (_tmp2 = (_tmp1 = PLIST_STRING (ke)->str, (_tmp1 == NULL) ? NULL : g_strdup (_tmp1)), self->key_equivalent = (g_free (self->key_equivalent), NULL), _tmp2);
	}
	sn = plist_dict_get (self->priv->_plist, "scopeName");
	if (sn != NULL) {
		char* _tmp4;
		const char* _tmp3;
		_tmp4 = NULL;
		_tmp3 = NULL;
		self->scope_name = (_tmp4 = (_tmp3 = PLIST_STRING (sn)->str, (_tmp3 == NULL) ? NULL : g_strdup (_tmp3)), self->scope_name = (g_free (self->scope_name), NULL), _tmp4);
	}
	cm = plist_dict_get (self->priv->_plist, "comment");
	if (cm != NULL) {
		char* _tmp6;
		const char* _tmp5;
		_tmp6 = NULL;
		_tmp5 = NULL;
		self->comment = (_tmp6 = (_tmp5 = PLIST_STRING (cm)->str, (_tmp5 == NULL) ? NULL : g_strdup (_tmp5)), self->comment = (g_free (self->comment), NULL), _tmp6);
	}
	filetypes = plist_dict_get (self->priv->_plist, "fileTypes");
	if (filetypes != NULL) {
		PListArray* _tmp7;
		PListArray* fts;
		char** _tmp9;
		gint _tmp8;
		gint i;
		_tmp7 = NULL;
		fts = (_tmp7 = PLIST_ARRAY (filetypes), (_tmp7 == NULL) ? NULL : g_object_ref (_tmp7));
		_tmp9 = NULL;
		self->file_types = (_tmp9 = g_new0 (char*, (_tmp8 = gee_collection_get_size ((GeeCollection*) fts->array)) + 1), self->file_types = (_vala_array_free (self->file_types, self->file_types_length1, (GDestroyNotify) g_free), NULL), self->file_types_length1 = _tmp8, _tmp9);
		i = 0;
		{
			GeeIterator* _n_it;
			_n_it = gee_iterable_iterator ((GeeIterable*) fts->array);
			while (gee_iterator_next (_n_it)) {
				PListNode* n;
				gint _tmp12;
				char* _tmp11;
				const char* _tmp10;
				n = (PListNode*) gee_iterator_get (_n_it);
				_tmp11 = NULL;
				_tmp10 = NULL;
				_tmp12 = i++;
				self->file_types[_tmp12] = (_tmp11 = (_tmp10 = PLIST_STRING (n)->str, (_tmp10 == NULL) ? NULL : g_strdup (_tmp10)), self->file_types[_tmp12] = (g_free (self->file_types[_tmp12]), NULL), _tmp11);
				(n == NULL) ? NULL : (n = (g_object_unref (n), NULL));
			}
			(_n_it == NULL) ? NULL : (_n_it = (g_object_unref (_n_it), NULL));
		}
		(fts == NULL) ? NULL : (fts = (g_object_unref (fts), NULL));
	}
Example #6
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));
}