/*
 * This file was generated automatically by ExtUtils::ParseXS version 3.40 from the
 * contents of Window.xs. Do not edit this file, edit Window.xs instead.
 *
 *    ANY CHANGES MADE HERE WILL BE LOST!
 *
 */

#line 1 "Window.xs"
#define PERL_NO_GET_CONTEXT
#include "module.h"

#include "window-activity.h"

#line 16 "Window.c"
#ifndef PERL_UNUSED_VAR
#  define PERL_UNUSED_VAR(var) if (0) var = var
#endif

#ifndef dVAR
#  define dVAR		dNOOP
#endif


/* This stuff is not part of the API! You have been warned. */
#ifndef PERL_VERSION_DECIMAL
#  define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
#endif
#ifndef PERL_DECIMAL_VERSION
#  define PERL_DECIMAL_VERSION \
	  PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
#endif
#ifndef PERL_VERSION_GE
#  define PERL_VERSION_GE(r,v,s) \
	  (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
#endif
#ifndef PERL_VERSION_LE
#  define PERL_VERSION_LE(r,v,s) \
	  (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
#endif

/* XS_INTERNAL is the explicit static-linkage variant of the default
 * XS macro.
 *
 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
 * "STATIC", ie. it exports XSUB symbols. You probably don't want that
 * for anything but the BOOT XSUB.
 *
 * See XSUB.h in core!
 */


/* TODO: This might be compatible further back than 5.10.0. */
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
#  undef XS_EXTERNAL
#  undef XS_INTERNAL
#  if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
#    define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
#    define XS_INTERNAL(name) STATIC XSPROTO(name)
#  endif
#  if defined(__SYMBIAN32__)
#    define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
#    define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
#  endif
#  ifndef XS_EXTERNAL
#    if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
#      define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
#      define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
#    else
#      ifdef __cplusplus
#        define XS_EXTERNAL(name) extern "C" XSPROTO(name)
#        define XS_INTERNAL(name) static XSPROTO(name)
#      else
#        define XS_EXTERNAL(name) XSPROTO(name)
#        define XS_INTERNAL(name) STATIC XSPROTO(name)
#      endif
#    endif
#  endif
#endif

/* perl >= 5.10.0 && perl <= 5.15.1 */


/* The XS_EXTERNAL macro is used for functions that must not be static
 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
 * macro defined, the best we can do is assume XS is the same.
 * Dito for XS_INTERNAL.
 */
#ifndef XS_EXTERNAL
#  define XS_EXTERNAL(name) XS(name)
#endif
#ifndef XS_INTERNAL
#  define XS_INTERNAL(name) XS(name)
#endif

/* Now, finally, after all this mess, we want an ExtUtils::ParseXS
 * internal macro that we're free to redefine for varying linkage due
 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
 */

#undef XS_EUPXS
#if defined(PERL_EUPXS_ALWAYS_EXPORT)
#  define XS_EUPXS(name) XS_EXTERNAL(name)
#else
   /* default to internal */
#  define XS_EUPXS(name) XS_INTERNAL(name)
#endif

#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)

/* prototype to pass -Wmissing-prototypes */
STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params);

STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params)
{
    const GV *const gv = CvGV(cv);

    PERL_ARGS_ASSERT_CROAK_XS_USAGE;

    if (gv) {
        const char *const gvname = GvNAME(gv);
        const HV *const stash = GvSTASH(gv);
        const char *const hvname = stash ? HvNAME(stash) : NULL;

        if (hvname)
	    Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
        else
	    Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
    } else {
        /* Pants. I don't think that it should be possible to get here. */
	Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
    }
}
#undef  PERL_ARGS_ASSERT_CROAK_XS_USAGE

#define croak_xs_usage        S_croak_xs_usage

#endif

/* NOTE: the prototype of newXSproto() is different in versions of perls,
 * so we define a portable version of newXSproto()
 */
