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

/*
 * Copyright 2016 Megh Parikh
 *
 * This file is part of LibGamepad.
 *
 * LibGamepad 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 3 of the License, or
 * (at your option) any later version.
 *
 * LibGamepad 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <stdlib.h>
#include <string.h>

#define LIB_GAMEPAD_GUID_LENGTH 8
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

VALA_EXTERN gchar* lib_gamepad_uint16s_to_hex_string (guint16* data,
                                          gint data_length1);

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
#line 1283 "glib-2.0.vapi"
	g_return_val_if_fail (self != NULL, '\0');
#line 1284 "glib-2.0.vapi"
	_tmp0_ = ((gchar*) self)[index];
#line 1284 "glib-2.0.vapi"
	result = _tmp0_;
#line 1284 "glib-2.0.vapi"
	return result;
#line 70 "helpers.c"
}

gchar*
lib_gamepad_uint16s_to_hex_string (guint16* data,
                                   gint data_length1)
{
#line 26 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
	static const char k_rgchHexToASCII[] = "0123456789abcdef";
#line 79 "helpers.c"
	GString* builder = NULL;
	GString* _tmp0_;
	GString* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* result;
#line 23 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
	_vala_return_val_if_fail (data_length1 == LIB_GAMEPAD_GUID_LENGTH, "data.length == GUID_LENGTH", NULL);
#line 28 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
	_tmp0_ = g_string_new ("");
#line 28 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
	builder = _tmp0_;
#line 92 "helpers.c"
	{
		gint i = 0;
#line 29 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
		i = 0;
#line 97 "helpers.c"
		{
			gboolean _tmp1_ = FALSE;
#line 29 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
			_tmp1_ = TRUE;
#line 29 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
			while (TRUE) {
#line 104 "helpers.c"
				guint8 c = 0U;
				guint16 _tmp3_;
				GString* _tmp4_;
				GString* _tmp5_;
				guint16 _tmp6_;
				GString* _tmp7_;
				GString* _tmp8_;
#line 29 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				if (!_tmp1_) {
#line 114 "helpers.c"
					gint _tmp2_;
#line 29 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
					_tmp2_ = i;
#line 29 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
					i = _tmp2_ + 1;
#line 120 "helpers.c"
				}
#line 29 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				_tmp1_ = FALSE;
#line 29 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				if (!(i < LIB_GAMEPAD_GUID_LENGTH)) {
#line 29 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
					break;
#line 128 "helpers.c"
				}
#line 30 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				_tmp3_ = data[i];
#line 30 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				c = (guint8) _tmp3_;
#line 31 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				_tmp4_ = builder;
#line 31 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				g_string_append_unichar (_tmp4_, (gunichar) string_get (k_rgchHexToASCII, (glong) (c >> 4)));
#line 32 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				_tmp5_ = builder;
#line 32 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				g_string_append_unichar (_tmp5_, (gunichar) string_get (k_rgchHexToASCII, (glong) (c & 0x0F)));
#line 34 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				_tmp6_ = data[i];
#line 34 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				c = (guint8) (_tmp6_ >> 8);
#line 35 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				_tmp7_ = builder;
#line 35 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				g_string_append_unichar (_tmp7_, (gunichar) string_get (k_rgchHexToASCII, (glong) (c >> 4)));
#line 36 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				_tmp8_ = builder;
#line 36 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
				g_string_append_unichar (_tmp8_, (gunichar) string_get (k_rgchHexToASCII, (glong) (c & 0x0F)));
#line 154 "helpers.c"
			}
		}
	}
#line 38 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
	_tmp9_ = builder;
#line 38 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
	_tmp10_ = _tmp9_->str;
#line 38 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
	_tmp11_ = g_strdup (_tmp10_);
#line 38 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
	result = _tmp11_;
#line 38 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
	_g_string_free0 (builder);
#line 38 "../Spice-up-1.9.1/src/Services/libgamepad/helpers.vala"
	return result;
#line 170 "helpers.c"
}

