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

#line 1 "GUtils.xs"
/*
 * Copyright (C) 2004-2005 by the gtk2-perl team (see the file AUTHORS for a
 * complete list)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * $Id$
 */
#include "gperl.h"
#include "gperl-gtypes.h"

#if GLIB_CHECK_VERSION (2, 14, 0)

GUserDirectory
SvGUserDirectory (SV *sv)
{
	return gperl_convert_enum (GPERL_TYPE_USER_DIRECTORY, sv);
}

SV *
newSVGUserDirectory (GUserDirectory dir)
{
	return gperl_convert_back_enum (GPERL_TYPE_USER_DIRECTORY, dir);
}

#endif

#line 51 "GUtils.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 195 "GUtils.c"

XS_EUPXS(XS_Glib_get_user_name); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib_get_user_name)
{
    dVAR; dXSARGS;
    dXSI32;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {
	const gchar *	RETVAL;
#line 106 "GUtils.xs"
	switch (ix) {
	    case 0: RETVAL = g_get_user_name (); break;
	    case 1: RETVAL = g_get_real_name (); break;
	    case 2: RETVAL = g_get_home_dir ();  break;
	    case 3: RETVAL = g_get_tmp_dir ();   break;
	    default:
		RETVAL = NULL;
		g_assert_not_reached ();
	}
#line 216 "GUtils.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    /* same as newSVGChar(), but not in a function */
	    sv_setpv ((SV*)RETVALSV, RETVAL);
	    SvUTF8_on (RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#if GLIB_CHECK_VERSION (2, 6, 0)
#define XSubPPtmpAAAA 1


XS_EUPXS(XS_Glib_get_user_data_dir); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib_get_user_data_dir)
{
    dVAR; dXSARGS;
    dXSI32;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {
	const gchar *	RETVAL;
#line 140 "GUtils.xs"
	switch (ix) {
	    case 0: RETVAL = g_get_user_data_dir (); break;
	    case 1: RETVAL = g_get_user_config_dir (); break;
	    case 2: RETVAL = g_get_user_cache_dir (); break;
	    default:
		RETVAL = NULL;
		g_assert_not_reached ();
	}
#line 251 "GUtils.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    /* same as newSVGChar(), but not in a function */
	    sv_setpv ((SV*)RETVALSV, RETVAL);
	    SvUTF8_on (RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Glib_get_system_data_dirs); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib_get_system_data_dirs)
{
    dVAR; dXSARGS;
    dXSI32;
    if (items != 0)
       croak_xs_usage(cv,  "");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
#line 172 "GUtils.xs"
	const gchar * const * strings;
	int i;
#line 278 "GUtils.c"
#line 175 "GUtils.xs"
	switch (ix) {
	    case 0: strings = g_get_system_data_dirs ();   break;
	    case 1: strings = g_get_system_config_dirs (); break;
	    case 2: strings = g_get_language_names ();     break;
	    default:
		strings = NULL;
		g_assert_not_reached ();
	}

	for (i = 0; strings[i]; i++)
		XPUSHs (sv_2mortal (newSVGChar (strings[i])));
#line 291 "GUtils.c"
	PUTBACK;
	return;
    }
}

#endif
#if GLIB_CHECK_VERSION (2, 14, 0)
#define XSubPPtmpAAAB 1


XS_EUPXS(XS_Glib_get_user_special_dir); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib_get_user_special_dir)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "directory");
    {
	const gchar *	RETVAL;
	GUserDirectory	directory = SvGUserDirectory (ST(0))
;

	RETVAL = g_get_user_special_dir(directory);
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    /* same as newSVGChar(), but not in a function */
	    sv_setpv ((SV*)RETVALSV, RETVAL);
	    SvUTF8_on (RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif

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

	RETVAL = g_get_prgname();
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    /* same as newSVGChar(), but not in a function */
	    sv_setpv ((SV*)RETVALSV, RETVAL);
	    SvUTF8_on (RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Glib_set_prgname); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib_set_prgname)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "prgname");
    {
	const gchar *	prgname;

	/* same as SvGChar(), but not in a function */
	sv_utf8_upgrade (ST(0));
	prgname = (const gchar *)SvPV_nolen (ST(0))
;

	g_set_prgname(prgname);
    }
    XSRETURN_EMPTY;
}

