Discussion:
gw:wcp types in Guile-Gnome
Tommi Höynälänmaa
2017-08-17 16:06:21 UTC
Permalink
Pango attributes are instances of class <gw:wcp> in Guile-Gnome but they
are not GOOPS instances (i.e. (instance? x) returns false). Class name
<pango-attribute> is not defined at all. How can I test if an arbitrary
object belongs to some specific <gw:wcp> class, e.g. if an object is a
Pango attribute?

- Tommi Höynälänmaa
David Pirotte
2017-08-27 04:01:28 UTC
Permalink
Hello,

Sorry for the late response, I was hoping someone else would answer before I
could, we are not that many but there are still a few very good guile-gnome
users out there ... :)
Post by Tommi Höynälänmaa
Pango attributes are instances of class <gw:wcp> in Guile-Gnome but they
are not GOOPS instances (i.e. (instance? x) returns false). Class name
<pango-attribute> is not defined at all.
Indeed, pango attributes are opaque pointers, in the manual you see:

Class: <pango-attribute>

Opaque pointer.

This class defines no direct slots.

Note that the manual is automatically generated, which is why you read 'Class:
<pango-attrobute>, but on the next entry you can also read 'Opaque pointer', which
is an indication for users that the class has not been 'optimally' wrapped:

they are not goops classes - subclass of <gobject>, such as <gtk-window>,
they are (G-Wrap) opaque pointers.

In the manual, references to <pango-attribute> means it wish to receive an opaque
pointer of the corresponding attribute ... and these are returned by the interface
creating pango attributes:

pango-attr-size-new, pango-attr-font-desc-new ...

Opaque pointers are low level G-Wrap beats, so you don't want to involve yourself
there :). Their printing representation miss leaded you to believe they are
instances of ... which is not the case. When you create an attribute:

scheme@(guile-user)> (pango-attr-size-new 10)
$3 = #<gw:wcp <pango-attribute> 0x562572ca8c40>

in the above, gw:wcp stands for 'g-wrap:wrap C type', and what you read is
just an opaque pointer printing representation for (pango-attr-size-new 10)

Just for info, below is a copy ot the automatically G-Wrap generated definition for
pango-attr-size-new [1]
Post by Tommi Höynälänmaa
How can I test if an arbitrary object belongs to some specific <gw:wcp> class,
e.g. if an object is a Pango attribute?
You can't, you have to use their creator interfaces and attribute list operators ...

scheme@(guile-user)> (pango-attr-list-new)
$2 = #<<pango-attr-list> 562572e2f260 [native]>
scheme@(guile-user)> (pango-attr-size-new 10)
$3 = #<gw:wcp <pango-attribute> 0x562572ca8c40>
scheme@(guile-user)> (pango-attr-list-insert $2 $3)
scheme@(guile-user)>

HTH,
David

[1]

{
const char *gw__tmp1217_arg_types[1];
static GWTypeSpec gw__tmp1218_arg_typespecs[] = { GW_TYPESPEC_CALLER_OWNED, };
gw__tmp1217_arg_types[0] = "int";
gw_wrapset_add_function(gw__tmp0_c_info, pango_attr_size_new, 1, 0, "<pango-attribute>", GW_TYPESPEC_CALLER_OWNED, gw__tmp1217_arg_types, gw__tmp1218_arg_typespecs, "pango-attr-size-new", NULL, GW_FUNCTION_FLAG_LEAVE_RUNTIME);
}
Tommi Höynälänmaa
2017-09-06 12:20:12 UTC
Permalink
Hi

IMHO it would not violate opaqueness if you could find out (runtime)
which wct class a wcp value belongs to.

- Tommi Höynälänmaa
David Pirotte
2017-09-06 22:45:57 UTC
Permalink
Hello,
Post by Tommi Höynälänmaa
IMHO it would not violate opaqueness if you could find out (runtime)
which wct class a wcp value belongs to.
'opaque' is just a name, there is no 'properties' such that one could 'violate' (or
not) an opaque type: these are just 'opaque' pointers, g-wrap pointers to a C
values, and these values, in the case of pango attributes, must be created using
their corresponding interface, as I wrote in my previus answer...

What you want to achieve wrt (gnome pango), in the current situation, is simply
impossible. To achieve that, you would need to 'manually' wrap pango attribute class
and subclasses ... something I'm not going to work on, sorry (and and I really would
not spend any time on this if I were you ... my 2c)

David

Loading...