#ifdef newXS_flags
#define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
#else
#define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
#endif /* !defined(newXS_flags) */

#if PERL_VERSION_LE(5, 21, 5)
#  define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
#else
#  define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
#endif

#line 160 "Window.c"

XS_EUPXS(XS_Irssi_windows); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_windows)
{
    dVAR; dXSARGS;
    if (items != 0)
       croak_xs_usage(cv,  "");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
#line 12 "Window.xs"
	GSList *tmp;
#line 173 "Window.c"
#line 14 "Window.xs"
	for (tmp = windows; tmp != NULL; tmp = tmp->next) {
		XPUSHs(sv_2mortal(plain_bless(tmp->data, "Irssi::UI::Window")));
	}
#line 178 "Window.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Irssi_active_win); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_active_win)
{
    dVAR; dXSARGS;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {
	Irssi__UI__Window	RETVAL;
#line 22 "Window.xs"
	RETVAL = active_win;
#line 195 "Window.c"
	{
	    SV * RETVALSV;
	    RETVALSV = plain_bless(RETVAL, "Irssi::UI::Window");
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi_active_server); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_active_server)
{
    dVAR; dXSARGS;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {
	Irssi__Server	RETVAL;
#line 29 "Window.xs"
	RETVAL = active_win->active_server;
#line 217 "Window.c"
	{
	    SV * RETVALSV;
	    RETVALSV = iobject_bless((SERVER_REC *)RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi_print); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_print)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "str, level=MSGLEVEL_CLIENTNOTICE");
    {
	char *	str = (char *)SvPV_nolen(ST(0))
;
	int	level;

	if (items < 2)
	    level = MSGLEVEL_CLIENTNOTICE;
	else {
	    level = (int)SvIV(ST(1))
;
	}
#line 38 "Window.xs"
	printtext_string(NULL, NULL, level, str);
#line 248 "Window.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi_window_find_name); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_window_find_name)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "name");
    {
	char *	name = (char *)SvPV_nolen(ST(0))
;
	Irssi__UI__Window	RETVAL;

	RETVAL = window_find_name(name);
	{
	    SV * RETVALSV;
	    RETVALSV = plain_bless(RETVAL, "Irssi::UI::Window");
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi_window_find_refnum); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_window_find_refnum)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "refnum");
    {
	int	refnum = (int)SvIV(ST(0))
;
	Irssi__UI__Window	RETVAL;

	RETVAL = window_find_refnum(refnum);
	{
	    SV * RETVALSV;
	    RETVALSV = plain_bless(RETVAL, "Irssi::UI::Window");
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi_window_refnum_prev); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_window_refnum_prev)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "refnum, wrap");
    {
	int	refnum = (int)SvIV(ST(0))
;
	int	wrap = (int)SvIV(ST(1))
;
	int	RETVAL;
	dXSTARG;

	RETVAL = window_refnum_prev(refnum, wrap);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi_window_refnum_next); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_window_refnum_next)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "refnum, wrap");
    {
	int	refnum = (int)SvIV(ST(0))
;
	int	wrap = (int)SvIV(ST(1))
;
	int	RETVAL;
	dXSTARG;

	RETVAL = window_refnum_next(refnum, wrap);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi_windows_refnum_last); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_windows_refnum_last)
{
    dVAR; dXSARGS;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {
	int	RETVAL;
	dXSTARG;

	RETVAL = windows_refnum_last();
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi_window_find_level); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_window_find_level)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "level");
    {
	int	level = (int)SvIV(ST(0))
;
	Irssi__UI__Window	RETVAL;
#line 65 "Window.xs"
	RETVAL = window_find_level(NULL, level);
#line 371 "Window.c"
	{
	    SV * RETVALSV;
	    RETVALSV = plain_bless(RETVAL, "Irssi::UI::Window");
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi_window_find_item); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_window_find_item)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "name");
    {
	char *	name = (char *)SvPV_nolen(ST(0))
;
	Irssi__UI__Window	RETVAL;
#line 73 "Window.xs"
	RETVAL = window_find_item(NULL, name);
#line 395 "Window.c"
	{
	    SV * RETVALSV;
	    RETVALSV = plain_bless(RETVAL, "Irssi::UI::Window");
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi_window_find_closest); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_window_find_closest)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "name, level");
    {
	char *	name = (char *)SvPV_nolen(ST(0))
;
	int	level = (int)SvIV(ST(1))
;
	Irssi__UI__Window	RETVAL;
#line 82 "Window.xs"
	RETVAL = window_find_closest(NULL, name, level);
#line 421 "Window.c"
	{
	    SV * RETVALSV;
	    RETVALSV = plain_bless(RETVAL, "Irssi::UI::Window");
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi_window_item_find); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi_window_item_find)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "name");
    {
	char *	name = (char *)SvPV_nolen(ST(0))
;
	Irssi__Windowitem	RETVAL;
#line 90 "Window.xs"
	RETVAL = window_item_find(NULL, name);
#line 445 "Window.c"
	{
	    SV * RETVALSV;
	    RETVALSV = iobject_bless((SERVER_REC *)RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi__Server_print); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Server_print)
{
    dVAR; dXSARGS;
    if (items < 3 || items > 4)
       croak_xs_usage(cv,  "server, channel, str, level=MSGLEVEL_CLIENTNOTICE");
    {
	Irssi__Server	server = irssi_ref_object(ST(0))
;
	char *	channel = (char *)SvPV_nolen(ST(1))
;
	char *	str = (char *)SvPV_nolen(ST(2))
;
	int	level;

	if (items < 4)
	    level = MSGLEVEL_CLIENTNOTICE;
	else {
	    level = (int)SvIV(ST(3))
;
	}
#line 106 "Window.xs"
	printtext_string(server, channel, level, str);
#line 480 "Window.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__Server_window_item_find); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Server_window_item_find)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "server, name");
    {
	Irssi__Server	server = irssi_ref_object(ST(0))
;
	char *	name = (char *)SvPV_nolen(ST(1))
;
	Irssi__Windowitem	RETVAL;

	RETVAL = window_item_find(server, name);
	{
	    SV * RETVALSV;
	    RETVALSV = iobject_bless((SERVER_REC *)RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi__Server_window_find_item); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Server_window_find_item)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "server, name");
    {
	Irssi__Server	server = irssi_ref_object(ST(0))
;
	char *	name = (char *)SvPV_nolen(ST(1))
;
	Irssi__UI__Window	RETVAL;

	RETVAL = window_find_item(server, name);
	{
	    SV * RETVALSV;
	    RETVALSV = plain_bless(RETVAL, "Irssi::UI::Window");
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi__Server_window_find_level); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Server_window_find_level)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "server, level");
    {
	Irssi__Server	server = irssi_ref_object(ST(0))
;
	int	level = (int)SvIV(ST(1))
;
	Irssi__UI__Window	RETVAL;

	RETVAL = window_find_level(server, level);
	{
	    SV * RETVALSV;
	    RETVALSV = plain_bless(RETVAL, "Irssi::UI::Window");
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi__Server_window_find_closest); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Server_window_find_closest)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "server, name, level");
    {
	Irssi__Server	server = irssi_ref_object(ST(0))
;
	char *	name = (char *)SvPV_nolen(ST(1))
;
	int	level = (int)SvIV(ST(2))
;
	Irssi__UI__Window	RETVAL;

	RETVAL = window_find_closest(server, name, level);
	{
	    SV * RETVALSV;
	    RETVALSV = plain_bless(RETVAL, "Irssi::UI::Window");
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi__UI__Window_items); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_items)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "window");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
#line 138 "Window.xs"
	GSList *tmp;
