本文整理汇总了C++中G_TYPE_FUNDAMENTAL函数的典型用法代码示例。如果您正苦于以下问题:C++ G_TYPE_FUNDAMENTAL函数的具体用法?C++ G_TYPE_FUNDAMENTAL怎么用?C++ G_TYPE_FUNDAMENTAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_TYPE_FUNDAMENTAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gtk_argloc_set_from_value
static inline gboolean
gtk_argloc_set_from_value (GtkArg *arg,
GValue *value,
gboolean copy_string)
{
switch (G_TYPE_FUNDAMENTAL (arg->type))
{
case G_TYPE_CHAR: *GTK_RETLOC_CHAR (*arg) = g_value_get_char (value); break;
case G_TYPE_UCHAR: *GTK_RETLOC_UCHAR (*arg) = g_value_get_uchar (value); break;
case G_TYPE_BOOLEAN: *GTK_RETLOC_BOOL (*arg) = g_value_get_boolean (value); break;
case G_TYPE_INT: *GTK_RETLOC_INT (*arg) = g_value_get_int (value); break;
case G_TYPE_UINT: *GTK_RETLOC_UINT (*arg) = g_value_get_uint (value); break;
case G_TYPE_LONG: *GTK_RETLOC_LONG (*arg) = g_value_get_long (value); break;
case G_TYPE_ULONG: *GTK_RETLOC_ULONG (*arg) = g_value_get_ulong (value); break;
case G_TYPE_ENUM: *GTK_RETLOC_ENUM (*arg) = g_value_get_enum (value); break;
case G_TYPE_FLAGS: *GTK_RETLOC_FLAGS (*arg) = g_value_get_flags (value); break;
case G_TYPE_FLOAT: *GTK_RETLOC_FLOAT (*arg) = g_value_get_float (value); break;
case G_TYPE_DOUBLE: *GTK_RETLOC_DOUBLE (*arg) = g_value_get_double (value); break;
case G_TYPE_BOXED: *GTK_RETLOC_BOXED (*arg) = g_value_get_boxed (value); break;
case G_TYPE_POINTER: *GTK_RETLOC_POINTER (*arg) = g_value_get_pointer (value); break;
case G_TYPE_OBJECT: *GTK_RETLOC_POINTER (*arg) = g_value_get_object (value); break;
case G_TYPE_STRING: if (copy_string)
*GTK_RETLOC_STRING (*arg) = g_value_dup_string (value);
else
*GTK_RETLOC_STRING (*arg) = (char *) g_value_get_string (value);
break;
default:
return FALSE;
}
return TRUE;
}
示例2: gobj_mark
static void
gobj_mark(gpointer ptr)
{
GObject* gobj = ptr;
guint n_properties;
GParamSpec** properties;
GValue gval = {0,};
guint i;
properties = g_object_class_list_properties(G_OBJECT_GET_CLASS(gobj), &n_properties);
for (i = 0; i < n_properties; i++) {
GParamSpec* pspec = properties[i];
GType value_type = G_PARAM_SPEC_VALUE_TYPE(pspec);
if (G_TYPE_FUNDAMENTAL(value_type) != G_TYPE_OBJECT) continue;
if (!(pspec->flags & G_PARAM_READABLE)) continue;
/* FIXME: exclude types that doesn't have identity. */
{
g_value_init(&gval, value_type);
g_object_get_property(gobj, pspec->name, &gval);
rbgobj_gc_mark_gvalue(&gval);
g_value_unset(&gval);
}
}
g_free(properties);
}
示例3: gtk_arg_static_to_value
static inline gboolean
gtk_arg_static_to_value (GtkArg *arg,
GValue *value)
{
switch (G_TYPE_FUNDAMENTAL (arg->type))
{
case G_TYPE_CHAR: g_value_set_char (value, GTK_VALUE_CHAR (*arg)); break;
case G_TYPE_UCHAR: g_value_set_uchar (value, GTK_VALUE_UCHAR (*arg)); break;
case G_TYPE_BOOLEAN: g_value_set_boolean (value, GTK_VALUE_BOOL (*arg)); break;
case G_TYPE_INT: g_value_set_int (value, GTK_VALUE_INT (*arg)); break;
case G_TYPE_UINT: g_value_set_uint (value, GTK_VALUE_UINT (*arg)); break;
case G_TYPE_LONG: g_value_set_long (value, GTK_VALUE_LONG (*arg)); break;
case G_TYPE_ULONG: g_value_set_ulong (value, GTK_VALUE_ULONG (*arg)); break;
case G_TYPE_ENUM: g_value_set_enum (value, GTK_VALUE_ENUM (*arg)); break;
case G_TYPE_FLAGS: g_value_set_flags (value, GTK_VALUE_FLAGS (*arg)); break;
case G_TYPE_FLOAT: g_value_set_float (value, GTK_VALUE_FLOAT (*arg)); break;
case G_TYPE_DOUBLE: g_value_set_double (value, GTK_VALUE_DOUBLE (*arg)); break;
case G_TYPE_STRING: g_value_set_static_string (value, GTK_VALUE_STRING (*arg)); break;
case G_TYPE_BOXED: g_value_set_static_boxed (value, GTK_VALUE_BOXED (*arg)); break;
case G_TYPE_POINTER: g_value_set_pointer (value, GTK_VALUE_POINTER (*arg)); break;
case G_TYPE_OBJECT: g_value_set_object (value, GTK_VALUE_POINTER (*arg)); break;
default:
return FALSE;
}
return TRUE;
}
示例4: rbgobj_ruby_object_from_instance2
VALUE
rbgobj_ruby_object_from_instance2(gpointer instance, gboolean alloc)
{
VALUE object;
GType type;
if (!instance)
return Qnil;
type = G_TYPE_FROM_INSTANCE(instance);
if (alloc) {
GType parent_type;
for (parent_type = type;
parent_type != G_TYPE_INVALID;
parent_type = g_type_parent(parent_type)) {
if (rbgobj_convert_instance2robj(parent_type, instance, &object))
return object;
}
}
switch (G_TYPE_FUNDAMENTAL(type)) {
case G_TYPE_OBJECT:
return rbgobj_get_ruby_object_from_gobject(instance, alloc);
case G_TYPE_PARAM:
return rbgobj_get_ruby_object_from_param_spec(instance, alloc);
default:
if (alloc) {
rb_raise(rb_eTypeError, "%s isn't supported", g_type_name(type));
} else {
return Qnil;
}
}
}
示例5: rbgobj_initialize_object
void
rbgobj_initialize_object(VALUE obj, gpointer cobj)
{
GType type;
GType parent_type;
if (!cobj)
rb_raise(rb_eRuntimeError, "failed to initialize");
type = RVAL2GTYPE(obj);
for (parent_type = type;
parent_type != G_TYPE_INVALID;
parent_type = g_type_parent(parent_type)) {
if (rbgobj_convert_initialize(parent_type, obj, cobj))
return;
}
type = G_TYPE_FUNDAMENTAL(type);
switch (type){
case G_TYPE_OBJECT:
rbgobj_gobject_initialize(obj, cobj);
break;
case G_TYPE_PARAM:
rbgobj_param_spec_initialize(obj, cobj);
break;
case G_TYPE_BOXED:
rbgobj_boxed_initialize(obj, cobj);
break;
default:
rbgobj_convert_initialize(type, obj, cobj);
}
}
示例6: GOM_ASTRING_TO_GSTRING_RETURN
/* void setAttribute (in nsIAtom name, in AString newValue); */
NS_IMETHODIMP
xgGtkElement::SetAttribute (nsIAtom *name, const nsAString &newValue)
{
GOM_ASTRING_TO_GSTRING_RETURN (value, newValue, NS_ERROR_INVALID_ARG);
GParamSpec *spec;
guint signal_id;
if (!Resolve (name, &spec, &signal_id)) {
return NS_ERROR_FAILURE;
}
if (!spec) {
return NS_ERROR_FAILURE;
}
GError *error = NULL;
GValue gval = { 0 };
if (G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (spec)) == G_TYPE_OBJECT) {
g_warning (GOM_LOC ("Attribute %s.%s is a %s, which a string cannot be converted to"),
G_OBJECT_TYPE_NAME (mObject), spec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (spec)));
return NS_ERROR_FAILURE;
} else if (gtk_builder_value_from_string (NULL, spec, value, &gval, &error)) {
g_object_set_property (mObject, spec->name, &gval);
g_value_unset (&gval);
} else {
g_warning (GOM_LOC ("Could not get value from string: '%s'"), value);
return NS_ERROR_FAILURE;
}
return NS_OK;
}
示例7: rbgobj_instance_from_ruby_object
gpointer
rbgobj_instance_from_ruby_object(VALUE obj)
{
GType type;
if (NIL_P(obj))
return NULL;
type = RVAL2GTYPE(obj);
if (rbgobj_convert_has_type(type)) {
gpointer instance;
if (rbgobj_convert_robj2instance(type, obj, &instance))
return instance;
}
type = G_TYPE_FUNDAMENTAL(type);
switch (type){
case G_TYPE_OBJECT:
return rbgobj_get_gobject(obj);
case G_TYPE_PARAM:
return rbgobj_get_param_spec(obj);
default:
{
gpointer instance;
if (!rbgobj_convert_robj2instance(type, obj, &instance)) {
rb_raise(rb_eTypeError, "%s isn't supported",
rb_class2name(CLASS_OF(obj)));
}
return instance;
}
}
}
示例8: gog_object_set_arg
void
gog_object_set_arg (char const *name, char const *val, GogObject *obj)
{
GParamSpec *pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (obj), name);
GType prop_type;
GValue res = { 0 };
gboolean success = TRUE;
if (pspec == NULL) {
g_warning ("unknown property `%s' for class `%s'",
name, G_OBJECT_TYPE_NAME (obj));
return;
}
prop_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
if (val == NULL &&
G_TYPE_FUNDAMENTAL (prop_type) != G_TYPE_BOOLEAN) {
g_warning ("could not convert NULL to type `%s' for property `%s'",
g_type_name (prop_type), pspec->name);
return;
}
if (!gsf_xml_gvalue_from_str (&res, prop_type, val))
success = FALSE;
if (!success) {
g_warning ("could not convert string to type `%s' for property `%s'",
g_type_name (prop_type), pspec->name);
} else
g_object_set_property (G_OBJECT (obj), name, &res);
g_value_unset (&res);
}
示例9: G_VALUE_TYPE
void bb_interpolate_value (GValue *out,
gdouble frac,
const GValue *a,
const GValue *b,
BbInterpolationMode interp_mode)
{
GType type = G_VALUE_TYPE (out);
g_assert (type == G_VALUE_TYPE (a));
g_assert (type == G_VALUE_TYPE (b));
switch (G_TYPE_FUNDAMENTAL (type))
{
case G_TYPE_DOUBLE:
g_value_set_double (out, bb_interpolate_double (frac, g_value_get_double (a), g_value_get_double (b), interp_mode));
break;
default:
if (type == BB_TYPE_DURATION)
{
BbDuration adur, bdur;
bb_value_get_duration (a, &adur);
bb_value_get_duration (b, &bdur);
if (adur.units != bdur.units)
g_error ("cannot interpolate between durations that are in different units");
adur.value = bb_interpolate_double (frac, adur.value, bdur.value, interp_mode);
bb_value_set_duration (out, adur.units, adur.value);
break;
}
else
g_error ("cannot interpolate value of type %s", g_type_name (type));
}
}
示例10: rbgobj_gc_mark_gvalue
void
rbgobj_gc_mark_gvalue(GValue* value)
{
GType gtype = G_VALUE_TYPE(value);
/* FIXME */
if (G_TYPE_FUNDAMENTAL(gtype) == G_TYPE_OBJECT)
rbgobj_gc_mark_instance(g_value_get_object(value));
}
示例11: rg_set_child_property
static VALUE
rg_set_child_property(VALUE self, VALUE child,
VALUE prop_name, VALUE val)
{
GParamSpec* pspec;
const char* name;
if (SYMBOL_P(prop_name)) {
name = rb_id2name(SYM2ID(prop_name));
} else {
StringValue(prop_name);
name = StringValuePtr(prop_name);
}
pspec = goo_canvas_item_class_find_child_property(G_OBJECT_GET_CLASS(RVAL2GOBJ(self)), name);
if (!pspec)
rb_raise(rb_eRuntimeError, "No such child property: %s", name);
#define _SET_PROP_FOR_TYPE(gtype, ctype, val) \
case gtype: \
goo_canvas_item_set_child_properties(SELF(self), SELF(child), name, (ctype)(val), NULL); \
break;
switch (G_TYPE_FUNDAMENTAL(G_PARAM_SPEC_VALUE_TYPE(pspec))) {
_SET_PROP_FOR_TYPE(G_TYPE_CHAR, gchar, NUM2INT(val));
_SET_PROP_FOR_TYPE(G_TYPE_UCHAR, guchar, NUM2INT(val));
_SET_PROP_FOR_TYPE(G_TYPE_BOOLEAN, gboolean, RTEST(val));
_SET_PROP_FOR_TYPE(G_TYPE_INT, gint, NUM2INT(val));
_SET_PROP_FOR_TYPE(G_TYPE_UINT, guint, NUM2UINT(val));
_SET_PROP_FOR_TYPE(G_TYPE_LONG, glong, NUM2LONG(val));
_SET_PROP_FOR_TYPE(G_TYPE_ULONG, gulong, NUM2ULONG(val));
_SET_PROP_FOR_TYPE(G_TYPE_INT64, gint64, rbglib_num_to_int64(val));
_SET_PROP_FOR_TYPE(G_TYPE_UINT64, guint64, rbglib_num_to_uint64(val));
_SET_PROP_FOR_TYPE(G_TYPE_ENUM, gint, rbgobj_get_enum(val, G_PARAM_SPEC_VALUE_TYPE(pspec)));
_SET_PROP_FOR_TYPE(G_TYPE_FLAGS, guint, rbgobj_get_flags(val, G_PARAM_SPEC_VALUE_TYPE(pspec)));
_SET_PROP_FOR_TYPE(G_TYPE_FLOAT, gfloat, NUM2DBL(val));
_SET_PROP_FOR_TYPE(G_TYPE_DOUBLE, gdouble, NUM2DBL(val));
case G_TYPE_STRING:
{
if (SYMBOL_P(val))
val = rb_funcall(val, rb_intern("to_s"), 0);
goo_canvas_item_set_child_properties(SELF(self), SELF(child), name, StringValuePtr(val), NULL);
break;
}
default:
g_warning("rb_goo_canvas_item_set_child_property: unsupported type: %s\n", g_type_name(G_PARAM_SPEC_VALUE_TYPE(pspec)));
return Qnil;
}
#undef _SET_PROP_FOR_TYPE
G_CHILD_ADD(child, val);
return self;
}
示例12: __get_expression_value
static void
__get_expression_value (GdaConnection *cnc, GValue *src, GString *str)
{
gchar *escaped_string = NULL;
switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (src))) {
case G_TYPE_STRING:
escaped_string = gda_connection_value_to_sql_string(cnc, src);
g_string_append_printf (str, "%s", escaped_string);
g_free(escaped_string);
break;
case G_TYPE_UINT:
g_string_append_printf (str, "%d", g_value_get_uint (src));
break;
case G_TYPE_INT:
g_string_append_printf (str, "%d", g_value_get_int (src));
break;
case G_TYPE_FLOAT:
g_string_append_printf (str, "%.04f", g_value_get_float (src));
break;
case G_TYPE_BOOLEAN:
g_string_append_printf (str, "%d", g_value_get_boolean (src));
break;
case G_TYPE_BOXED:
if (G_VALUE_TYPE (src) == G_TYPE_VALUE_ARRAY) {
GValueArray *array = (GValueArray *) g_value_get_boxed (src);
if (!array) {
/* FIXME, add this to validate */
g_warning ("Empty array given");
return;
}
guint i;
for (i = 0; i < array->n_values; i++) {
if (i > 0)
g_string_append (str, ", ");
__get_expression_value (cnc, g_value_array_get_nth (array, i), str);
}
} else {
/*FIXME, add this to validate */
g_warning ("BOXED type '%s' not implemented \n", G_VALUE_TYPE_NAME (src));
}
break;
default:
break;
}
return;
}
示例13: tp_g_value_slice_new_take_boxed
/**
* tp_g_value_slice_new_take_boxed:
* @type: a boxed type
* @p: a pointer of type @type which will be freed with g_boxed_free() by the
* returned #GValue (the caller must own it before calling this function, but
* no longer owns it after this function returns)
*
* Slice-allocate and initialize a #GValue. This function is convenient to
* use when constructing hash tables from string to #GValue, for example.
*
* Returns: a #GValue of type @type whose value is @p,
* to be freed with tp_g_value_slice_free() or g_slice_free()
*
* Since: 0.7.27
*/
GValue *
tp_g_value_slice_new_take_boxed (GType type,
gpointer p)
{
GValue *v;
g_return_val_if_fail (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED, NULL);
v = tp_g_value_slice_new (type);
g_value_take_boxed (v, p);
return v;
}
示例14: switch
static json_t *json_serialize_pspec (const GValue *value)
{
/* Only types in json-glib but G_TYPE_BOXED */
switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (value))) {
case G_TYPE_STRING:
if (!g_value_get_string (value))
break;
else
return json_string (g_value_get_string (value));
case G_TYPE_BOOLEAN:
if (g_value_get_boolean (value))
return json_true ();
else return json_false ();
case G_TYPE_INT:
return json_integer (g_value_get_int (value));
case G_TYPE_UINT:
return json_integer (g_value_get_uint (value));
case G_TYPE_LONG:
return json_integer (g_value_get_long (value));
case G_TYPE_ULONG:
return json_integer (g_value_get_ulong (value));
case G_TYPE_INT64:
return json_integer (g_value_get_int64 (value));
case G_TYPE_FLOAT:
return json_real (g_value_get_float (value));
case G_TYPE_DOUBLE:
return json_real (g_value_get_double (value));
case G_TYPE_CHAR:
return json_integer (g_value_get_schar (value));
case G_TYPE_UCHAR:
return json_integer (g_value_get_uchar (value));
case G_TYPE_ENUM:
return json_integer (g_value_get_enum (value));
case G_TYPE_FLAGS:
return json_integer (g_value_get_flags (value));
case G_TYPE_NONE:
break;
case G_TYPE_OBJECT:
{
GObject *object = g_value_get_object (value);
if (object)
return json_gobject_serialize (object);
}
break;
defalut:
g_warning("Unsuppoted type `%s'",g_type_name (G_VALUE_TYPE (value)));
}
return json_null();
}
示例15: gimp_config_deserialize_value
static GTokenType
gimp_config_deserialize_value (GValue *value,
GimpConfig *config,
GParamSpec *prop_spec,
GScanner *scanner)
{
if (G_TYPE_FUNDAMENTAL (prop_spec->value_type) == G_TYPE_ENUM)
{
return gimp_config_deserialize_enum (value, prop_spec, scanner);
}
else if (G_TYPE_IS_FUNDAMENTAL (prop_spec->value_type))
{
return gimp_config_deserialize_fundamental (value, prop_spec, scanner);
}
else if (prop_spec->value_type == GIMP_TYPE_MEMSIZE)
{
return gimp_config_deserialize_memsize (value, prop_spec, scanner);
}
else if (prop_spec->value_type == GIMP_TYPE_CONFIG_PATH)
{
return gimp_config_deserialize_path (value, prop_spec, scanner);
}
else if (prop_spec->value_type == GIMP_TYPE_RGB)
{
return gimp_config_deserialize_rgb (value, prop_spec, scanner);
}
else if (prop_spec->value_type == GIMP_TYPE_MATRIX2)
{
return gimp_config_deserialize_matrix2 (value, prop_spec, scanner);
}
else if (prop_spec->value_type == GIMP_TYPE_VALUE_ARRAY)
{
return gimp_config_deserialize_value_array (value,
config, prop_spec, scanner);
}
else if (prop_spec->value_type == GIMP_TYPE_UNIT)
{
return gimp_config_deserialize_unit (value, prop_spec, scanner);
}
else if (prop_spec->value_type == G_TYPE_FILE)
{
return gimp_config_deserialize_file_value (value, prop_spec, scanner);
}
/* This fallback will only work for value_types that
* can be transformed from a string value.
*/
return gimp_config_deserialize_any (value, prop_spec, scanner);
}