/* chess-engine.c generated by valac 0.36.1.2-2a0ee, the Vala compiler
 * generated from chess-engine.vala, do not modify */

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * Copyright (C) 2010-2013 Robert Ancell
 * Copyright (C) 2013-2014 Michael Catanzaro
 * Copyright (C) 2015-2016 Sahil Sareen
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
 * license.
 */

#include <glib.h>
#include <glib-object.h>
#include "libchess.h"
#include "portability.h"
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>


#define TYPE_CHESS_ENGINE (chess_engine_get_type ())
#define CHESS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHESS_ENGINE, ChessEngine))
#define CHESS_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHESS_ENGINE, ChessEngineClass))
#define IS_CHESS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHESS_ENGINE))
#define IS_CHESS_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHESS_ENGINE))
#define CHESS_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHESS_ENGINE, ChessEngineClass))

typedef struct _ChessEngine ChessEngine;
typedef struct _ChessEngineClass ChessEngineClass;
typedef struct _ChessEnginePrivate ChessEnginePrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_io_channel_unref0(var) ((var == NULL) ? NULL : (var = (g_io_channel_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
enum  {
	CHESS_ENGINE_STARTING_SIGNAL,
	CHESS_ENGINE_READY_CHANGED_SIGNAL,
	CHESS_ENGINE_MOVED_SIGNAL,
	CHESS_ENGINE_RESIGNED_SIGNAL,
	CHESS_ENGINE_STOPPED_UNEXPECTEDLY_SIGNAL,
	CHESS_ENGINE_ERROR_SIGNAL,
	CHESS_ENGINE_CLAIM_DRAW_SIGNAL,
	CHESS_ENGINE_OFFER_DRAW_SIGNAL,
	CHESS_ENGINE_LAST_SIGNAL
};
static guint chess_engine_signals[CHESS_ENGINE_LAST_SIGNAL] = {0};
#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 _ChessEngine {
	GObject parent_instance;
	ChessEnginePrivate * priv;
};

struct _ChessEngineClass {
	GObjectClass parent_class;
	void (*process_input) (ChessEngine* self, gchar* data, int data_length1);
	void (*start_game) (ChessEngine* self);
	void (*report_move) (ChessEngine* self, ChessMove* move);
	void (*do_undo) (ChessEngine* self);
	void (*request_move) (ChessEngine* self);
};

struct _ChessEnginePrivate {
	gchar* binary;
	gchar** args;
	gint args_length1;
	gint _args_size_;
	guint delay_seconds;
	guint pending_move_source_id;
	GPid pid;
	gint stdin_fd;
	gint stderr_fd;
	GIOChannel* stdout_channel;
	guint child_watch_id;
	guint stdout_watch_id;
	gboolean started;
	gboolean _ready;
};


static gpointer chess_engine_parent_class = NULL;

GType chess_engine_get_type (void) G_GNUC_CONST;
#define CHESS_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_CHESS_ENGINE, ChessEnginePrivate))
enum  {
	CHESS_ENGINE_DUMMY_PROPERTY,
	CHESS_ENGINE_READY
};
void chess_engine_process_input (ChessEngine* self, gchar* data, int data_length1);
static void chess_engine_real_process_input (ChessEngine* self, gchar* data, int data_length1);
ChessEngine* chess_engine_construct (GType object_type, const gchar* binary, gchar** args, int args_length1, guint delay_seconds);
static gchar** _vala_array_dup19 (gchar** self, int length);
gboolean chess_engine_start (ChessEngine* self);
static void _vala_array_add1 (gchar** * array, int* length, int* size, gchar* value);
static void _vala_array_add2 (gchar** * array, int* length, int* size, gchar* value);
static void ___lambda4_ (ChessEngine* self);
static void ____lambda4__gspawn_child_setup_func (gpointer self);
static void chess_engine_engine_stopped_cb (ChessEngine* self, GPid pid);
static void _chess_engine_engine_stopped_cb_gchild_watch_func (GPid pid, gint status, gpointer self);
static gboolean chess_engine_read_cb (ChessEngine* self, GIOChannel* source, GIOCondition condition);
static gboolean _chess_engine_read_cb_gio_func (GIOChannel* source, GIOCondition condition, gpointer self);
void chess_engine_stop (ChessEngine* self, gboolean kill_engine);
void chess_engine_start_game (ChessEngine* self);
static void chess_engine_real_start_game (ChessEngine* self);
void chess_engine_report_move (ChessEngine* self, ChessMove* move);
static void chess_engine_real_report_move (ChessEngine* self, ChessMove* move);
void chess_engine_do_undo (ChessEngine* self);
static void chess_engine_real_do_undo (ChessEngine* self);
void chess_engine_request_move (ChessEngine* self);
static void chess_engine_real_request_move (ChessEngine* self);
void chess_engine_move (ChessEngine* self);
static gboolean __lambda5_ (ChessEngine* self);
static gboolean ___lambda5__gsource_func (gpointer self);
void chess_engine_undo (ChessEngine* self);
void chess_engine_write (ChessEngine* self, gchar* data, int data_length1);
void chess_engine_write_line (ChessEngine* self, const gchar* line);
gboolean chess_engine_get_ready (ChessEngine* self);
void chess_engine_set_ready (ChessEngine* self, gboolean value);
static void chess_engine_finalize (GObject * obj);
static void _vala_chess_engine_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_chess_engine_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static void chess_engine_real_process_input (ChessEngine* self, gchar* data, int data_length1) {
}


void chess_engine_process_input (ChessEngine* self, gchar* data, int data_length1) {
#line 30 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 30 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	CHESS_ENGINE_GET_CLASS (self)->process_input (self, data, data_length1);
#line 146 "chess-engine.c"
}


static gchar** _vala_array_dup19 (gchar** self, int length) {
	gchar** result;
	int i;
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	result = g_new0 (gchar*, length + 1);
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	for (i = 0; i < length; i++) {
#line 157 "chess-engine.c"
		gchar* _tmp0_;
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp0_ = g_strdup (self[i]);
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		result[i] = _tmp0_;
#line 163 "chess-engine.c"
	}
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return result;
#line 167 "chess-engine.c"
}


ChessEngine* chess_engine_construct (GType object_type, const gchar* binary, gchar** args, int args_length1, guint delay_seconds) {
	ChessEngine * self = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gchar** _tmp3_;
	gint _tmp3__length1;
	guint _tmp4_;
#line 55 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_val_if_fail (binary != NULL, NULL);
#line 55 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self = (ChessEngine*) g_object_new (object_type, NULL);
#line 57 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp0_ = binary;
#line 57 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp1_ = g_strdup (_tmp0_);
#line 57 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_g_free0 (self->priv->binary);
#line 57 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->binary = _tmp1_;
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp2_ = args;
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp2__length1 = args_length1;
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp3_ = (_tmp2_ != NULL) ? _vala_array_dup19 (_tmp2_, _tmp2__length1) : ((gpointer) _tmp2_);
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp3__length1 = _tmp2__length1;
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->args = (_vala_array_free (self->priv->args, self->priv->args_length1, (GDestroyNotify) g_free), NULL);
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->args = _tmp3_;
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->args_length1 = _tmp3__length1;
#line 58 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->_args_size_ = self->priv->args_length1;
#line 59 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp4_ = delay_seconds;
#line 59 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->delay_seconds = _tmp4_;
#line 55 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return self;
#line 214 "chess-engine.c"
}


static void _vala_array_add1 (gchar** * array, int* length, int* size, gchar* value) {
#line 77 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if ((*length) == (*size)) {
#line 77 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		*size = (*size) ? (2 * (*size)) : 4;
#line 77 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		*array = g_renew (gchar*, *array, (*size) + 1);
#line 225 "chess-engine.c"
	}
#line 77 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	(*array)[(*length)++] = value;
#line 77 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	(*array)[*length] = NULL;
#line 231 "chess-engine.c"
}


static void _vala_array_add2 (gchar** * array, int* length, int* size, gchar* value) {
#line 78 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if ((*length) == (*size)) {
#line 78 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		*size = (*size) ? (2 * (*size)) : 4;
#line 78 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		*array = g_renew (gchar*, *array, (*size) + 1);
#line 242 "chess-engine.c"
	}
#line 78 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	(*array)[(*length)++] = value;
#line 78 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	(*array)[*length] = NULL;
#line 248 "chess-engine.c"
}