#line 601 "Window.c"
#line 140 "Window.xs"
	for (tmp = window->items; tmp != NULL; tmp = tmp->next) {
                CHANNEL_REC *rec = tmp->data;

		XPUSHs(sv_2mortal(iobject_bless(rec)));
	}
#line 608 "Window.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Irssi__UI__Window_print); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_print)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "window, str, level=MSGLEVEL_CLIENTNOTICE");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
	char *	str = (char *)SvPV_nolen(ST(1))
;
	int	level;

	if (items < 3)
	    level = MSGLEVEL_CLIENTNOTICE;
	else {
	    level = (int)SvIV(ST(2))
;
	}
#line 152 "Window.xs"
	printtext_string_window(window, level, str);
#line 636 "Window.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_command); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_command)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "window, cmd");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
	char *	cmd = (char *)SvPV_nolen(ST(1))
;
#line 159 "Window.xs"
	WINDOW_REC *old;
#line 655 "Window.c"
#line 161 "Window.xs"
	old = active_win;
	active_win = window;
	perl_command(cmd, window->active_server, window->active);
	if (active_win == window &&
	    g_slist_find(windows, old) != NULL)
        	active_win = old;
#line 663 "Window.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_item_add); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_item_add)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "window, item, automatic");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
	Irssi__Windowitem	item = irssi_ref_object(ST(1))
