/* objects_regex.c generated by valac, the Vala compiler * generated from objects_regex.vala, do not modify */ #include #include #include #include #include #if !defined(VALA_EXTERN) #if defined(_WIN32) || defined(__CYGWIN__) #define VALA_EXTERN __declspec(dllexport) extern #elif __GNUC__ >= 4 #define VALA_EXTERN __attribute__((visibility("default"))) extern #else #define VALA_EXTERN extern #endif #endif #define TYPE_TEST (test_get_type ()) #define TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TEST, Test)) #define TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TEST, TestClass)) #define IS_TEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TEST)) #define IS_TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TEST)) #define TEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TEST, TestClass)) typedef struct _Test Test; typedef struct _TestClass TestClass; typedef struct _TestPrivate TestPrivate; enum { TEST_0_PROPERTY, TEST_NUM_PROPERTIES }; static GParamSpec* test_properties[TEST_NUM_PROPERTIES]; enum { TEST_REGEX_TEST_SIGNAL, TEST_NUM_SIGNALS }; static guint test_signals[TEST_NUM_SIGNALS] = {0}; typedef struct _Block1Data Block1Data; #define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL))) #define _g_match_info_unref0(var) ((var == NULL) ? NULL : (var = (g_match_info_unref (var), NULL))) #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } #define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; } #define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); struct _Test { GObject parent_instance; TestPrivate * priv; }; struct _TestClass { GObjectClass parent_class; }; struct _Block1Data { int _ref_count_; GMatchInfo* info; GRegex* rc; }; static gpointer test_parent_class = NULL; VALA_EXTERN GRegex* get_from_array (gint index); VALA_EXTERN GRegex* get_fixed (void); VALA_EXTERN GType test_get_type (void) G_GNUC_CONST ; G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test, g_object_unref) VALA_EXTERN void test_run (Test* self, const gchar* s); VALA_EXTERN Test* test_new (void); VALA_EXTERN Test* test_construct (GType object_type); static GType test_get_type_once (void); static void _vala_main (void); static Block1Data* block1_data_ref (Block1Data* _data1_); static void block1_data_unref (void * _userdata_); static void __lambda4_ (Block1Data* _data1_, const gchar* s); static void ___lambda4__test_regex_test (Test* _sender, const gchar* str, gpointer self); static void _vala_array_destroy (gpointer array, gssize array_length, GDestroyNotify destroy_func); static void _vala_array_free (gpointer array, gssize array_length, GDestroyNotify destroy_func); static GRegex* _tmp_regex_0 = NULL; static GRegex* _tmp_regex_1 = NULL; static GRegex* _tmp_regex_2 = NULL; static GRegex* _tmp_regex_3 = NULL; static GRegex* _tmp_regex_4 = NULL; static GRegex* _tmp_regex_5 = NULL; static GRegex* _tmp_regex_6 = NULL; static GRegex* _tmp_regex_7 = NULL; static GRegex* _tmp_regex_8 = NULL; static GRegex* _tmp_regex_9 = NULL; static GRegex* _tmp_regex_10 = NULL; static GRegex* _tmp_regex_11 = NULL; static inline GRegex* _thread_safe_regex_init (GRegex** re, const gchar * pattern, GRegexCompileFlags compile_flags) { if (g_once_init_enter ((volatile gsize*) re)) { GRegex* val = g_regex_new (pattern, compile_flags, 0, NULL); g_once_init_leave ((volatile gsize*) re, (gsize) val); } return *re; } static gpointer _g_regex_ref0 (gpointer self) { return self ? g_regex_ref (self) : NULL; } GRegex* get_from_array (gint index) { GRegex** arr = NULL; GRegex* _tmp0_; GRegex* _tmp1_; GRegex* _tmp2_; GRegex* _tmp3_; GRegex** _tmp4_; gint arr_length1; gint _arr_size_; gint _tmp5_; GRegex* _tmp6_; GRegex* _tmp7_; GRegex* result; _tmp0_ = _g_regex_ref0 (_thread_safe_regex_init (&_tmp_regex_0, "(\\d+\\.\\d+\\.\\d+)", 0)); _tmp1_ = _g_regex_ref0 (_thread_safe_regex_init (&_tmp_regex_1, "(\\d+)\\.\\d+\\.\\d+", 0)); _tmp2_ = _g_regex_ref0 (_thread_safe_regex_init (&_tmp_regex_2, "\\d+\\.(\\d+)\\.\\d+", 0)); _tmp3_ = _g_regex_ref0 (_thread_safe_regex_init (&_tmp_regex_3, "(\\d+)\\.\\d+\\.(\\d+)", 0)); _tmp4_ = g_new0 (GRegex*, 4 + 1); _tmp4_[0] = _tmp0_; _tmp4_[1] = _tmp1_; _tmp4_[2] = _tmp2_; _tmp4_[3] = _tmp3_; arr = _tmp4_; arr_length1 = 4; _arr_size_ = arr_length1; _tmp5_ = index; _vala_assert ((0 <= _tmp5_) && (_tmp5_ <= 3), "0 <= index <= 3"); _tmp6_ = arr[index]; _tmp7_ = _g_regex_ref0 (_tmp6_); result = _tmp7_; arr = (_vala_array_free (arr, arr_length1, (GDestroyNotify) g_regex_unref), NULL); return result; } GRegex* get_fixed (void) { GRegex* _tmp0_; GRegex* result; _tmp0_ = _g_regex_ref0 (_thread_safe_regex_init (&_tmp_regex_4, "(is.*ip)", 0)); result = _tmp0_; return result; } void test_run (Test* self, const gchar* s) { g_return_if_fail (IS_TEST (self)); g_return_if_fail (s != NULL); g_signal_emit (self, test_signals[TEST_REGEX_TEST_SIGNAL], 0, s); } Test* test_construct (GType object_type) { Test * self = NULL; self = (Test*) g_object_new (object_type, NULL); return self; } Test* test_new (void) { return test_construct (TYPE_TEST); } static void test_class_init (TestClass * klass, gpointer klass_data) { test_parent_class = g_type_class_peek_parent (klass); test_signals[TEST_REGEX_TEST_SIGNAL] = g_signal_new ("regex-test", TYPE_TEST, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); } static void test_instance_init (Test * self, gpointer klass) { } static GType test_get_type_once (void) { static const GTypeInfo g_define_type_info = { sizeof (TestClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) test_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Test), 0, (GInstanceInitFunc) test_instance_init, NULL }; GType test_type_id; test_type_id = g_type_register_static (G_TYPE_OBJECT, "Test", &g_define_type_info, 0); return test_type_id; } GType test_get_type (void) { static volatile gsize test_type_id__once = 0; if (g_once_init_enter (&test_type_id__once)) { GType test_type_id; test_type_id = test_get_type_once (); g_once_init_leave (&test_type_id__once, test_type_id); } return test_type_id__once; } static Block1Data* block1_data_ref (Block1Data* _data1_) { g_atomic_int_inc (&_data1_->_ref_count_); return _data1_; } static void block1_data_unref (void * _userdata_) { Block1Data* _data1_; _data1_ = (Block1Data*) _userdata_; if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) { _g_regex_unref0 (_data1_->rc); _g_match_info_unref0 (_data1_->info); g_slice_free (Block1Data, _data1_); } } static void __lambda4_ (Block1Data* _data1_, const gchar* s) { GMatchInfo* _tmp0_ = NULL; gboolean _tmp1_; GMatchInfo* _tmp7_ = NULL; gboolean _tmp8_; g_return_if_fail (s != NULL); _tmp1_ = g_regex_match (_data1_->rc, s, 0, &_tmp0_); _g_match_info_unref0 (_data1_->info); _data1_->info = _tmp0_; if (_tmp1_) { FILE* _tmp2_; GMatchInfo* _tmp3_; gchar* _tmp4_; gchar* _tmp5_; _tmp2_ = stdout; _tmp3_ = _data1_->info; _tmp4_ = g_match_info_fetch (_tmp3_, 1); _tmp5_ = _tmp4_; fprintf (_tmp2_, "Lambda (closure var.): %s -> %s\n", s, _tmp5_); _g_free0 (_tmp5_); } else { FILE* _tmp6_; _tmp6_ = stdout; fprintf (_tmp6_, "Does not match.\n"); } _tmp8_ = g_regex_match (_thread_safe_regex_init (&_tmp_regex_11, "foo(bar)", 0 | G_REGEX_CASELESS), s, 0, &_tmp7_); _g_match_info_unref0 (_data1_->info); _data1_->info = _tmp7_; if (_tmp8_) { FILE* _tmp9_; GMatchInfo* _tmp10_; gchar* _tmp11_; gchar* _tmp12_; _tmp9_ = stdout; _tmp10_ = _data1_->info; _tmp11_ = g_match_info_fetch (_tmp10_, 1); _tmp12_ = _tmp11_; fprintf (_tmp9_, "Lambda (lit.): %s -> %s\n", s, _tmp12_); _g_free0 (_tmp12_); } else { FILE* _tmp13_; _tmp13_ = stdout; fprintf (_tmp13_, "Does not match.\n"); } } static void ___lambda4__test_regex_test (Test* _sender, const gchar* str, gpointer self) { __lambda4_ (self, str); } static void _vala_main (void) { Block1Data* _data1_; gchar* str1 = NULL; gchar* _tmp0_; GRegex* _tmp1_; GRegex* _tmp2_; const gchar* _tmp3_; GMatchInfo* _tmp4_ = NULL; gboolean _tmp5_; gboolean _tmp6_; gchar* str2 = NULL; gchar* _tmp13_; const gchar* _tmp14_; GMatchInfo* _tmp15_ = NULL; gboolean _tmp16_; gchar* ts = NULL; gchar* _tmp24_; const gchar* _tmp25_; GMatchInfo* _tmp26_ = NULL; gboolean _tmp27_; GRegex* r = NULL; GRegex* r1 = NULL; GRegex* r2 = NULL; GRegex* _tmp56_ = NULL; GRegex* _tmp57_; GRegex* _tmp60_; GRegex* _tmp61_; GMatchInfo* _tmp62_ = NULL; gboolean _tmp63_; GRegex* _tmp70_; Test* test = NULL; Test* _tmp71_; GError* _inner_error0_ = NULL; _data1_ = g_slice_new0 (Block1Data); _data1_->_ref_count_ = 1; _tmp0_ = g_strdup ("mississippi"); str1 = _tmp0_; _tmp1_ = get_fixed (); _tmp2_ = _tmp1_; _tmp3_ = str1; _tmp5_ = g_regex_match (_tmp2_, _tmp3_, 0, &_tmp4_); _g_match_info_unref0 (_data1_->info); _data1_->info = _tmp4_; _tmp6_ = _tmp5_; _g_regex_unref0 (_tmp2_); if (_tmp6_) { FILE* _tmp7_; const gchar* _tmp8_; GMatchInfo* _tmp9_; gchar* _tmp10_; gchar* _tmp11_; _tmp7_ = stdout; _tmp8_ = str1; _tmp9_ = _data1_->info; _tmp10_ = g_match_info_fetch (_tmp9_, 1); _tmp11_ = _tmp10_; fprintf (_tmp7_, "Part of %s is '%s'...\n", _tmp8_, _tmp11_); _g_free0 (_tmp11_); } else { FILE* _tmp12_; _tmp12_ = stdout; fprintf (_tmp12_, "Did not match at all.\n"); } _tmp13_ = g_strdup ("demonStration"); str2 = _tmp13_; _tmp14_ = str2; _tmp16_ = g_regex_match (_thread_safe_regex_init (&_tmp_regex_5, "mon(str.*o)n", 0 | G_REGEX_CASELESS), _tmp14_, 0, &_tmp15_); _g_match_info_unref0 (_data1_->info); _data1_->info = _tmp15_; if (_tmp16_) { FILE* _tmp17_; const gchar* _tmp18_; GMatchInfo* _tmp19_; gchar* _tmp20_; gchar* _tmp21_; _tmp17_ = stdout; _tmp18_ = str2; _tmp19_ = _data1_->info; _tmp20_ = g_match_info_fetch (_tmp19_, 1); _tmp21_ = _tmp20_; fprintf (_tmp17_, "Part of %s is '%s'...\n", _tmp18_, _tmp21_); _g_free0 (_tmp21_); } else { FILE* _tmp22_; const gchar* _tmp23_; _tmp22_ = stdout; _tmp23_ = str2; fprintf (_tmp22_, "%s did not match at all.\n", _tmp23_); } _tmp24_ = g_strdup ("Time: 10:42:12"); ts = _tmp24_; _tmp25_ = ts; _tmp27_ = g_regex_match (_thread_safe_regex_init (&_tmp_regex_6, "Time: (..):(..):(..)", 0), _tmp25_, 0, &_tmp26_); _g_match_info_unref0 (_data1_->info); _data1_->info = _tmp26_; if (_tmp27_) { FILE* _tmp28_; const gchar* _tmp29_; GMatchInfo* _tmp30_; gchar* _tmp31_; gchar* _tmp32_; GMatchInfo* _tmp33_; gchar* _tmp34_; gchar* _tmp35_; GMatchInfo* _tmp36_; gchar* _tmp37_; gchar* _tmp38_; _tmp28_ = stdout; _tmp29_ = ts; _tmp30_ = _data1_->info; _tmp31_ = g_match_info_fetch (_tmp30_, 1); _tmp32_ = _tmp31_; _tmp33_ = _data1_->info; _tmp34_ = g_match_info_fetch (_tmp33_, 2); _tmp35_ = _tmp34_; _tmp36_ = _data1_->info; _tmp37_ = g_match_info_fetch (_tmp36_, 3); _tmp38_ = _tmp37_; fprintf (_tmp28_, "%s\n\thours = %s\n\tminutes = %s\n\tseconds = %s\n\n", _tmp29_, _tmp32_, _tmp35_, _tmp38_); _g_free0 (_tmp38_); _g_free0 (_tmp35_); _g_free0 (_tmp32_); } { gchar* str = NULL; gchar* _tmp39_; gchar* _tmp40_ = NULL; gchar* _tmp41_; FILE* _tmp42_; _tmp39_ = g_strdup ("apple grape"); str = _tmp39_; _tmp41_ = g_regex_replace (_thread_safe_regex_init (&_tmp_regex_7, "^([^ ]*) *([^ ]*)", 0), str, (gssize) -1, 0, "\\2 \\1", 0, &_inner_error0_); _tmp40_ = _tmp41_; if (G_UNLIKELY (_inner_error0_ != NULL)) { _g_free0 (str); if (_inner_error0_->domain == G_REGEX_ERROR) { goto __catch0_g_regex_error; } _g_free0 (ts); _g_free0 (str2); _g_free0 (str1); block1_data_unref (_data1_); _data1_ = NULL; g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); g_clear_error (&_inner_error0_); return; } _tmp42_ = stdout; fprintf (_tmp42_, "'%s' becomes '%s'\n", str, _tmp40_); _g_free0 (_tmp40_); _g_free0 (str); } goto __finally0; __catch0_g_regex_error: { GError* err = NULL; GError* _tmp43_; const gchar* _tmp44_; err = _inner_error0_; _inner_error0_ = NULL; _tmp43_ = err; _tmp44_ = _tmp43_->message; g_message ("objects_regex.vala:62: %s", _tmp44_); _g_error_free0 (err); } __finally0: if (G_UNLIKELY (_inner_error0_ != NULL)) { _g_free0 (ts); _g_free0 (str2); _g_free0 (str1); block1_data_unref (_data1_); _data1_ = NULL; g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); g_clear_error (&_inner_error0_); return; } { gint i = 0; i = 0; { gboolean _tmp45_ = FALSE; _tmp45_ = TRUE; while (TRUE) { GRegex* _tmp47_; GRegex* _tmp48_; GMatchInfo* _tmp49_ = NULL; gboolean _tmp50_; gboolean _tmp51_; if (!_tmp45_) { gint _tmp46_; _tmp46_ = i; i = _tmp46_ + 1; } _tmp45_ = FALSE; if (!(i < 4)) { break; } _tmp47_ = get_from_array (i); _tmp48_ = _tmp47_; _tmp50_ = g_regex_match (_tmp48_, "23.3.2010", 0, &_tmp49_); _g_match_info_unref0 (_data1_->info); _data1_->info = _tmp49_; _tmp51_ = _tmp50_; _g_regex_unref0 (_tmp48_); if (_tmp51_) { FILE* _tmp52_; GMatchInfo* _tmp53_; gchar* _tmp54_; gchar* _tmp55_; _tmp52_ = stdout; _tmp53_ = _data1_->info; _tmp54_ = g_match_info_fetch (_tmp53_, 1); _tmp55_ = _tmp54_; fprintf (_tmp52_, "Round %d: %s\n", i, _tmp55_); _g_free0 (_tmp55_); } } } } r = NULL; r1 = NULL; r2 = NULL; _tmp57_ = r1; _tmp56_ = _tmp57_; if (_tmp56_ == NULL) { GRegex* _tmp58_ = NULL; GRegex* _tmp59_; _tmp59_ = r2; _tmp58_ = _tmp59_; if (_tmp58_ == NULL) { _tmp58_ = _thread_safe_regex_init (&_tmp_regex_8, "match (this)", 0 | G_REGEX_CASELESS); } _tmp56_ = _tmp58_; } _tmp60_ = _g_regex_ref0 (_tmp56_); _g_regex_unref0 (r); r = _tmp60_; _tmp61_ = r; _tmp63_ = g_regex_match (_tmp61_, "match THIS", 0, &_tmp62_); _g_match_info_unref0 (_data1_->info); _data1_->info = _tmp62_; if (_tmp63_) { FILE* _tmp64_; GMatchInfo* _tmp65_; gchar* _tmp66_; gchar* _tmp67_; _tmp64_ = stdout; _tmp65_ = _data1_->info; _tmp66_ = g_match_info_fetch (_tmp65_, 1); _tmp67_ = _tmp66_; fprintf (_tmp64_, "Match: %s\n", _tmp67_); _g_free0 (_tmp67_); } if (g_regex_match (_thread_safe_regex_init (&_tmp_regex_9, "\\.\\+\\(\\)\\-\\?\\/\\\"\\$\\[\\]\\*\\^", 0), ".+()-?/\"$[]*^", 0, NULL)) { FILE* _tmp68_; _tmp68_ = stdout; fprintf (_tmp68_, "Matches\n"); } else { FILE* _tmp69_; _tmp69_ = stdout; fprintf (_tmp69_, "Does not match.\n"); } _tmp70_ = _g_regex_ref0 (_thread_safe_regex_init (&_tmp_regex_10, "foo(bar)", 0 | G_REGEX_CASELESS)); _data1_->rc = _tmp70_; _tmp71_ = test_new (); test = _tmp71_; g_signal_connect_data (test, "regex-test", (GCallback) ___lambda4__test_regex_test, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0); test_run (test, "fooBar"); test_run (test, "foobAr"); _g_object_unref0 (test); _g_regex_unref0 (r2); _g_regex_unref0 (r1); _g_regex_unref0 (r); _g_free0 (ts); _g_free0 (str2); _g_free0 (str1); block1_data_unref (_data1_); _data1_ = NULL; } int main (int argc, char ** argv) { _vala_main (); return 0; } static void _vala_array_destroy (gpointer array, gssize array_length, GDestroyNotify destroy_func) { if ((array != NULL) && (destroy_func != NULL)) { gssize i; for (i = 0; i < array_length; i = i + 1) { if (((gpointer*) array)[i] != NULL) { destroy_func (((gpointer*) array)[i]); } } } } static void _vala_array_free (gpointer array, gssize array_length, GDestroyNotify destroy_func) { _vala_array_destroy (array, array_length, destroy_func); g_free (array); }