1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
/* functions.c generated by valac 0.19.0.4-d6d4, the Vala compiler
* generated from functions.vala, do not modify */
/* functions.vala
*
* Copyright (C) 2009 Didier Villevalois, Maciej Piechotka
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* 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
*
* Author:
* Didier 'Ptitjes' Villevalois <ptitjes@free.fr>
* Maciej Piechotka <uzytkownik2@gmail.com>
*/
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#define GEE_TYPE_COMPARABLE (gee_comparable_get_type ())
#define GEE_COMPARABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_COMPARABLE, GeeComparable))
#define GEE_IS_COMPARABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_COMPARABLE))
#define GEE_COMPARABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_COMPARABLE, GeeComparableIface))
typedef struct _GeeComparable GeeComparable;
typedef struct _GeeComparableIface GeeComparableIface;
struct _GeeComparableIface {
GTypeInterface parent_iface;
gint (*compare_to) (GeeComparable* self, gconstpointer object);
};
GEqualFunc gee_functions_get_equal_func_for (GType t);
GHashFunc gee_functions_get_hash_func_for (GType t);
GCompareFunc gee_functions_get_compare_func_for (GType t);
GType gee_comparable_get_type (void) G_GNUC_CONST;
gint gee_comparable_compare_to (GeeComparable* self, gconstpointer object);
gint gee_direct_compare (void* _val1, void* _val2);
/**
* Get a equality testing function for a given type.
*
* @param t the type which to get an equality testing function for.
*
* @return the equality testing function corresponding to the given type.
*/
GEqualFunc gee_functions_get_equal_func_for (GType t) {
GEqualFunc result = NULL;
GType _tmp0_;
_tmp0_ = t;
if (_tmp0_ == G_TYPE_STRING) {
GEqualFunc _tmp1_;
_tmp1_ = g_str_equal;
result = _tmp1_;
return result;
} else {
GEqualFunc _tmp2_;
_tmp2_ = g_direct_equal;
result = _tmp2_;
return result;
}
}
/**
* Get a hash function for a given type.
*
* @param t the type which to get the hash function for.
*
* @return the hash function corresponding to the given type.
*/
GHashFunc gee_functions_get_hash_func_for (GType t) {
GHashFunc result = NULL;
GType _tmp0_;
_tmp0_ = t;
if (_tmp0_ == G_TYPE_STRING) {
GHashFunc _tmp1_;
_tmp1_ = g_str_hash;
result = _tmp1_;
return result;
} else {
GHashFunc _tmp2_;
_tmp2_ = g_direct_hash;
result = _tmp2_;
return result;
}
}
/**
* Get a comparator function for a given type.
*
* @param t the type which to get a comparator function for.
*
* @return the comparator function corresponding to the given type.
*/
GCompareFunc gee_functions_get_compare_func_for (GType t) {
GCompareFunc result = NULL;
GType _tmp0_;
_tmp0_ = t;
if (_tmp0_ == G_TYPE_STRING) {
GCompareFunc _tmp1_;
_tmp1_ = g_strcmp0;
result = (GCompareFunc) _tmp1_;
return result;
} else {
GType _tmp2_;
gboolean _tmp3_ = FALSE;
_tmp2_ = t;
_tmp3_ = g_type_is_a (_tmp2_, GEE_TYPE_COMPARABLE);
if (_tmp3_) {
result = (GCompareFunc) gee_comparable_compare_to;
return result;
} else {
result = (GCompareFunc) gee_direct_compare;
return result;
}
}
}
/**
* Compares two arbitrary elements together.
*
* The comparison is done on pointers and not on values behind.
*
* @param _val1 the first value to compare.
* @param _val2 the second value to compare.
*
* @return a negative value if _val1 is lesser than _val2, a positive value
* if _val1 is greater then _val2 and zero if both are equal.
*/
gint gee_direct_compare (void* _val1, void* _val2) {
gint result = 0;
void* _tmp0_;
glong val1;
void* _tmp1_;
glong val2;
glong _tmp2_;
glong _tmp3_;
_tmp0_ = _val1;
val1 = (glong) _tmp0_;
_tmp1_ = _val2;
val2 = (glong) _tmp1_;
_tmp2_ = val1;
_tmp3_ = val2;
if (_tmp2_ > _tmp3_) {
result = 1;
return result;
} else {
glong _tmp4_;
glong _tmp5_;
_tmp4_ = val1;
_tmp5_ = val2;
if (_tmp4_ == _tmp5_) {
result = 0;
return result;
} else {
result = -1;
return result;
}
}
}
|