Re: gvalue type conversions

On 8 Jan 2001, Havoc Pennington wrote:

> Hi,
> I noticed that GValue currently only has the type conversions you
> might expect for C types (e.g. int<->uint). 
> What are the guidelines for which conversions are allowed, and when
> conversion should be performed?
> It would seem useful to support conversions from most primitive types
> (int, float, etc.) to strings, for the purposes of the TreeView. If
> you have a GtkListStore containing integers, for example, it would be
> convenient if GtkCellRendererText could automatically display those as
> text.  It looks like adding an int->string conversion makes this
> happen automatically, because you can set the "text" property from a
> GValue with type G_VALUE_INT.

basically such conversions are fine with me, but keep in mind
the following:
- owen thinks my underlying exchange implementation isn't the right way
  to do things, since not every conversion is neccessarily revertible.
  afaiac, splitting them up would be ok, i mostly did things the way
  they are to spare the work of writing twice as many functions
- conversions like string<->int may have some pitfalls, like:
  ((int)0)->(char*) ?

it might be better to change the API and implementation to
1) feature one-sided conversions
2) maybe make the success of conversions dependant on value
   contents, not just their types

but that's not too high on my priority list currently, so for the
moment i'd take your string<->int code, unless you also want to work
on revamping the current concept.

> Havoc


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]