static void ___lambda4_ (ChessEngine* self) {
#line 85 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	maybe_kill_orphan_engine ();
#line 255 "chess-engine.c"
}


static void ____lambda4__gspawn_child_setup_func (gpointer self) {
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	___lambda4_ ((ChessEngine*) self);
#line 262 "chess-engine.c"
}


static void _chess_engine_engine_stopped_cb_gchild_watch_func (GPid pid, gint status, gpointer self) {
#line 94 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_engine_stopped_cb ((ChessEngine*) self, pid);
#line 269 "chess-engine.c"
}


static gboolean _chess_engine_read_cb_gio_func (GIOChannel* source, GIOCondition condition, gpointer self) {
	gboolean result;
	result = chess_engine_read_cb ((ChessEngine*) self, source, condition);
#line 106 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return result;
#line 278 "chess-engine.c"
}


gboolean chess_engine_start (ChessEngine* self) {
	gboolean result = FALSE;
	GPid _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gboolean _tmp5_;
	gchar** argv;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar** _tmp8_;
	gint argv_length1;
	gint _argv_size_;
	gchar** _tmp9_;
	gint _tmp9__length1;
	gchar** _tmp14_;
	gint _tmp14__length1;
	gint stdout_fd = 0;
	GPid _tmp24_;
	guint _tmp25_;
	gint _tmp26_;
	GIOChannel* _tmp27_;
	GIOChannel* _tmp33_;
	GIOChannel* _tmp34_;
	guint _tmp35_;
	GError * _inner_error_ = NULL;
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp0_ = self->priv->pid;
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_val_if_fail (_tmp0_ == ((GPid) 0), "pid == 0", FALSE);
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp1_ = self->priv->child_watch_id;
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_val_if_fail (_tmp1_ == ((guint) 0), "child_watch_id == 0", FALSE);
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp2_ = self->priv->stdout_watch_id;
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_val_if_fail (_tmp2_ == ((guint) 0), "stdout_watch_id == 0", FALSE);
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp3_ = self->priv->stdin_fd;
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_val_if_fail (_tmp3_ == -1, "stdin_fd == -1", FALSE);
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp4_ = self->priv->stderr_fd;
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_val_if_fail (_tmp4_ == -1, "stderr_fd == -1", FALSE);
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp5_ = self->priv->started;
#line 67 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_val_if_fail (!_tmp5_, "!started", FALSE);
#line 75 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp6_ = self->priv->binary;
#line 75 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp7_ = g_strdup (_tmp6_);
#line 75 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp8_ = g_new0 (gchar*, 1 + 1);
#line 75 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp8_[0] = _tmp7_;
#line 75 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	argv = _tmp8_;
#line 75 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	argv_length1 = 1;
#line 75 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_argv_size_ = argv_length1;
#line 76 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp9_ = self->priv->args;
#line 76 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp9__length1 = self->priv->args_length1;
#line 353 "chess-engine.c"
	{
		gchar** arg_collection = NULL;
		gint arg_collection_length1 = 0;
		gint _arg_collection_size_ = 0;
		gint arg_it = 0;
#line 76 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		arg_collection = _tmp9_;
#line 76 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		arg_collection_length1 = _tmp9__length1;
#line 76 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		for (arg_it = 0; arg_it < _tmp9__length1; arg_it = arg_it + 1) {
#line 365 "chess-engine.c"
			gchar* _tmp10_;
			gchar* arg = NULL;
#line 76 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp10_ = g_strdup (arg_collection[arg_it]);
#line 76 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			arg = _tmp10_;
#line 372 "chess-engine.c"
			{
				gchar** _tmp11_;
				gint _tmp11__length1;
				const gchar* _tmp12_;
				gchar* _tmp13_;
#line 77 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
				_tmp11_ = argv;
#line 77 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
				_tmp11__length1 = argv_length1;
#line 77 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
				_tmp12_ = arg;
#line 77 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
				_tmp13_ = g_strdup (_tmp12_);
#line 77 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
				_vala_array_add1 (&argv, &argv_length1, &_argv_size_, _tmp13_);
#line 76 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
				_g_free0 (arg);
#line 390 "chess-engine.c"
			}
		}
	}