;
	int	automatic = (int)SvIV(ST(2))
;

	window_item_add(window, item, automatic);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_item_remove); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_item_remove)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "item");
    {
	Irssi__Windowitem	item = irssi_ref_object(ST(0))
;

	window_item_remove(item);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_item_destroy); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_item_destroy)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "item");
    {
	Irssi__Windowitem	item = irssi_ref_object(ST(0))
;

	window_item_destroy(item);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_item_prev); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_item_prev)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "window");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;

	window_item_prev(window);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_item_next); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_item_next)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "window");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;

	window_item_next(window);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_destroy); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_destroy)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "window");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;

	window_destroy(window);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_set_active); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_set_active)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "window");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;

	window_set_active(window);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_change_server); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_change_server)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "window, server");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
	Irssi__Server	server = irssi_ref_object(ST(1))
;

	window_change_server(window, server);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_set_refnum); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_set_refnum)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "window, refnum");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
	int	refnum = (int)SvIV(ST(1))
;

	window_set_refnum(window, refnum);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_set_name); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_set_name)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "window, name");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
	char *	name = (char *)SvPV_nolen(ST(1))
;

	window_set_name(window, name);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_set_history); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_set_history)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "window, name");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
	char *	name = (char *)SvPV_nolen(ST(1))
;

	window_set_history(window, name);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_set_level); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_set_level)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "window, level");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
	int	level = (int)SvIV(ST(1))
;

	window_set_level(window, level);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_activity); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_activity)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "window, data_level, hilight_color=NULL");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
	int	data_level = (int)SvIV(ST(1))
;
	char *	hilight_color;

	if (items < 3)
	    hilight_color = NULL;
	else {
	    hilight_color = (char *)SvPV_nolen(ST(2))
;
	}

	window_activity(window, data_level, hilight_color);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__UI__Window_get_active_name); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_get_active_name)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "window");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
	char *	RETVAL;
	dXSTARG;
#line 233 "Window.xs"
	RETVAL = (char *) window_get_active_name(window);
#line 914 "Window.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi__UI__Window_item_find); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_item_find)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "window, server, name");
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
	Irssi__Server	server = irssi_ref_object(ST(1))
;
	char *	name = (char *)SvPV_nolen(ST(2))
;
	Irssi__Windowitem	RETVAL;
#line 243 "Window.xs"
	RETVAL = window_item_find_window(window, server, name);
#line 937 "Window.c"
	{
	    SV * RETVALSV;
	    RETVALSV = iobject_bless((SERVER_REC *)RETVAL);
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi__UI__Window_get_history_lines); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_get_history_lines)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "window");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
#line 251 "Window.xs"
	HISTORY_REC *rec;
	GList *tmp;
