/* pattern.c generated by valac 0.38.8, the Vala compiler
 * generated from pattern.vala, do not modify */

/*
 Copyright (C) 2009-2014 Christian Dywan <christian@twotoasts.de>
 Copyright (C) 2009-2012 Alexander Butenko <a.butenka@gmail.com>

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 See the file COPYING for the full license text.
*/

#include <glib.h>
#include <glib-object.h>
#include "toolbar-editor.h"
#include <stdlib.h>
#include <string.h>

enum  {
	ADBLOCK_PATTERN_0_PROPERTY,
	ADBLOCK_PATTERN_NUM_PROPERTIES
};
static GParamSpec* adblock_pattern_properties[ADBLOCK_PATTERN_NUM_PROPERTIES];
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))


static gpointer adblock_pattern_parent_class = NULL;

static AdblockDirective* adblock_pattern_real_match (AdblockFeature* base, const gchar* request_uri, const gchar* page_uri, GError** error);
static AdblockDirective* _adblock_directive_dup (AdblockDirective* self);


AdblockPattern* adblock_pattern_construct (GType object_type, AdblockOptions* options) {
	AdblockPattern * self = NULL;
	AdblockOptions* _tmp0_;
#line 15 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	g_return_val_if_fail (options != NULL, NULL);
#line 16 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	_tmp0_ = options;
#line 16 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	self = (AdblockPattern*) adblock_filter_construct (object_type, _tmp0_);
#line 15 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	return self;
#line 48 "pattern.c"
}


AdblockPattern* adblock_pattern_new (AdblockOptions* options) {
#line 15 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	return adblock_pattern_construct (ADBLOCK_TYPE_PATTERN, options);
#line 55 "pattern.c"
}


static AdblockDirective* _adblock_directive_dup (AdblockDirective* self) {
	AdblockDirective* dup;
#line 22 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	dup = g_new0 (AdblockDirective, 1);
#line 22 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	memcpy (dup, self, sizeof (AdblockDirective));
#line 22 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	return dup;
#line 67 "pattern.c"
}


static gpointer __adblock_directive_dup0 (gpointer self) {
#line 22 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	return self ? _adblock_directive_dup (self) : NULL;
#line 74 "pattern.c"
}


static AdblockDirective* adblock_pattern_real_match (AdblockFeature* base, const gchar* request_uri, const gchar* page_uri, GError** error) {
	AdblockPattern * self;
	AdblockDirective* result = NULL;
	GHashTable* _tmp0_;
	GList* _tmp1_;
	GError * _inner_error_ = NULL;
#line 19 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	self = (AdblockPattern*) base;
#line 19 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	g_return_val_if_fail (request_uri != NULL, NULL);
#line 19 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	g_return_val_if_fail (page_uri != NULL, NULL);
#line 20 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	_tmp0_ = ((AdblockFilter*) self)->rules;
#line 20 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	_tmp1_ = g_hash_table_get_keys (_tmp0_);
#line 94 "pattern.c"
	{
		GList* patt_collection = NULL;
		GList* patt_it = NULL;
#line 20 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
		patt_collection = _tmp1_;
#line 20 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
		for (patt_it = patt_collection; patt_it != NULL; patt_it = patt_it->next) {
#line 102 "pattern.c"
			const gchar* patt = NULL;
#line 20 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
			patt = (const gchar*) patt_it->data;
#line 106 "pattern.c"
			{
				gboolean _tmp2_ = FALSE;
				GHashTable* _tmp3_;
				const gchar* _tmp4_;
				gconstpointer _tmp5_;
				const gchar* _tmp6_;
				const gchar* _tmp7_;
				const gchar* _tmp8_;
				gboolean _tmp9_;
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
				_tmp3_ = ((AdblockFilter*) self)->rules;
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
				_tmp4_ = patt;
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
				_tmp5_ = g_hash_table_lookup (_tmp3_, _tmp4_);
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
				_tmp6_ = patt;
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
				_tmp7_ = request_uri;
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
				_tmp8_ = page_uri;
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
				_tmp9_ = adblock_filter_check_rule ((AdblockFilter*) self, (GRegex*) _tmp5_, _tmp6_, _tmp7_, _tmp8_, &_inner_error_);
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
				_tmp2_ = _tmp9_;
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
				if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
					g_propagate_error (error, _inner_error_);
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
					_g_list_free0 (patt_collection);
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
					return NULL;
#line 140 "pattern.c"
				}
#line 21 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
				if (_tmp2_) {
#line 144 "pattern.c"
					AdblockDirective _tmp10_;
					AdblockDirective* _tmp11_;
#line 22 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
					_tmp10_ = ADBLOCK_DIRECTIVE_BLOCK;
#line 22 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
					_tmp11_ = __adblock_directive_dup0 (&_tmp10_);
#line 22 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
					result = _tmp11_;
#line 22 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
					_g_list_free0 (patt_collection);
#line 22 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
					return result;
#line 157 "pattern.c"
				}
			}
		}
#line 20 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
		_g_list_free0 (patt_collection);
#line 163 "pattern.c"
	}
#line 23 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	result = NULL;
#line 23 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	return result;
#line 169 "pattern.c"
}


static void adblock_pattern_class_init (AdblockPatternClass * klass) {
#line 14 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	adblock_pattern_parent_class = g_type_class_peek_parent (klass);
#line 14 "/usr/src/ports/midori/midori-0.5.11-2.i686/src/midori-0.5.11/extensions/adblock/pattern.vala"
	((AdblockFeatureClass *) klass)->match = (AdblockDirective* (*) (AdblockFeature *, const gchar*, const gchar*, GError**)) adblock_pattern_real_match;
#line 178 "pattern.c"
}


static void adblock_pattern_instance_init (AdblockPattern * self) {
}


GType adblock_pattern_get_type (void) {
	static volatile gsize adblock_pattern_type_id__volatile = 0;
	if (g_once_init_enter (&adblock_pattern_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (AdblockPatternClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) adblock_pattern_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AdblockPattern), 0, (GInstanceInitFunc) adblock_pattern_instance_init, NULL };
		GType adblock_pattern_type_id;
		adblock_pattern_type_id = g_type_register_static (ADBLOCK_TYPE_FILTER, "AdblockPattern", &g_define_type_info, 0);
		g_once_init_leave (&adblock_pattern_type_id__volatile, adblock_pattern_type_id);
	}
	return adblock_pattern_type_id__volatile;
}