#line 78 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp14_ = argv;
#line 78 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp14__length1 = argv_length1;
#line 78 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_array_add2 (&argv, &argv_length1, &_argv_size_, NULL);
#line 400 "chess-engine.c"
	{
		gchar** _tmp15_;
		gint _tmp15__length1;
		GPid _tmp16_ = 0;
		gint _tmp17_ = 0;
		gint _tmp18_ = 0;
		gint _tmp19_ = 0;
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp15_ = argv;
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp15__length1 = argv_length1;
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_spawn_async_with_pipes (NULL, _tmp15_, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, ____lambda4__gspawn_child_setup_func, self, &_tmp16_, &_tmp17_, &_tmp18_, &_tmp19_, &_inner_error_);
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		self->priv->pid = _tmp16_;
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		self->priv->stdin_fd = _tmp17_;
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		stdout_fd = _tmp18_;
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		self->priv->stderr_fd = _tmp19_;
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 424 "chess-engine.c"
			gboolean _tmp20_ = FALSE;
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			if (_inner_error_->domain == G_SPAWN_ERROR) {
#line 428 "chess-engine.c"
				goto __catch10_g_spawn_error;
			}
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			argv = (_vala_array_free (argv, argv_length1, (GDestroyNotify) g_free), NULL);
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			g_clear_error (&_inner_error_);
#line 83 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			return _tmp20_;
#line 439 "chess-engine.c"
		}
	}
	goto __finally10;
	__catch10_g_spawn_error:
	{
		GError* e = NULL;
		GError* _tmp21_;
		const gchar* _tmp22_;
#line 81 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		e = _inner_error_;
#line 81 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_inner_error_ = NULL;
#line 90 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp21_ = e;
#line 90 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp22_ = _tmp21_->message;
#line 90 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_warning ("chess-engine.vala:90: Failed to execute chess engine: %s\n", _tmp22_);
#line 91 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		result = FALSE;
#line 91 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_g_error_free0 (e);
#line 91 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		argv = (_vala_array_free (argv, argv_length1, (GDestroyNotify) g_free), NULL);
#line 91 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		return result;
#line 466 "chess-engine.c"
	}
	__finally10:
#line 81 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 471 "chess-engine.c"
		gboolean _tmp23_ = FALSE;
#line 81 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		argv = (_vala_array_free (argv, argv_length1, (GDestroyNotify) g_free), NULL);
#line 81 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		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);
#line 81 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_clear_error (&_inner_error_);
#line 81 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		return _tmp23_;
#line 481 "chess-engine.c"
	}
#line 94 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp24_ = self->priv->pid;
#line 94 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp25_ = g_child_watch_add_full (G_PRIORITY_DEFAULT_IDLE, _tmp24_, _chess_engine_engine_stopped_cb_gchild_watch_func, g_object_ref (self), g_object_unref);
#line 94 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->child_watch_id = _tmp25_;
#line 96 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp26_ = stdout_fd;
#line 96 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp27_ = g_io_channel_unix_new (_tmp26_);
#line 96 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_g_io_channel_unref0 (self->priv->stdout_channel);
#line 96 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->stdout_channel = _tmp27_;
#line 497 "chess-engine.c"
	{
		GIOChannel* _tmp28_;
#line 99 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp28_ = self->priv->stdout_channel;
#line 99 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_io_channel_set_flags (_tmp28_, G_IO_FLAG_NONBLOCK, &_inner_error_);
#line 99 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 506 "chess-engine.c"
			gboolean _tmp29_ = FALSE;
#line 99 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			if (_inner_error_->domain == G_IO_CHANNEL_ERROR) {
#line 510 "chess-engine.c"
				goto __catch11_g_io_channel_error;
			}
#line 99 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			argv = (_vala_array_free (argv, argv_length1, (GDestroyNotify) g_free), NULL);
#line 99 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
#line 99 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			g_clear_error (&_inner_error_);
#line 99 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			return _tmp29_;
#line 521 "chess-engine.c"
		}
	}
	goto __finally11;
	__catch11_g_io_channel_error:
	{
		GError* e = NULL;
		GError* _tmp30_;
		const gchar* _tmp31_;
#line 97 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		e = _inner_error_;
#line 97 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_inner_error_ = NULL;
#line 103 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp30_ = e;
#line 103 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp31_ = _tmp30_->message;
#line 103 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_warning ("chess-engine.vala:103: Failed to set input from chess engine to non-bl" \
"ocking: %s", _tmp31_);
#line 97 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_g_error_free0 (e);
#line 542 "chess-engine.c"
	}
	__finally11:
#line 97 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 547 "chess-engine.c"
		gboolean _tmp32_ = FALSE;
