mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 07:26:15 +01:00
made config arg to g_scanner_new() const.
Fri Mar 9 18:01:43 2001 Tim Janik <timj@gtk.org> * gscanner.[hc]: made config arg to g_scanner_new() const. Fri Mar 9 16:42:08 2001 Tim Janik <timj@gtk.org> * gvaluetypes.[hc]: moved g_strdup_value_contents() into this file as a public function (was static in gobject.c before). it's a bit odd to have that function here, especially since it requires extra includes, but then it doesn't very well fit somewhere else either. * gparamspecs.c: added default/max/min checks to param spec creation functions.
This commit is contained in:
parent
096ba91bdc
commit
009942e1ac
@ -1,3 +1,7 @@
|
|||||||
|
Fri Mar 9 18:01:43 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gscanner.[hc]: made config arg to g_scanner_new() const.
|
||||||
|
|
||||||
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
Fri Mar 9 18:01:43 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gscanner.[hc]: made config arg to g_scanner_new() const.
|
||||||
|
|
||||||
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
Fri Mar 9 18:01:43 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gscanner.[hc]: made config arg to g_scanner_new() const.
|
||||||
|
|
||||||
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
Fri Mar 9 18:01:43 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gscanner.[hc]: made config arg to g_scanner_new() const.
|
||||||
|
|
||||||
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
Fri Mar 9 18:01:43 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gscanner.[hc]: made config arg to g_scanner_new() const.
|
||||||
|
|
||||||
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
Fri Mar 9 18:01:43 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gscanner.[hc]: made config arg to g_scanner_new() const.
|
||||||
|
|
||||||
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
Fri Mar 9 18:01:43 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gscanner.[hc]: made config arg to g_scanner_new() const.
|
||||||
|
|
||||||
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
Fri Mar 9 18:01:43 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gscanner.[hc]: made config arg to g_scanner_new() const.
|
||||||
|
|
||||||
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
2001-03-12 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
||||||
|
@ -171,7 +171,7 @@ g_scanner_char_2_num (guchar c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GScanner*
|
GScanner*
|
||||||
g_scanner_new (GScannerConfig *config_templ)
|
g_scanner_new (const GScannerConfig *config_templ)
|
||||||
{
|
{
|
||||||
GScanner *scanner;
|
GScanner *scanner;
|
||||||
|
|
||||||
@ -188,33 +188,33 @@ g_scanner_new (GScannerConfig *config_templ)
|
|||||||
|
|
||||||
scanner->config = g_new0 (GScannerConfig, 1);
|
scanner->config = g_new0 (GScannerConfig, 1);
|
||||||
|
|
||||||
scanner->config->case_sensitive = config_templ->case_sensitive;
|
scanner->config->case_sensitive = config_templ->case_sensitive;
|
||||||
scanner->config->cset_skip_characters = config_templ->cset_skip_characters;
|
scanner->config->cset_skip_characters = config_templ->cset_skip_characters;
|
||||||
if (!scanner->config->cset_skip_characters)
|
if (!scanner->config->cset_skip_characters)
|
||||||
scanner->config->cset_skip_characters = "";
|
scanner->config->cset_skip_characters = "";
|
||||||
scanner->config->cset_identifier_first= config_templ->cset_identifier_first;
|
scanner->config->cset_identifier_first = config_templ->cset_identifier_first;
|
||||||
scanner->config->cset_identifier_nth = config_templ->cset_identifier_nth;
|
scanner->config->cset_identifier_nth = config_templ->cset_identifier_nth;
|
||||||
scanner->config->cpair_comment_single = config_templ->cpair_comment_single;
|
scanner->config->cpair_comment_single = config_templ->cpair_comment_single;
|
||||||
scanner->config->skip_comment_multi = config_templ->skip_comment_multi;
|
scanner->config->skip_comment_multi = config_templ->skip_comment_multi;
|
||||||
scanner->config->skip_comment_single = config_templ->skip_comment_single;
|
scanner->config->skip_comment_single = config_templ->skip_comment_single;
|
||||||
scanner->config->scan_comment_multi = config_templ->scan_comment_multi;
|
scanner->config->scan_comment_multi = config_templ->scan_comment_multi;
|
||||||
scanner->config->scan_identifier = config_templ->scan_identifier;
|
scanner->config->scan_identifier = config_templ->scan_identifier;
|
||||||
scanner->config->scan_identifier_1char= config_templ->scan_identifier_1char;
|
scanner->config->scan_identifier_1char = config_templ->scan_identifier_1char;
|
||||||
scanner->config->scan_identifier_NULL = config_templ->scan_identifier_NULL;
|
scanner->config->scan_identifier_NULL = config_templ->scan_identifier_NULL;
|
||||||
scanner->config->scan_symbols = config_templ->scan_symbols;
|
scanner->config->scan_symbols = config_templ->scan_symbols;
|
||||||
scanner->config->scan_binary = config_templ->scan_binary;
|
scanner->config->scan_binary = config_templ->scan_binary;
|
||||||
scanner->config->scan_octal = config_templ->scan_octal;
|
scanner->config->scan_octal = config_templ->scan_octal;
|
||||||
scanner->config->scan_float = config_templ->scan_float;
|
scanner->config->scan_float = config_templ->scan_float;
|
||||||
scanner->config->scan_hex = config_templ->scan_hex;
|
scanner->config->scan_hex = config_templ->scan_hex;
|
||||||
scanner->config->scan_hex_dollar = config_templ->scan_hex_dollar;
|
scanner->config->scan_hex_dollar = config_templ->scan_hex_dollar;
|
||||||
scanner->config->scan_string_sq = config_templ->scan_string_sq;
|
scanner->config->scan_string_sq = config_templ->scan_string_sq;
|
||||||
scanner->config->scan_string_dq = config_templ->scan_string_dq;
|
scanner->config->scan_string_dq = config_templ->scan_string_dq;
|
||||||
scanner->config->numbers_2_int = config_templ->numbers_2_int;
|
scanner->config->numbers_2_int = config_templ->numbers_2_int;
|
||||||
scanner->config->int_2_float = config_templ->int_2_float;
|
scanner->config->int_2_float = config_templ->int_2_float;
|
||||||
scanner->config->identifier_2_string = config_templ->identifier_2_string;
|
scanner->config->identifier_2_string = config_templ->identifier_2_string;
|
||||||
scanner->config->char_2_token = config_templ->char_2_token;
|
scanner->config->char_2_token = config_templ->char_2_token;
|
||||||
scanner->config->symbol_2_token = config_templ->symbol_2_token;
|
scanner->config->symbol_2_token = config_templ->symbol_2_token;
|
||||||
scanner->config->scope_0_fallback = config_templ->scope_0_fallback;
|
scanner->config->scope_0_fallback = config_templ->scope_0_fallback;
|
||||||
|
|
||||||
scanner->token = G_TOKEN_NONE;
|
scanner->token = G_TOKEN_NONE;
|
||||||
scanner->value.v_int = 0;
|
scanner->value.v_int = 0;
|
||||||
|
@ -198,7 +198,7 @@ struct _GScanner
|
|||||||
GScannerMsgFunc msg_handler;
|
GScannerMsgFunc msg_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
GScanner* g_scanner_new (GScannerConfig *config_templ);
|
GScanner* g_scanner_new (const GScannerConfig *config_templ);
|
||||||
void g_scanner_destroy (GScanner *scanner);
|
void g_scanner_destroy (GScanner *scanner);
|
||||||
void g_scanner_input_file (GScanner *scanner,
|
void g_scanner_input_file (GScanner *scanner,
|
||||||
gint input_fd);
|
gint input_fd);
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
Fri Mar 9 16:42:08 2001 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gvaluetypes.[hc]: moved g_strdup_value_contents() into this file as
|
||||||
|
a public function (was static in gobject.c before). it's a bit odd
|
||||||
|
to have that function here, especially since it requires extra includes,
|
||||||
|
but then it doesn't very well fit somewhere else either.
|
||||||
|
|
||||||
|
* gparamspecs.c: added default/max/min checks to param spec creation
|
||||||
|
functions.
|
||||||
|
|
||||||
2001-03-10 Tor Lillqvist <tml@iki.fi>
|
2001-03-10 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gobject.def: Add a couple of missing entries.
|
* gobject.def: Add a couple of missing entries.
|
||||||
|
@ -641,67 +641,6 @@ object_get_property (GObject *object,
|
|||||||
class->get_property (object, PARAM_SPEC_PARAM_ID (pspec), value, pspec);
|
class->get_property (object, PARAM_SPEC_PARAM_ID (pspec), value, pspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar*
|
|
||||||
g_strdup_value_contents (const GValue *value)
|
|
||||||
{
|
|
||||||
const gchar *src;
|
|
||||||
gchar *contents;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_VALUE (value), NULL);
|
|
||||||
|
|
||||||
if (G_VALUE_HOLDS_STRING (value))
|
|
||||||
{
|
|
||||||
src = g_value_get_string (value);
|
|
||||||
|
|
||||||
if (!src)
|
|
||||||
contents = g_strdup ("NULL");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gchar *s = g_strescape (src, NULL);
|
|
||||||
|
|
||||||
contents = g_strdup_printf ("\"%s\"", s);
|
|
||||||
g_free (s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (g_value_type_transformable (G_VALUE_TYPE (value), G_TYPE_STRING))
|
|
||||||
{
|
|
||||||
GValue tmp_value = { 0, };
|
|
||||||
|
|
||||||
g_value_init (&tmp_value, G_TYPE_STRING);
|
|
||||||
g_value_transform (value, &tmp_value);
|
|
||||||
if (G_VALUE_HOLDS_ENUM (value) || G_VALUE_HOLDS_FLAGS (value))
|
|
||||||
contents = g_strdup_printf ("((%s) %s)",
|
|
||||||
g_type_name (G_VALUE_TYPE (value)),
|
|
||||||
g_value_get_string (&tmp_value));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
src = g_value_get_string (&tmp_value);
|
|
||||||
contents = g_strdup (src ? src : "NULL");
|
|
||||||
}
|
|
||||||
g_value_unset (&tmp_value);
|
|
||||||
}
|
|
||||||
else if (g_value_fits_pointer (value))
|
|
||||||
{
|
|
||||||
gpointer p = g_value_peek_pointer (value);
|
|
||||||
|
|
||||||
if (!p)
|
|
||||||
contents = g_strdup ("NULL");
|
|
||||||
else if (G_VALUE_HOLDS_OBJECT (value))
|
|
||||||
contents = g_strdup_printf ("((%s*) %p)", G_OBJECT_TYPE_NAME (p), p);
|
|
||||||
else if (G_VALUE_HOLDS_PARAM (value))
|
|
||||||
contents = g_strdup_printf ("((%s*) %p)", G_PARAM_SPEC_TYPE_NAME (p), p);
|
|
||||||
else if (G_VALUE_HOLDS_BOXED (value))
|
|
||||||
contents = g_strdup_printf ("((%s*) %p)", g_type_name (G_VALUE_TYPE (value)), p);
|
|
||||||
else if (G_VALUE_HOLDS_POINTER (value))
|
|
||||||
contents = g_strdup_printf ("((gpointer) %p)", p);
|
|
||||||
else
|
|
||||||
contents = g_strdup ("???");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
contents = g_strdup ("???");
|
|
||||||
return contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
object_set_property (GObject *object,
|
object_set_property (GObject *object,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
|
@ -1199,11 +1199,15 @@ g_param_spec_char (const gchar *name,
|
|||||||
gint8 default_value,
|
gint8 default_value,
|
||||||
GParamFlags flags)
|
GParamFlags flags)
|
||||||
{
|
{
|
||||||
GParamSpecChar *cspec = g_param_spec_internal (G_TYPE_PARAM_CHAR,
|
GParamSpecChar *cspec;
|
||||||
name,
|
|
||||||
nick,
|
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||||
blurb,
|
|
||||||
flags);
|
cspec = g_param_spec_internal (G_TYPE_PARAM_CHAR,
|
||||||
|
name,
|
||||||
|
nick,
|
||||||
|
blurb,
|
||||||
|
flags);
|
||||||
|
|
||||||
cspec->minimum = minimum;
|
cspec->minimum = minimum;
|
||||||
cspec->maximum = maximum;
|
cspec->maximum = maximum;
|
||||||
@ -1221,11 +1225,15 @@ g_param_spec_uchar (const gchar *name,
|
|||||||
guint8 default_value,
|
guint8 default_value,
|
||||||
GParamFlags flags)
|
GParamFlags flags)
|
||||||
{
|
{
|
||||||
GParamSpecUChar *uspec = g_param_spec_internal (G_TYPE_PARAM_UCHAR,
|
GParamSpecUChar *uspec;
|
||||||
name,
|
|
||||||
nick,
|
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||||
blurb,
|
|
||||||
flags);
|
uspec = g_param_spec_internal (G_TYPE_PARAM_UCHAR,
|
||||||
|
name,
|
||||||
|
nick,
|
||||||
|
blurb,
|
||||||
|
flags);
|
||||||
|
|
||||||
uspec->minimum = minimum;
|
uspec->minimum = minimum;
|
||||||
uspec->maximum = maximum;
|
uspec->maximum = maximum;
|
||||||
@ -1241,11 +1249,15 @@ g_param_spec_boolean (const gchar *name,
|
|||||||
gboolean default_value,
|
gboolean default_value,
|
||||||
GParamFlags flags)
|
GParamFlags flags)
|
||||||
{
|
{
|
||||||
GParamSpecBoolean *bspec = g_param_spec_internal (G_TYPE_PARAM_BOOLEAN,
|
GParamSpecBoolean *bspec;
|
||||||
name,
|
|
||||||
nick,
|
g_return_val_if_fail (default_value == TRUE || default_value == FALSE, NULL);
|
||||||
blurb,
|
|
||||||
flags);
|
bspec = g_param_spec_internal (G_TYPE_PARAM_BOOLEAN,
|
||||||
|
name,
|
||||||
|
nick,
|
||||||
|
blurb,
|
||||||
|
flags);
|
||||||
|
|
||||||
bspec->default_value = default_value;
|
bspec->default_value = default_value;
|
||||||
|
|
||||||
@ -1261,11 +1273,15 @@ g_param_spec_int (const gchar *name,
|
|||||||
gint default_value,
|
gint default_value,
|
||||||
GParamFlags flags)
|
GParamFlags flags)
|
||||||
{
|
{
|
||||||
GParamSpecInt *ispec = g_param_spec_internal (G_TYPE_PARAM_INT,
|
GParamSpecInt *ispec;
|
||||||
name,
|
|
||||||
nick,
|
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||||
blurb,
|
|
||||||
flags);
|
ispec = g_param_spec_internal (G_TYPE_PARAM_INT,
|
||||||
|
name,
|
||||||
|
nick,
|
||||||
|
blurb,
|
||||||
|
flags);
|
||||||
|
|
||||||
ispec->minimum = minimum;
|
ispec->minimum = minimum;
|
||||||
ispec->maximum = maximum;
|
ispec->maximum = maximum;
|
||||||
@ -1283,11 +1299,15 @@ g_param_spec_uint (const gchar *name,
|
|||||||
guint default_value,
|
guint default_value,
|
||||||
GParamFlags flags)
|
GParamFlags flags)
|
||||||
{
|
{
|
||||||
GParamSpecUInt *uspec = g_param_spec_internal (G_TYPE_PARAM_UINT,
|
GParamSpecUInt *uspec;
|
||||||
name,
|
|
||||||
nick,
|
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||||
blurb,
|
|
||||||
flags);
|
uspec = g_param_spec_internal (G_TYPE_PARAM_UINT,
|
||||||
|
name,
|
||||||
|
nick,
|
||||||
|
blurb,
|
||||||
|
flags);
|
||||||
|
|
||||||
uspec->minimum = minimum;
|
uspec->minimum = minimum;
|
||||||
uspec->maximum = maximum;
|
uspec->maximum = maximum;
|
||||||
@ -1305,11 +1325,15 @@ g_param_spec_long (const gchar *name,
|
|||||||
glong default_value,
|
glong default_value,
|
||||||
GParamFlags flags)
|
GParamFlags flags)
|
||||||
{
|
{
|
||||||
GParamSpecLong *lspec = g_param_spec_internal (G_TYPE_PARAM_LONG,
|
GParamSpecLong *lspec;
|
||||||
name,
|
|
||||||
nick,
|
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||||
blurb,
|
|
||||||
flags);
|
lspec = g_param_spec_internal (G_TYPE_PARAM_LONG,
|
||||||
|
name,
|
||||||
|
nick,
|
||||||
|
blurb,
|
||||||
|
flags);
|
||||||
|
|
||||||
lspec->minimum = minimum;
|
lspec->minimum = minimum;
|
||||||
lspec->maximum = maximum;
|
lspec->maximum = maximum;
|
||||||
@ -1327,11 +1351,15 @@ g_param_spec_ulong (const gchar *name,
|
|||||||
gulong default_value,
|
gulong default_value,
|
||||||
GParamFlags flags)
|
GParamFlags flags)
|
||||||
{
|
{
|
||||||
GParamSpecULong *uspec = g_param_spec_internal (G_TYPE_PARAM_ULONG,
|
GParamSpecULong *uspec;
|
||||||
name,
|
|
||||||
nick,
|
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||||
blurb,
|
|
||||||
flags);
|
uspec = g_param_spec_internal (G_TYPE_PARAM_ULONG,
|
||||||
|
name,
|
||||||
|
nick,
|
||||||
|
blurb,
|
||||||
|
flags);
|
||||||
|
|
||||||
uspec->minimum = minimum;
|
uspec->minimum = minimum;
|
||||||
uspec->maximum = maximum;
|
uspec->maximum = maximum;
|
||||||
@ -1349,16 +1377,21 @@ g_param_spec_enum (const gchar *name,
|
|||||||
GParamFlags flags)
|
GParamFlags flags)
|
||||||
{
|
{
|
||||||
GParamSpecEnum *espec;
|
GParamSpecEnum *espec;
|
||||||
|
GEnumClass *enum_class;
|
||||||
|
|
||||||
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
|
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
|
||||||
|
|
||||||
|
enum_class = g_type_class_ref (enum_type);
|
||||||
|
|
||||||
|
g_return_val_if_fail (g_enum_get_value (enum_class, default_value) != NULL, NULL);
|
||||||
|
|
||||||
espec = g_param_spec_internal (G_TYPE_PARAM_ENUM,
|
espec = g_param_spec_internal (G_TYPE_PARAM_ENUM,
|
||||||
name,
|
name,
|
||||||
nick,
|
nick,
|
||||||
blurb,
|
blurb,
|
||||||
flags);
|
flags);
|
||||||
|
|
||||||
espec->enum_class = g_type_class_ref (enum_type);
|
espec->enum_class = enum_class;
|
||||||
espec->default_value = default_value;
|
espec->default_value = default_value;
|
||||||
G_PARAM_SPEC (espec)->value_type = enum_type;
|
G_PARAM_SPEC (espec)->value_type = enum_type;
|
||||||
|
|
||||||
@ -1374,16 +1407,21 @@ g_param_spec_flags (const gchar *name,
|
|||||||
GParamFlags flags)
|
GParamFlags flags)
|
||||||
{
|
{
|
||||||
GParamSpecFlags *fspec;
|
GParamSpecFlags *fspec;
|
||||||
|
GFlagsClass *flags_class;
|
||||||
|
|
||||||
g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL);
|
g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL);
|
||||||
|
|
||||||
|
flags_class = g_type_class_ref (flags_type);
|
||||||
|
|
||||||
|
g_return_val_if_fail ((default_value & flags_class->mask) == default_value, NULL);
|
||||||
|
|
||||||
fspec = g_param_spec_internal (G_TYPE_PARAM_FLAGS,
|
fspec = g_param_spec_internal (G_TYPE_PARAM_FLAGS,
|
||||||
name,
|
name,
|
||||||
nick,
|
nick,
|
||||||
blurb,
|
blurb,
|
||||||
flags);
|
flags);
|
||||||
|
|
||||||
fspec->flags_class = g_type_class_ref (flags_type);
|
fspec->flags_class = flags_class;
|
||||||
fspec->default_value = default_value;
|
fspec->default_value = default_value;
|
||||||
G_PARAM_SPEC (fspec)->value_type = flags_type;
|
G_PARAM_SPEC (fspec)->value_type = flags_type;
|
||||||
|
|
||||||
@ -1399,11 +1437,15 @@ g_param_spec_float (const gchar *name,
|
|||||||
gfloat default_value,
|
gfloat default_value,
|
||||||
GParamFlags flags)
|
GParamFlags flags)
|
||||||
{
|
{
|
||||||
GParamSpecFloat *fspec = g_param_spec_internal (G_TYPE_PARAM_FLOAT,
|
GParamSpecFloat *fspec;
|
||||||
name,
|
|
||||||
nick,
|
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||||
blurb,
|
|
||||||
flags);
|
fspec = g_param_spec_internal (G_TYPE_PARAM_FLOAT,
|
||||||
|
name,
|
||||||
|
nick,
|
||||||
|
blurb,
|
||||||
|
flags);
|
||||||
|
|
||||||
fspec->minimum = minimum;
|
fspec->minimum = minimum;
|
||||||
fspec->maximum = maximum;
|
fspec->maximum = maximum;
|
||||||
@ -1421,11 +1463,15 @@ g_param_spec_double (const gchar *name,
|
|||||||
gdouble default_value,
|
gdouble default_value,
|
||||||
GParamFlags flags)
|
GParamFlags flags)
|
||||||
{
|
{
|
||||||
GParamSpecDouble *dspec = g_param_spec_internal (G_TYPE_PARAM_DOUBLE,
|
GParamSpecDouble *dspec;
|
||||||
name,
|
|
||||||
nick,
|
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||||
blurb,
|
|
||||||
flags);
|
dspec = g_param_spec_internal (G_TYPE_PARAM_DOUBLE,
|
||||||
|
name,
|
||||||
|
nick,
|
||||||
|
blurb,
|
||||||
|
flags);
|
||||||
|
|
||||||
dspec->minimum = minimum;
|
dspec->minimum = minimum;
|
||||||
dspec->maximum = maximum;
|
dspec->maximum = maximum;
|
||||||
@ -1508,7 +1554,7 @@ g_param_spec_boxed (const gchar *name,
|
|||||||
GParamSpecBoxed *bspec;
|
GParamSpecBoxed *bspec;
|
||||||
|
|
||||||
g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL);
|
g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL);
|
||||||
g_return_val_if_fail (G_TYPE_IS_DERIVED (boxed_type), NULL);
|
g_return_val_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type), NULL);
|
||||||
|
|
||||||
bspec = g_param_spec_internal (G_TYPE_PARAM_BOXED,
|
bspec = g_param_spec_internal (G_TYPE_PARAM_BOXED,
|
||||||
name,
|
name,
|
||||||
|
@ -710,3 +710,72 @@ g_value_get_pointer (const GValue *value)
|
|||||||
|
|
||||||
return value->data[0].v_pointer;
|
return value->data[0].v_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* need extra includes for g_strdup_value_contents() ;( */
|
||||||
|
#include "gobject.h"
|
||||||
|
#include "gparam.h"
|
||||||
|
#include "gboxed.h"
|
||||||
|
#include "genums.h"
|
||||||
|
|
||||||
|
gchar*
|
||||||
|
g_strdup_value_contents (const GValue *value)
|
||||||
|
{
|
||||||
|
const gchar *src;
|
||||||
|
gchar *contents;
|
||||||
|
|
||||||
|
g_return_val_if_fail (G_IS_VALUE (value), NULL);
|
||||||
|
|
||||||
|
if (G_VALUE_HOLDS_STRING (value))
|
||||||
|
{
|
||||||
|
src = g_value_get_string (value);
|
||||||
|
|
||||||
|
if (!src)
|
||||||
|
contents = g_strdup ("NULL");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gchar *s = g_strescape (src, NULL);
|
||||||
|
|
||||||
|
contents = g_strdup_printf ("\"%s\"", s);
|
||||||
|
g_free (s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (g_value_type_transformable (G_VALUE_TYPE (value), G_TYPE_STRING))
|
||||||
|
{
|
||||||
|
GValue tmp_value = { 0, };
|
||||||
|
|
||||||
|
g_value_init (&tmp_value, G_TYPE_STRING);
|
||||||
|
g_value_transform (value, &tmp_value);
|
||||||
|
if (G_VALUE_HOLDS_ENUM (value) || G_VALUE_HOLDS_FLAGS (value))
|
||||||
|
contents = g_strdup_printf ("((%s) %s)",
|
||||||
|
g_type_name (G_VALUE_TYPE (value)),
|
||||||
|
g_value_get_string (&tmp_value));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
src = g_value_get_string (&tmp_value);
|
||||||
|
contents = g_strdup (src ? src : "NULL");
|
||||||
|
}
|
||||||
|
g_value_unset (&tmp_value);
|
||||||
|
}
|
||||||
|
else if (g_value_fits_pointer (value))
|
||||||
|
{
|
||||||
|
gpointer p = g_value_peek_pointer (value);
|
||||||
|
|
||||||
|
if (!p)
|
||||||
|
contents = g_strdup ("NULL");
|
||||||
|
else if (G_VALUE_HOLDS_OBJECT (value))
|
||||||
|
contents = g_strdup_printf ("((%s*) %p)", G_OBJECT_TYPE_NAME (p), p);
|
||||||
|
else if (G_VALUE_HOLDS_PARAM (value))
|
||||||
|
contents = g_strdup_printf ("((%s*) %p)", G_PARAM_SPEC_TYPE_NAME (p), p);
|
||||||
|
else if (G_VALUE_HOLDS_BOXED (value))
|
||||||
|
contents = g_strdup_printf ("((%s*) %p)", g_type_name (G_VALUE_TYPE (value)), p);
|
||||||
|
else if (G_VALUE_HOLDS_POINTER (value))
|
||||||
|
contents = g_strdup_printf ("((gpointer) %p)", p);
|
||||||
|
else
|
||||||
|
contents = g_strdup ("???");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
contents = g_strdup ("???");
|
||||||
|
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
@ -79,6 +79,10 @@ void g_value_set_pointer (GValue *value,
|
|||||||
gpointer g_value_get_pointer (const GValue *value);
|
gpointer g_value_get_pointer (const GValue *value);
|
||||||
|
|
||||||
|
|
||||||
|
/* debugging aid, describe value contents as string */
|
||||||
|
gchar* g_strdup_value_contents (const GValue *value);
|
||||||
|
|
||||||
|
|
||||||
/* --- marshaller specific --- */
|
/* --- marshaller specific --- */
|
||||||
void g_value_set_string_take_ownership (GValue *value,
|
void g_value_set_string_take_ownership (GValue *value,
|
||||||
gchar *v_string);
|
gchar *v_string);
|
||||||
|
52
gscanner.c
52
gscanner.c
@ -171,7 +171,7 @@ g_scanner_char_2_num (guchar c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GScanner*
|
GScanner*
|
||||||
g_scanner_new (GScannerConfig *config_templ)
|
g_scanner_new (const GScannerConfig *config_templ)
|
||||||
{
|
{
|
||||||
GScanner *scanner;
|
GScanner *scanner;
|
||||||
|
|
||||||
@ -188,33 +188,33 @@ g_scanner_new (GScannerConfig *config_templ)
|
|||||||
|
|
||||||
scanner->config = g_new0 (GScannerConfig, 1);
|
scanner->config = g_new0 (GScannerConfig, 1);
|
||||||
|
|
||||||
scanner->config->case_sensitive = config_templ->case_sensitive;
|
scanner->config->case_sensitive = config_templ->case_sensitive;
|
||||||
scanner->config->cset_skip_characters = config_templ->cset_skip_characters;
|
scanner->config->cset_skip_characters = config_templ->cset_skip_characters;
|
||||||
if (!scanner->config->cset_skip_characters)
|
if (!scanner->config->cset_skip_characters)
|
||||||
scanner->config->cset_skip_characters = "";
|
scanner->config->cset_skip_characters = "";
|
||||||
scanner->config->cset_identifier_first= config_templ->cset_identifier_first;
|
scanner->config->cset_identifier_first = config_templ->cset_identifier_first;
|
||||||
scanner->config->cset_identifier_nth = config_templ->cset_identifier_nth;
|
scanner->config->cset_identifier_nth = config_templ->cset_identifier_nth;
|
||||||
scanner->config->cpair_comment_single = config_templ->cpair_comment_single;
|
scanner->config->cpair_comment_single = config_templ->cpair_comment_single;
|
||||||
scanner->config->skip_comment_multi = config_templ->skip_comment_multi;
|
scanner->config->skip_comment_multi = config_templ->skip_comment_multi;
|
||||||
scanner->config->skip_comment_single = config_templ->skip_comment_single;
|
scanner->config->skip_comment_single = config_templ->skip_comment_single;
|
||||||
scanner->config->scan_comment_multi = config_templ->scan_comment_multi;
|
scanner->config->scan_comment_multi = config_templ->scan_comment_multi;
|
||||||
scanner->config->scan_identifier = config_templ->scan_identifier;
|
scanner->config->scan_identifier = config_templ->scan_identifier;
|
||||||
scanner->config->scan_identifier_1char= config_templ->scan_identifier_1char;
|
scanner->config->scan_identifier_1char = config_templ->scan_identifier_1char;
|
||||||
scanner->config->scan_identifier_NULL = config_templ->scan_identifier_NULL;
|
scanner->config->scan_identifier_NULL = config_templ->scan_identifier_NULL;
|
||||||
scanner->config->scan_symbols = config_templ->scan_symbols;
|
scanner->config->scan_symbols = config_templ->scan_symbols;
|
||||||
scanner->config->scan_binary = config_templ->scan_binary;
|
scanner->config->scan_binary = config_templ->scan_binary;
|
||||||
scanner->config->scan_octal = config_templ->scan_octal;
|
scanner->config->scan_octal = config_templ->scan_octal;
|
||||||
scanner->config->scan_float = config_templ->scan_float;
|
scanner->config->scan_float = config_templ->scan_float;
|
||||||
scanner->config->scan_hex = config_templ->scan_hex;
|
scanner->config->scan_hex = config_templ->scan_hex;
|
||||||
scanner->config->scan_hex_dollar = config_templ->scan_hex_dollar;
|
scanner->config->scan_hex_dollar = config_templ->scan_hex_dollar;
|
||||||
scanner->config->scan_string_sq = config_templ->scan_string_sq;
|
scanner->config->scan_string_sq = config_templ->scan_string_sq;
|
||||||
scanner->config->scan_string_dq = config_templ->scan_string_dq;
|
scanner->config->scan_string_dq = config_templ->scan_string_dq;
|
||||||
scanner->config->numbers_2_int = config_templ->numbers_2_int;
|
scanner->config->numbers_2_int = config_templ->numbers_2_int;
|
||||||
scanner->config->int_2_float = config_templ->int_2_float;
|
scanner->config->int_2_float = config_templ->int_2_float;
|
||||||
scanner->config->identifier_2_string = config_templ->identifier_2_string;
|
scanner->config->identifier_2_string = config_templ->identifier_2_string;
|
||||||
scanner->config->char_2_token = config_templ->char_2_token;
|
scanner->config->char_2_token = config_templ->char_2_token;
|
||||||
scanner->config->symbol_2_token = config_templ->symbol_2_token;
|
scanner->config->symbol_2_token = config_templ->symbol_2_token;
|
||||||
scanner->config->scope_0_fallback = config_templ->scope_0_fallback;
|
scanner->config->scope_0_fallback = config_templ->scope_0_fallback;
|
||||||
|
|
||||||
scanner->token = G_TOKEN_NONE;
|
scanner->token = G_TOKEN_NONE;
|
||||||
scanner->value.v_int = 0;
|
scanner->value.v_int = 0;
|
||||||
|
@ -198,7 +198,7 @@ struct _GScanner
|
|||||||
GScannerMsgFunc msg_handler;
|
GScannerMsgFunc msg_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
GScanner* g_scanner_new (GScannerConfig *config_templ);
|
GScanner* g_scanner_new (const GScannerConfig *config_templ);
|
||||||
void g_scanner_destroy (GScanner *scanner);
|
void g_scanner_destroy (GScanner *scanner);
|
||||||
void g_scanner_input_file (GScanner *scanner,
|
void g_scanner_input_file (GScanner *scanner,
|
||||||
gint input_fd);
|
gint input_fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user