#line 963 "Window.c"
#line 254 "Window.xs"
	rec = command_history_current(window);
	for (tmp = command_history_list_first(rec); tmp != NULL; tmp = command_history_list_next(rec, tmp))
		XPUSHs(sv_2mortal(new_pv(((HISTORY_ENTRY_REC *)tmp->data)->text)));
#line 968 "Window.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Irssi__UI__Window_get_history_entries); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_get_history_entries)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "window");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
#line 262 "Window.xs"
	HISTORY_REC *rec;
	HISTORY_ENTRY_REC *ent;
	WINDOW_REC *win;
	GList *tmp;
	GSList *stmp;
	HV *hv;
#line 993 "Window.c"
#line 269 "Window.xs"
	rec = window == NULL ? NULL : command_history_current(window);
	for (tmp = command_history_list_first(rec); tmp != NULL; tmp = command_history_list_next(rec, tmp)) {
		hv = (HV*)sv_2mortal((SV*)newHV());
		ent = tmp->data;
		hv_store(hv, "text", 4, newSVpv(ent->text, 0), 0);
		hv_store(hv, "time", 4, newSViv(ent->time), 0);
		if (ent->history == command_history_current(NULL)) {
			hv_store(hv, "history", 7, newSV(0), 0);
			hv_store(hv, "window", 6, newSV(0), 0);
		} else {
			if (ent->history->name == NULL) {
				hv_store(hv, "history", 7, newSV(0), 0);
				for (stmp = windows; stmp != NULL; stmp = stmp->next) {
					win = stmp->data;
					if (win->history == ent->history) {
						hv_store(hv, "window", 6, newSViv(win->refnum), 0);
						break;
					}
				}
			} else {
				hv_store(hv, "history", 7, new_pv(ent->history->name), 0);
				hv_store(hv, "window", 6, newSV(0), 0);
			}
		}
		XPUSHs(sv_2mortal(newRV_inc((SV*)hv)));
	}
#line 1021 "Window.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Irssi__UI__Window_load_history_entries); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_load_history_entries)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "window, ...");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
#line 300 "Window.xs"
	HV *hv;
	SV **sv;
	HISTORY_REC *history;
	WINDOW_REC *tmp;
	const char *text;
	long hist_time;
	int i;
#line 1047 "Window.c"
#line 308 "Window.xs"
	for (i = 1; i < items; i++) {
		if (!is_hvref(ST(i))) {
			croak("Usage: Irssi::UI::Window::load_history_entries(window, hash...)");
		}
		hv = hvref(ST(i));
		if (hv != NULL) {
			tmp = NULL;
			text = NULL;
			hist_time = time(NULL);
			history = command_history_current(NULL);

			sv = hv_fetch(hv, "text", 4, 0);
			if (sv != NULL) text = SvPV_nolen(*sv);
			sv = hv_fetch(hv, "time", 4, 0);
			if (sv != NULL && SvOK(*sv)) hist_time = SvIV(*sv);

			if (window != NULL) {
				history = command_history_current(window);
			} else {
				sv = hv_fetch(hv, "history", 7, 0);
				if (sv != NULL && SvOK(*sv)) {
					history = command_history_find_name(SvPV_nolen(*sv));
				}

				sv = hv_fetch(hv, "window", 6, 0);
				if (sv != NULL && SvOK(*sv)) {
					tmp = window_find_refnum(SvIV(*sv));
					if (tmp != NULL) {
						history = tmp->history;
					}
				}
			}

			if (text != NULL && history != NULL) {
				command_history_load_entry(hist_time, history, text);
			}
		}
	}