#line 97 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		argv = (_vala_array_free (argv, argv_length1, (GDestroyNotify) g_free), NULL);
#line 97 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		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);
#line 97 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_clear_error (&_inner_error_);
#line 97 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		return _tmp32_;
#line 557 "chess-engine.c"
	}
#line 105 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp33_ = self->priv->stdout_channel;
#line 105 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_io_channel_set_close_on_unref (_tmp33_, TRUE);
#line 106 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp34_ = self->priv->stdout_channel;
#line 106 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp35_ = g_io_add_watch (_tmp34_, G_IO_IN, _chess_engine_read_cb_gio_func, self);
#line 106 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->stdout_watch_id = _tmp35_;
#line 108 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->started = TRUE;
#line 109 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_signal_emit (self, chess_engine_signals[CHESS_ENGINE_STARTING_SIGNAL], 0);
#line 111 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	result = TRUE;
#line 111 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	argv = (_vala_array_free (argv, argv_length1, (GDestroyNotify) g_free), NULL);
#line 111 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return result;
#line 579 "chess-engine.c"
}


static void chess_engine_engine_stopped_cb (ChessEngine* self, GPid pid) {
	gboolean _tmp0_;
	GPid _tmp1_;
	GPid _tmp2_;
#line 114 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 114 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp0_ = self->priv->started;
#line 114 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_if_fail (_tmp0_, "started");
#line 114 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp1_ = pid;
#line 114 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp2_ = self->priv->pid;
#line 114 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_if_fail (_tmp1_ == _tmp2_, "pid == this.pid");
#line 118 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_stop (self, FALSE);
#line 119 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_signal_emit (self, chess_engine_signals[CHESS_ENGINE_STOPPED_UNEXPECTEDLY_SIGNAL], 0);
#line 603 "chess-engine.c"
}


static void chess_engine_real_start_game (ChessEngine* self) {
#line 122 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_critical ("Type `%s' does not implement abstract method `chess_engine_start_game'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
#line 122 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return;
#line 612 "chess-engine.c"
}


void chess_engine_start_game (ChessEngine* self) {
#line 122 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 122 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	CHESS_ENGINE_GET_CLASS (self)->start_game (self);
#line 621 "chess-engine.c"
}


static void chess_engine_real_report_move (ChessEngine* self, ChessMove* move) {
#line 124 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_critical ("Type `%s' does not implement abstract method `chess_engine_report_move'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
#line 124 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return;
#line 630 "chess-engine.c"
}


void chess_engine_report_move (ChessEngine* self, ChessMove* move) {
#line 124 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 124 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	CHESS_ENGINE_GET_CLASS (self)->report_move (self, move);
#line 639 "chess-engine.c"
}


static void chess_engine_real_do_undo (ChessEngine* self) {
#line 126 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_critical ("Type `%s' does not implement abstract method `chess_engine_do_undo'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
#line 126 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return;
#line 648 "chess-engine.c"
}


void chess_engine_do_undo (ChessEngine* self) {
#line 126 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 126 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	CHESS_ENGINE_GET_CLASS (self)->do_undo (self);
#line 657 "chess-engine.c"
}


static void chess_engine_real_request_move (ChessEngine* self) {
#line 128 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_critical ("Type `%s' does not implement abstract method `chess_engine_request_move'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
#line 128 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return;
#line 666 "chess-engine.c"
}


void chess_engine_request_move (ChessEngine* self) {
#line 128 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 128 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	CHESS_ENGINE_GET_CLASS (self)->request_move (self);
#line 675 "chess-engine.c"
}


static gboolean __lambda5_ (ChessEngine* self) {
	gboolean result = FALSE;
#line 133 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->pending_move_source_id = (guint) 0;
#line 134 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_request_move (self);
#line 135 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	result = G_SOURCE_REMOVE;
#line 135 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return result;
#line 689 "chess-engine.c"
}


static gboolean ___lambda5__gsource_func (gpointer self) {
	gboolean result;
	result = __lambda5_ ((ChessEngine*) self);
#line 132 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return result;
#line 698 "chess-engine.c"
}


void chess_engine_move (ChessEngine* self) {
	guint _tmp0_;
	guint _tmp1_;
#line 130 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 132 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp0_ = self->priv->delay_seconds;
#line 132 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp1_ = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, _tmp0_, ___lambda5__gsource_func, g_object_ref (self), g_object_unref);
#line 132 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->pending_move_source_id = _tmp1_;
#line 713 "chess-engine.c"
}


void chess_engine_undo (ChessEngine* self) {
	guint _tmp0_;
#line 139 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 141 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp0_ = self->priv->pending_move_source_id;
#line 141 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (_tmp0_ != ((guint) 0)) {
#line 725 "chess-engine.c"
		guint _tmp1_;
#line 143 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp1_ = self->priv->pending_move_source_id;
#line 143 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_source_remove (_tmp1_);
#line 144 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		self->priv->pending_move_source_id = (guint) 0;
#line 733 "chess-engine.c"
	}
#line 147 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_do_undo (self);
#line 737 "chess-engine.c"
}


