mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +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>
|
||||
|
||||
* 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>
|
||||
|
||||
* 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>
|
||||
|
||||
* 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>
|
||||
|
||||
* 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>
|
||||
|
||||
* 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>
|
||||
|
||||
* 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>
|
||||
|
||||
* 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>
|
||||
|
||||
* tests/Makefile.am (libmoduletestplugin_b_la_LIBADD,
|
||||
|
@ -171,7 +171,7 @@ g_scanner_char_2_num (guchar c,
|
||||
}
|
||||
|
||||
GScanner*
|
||||
g_scanner_new (GScannerConfig *config_templ)
|
||||
g_scanner_new (const GScannerConfig *config_templ)
|
||||
{
|
||||
GScanner *scanner;
|
||||
|
||||
@ -192,14 +192,14 @@ g_scanner_new (GScannerConfig *config_templ)
|
||||
scanner->config->cset_skip_characters = config_templ->cset_skip_characters;
|
||||
if (!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->cpair_comment_single = config_templ->cpair_comment_single;
|
||||
scanner->config->skip_comment_multi = config_templ->skip_comment_multi;
|
||||
scanner->config->skip_comment_single = config_templ->skip_comment_single;
|
||||
scanner->config->scan_comment_multi = config_templ->scan_comment_multi;
|
||||
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_symbols = config_templ->scan_symbols;
|
||||
scanner->config->scan_binary = config_templ->scan_binary;
|
||||
|
@ -198,7 +198,7 @@ struct _GScanner
|
||||
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_input_file (GScanner *scanner,
|
||||
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>
|
||||
|
||||
* 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);
|
||||
}
|
||||
|
||||
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
|
||||
object_set_property (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
|
@ -1199,7 +1199,11 @@ g_param_spec_char (const gchar *name,
|
||||
gint8 default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecChar *cspec = g_param_spec_internal (G_TYPE_PARAM_CHAR,
|
||||
GParamSpecChar *cspec;
|
||||
|
||||
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||
|
||||
cspec = g_param_spec_internal (G_TYPE_PARAM_CHAR,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
@ -1221,7 +1225,11 @@ g_param_spec_uchar (const gchar *name,
|
||||
guint8 default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecUChar *uspec = g_param_spec_internal (G_TYPE_PARAM_UCHAR,
|
||||
GParamSpecUChar *uspec;
|
||||
|
||||
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||
|
||||
uspec = g_param_spec_internal (G_TYPE_PARAM_UCHAR,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
@ -1241,7 +1249,11 @@ g_param_spec_boolean (const gchar *name,
|
||||
gboolean default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecBoolean *bspec = g_param_spec_internal (G_TYPE_PARAM_BOOLEAN,
|
||||
GParamSpecBoolean *bspec;
|
||||
|
||||
g_return_val_if_fail (default_value == TRUE || default_value == FALSE, NULL);
|
||||
|
||||
bspec = g_param_spec_internal (G_TYPE_PARAM_BOOLEAN,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
@ -1261,7 +1273,11 @@ g_param_spec_int (const gchar *name,
|
||||
gint default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecInt *ispec = g_param_spec_internal (G_TYPE_PARAM_INT,
|
||||
GParamSpecInt *ispec;
|
||||
|
||||
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||
|
||||
ispec = g_param_spec_internal (G_TYPE_PARAM_INT,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
@ -1283,7 +1299,11 @@ g_param_spec_uint (const gchar *name,
|
||||
guint default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecUInt *uspec = g_param_spec_internal (G_TYPE_PARAM_UINT,
|
||||
GParamSpecUInt *uspec;
|
||||
|
||||
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||
|
||||
uspec = g_param_spec_internal (G_TYPE_PARAM_UINT,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
@ -1305,7 +1325,11 @@ g_param_spec_long (const gchar *name,
|
||||
glong default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecLong *lspec = g_param_spec_internal (G_TYPE_PARAM_LONG,
|
||||
GParamSpecLong *lspec;
|
||||
|
||||
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||
|
||||
lspec = g_param_spec_internal (G_TYPE_PARAM_LONG,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
@ -1327,7 +1351,11 @@ g_param_spec_ulong (const gchar *name,
|
||||
gulong default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecULong *uspec = g_param_spec_internal (G_TYPE_PARAM_ULONG,
|
||||
GParamSpecULong *uspec;
|
||||
|
||||
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||
|
||||
uspec = g_param_spec_internal (G_TYPE_PARAM_ULONG,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
@ -1349,16 +1377,21 @@ g_param_spec_enum (const gchar *name,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecEnum *espec;
|
||||
GEnumClass *enum_class;
|
||||
|
||||
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,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
flags);
|
||||
|
||||
espec->enum_class = g_type_class_ref (enum_type);
|
||||
espec->enum_class = enum_class;
|
||||
espec->default_value = default_value;
|
||||
G_PARAM_SPEC (espec)->value_type = enum_type;
|
||||
|
||||
@ -1374,16 +1407,21 @@ g_param_spec_flags (const gchar *name,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecFlags *fspec;
|
||||
GFlagsClass *flags_class;
|
||||
|
||||
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,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
flags);
|
||||
|
||||
fspec->flags_class = g_type_class_ref (flags_type);
|
||||
fspec->flags_class = flags_class;
|
||||
fspec->default_value = default_value;
|
||||
G_PARAM_SPEC (fspec)->value_type = flags_type;
|
||||
|
||||
@ -1399,7 +1437,11 @@ g_param_spec_float (const gchar *name,
|
||||
gfloat default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecFloat *fspec = g_param_spec_internal (G_TYPE_PARAM_FLOAT,
|
||||
GParamSpecFloat *fspec;
|
||||
|
||||
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||
|
||||
fspec = g_param_spec_internal (G_TYPE_PARAM_FLOAT,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
@ -1421,7 +1463,11 @@ g_param_spec_double (const gchar *name,
|
||||
gdouble default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpecDouble *dspec = g_param_spec_internal (G_TYPE_PARAM_DOUBLE,
|
||||
GParamSpecDouble *dspec;
|
||||
|
||||
g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
|
||||
|
||||
dspec = g_param_spec_internal (G_TYPE_PARAM_DOUBLE,
|
||||
name,
|
||||
nick,
|
||||
blurb,
|
||||
@ -1508,7 +1554,7 @@ g_param_spec_boxed (const gchar *name,
|
||||
GParamSpecBoxed *bspec;
|
||||
|
||||
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,
|
||||
name,
|
||||
|
@ -710,3 +710,72 @@ g_value_get_pointer (const GValue *value)
|
||||
|
||||
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);
|
||||
|
||||
|
||||
/* debugging aid, describe value contents as string */
|
||||
gchar* g_strdup_value_contents (const GValue *value);
|
||||
|
||||
|
||||
/* --- marshaller specific --- */
|
||||
void g_value_set_string_take_ownership (GValue *value,
|
||||
gchar *v_string);
|
||||
|
@ -171,7 +171,7 @@ g_scanner_char_2_num (guchar c,
|
||||
}
|
||||
|
||||
GScanner*
|
||||
g_scanner_new (GScannerConfig *config_templ)
|
||||
g_scanner_new (const GScannerConfig *config_templ)
|
||||
{
|
||||
GScanner *scanner;
|
||||
|
||||
@ -192,14 +192,14 @@ g_scanner_new (GScannerConfig *config_templ)
|
||||
scanner->config->cset_skip_characters = config_templ->cset_skip_characters;
|
||||
if (!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->cpair_comment_single = config_templ->cpair_comment_single;
|
||||
scanner->config->skip_comment_multi = config_templ->skip_comment_multi;
|
||||
scanner->config->skip_comment_single = config_templ->skip_comment_single;
|
||||
scanner->config->scan_comment_multi = config_templ->scan_comment_multi;
|
||||
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_symbols = config_templ->scan_symbols;
|
||||
scanner->config->scan_binary = config_templ->scan_binary;
|
||||
|
@ -198,7 +198,7 @@ struct _GScanner
|
||||
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_input_file (GScanner *scanner,
|
||||
gint input_fd);
|
||||
|
Loading…
Reference in New Issue
Block a user