#line 1087 "Window.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Irssi__UI__Window_delete_history_entries); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__UI__Window_delete_history_entries)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "window, ...");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	Irssi__UI__Window	window = irssi_ref_object(ST(0))
;
#line 351 "Window.xs"
	HV *hv;
	SV **sv;
	HISTORY_REC *history;
	WINDOW_REC *tmp;
	const char *text;
	long hist_time;
	int i;
#line 1113 "Window.c"
#line 359 "Window.xs"
	for (i = 1; i < items; i++) {
		if (!is_hvref(ST(i))) {
			croak("Usage: Irssi::UI::Window::delete_history_entries(window, hash...)");
		}
		hv = hvref(ST(i));
		if (hv != NULL) {
			tmp = NULL;
			text = NULL;
			hist_time = -1;
			history = command_history_current(NULL);

			sv = hv_fetch(hv, "text", 4, 0);
			if (sv != NULL) text = SvPV_nolen(*sv);
			sv = hv_fetch(hv, "time", 4, 0);
			if (sv != NULL && SvOK(*sv)) hist_time = SvIV(*sv);

			if (window != NULL) {
				history = command_history_current(window);
			} else {
				sv = hv_fetch(hv, "history", 7, 0);
				if (sv != NULL && SvOK(*sv)) {
					history = command_history_find_name(SvPV_nolen(*sv));
				}

				sv = hv_fetch(hv, "window", 6, 0);
				if (sv != NULL && SvOK(*sv)) {
					tmp = window_find_refnum(SvIV(*sv));
					if (tmp != NULL) {
						history = tmp->history;
					}
				}
			}

			if (text != NULL && history != NULL) {
				XPUSHs(boolSV(command_history_delete_entry(hist_time, history, text)));
			}
		}
	}
#line 1153 "Window.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Irssi__Windowitem_print); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Windowitem_print)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "item, str, level=MSGLEVEL_CLIENTNOTICE");
    {
	Irssi__Windowitem	item = irssi_ref_object(ST(0))
;
	int	level;
	char *	str = (char *)SvPV_nolen(ST(1))
;

	if (items < 3)
	    level = MSGLEVEL_CLIENTNOTICE;
	else {
	    level = (int)SvIV(ST(2))
;
	}
#line 408 "Window.xs"
	printtext_string(item->server, item->visible_name, level, str);
#line 1181 "Window.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__Windowitem_window_create); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Windowitem_window_create)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "item, automatic");
    {
	Irssi__Windowitem	item = irssi_ref_object(ST(0))
;
	int	automatic = (int)SvIV(ST(1))
;
	Irssi__UI__Window	RETVAL;

	RETVAL = window_create(item, automatic);
	{
	    SV * RETVALSV;
	    RETVALSV = plain_bless(RETVAL, "Irssi::UI::Window");
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi__Windowitem_window); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Windowitem_window)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "item");
    {
	Irssi__Windowitem	item = irssi_ref_object(ST(0))
;
	Irssi__UI__Window	RETVAL;
#line 419 "Window.xs"
	RETVAL = window_item_window(item);
#line 1224 "Window.c"
	{
	    SV * RETVALSV;
	    RETVALSV = plain_bless(RETVAL, "Irssi::UI::Window");
	    RETVALSV = sv_2mortal(RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi__Windowitem_change_server); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Windowitem_change_server)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "item, server");
    {
	Irssi__Windowitem	item = irssi_ref_object(ST(0))
;
	Irssi__Server	server = irssi_ref_object(ST(1))
;

	window_item_change_server(item, server);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__Windowitem_is_active); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Windowitem_is_active)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "item");
    {
	Irssi__Windowitem	item = irssi_ref_object(ST(0))
;
	int	RETVAL;
	dXSTARG;

	RETVAL = window_item_is_active(item);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Irssi__Windowitem_set_active); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Windowitem_set_active)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "item");
    {
	Irssi__Windowitem	item = irssi_ref_object(ST(0))
;
#line 436 "Window.xs"
	window_item_set_active(window_item_window(item), item);
#line 1284 "Window.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Irssi__Windowitem_activity); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Irssi__Windowitem_activity)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "item, data_level, hilight_color=NULL");
    {
	Irssi__Windowitem	item = irssi_ref_object(ST(0))
;
	int	data_level = (int)SvIV(ST(1))
;
	char *	hilight_color;

	if (items < 3)
	    hilight_color = NULL;
	else {
	    hilight_color = (char *)SvPV_nolen(ST(2))
;
	}

	window_item_activity(item, data_level, hilight_color);
    }
    XSRETURN_EMPTY;
}