void chess_engine_stop (ChessEngine* self, gboolean kill_engine) {
	gboolean _tmp0_;
	GIOChannel* _tmp1_;
	gboolean _tmp2_;
	gint _tmp3_;
	gboolean _tmp4_;
	gint _tmp5_;
	gboolean _tmp6_;
	GPid _tmp7_;
	gboolean _tmp8_;
	guint _tmp9_;
	gboolean _tmp10_;
	guint _tmp11_;
	gint _tmp16_;
	gint _tmp17_;
	gint _tmp20_;
	gint _tmp21_;
	guint _tmp24_;
	gboolean _tmp25_ = FALSE;
	gboolean _tmp26_;
	GPid _tmp31_;
	GError * _inner_error_ = NULL;
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp0_ = self->priv->started;
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp1_ = self->priv->stdout_channel;
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_if_fail ((!_tmp0_) || (_tmp1_ != NULL), "!started || stdout_channel != null");
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp2_ = self->priv->started;
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp3_ = self->priv->stdin_fd;
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_if_fail ((!_tmp2_) || (_tmp3_ != -1), "!started || stdin_fd != -1");
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp4_ = self->priv->started;
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp5_ = self->priv->stderr_fd;
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_if_fail ((!_tmp4_) || (_tmp5_ != -1), "!started || stderr_fd != -1");
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp6_ = self->priv->started;
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp7_ = self->priv->pid;
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_if_fail ((!_tmp6_) || (_tmp7_ != ((GPid) 0)), "!started || pid != 0");
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp8_ = self->priv->started;
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp9_ = self->priv->child_watch_id;
#line 150 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_if_fail ((!_tmp8_) || (_tmp9_ != ((guint) 0)), "!started || child_watch_id != 0");
#line 157 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp10_ = self->priv->started;
#line 157 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (!_tmp10_) {
#line 158 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		return;
#line 801 "chess-engine.c"
	}
#line 159 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->started = FALSE;
#line 162 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp11_ = self->priv->stdout_watch_id;
#line 162 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (_tmp11_ != ((guint) 0)) {
#line 809 "chess-engine.c"
		guint _tmp12_;
#line 163 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp12_ = self->priv->stdout_watch_id;
#line 163 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_source_remove (_tmp12_);
#line 164 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		self->priv->stdout_watch_id = (guint) 0;
#line 817 "chess-engine.c"
	}
	{
		GIOChannel* _tmp13_;
#line 169 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp13_ = self->priv->stdout_channel;
#line 169 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_io_channel_shutdown (_tmp13_, FALSE, &_inner_error_);
#line 169 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 169 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			if (_inner_error_->domain == G_IO_CHANNEL_ERROR) {
#line 829 "chess-engine.c"
				goto __catch12_g_io_channel_error;
			}
#line 169 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
#line 169 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			g_clear_error (&_inner_error_);
#line 169 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			return;
#line 838 "chess-engine.c"
		}
	}
	goto __finally12;
	__catch12_g_io_channel_error:
	{
		GError* e = NULL;
		GError* _tmp14_;
		const gchar* _tmp15_;
#line 167 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		e = _inner_error_;
#line 167 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_inner_error_ = NULL;
#line 173 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp14_ = e;
#line 173 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp15_ = _tmp14_->message;
#line 173 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_warning ("chess-engine.vala:173: Failed to close channel to engine's stdout: %s", _tmp15_);
#line 167 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_g_error_free0 (e);
#line 859 "chess-engine.c"
	}
	__finally12:
#line 167 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 167 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		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);
#line 167 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_clear_error (&_inner_error_);
#line 167 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		return;
#line 870 "chess-engine.c"
	}
#line 175 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_g_io_channel_unref0 (self->priv->stdout_channel);
#line 175 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->stdout_channel = NULL;
#line 177 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp16_ = self->priv->stdin_fd;
#line 177 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp17_ = close (_tmp16_);
#line 177 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (_tmp17_ == -1) {
#line 882 "chess-engine.c"
		gint _tmp18_;
		const gchar* _tmp19_;
#line 178 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp18_ = errno;
#line 178 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp19_ = g_strerror (_tmp18_);
#line 178 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_warning ("chess-engine.vala:178: Failed to close pipe to engine's stdin: %s", _tmp19_);
#line 891 "chess-engine.c"
	}
#line 179 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->stdin_fd = -1;
#line 181 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp20_ = self->priv->stderr_fd;
#line 181 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp21_ = close (_tmp20_);
#line 181 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (_tmp21_ == -1) {
#line 901 "chess-engine.c"
		gint _tmp22_;
		const gchar* _tmp23_;
#line 182 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp22_ = errno;
#line 182 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp23_ = g_strerror (_tmp22_);
#line 182 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_warning ("chess-engine.vala:182: Failed to close pipe to engine's stderr: %s", _tmp23_);
#line 910 "chess-engine.c"
	}
#line 183 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->stderr_fd = -1;
#line 185 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp24_ = self->priv->child_watch_id;
#line 185 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_source_remove (_tmp24_);
#line 186 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->child_watch_id = (guint) 0;
#line 188 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp26_ = kill_engine;
#line 188 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (_tmp26_) {
#line 924 "chess-engine.c"
		GPid _tmp27_;
		gint _tmp28_;
#line 188 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp27_ = self->priv->pid;
#line 188 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp28_ = kill ((pid_t) _tmp27_, SIGTERM);
#line 188 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp25_ = _tmp28_ == -1;
#line 933 "chess-engine.c"
	} else {
#line 188 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp25_ = FALSE;
#line 937 "chess-engine.c"
	}
#line 188 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (_tmp25_) {
#line 941 "chess-engine.c"
		gint _tmp29_;
		const gchar* _tmp30_;
#line 189 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp29_ = errno;
#line 189 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp30_ = g_strerror (_tmp29_);
#line 189 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_warning ("chess-engine.vala:189: Failed to kill engine: %s", _tmp30_);
#line 950 "chess-engine.c"
	}
#line 190 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp31_ = self->priv->pid;
#line 190 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_spawn_close_pid (_tmp31_);
#line 191 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->pid = (GPid) 0;
#line 958 "chess-engine.c"
}