#if GLIB_CHECK_VERSION(2, 2, 0)
#define XSubPPtmpAAAC 1


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

	RETVAL = g_get_application_name();
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    /* same as newSVGChar(), but not in a function */
	    sv_setpv ((SV*)RETVALSV, RETVAL);
	    SvUTF8_on (RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Glib_set_application_name); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib_set_application_name)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "application_name");
    {
	const gchar *	application_name;

	/* same as SvGChar(), but not in a function */
	sv_utf8_upgrade (ST(0));
	application_name = (const gchar *)SvPV_nolen (ST(0))
;

	g_set_application_name(application_name);
    }
    XSRETURN_EMPTY;
}

#endif

XS_EUPXS(XS_Glib_strerror); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib_strerror)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "err");
    {
	const gchar *	RETVAL;
	gint	err = (gint)SvIV(ST(0))
;

	RETVAL = g_strerror(err);
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    /* same as newSVGChar(), but not in a function */
	    sv_setpv ((SV*)RETVALSV, RETVAL);
	    SvUTF8_on (RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Glib_strsignal); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib_strsignal)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "signum");
    {
	const gchar *	RETVAL;
	gint	signum = (gint)SvIV(ST(0))
;

	RETVAL = g_strsignal(signum);
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    /* same as newSVGChar(), but not in a function */
	    sv_setpv ((SV*)RETVALSV, RETVAL);
	    SvUTF8_on (RETVALSV);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Glib_MAJOR_VERSION); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib_MAJOR_VERSION)
{
    dVAR; dXSARGS;
    dXSI32;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {
	guint	RETVAL;
	dXSTARG;
#line 425 "GUtils.xs"
	switch (ix)
	{
	case 0: RETVAL = GLIB_MAJOR_VERSION; break;
	case 1: RETVAL = GLIB_MINOR_VERSION; break;
	case 2: RETVAL = GLIB_MICRO_VERSION; break;
	case 3: RETVAL = glib_major_version; break;
	case 4: RETVAL = glib_minor_version; break;
	case 5: RETVAL = glib_micro_version; break;
	default:
		RETVAL = -1;
		g_assert_not_reached ();
	}
#line 491 "GUtils.c"
	XSprePUSH;
	PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Glib_GET_VERSION_INFO); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib_GET_VERSION_INFO)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "class");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
#line 448 "GUtils.xs"
	EXTEND (SP, 3);
	PUSHs (sv_2mortal (newSViv (GLIB_MAJOR_VERSION)));
	PUSHs (sv_2mortal (newSViv (GLIB_MINOR_VERSION)));
	PUSHs (sv_2mortal (newSViv (GLIB_MICRO_VERSION)));
	PERL_UNUSED_VAR (ax);