#ifdef __cplusplus
extern "C"
#endif
XS_EXTERNAL(boot_Irssi__UI__Window); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_Irssi__UI__Window)
{
#if PERL_VERSION_LE(5, 21, 5)
    dVAR; dXSARGS;
#else
    dVAR; dXSBOOTARGSXSAPIVERCHK;
#endif
#if (PERL_REVISION == 5 && PERL_VERSION < 9)
    char* file = __FILE__;
#else
    const char* file = __FILE__;
#endif

    PERL_UNUSED_VAR(file);

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
#if PERL_VERSION_LE(5, 21, 5)
    XS_VERSION_BOOTCHECK;
#  ifdef XS_APIVERSION_BOOTCHECK
    XS_APIVERSION_BOOTCHECK;
#  endif
#endif

        (void)newXSproto_portable("Irssi::windows", XS_Irssi_windows, file, "");
        (void)newXSproto_portable("Irssi::active_win", XS_Irssi_active_win, file, "");
        (void)newXSproto_portable("Irssi::active_server", XS_Irssi_active_server, file, "");
        (void)newXSproto_portable("Irssi::print", XS_Irssi_print, file, "$;$");
        (void)newXSproto_portable("Irssi::window_find_name", XS_Irssi_window_find_name, file, "$");
        (void)newXSproto_portable("Irssi::window_find_refnum", XS_Irssi_window_find_refnum, file, "$");
        (void)newXSproto_portable("Irssi::window_refnum_prev", XS_Irssi_window_refnum_prev, file, "$$");
        (void)newXSproto_portable("Irssi::window_refnum_next", XS_Irssi_window_refnum_next, file, "$$");
        (void)newXSproto_portable("Irssi::windows_refnum_last", XS_Irssi_windows_refnum_last, file, "");
        (void)newXSproto_portable("Irssi::window_find_level", XS_Irssi_window_find_level, file, "$");
        (void)newXSproto_portable("Irssi::window_find_item", XS_Irssi_window_find_item, file, "$");
        (void)newXSproto_portable("Irssi::window_find_closest", XS_Irssi_window_find_closest, file, "$$");
        (void)newXSproto_portable("Irssi::window_item_find", XS_Irssi_window_item_find, file, "$");
        (void)newXSproto_portable("Irssi::Server::print", XS_Irssi__Server_print, file, "$$$;$");
        (void)newXSproto_portable("Irssi::Server::window_item_find", XS_Irssi__Server_window_item_find, file, "$$");
        (void)newXSproto_portable("Irssi::Server::window_find_item", XS_Irssi__Server_window_find_item, file, "$$");
        (void)newXSproto_portable("Irssi::Server::window_find_level", XS_Irssi__Server_window_find_level, file, "$$");
        (void)newXSproto_portable("Irssi::Server::window_find_closest", XS_Irssi__Server_window_find_closest, file, "$$$");
        (void)newXSproto_portable("Irssi::UI::Window::items", XS_Irssi__UI__Window_items, file, "$");
        (void)newXSproto_portable("Irssi::UI::Window::print", XS_Irssi__UI__Window_print, file, "$$;$");
        (void)newXSproto_portable("Irssi::UI::Window::command", XS_Irssi__UI__Window_command, file, "$$");
        (void)newXSproto_portable("Irssi::UI::Window::item_add", XS_Irssi__UI__Window_item_add, file, "$$$");
        (void)newXSproto_portable("Irssi::UI::Window::item_remove", XS_Irssi__UI__Window_item_remove, file, "$");
        (void)newXSproto_portable("Irssi::UI::Window::item_destroy", XS_Irssi__UI__Window_item_destroy, file, "$");
        (void)newXSproto_portable("Irssi::UI::Window::item_prev", XS_Irssi__UI__Window_item_prev, file, "$");
        (void)newXSproto_portable("Irssi::UI::Window::item_next", XS_Irssi__UI__Window_item_next, file, "$");
        (void)newXSproto_portable("Irssi::UI::Window::destroy", XS_Irssi__UI__Window_destroy, file, "$");
        (void)newXSproto_portable("Irssi::UI::Window::set_active", XS_Irssi__UI__Window_set_active, file, "$");
        (void)newXSproto_portable("Irssi::UI::Window::change_server", XS_Irssi__UI__Window_change_server, file, "$$");
        (void)newXSproto_portable("Irssi::UI::Window::set_refnum", XS_Irssi__UI__Window_set_refnum, file, "$$");
        (void)newXSproto_portable("Irssi::UI::Window::set_name", XS_Irssi__UI__Window_set_name, file, "$$");
        (void)newXSproto_portable("Irssi::UI::Window::set_history", XS_Irssi__UI__Window_set_history, file, "$$");
        (void)newXSproto_portable("Irssi::UI::Window::set_level", XS_Irssi__UI__Window_set_level, file, "$$");
        (void)newXSproto_portable("Irssi::UI::Window::activity", XS_Irssi__UI__Window_activity, file, "$$;$");
        (void)newXSproto_portable("Irssi::UI::Window::get_active_name", XS_Irssi__UI__Window_get_active_name, file, "$");
        (void)newXSproto_portable("Irssi::UI::Window::item_find", XS_Irssi__UI__Window_item_find, file, "$$$");
        (void)newXSproto_portable("Irssi::UI::Window::get_history_lines", XS_Irssi__UI__Window_get_history_lines, file, "$");
        (void)newXSproto_portable("Irssi::UI::Window::get_history_entries", XS_Irssi__UI__Window_get_history_entries, file, "$");
        (void)newXSproto_portable("Irssi::UI::Window::load_history_entries", XS_Irssi__UI__Window_load_history_entries, file, "$;@");
        (void)newXSproto_portable("Irssi::UI::Window::delete_history_entries", XS_Irssi__UI__Window_delete_history_entries, file, "$;@");
        (void)newXSproto_portable("Irssi::Windowitem::print", XS_Irssi__Windowitem_print, file, "$$;$");
        (void)newXSproto_portable("Irssi::Windowitem::window_create", XS_Irssi__Windowitem_window_create, file, "$$");
        (void)newXSproto_portable("Irssi::Windowitem::window", XS_Irssi__Windowitem_window, file, "$");
        (void)newXSproto_portable("Irssi::Windowitem::change_server", XS_Irssi__Windowitem_change_server, file, "$$");
        (void)newXSproto_portable("Irssi::Windowitem::is_active", XS_Irssi__Windowitem_is_active, file, "$");
        (void)newXSproto_portable("Irssi::Windowitem::set_active", XS_Irssi__Windowitem_set_active, file, "$");
        (void)newXSproto_portable("Irssi::Windowitem::activity", XS_Irssi__Windowitem_activity, file, "$$;$");
#if PERL_VERSION_LE(5, 21, 5)
#  if PERL_VERSION_GE(5, 9, 0)
    if (PL_unitcheckav)
        call_list(PL_scopestack_ix, PL_unitcheckav);
#  endif
    XSRETURN_YES;
#else
    Perl_xs_boot_epilog(aTHX_ ax);
#endif
}