static gboolean chess_engine_read_cb (ChessEngine* self, GIOChannel* source, GIOCondition condition) {
	gboolean result = FALSE;
	guint _tmp0_;
	gchar* buf = NULL;
	gint buf_length1 = 0;
	gint _buf_size_ = 0;
	gsize n_read = 0UL;
	GIOStatus status = 0;
	gchar* _tmp1_;
	GIOStatus _tmp13_;
	GIOStatus _tmp14_;
	GError * _inner_error_ = NULL;
#line 194 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 194 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_val_if_fail (source != NULL, FALSE);
#line 194 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp0_ = self->priv->stdout_watch_id;
#line 194 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_return_val_if_fail (_tmp0_ != ((guint) 0), "stdout_watch_id != 0", FALSE);
#line 201 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp1_ = g_new0 (gchar, 1024);
#line 201 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	buf = (g_free (buf), NULL);
#line 201 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	buf = _tmp1_;
#line 201 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	buf_length1 = 1024;
#line 201 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_buf_size_ = buf_length1;
#line 992 "chess-engine.c"
	{
		GIOStatus _tmp2_;
		GIOChannel* _tmp3_;
		gchar* _tmp4_;
		gint _tmp4__length1;
		gsize _tmp5_ = 0UL;
		GIOStatus _tmp6_;
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp3_ = source;
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp4_ = buf;
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp4__length1 = buf_length1;
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp6_ = g_io_channel_read_chars (_tmp3_, _tmp4_, _tmp4__length1, &_tmp5_, &_inner_error_);
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		n_read = _tmp5_;
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp2_ = _tmp6_;
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 1014 "chess-engine.c"
			gboolean _tmp7_ = FALSE;
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			if (_inner_error_->domain == G_CONVERT_ERROR) {
#line 1018 "chess-engine.c"
				goto __catch13_g_convert_error;
			}
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			if (_inner_error_->domain == G_IO_CHANNEL_ERROR) {
#line 1023 "chess-engine.c"
				goto __catch13_g_io_channel_error;
			}
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			buf = (g_free (buf), NULL);
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			g_clear_error (&_inner_error_);
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			return _tmp7_;
#line 1034 "chess-engine.c"
		}
#line 204 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		status = _tmp2_;
#line 1038 "chess-engine.c"
	}
	goto __finally13;
	__catch13_g_convert_error:
	{
		GError* e = NULL;
		GError* _tmp8_;
		const gchar* _tmp9_;
#line 202 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		e = _inner_error_;
#line 202 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_inner_error_ = NULL;
#line 208 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp8_ = e;
#line 208 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp9_ = _tmp8_->message;
#line 208 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_warning ("chess-engine.vala:208: Failed to read from engine: %s", _tmp9_);
#line 209 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		self->priv->stdout_watch_id = (guint) 0;
#line 210 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		result = FALSE;
#line 210 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_g_error_free0 (e);
#line 210 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		buf = (g_free (buf), NULL);
#line 210 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		return result;
#line 1066 "chess-engine.c"
	}
	goto __finally13;
	__catch13_g_io_channel_error:
	{
		GError* e = NULL;
		GError* _tmp10_;
		const gchar* _tmp11_;
#line 202 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		e = _inner_error_;
#line 202 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_inner_error_ = NULL;
#line 214 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp10_ = e;
#line 214 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp11_ = _tmp10_->message;
#line 214 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_warning ("chess-engine.vala:214: Failed to read from engine: %s", _tmp11_);
#line 215 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		self->priv->stdout_watch_id = (guint) 0;
#line 216 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		result = FALSE;
#line 216 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_g_error_free0 (e);
#line 216 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		buf = (g_free (buf), NULL);
#line 216 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		return result;
#line 1094 "chess-engine.c"
	}
	__finally13:
#line 202 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 1099 "chess-engine.c"
		gboolean _tmp12_ = FALSE;
#line 202 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		buf = (g_free (buf), NULL);
#line 202 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		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);
#line 202 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_clear_error (&_inner_error_);
#line 202 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		return _tmp12_;
#line 1109 "chess-engine.c"
	}
#line 219 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp13_ = status;
#line 219 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (_tmp13_ == G_IO_STATUS_EOF) {
#line 221 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_debug ("chess-engine.vala:221: EOF");
#line 222 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		self->priv->stdout_watch_id = (guint) 0;
#line 223 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		result = FALSE;
#line 223 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		buf = (g_free (buf), NULL);
#line 223 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		return result;
#line 1125 "chess-engine.c"
	}
#line 225 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp14_ = status;
#line 225 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (_tmp14_ == G_IO_STATUS_NORMAL) {
#line 1131 "chess-engine.c"
		gsize _tmp15_;
		gint _tmp16_;
		gchar* _tmp17_;
		gint _tmp17__length1;
#line 227 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp15_ = n_read;
#line 227 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp16_ = (gint) _tmp15_;
#line 227 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		buf = g_renew (gchar, buf, (gint) _tmp15_);
#line 227 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		(_tmp16_ > buf_length1) ? memset (buf + buf_length1, 0, sizeof (gchar) * (_tmp16_ - buf_length1)) : NULL;
#line 227 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		buf_length1 = _tmp16_;
#line 227 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_buf_size_ = _tmp16_;
#line 228 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp17_ = buf;
#line 228 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp17__length1 = buf_length1;
#line 228 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		chess_engine_process_input (self, _tmp17_, _tmp17__length1);
#line 1154 "chess-engine.c"
	}
#line 231 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	result = TRUE;
#line 231 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	buf = (g_free (buf), NULL);
#line 231 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return result;
#line 1162 "chess-engine.c"
}