#line 514 "GUtils.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Glib_CHECK_VERSION); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib_CHECK_VERSION)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "class, required_major, required_minor, required_micro");
    {
	gboolean	RETVAL;
	guint	required_major = (guint)SvUV(ST(1))
;
	guint	required_minor = (guint)SvUV(ST(2))
;
	guint	required_micro = (guint)SvUV(ST(3))
;
#line 461 "GUtils.xs"
	RETVAL = GLIB_CHECK_VERSION (required_major, required_minor,
				    required_micro);
#line 538 "GUtils.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Glib__Markup_escape_text); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Glib__Markup_escape_text)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "text");
    {
	const gchar*	text;
	gchar_own *	RETVAL;

	/* same as SvGChar(), but not in a function */
	sv_utf8_upgrade (ST(0));
	text = (const gchar *)SvPV_nolen (ST(0))
;
#line 478 "GUtils.xs"
	RETVAL = g_markup_escape_text (text, strlen (text));
#line 561 "GUtils.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    /* used when we can directly own the returned string. */
	    /* we have to copy in the case when perl's malloc != gtk's malloc,
	     * so best copy all the time. */
	    sv_setpv ((SV*)RETVALSV, RETVAL);
	    SvUTF8_on (RETVALSV);
	    g_free (RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#ifdef __cplusplus
extern "C"
#endif
XS_EXTERNAL(boot_Glib__Utils); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_Glib__Utils)
{
#if PERL_VERSION_LE(5, 21, 5)
    dVAR; dXSARGS;
#else
    dVAR; dXSBOOTARGSXSAPIVERCHK;
#endif
#if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
    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

        cv = newXS_deffile("Glib::get_home_dir", XS_Glib_get_user_name);
        XSANY.any_i32 = 2;
        cv = newXS_deffile("Glib::get_real_name", XS_Glib_get_user_name);
        XSANY.any_i32 = 1;
        cv = newXS_deffile("Glib::get_tmp_dir", XS_Glib_get_user_name);
        XSANY.any_i32 = 3;
        cv = newXS_deffile("Glib::get_user_name", XS_Glib_get_user_name);
        XSANY.any_i32 = 0;
#if XSubPPtmpAAAA
        cv = newXS_deffile("Glib::get_user_cache_dir", XS_Glib_get_user_data_dir);
        XSANY.any_i32 = 2;
        cv = newXS_deffile("Glib::get_user_config_dir", XS_Glib_get_user_data_dir);
        XSANY.any_i32 = 1;
        cv = newXS_deffile("Glib::get_user_data_dir", XS_Glib_get_user_data_dir);
        XSANY.any_i32 = 0;
        cv = newXS_deffile("Glib::get_language_names", XS_Glib_get_system_data_dirs);
        XSANY.any_i32 = 2;
        cv = newXS_deffile("Glib::get_system_config_dirs", XS_Glib_get_system_data_dirs);
        XSANY.any_i32 = 1;
        cv = newXS_deffile("Glib::get_system_data_dirs", XS_Glib_get_system_data_dirs);
        XSANY.any_i32 = 0;
#endif
#if XSubPPtmpAAAB
        newXS_deffile("Glib::get_user_special_dir", XS_Glib_get_user_special_dir);
#endif
        newXS_deffile("Glib::get_prgname", XS_Glib_get_prgname);
        newXS_deffile("Glib::set_prgname", XS_Glib_set_prgname);
#if XSubPPtmpAAAC
        newXS_deffile("Glib::get_application_name", XS_Glib_get_application_name);
        newXS_deffile("Glib::set_application_name", XS_Glib_set_application_name);
#endif
        newXS_deffile("Glib::strerror", XS_Glib_strerror);
        newXS_deffile("Glib::strsignal", XS_Glib_strsignal);
        cv = newXS_deffile("Glib::MAJOR_VERSION", XS_Glib_MAJOR_VERSION);
        XSANY.any_i32 = 0;
        cv = newXS_deffile("Glib::MICRO_VERSION", XS_Glib_MAJOR_VERSION);
        XSANY.any_i32 = 2;
        cv = newXS_deffile("Glib::MINOR_VERSION", XS_Glib_MAJOR_VERSION);
        XSANY.any_i32 = 1;
        cv = newXS_deffile("Glib::major_version", XS_Glib_MAJOR_VERSION);
        XSANY.any_i32 = 3;
        cv = newXS_deffile("Glib::micro_version", XS_Glib_MAJOR_VERSION);
        XSANY.any_i32 = 5;
        cv = newXS_deffile("Glib::minor_version", XS_Glib_MAJOR_VERSION);
        XSANY.any_i32 = 4;
        newXS_deffile("Glib::GET_VERSION_INFO", XS_Glib_GET_VERSION_INFO);
        newXS_deffile("Glib::CHECK_VERSION", XS_Glib_CHECK_VERSION);
        newXS_deffile("Glib::Markup::escape_text", XS_Glib__Markup_escape_text);

    /* Initialisation Section */

#line 44 "GUtils.xs"
#if GLIB_CHECK_VERSION (2, 14, 0)
	gperl_register_fundamental (GPERL_TYPE_USER_DIRECTORY,
	                            "Glib::UserDirectory");
#endif

#if XSubPPtmpAAAA
#endif
#if XSubPPtmpAAAB
#endif
#if XSubPPtmpAAAC
#endif
#line 668 "GUtils.c"

    /* End of Initialisation Section */

#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
}