void chess_engine_write (ChessEngine* self, gchar* data, int data_length1) {
	gsize offset;
	gsize n_written;
#line 234 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 236 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	offset = (gsize) 0;
#line 237 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	n_written = (gsize) 0;
#line 1175 "chess-engine.c"
	{
		gboolean _tmp0_;
#line 239 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp0_ = TRUE;
#line 239 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		while (TRUE) {
#line 1182 "chess-engine.c"
			gint _tmp5_;
			gchar* _tmp6_;
			gint _tmp6__length1;
			gsize _tmp7_;
			gchar* _tmp8_;
			gint _tmp8__length1;
			gsize _tmp9_;
			gssize _tmp10_;
			gsize _tmp11_;
			gsize _tmp12_;
#line 239 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			if (!_tmp0_) {
#line 1195 "chess-engine.c"
				gboolean _tmp1_ = FALSE;
				gsize _tmp2_;
#line 243 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
				_tmp2_ = n_written;
#line 243 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
				if (_tmp2_ > ((gsize) 0)) {
#line 1202 "chess-engine.c"
					gsize _tmp3_;
					gchar* _tmp4_;
					gint _tmp4__length1;
#line 243 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
					_tmp3_ = offset;
#line 243 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
					_tmp4_ = data;
#line 243 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
					_tmp4__length1 = data_length1;
#line 243 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
					_tmp1_ = _tmp3_ < ((gsize) _tmp4__length1);
#line 1214 "chess-engine.c"
				} else {
#line 243 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
					_tmp1_ = FALSE;
#line 1218 "chess-engine.c"
				}
#line 243 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
				if (!_tmp1_) {
#line 243 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
					break;
#line 1224 "chess-engine.c"
				}
			}
#line 239 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp0_ = FALSE;
#line 241 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp5_ = self->priv->stdin_fd;
#line 241 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp6_ = data;
#line 241 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp6__length1 = data_length1;
#line 241 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp7_ = offset;
#line 241 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp8_ = data;
#line 241 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp8__length1 = data_length1;
#line 241 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp9_ = offset;
#line 241 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp10_ = write (_tmp5_, &_tmp6_[_tmp7_], _tmp8__length1 - _tmp9_);
#line 241 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			n_written = (gsize) _tmp10_;
#line 242 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp11_ = offset;
#line 242 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			_tmp12_ = n_written;
#line 242 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
			offset = _tmp11_ + _tmp12_;
#line 1253 "chess-engine.c"
		}
	}
}


static gchar* string_to_utf8 (const gchar* self, int* result_length1) {
	gchar* result = NULL;
	gchar* _result_;
	gint _tmp0_;
	gint _tmp1_;
	gchar* _tmp2_;
	gint _result__length1;
	gint __result__size_;
	gint _tmp3_;
	gchar* _tmp4_;
	gint _tmp4__length1;
	gint _tmp5_;
	gint _tmp6_;
	gchar* _tmp7_;
	gint _tmp7__length1;
#line 1435 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	g_return_val_if_fail (self != NULL, NULL);
#line 1436 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_tmp0_ = strlen (self);
#line 1436 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_tmp1_ = _tmp0_;
#line 1436 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_tmp2_ = g_new0 (gchar, _tmp1_ + 1);
#line 1436 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_result_ = _tmp2_;
#line 1436 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_result__length1 = _tmp1_ + 1;
#line 1436 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	__result__size_ = _result__length1;
#line 1437 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_tmp3_ = _result__length1;
#line 1437 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_result__length1 = _tmp3_ - 1;
#line 1438 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_tmp4_ = _result_;
#line 1438 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_tmp4__length1 = _result__length1;
#line 1438 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_tmp5_ = strlen (self);
#line 1438 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_tmp6_ = _tmp5_;
#line 1438 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	memcpy (_tmp4_, self, (gsize) _tmp6_);
#line 1439 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_tmp7_ = _result_;
#line 1439 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	_tmp7__length1 = _result__length1;
#line 1439 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	if (result_length1) {
#line 1439 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
		*result_length1 = _tmp7__length1;
#line 1310 "chess-engine.c"
	}
#line 1439 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	result = _tmp7_;
#line 1439 "/home/mcatanzaro/Projects/GNOME/install/share/vala-0.36/vapi/glib-2.0.vapi"
	return result;
#line 1316 "chess-engine.c"
}


void chess_engine_write_line (ChessEngine* self, const gchar* line) {
	gchar* l;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* d;
	const gchar* _tmp3_;
	gint _tmp4_;
	gchar* _tmp5_;
	gint d_length1;
	gint _d_size_;
	gchar* _tmp6_;
	gint _tmp6__length1;
#line 246 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 246 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (line != NULL);
#line 248 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp0_ = line;
#line 248 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp1_ = g_strconcat (_tmp0_, "\n", NULL);
#line 248 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	l = _tmp1_;
#line 249 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp2_ = line;
#line 249 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_debug ("chess-engine.vala:249: Writing line to engine: '%s'", _tmp2_);
#line 250 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp3_ = l;
#line 250 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp5_ = string_to_utf8 (_tmp3_, &_tmp4_);
#line 250 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	d = _tmp5_;
#line 250 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	d_length1 = _tmp4_;
#line 250 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_d_size_ = d_length1;
#line 251 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp6_ = d;
#line 251 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp6__length1 = d_length1;
#line 251 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	if (_tmp6_ != NULL) {
#line 1363 "chess-engine.c"
		gchar* _tmp7_;
		gint _tmp7__length1;
#line 252 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp7_ = d;
#line 252 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		_tmp7__length1 = d_length1;
#line 252 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		chess_engine_write (self, _tmp7_, _tmp7__length1);
#line 1372 "chess-engine.c"
	}
#line 246 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	d = (g_free (d), NULL);
#line 246 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_g_free0 (l);
#line 1378 "chess-engine.c"
}


gboolean chess_engine_get_ready (ChessEngine* self) {
	gboolean result;
	gboolean _tmp0_;
#line 49 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 51 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp0_ = self->priv->_ready;
#line 51 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	result = _tmp0_;
#line 51 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	return result;
#line 1393 "chess-engine.c"
}


void chess_engine_set_ready (ChessEngine* self, gboolean value) {
	gboolean _tmp0_;
#line 44 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_return_if_fail (self != NULL);
#line 46 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp0_ = value;
#line 46 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->_ready = _tmp0_;
#line 47 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_signal_emit (self, chess_engine_signals[CHESS_ENGINE_READY_CHANGED_SIGNAL], 0);
#line 44 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_object_notify ((GObject *) self, "ready");
#line 1409 "chess-engine.c"
}


static void chess_engine_class_init (ChessEngineClass * klass) {
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_parent_class = g_type_class_peek_parent (klass);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_type_class_add_private (klass, sizeof (ChessEnginePrivate));
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	((ChessEngineClass *) klass)->process_input = (void (*) (ChessEngine *, gchar*, int)) chess_engine_real_process_input;
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	((ChessEngineClass *) klass)->start_game = (void (*) (ChessEngine *)) chess_engine_real_start_game;
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	((ChessEngineClass *) klass)->report_move = (void (*) (ChessEngine *, ChessMove*)) chess_engine_real_report_move;
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	((ChessEngineClass *) klass)->do_undo = (void (*) (ChessEngine *)) chess_engine_real_do_undo;
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	((ChessEngineClass *) klass)->request_move = (void (*) (ChessEngine *)) chess_engine_real_request_move;
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	G_OBJECT_CLASS (klass)->get_property = _vala_chess_engine_get_property;
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	G_OBJECT_CLASS (klass)->set_property = _vala_chess_engine_set_property;
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	G_OBJECT_CLASS (klass)->finalize = chess_engine_finalize;
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHESS_ENGINE_READY, g_param_spec_boolean ("ready", "ready", "ready", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_signals[CHESS_ENGINE_STARTING_SIGNAL] = g_signal_new ("starting", TYPE_CHESS_ENGINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_signals[CHESS_ENGINE_READY_CHANGED_SIGNAL] = g_signal_new ("ready_changed", TYPE_CHESS_ENGINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_signals[CHESS_ENGINE_MOVED_SIGNAL] = g_signal_new ("moved", TYPE_CHESS_ENGINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_signals[CHESS_ENGINE_RESIGNED_SIGNAL] = g_signal_new ("resigned", TYPE_CHESS_ENGINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_signals[CHESS_ENGINE_STOPPED_UNEXPECTEDLY_SIGNAL] = g_signal_new ("stopped_unexpectedly", TYPE_CHESS_ENGINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_signals[CHESS_ENGINE_ERROR_SIGNAL] = g_signal_new ("error", TYPE_CHESS_ENGINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_signals[CHESS_ENGINE_CLAIM_DRAW_SIGNAL] = g_signal_new ("claim_draw", TYPE_CHESS_ENGINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	chess_engine_signals[CHESS_ENGINE_OFFER_DRAW_SIGNAL] = g_signal_new ("offer_draw", TYPE_CHESS_ENGINE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
#line 1452 "chess-engine.c"
}


static void chess_engine_instance_init (ChessEngine * self) {
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv = CHESS_ENGINE_GET_PRIVATE (self);
#line 22 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->pid = (GPid) 0;
#line 23 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->stdin_fd = -1;
#line 24 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->stderr_fd = -1;
#line 26 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->child_watch_id = (guint) 0;
#line 27 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->stdout_watch_id = (guint) 0;
#line 28 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->started = FALSE;
#line 41 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->_ready = FALSE;
#line 1473 "chess-engine.c"
}


static void chess_engine_finalize (GObject * obj) {
	ChessEngine * self;
	gboolean _tmp0_;
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CHESS_ENGINE, ChessEngine);
#line 64 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_tmp0_ = self->priv->started;
#line 64 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_vala_assert (!_tmp0_, "!started");
#line 16 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_g_free0 (self->priv->binary);
#line 17 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	self->priv->args = (_vala_array_free (self->priv->args, self->priv->args_length1, (GDestroyNotify) g_free), NULL);
#line 25 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	_g_io_channel_unref0 (self->priv->stdout_channel);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	G_OBJECT_CLASS (chess_engine_parent_class)->finalize (obj);
#line 1494 "chess-engine.c"
}


GType chess_engine_get_type (void) {
	static volatile gsize chess_engine_type_id__volatile = 0;
	if (g_once_init_enter (&chess_engine_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ChessEngineClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) chess_engine_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ChessEngine), 0, (GInstanceInitFunc) chess_engine_instance_init, NULL };
		GType chess_engine_type_id;
		chess_engine_type_id = g_type_register_static (G_TYPE_OBJECT, "ChessEngine", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
		g_once_init_leave (&chess_engine_type_id__volatile, chess_engine_type_id);
	}
	return chess_engine_type_id__volatile;
}


static void _vala_chess_engine_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	ChessEngine * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_CHESS_ENGINE, ChessEngine);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	switch (property_id) {
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		case CHESS_ENGINE_READY:
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		g_value_set_boolean (value, chess_engine_get_ready (self));
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		break;
#line 1521 "chess-engine.c"
		default:
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		break;
#line 1527 "chess-engine.c"
	}
}


static void _vala_chess_engine_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	ChessEngine * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_CHESS_ENGINE, ChessEngine);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
	switch (property_id) {
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		case CHESS_ENGINE_READY:
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		chess_engine_set_ready (self, g_value_get_boolean (value));
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		break;
#line 1543 "chess-engine.c"
		default:
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 14 "/home/mcatanzaro/Projects/GNOME/gnome-chess/src/chess-engine.vala"
		break;
#line 1549 "chess-engine.c"
	}
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



