Re: GtkImageView
- From: muppet <scott asofyet org>
- To: gtk2-perl List <gtk-perl-list gnome org>
- Subject: Re: GtkImageView
- Date: Tue, 18 Dec 2007 21:21:46 -0500
On Dec 18, 2007, at 7:05 AM, Jeffrey Ratcliffe wrote:
gtk2-perl does not have separate typemaps for every event type. There
is just one for GdkEvent which looks at the event's type at run-time
to decide how to represent it.
As an aside, the reason for this is the way that GdkEvent is
implemented. GdkEvent is the structure type, which contains a union
of all the event types, and a type code that tells you which of the
union members is valid.
Once you have the converters newSVStructName and SVStructName, you can
That should be SvStructName() -- note the lower-case "v". (Blame the
perlapi, not me.)
You're trying to use a GdkRectangle where a GdkRectangle* is
wanted. I
think this should work:
Thanks, Torsten and Muppet. I briefly had the same but discarded it
when I got the error message:
IImageTool.xs: In function `SvDrawSettings':
IImageTool.xs:62: warning: dereferencing `void *' pointer
IImageTool.xs:62: error: void value not ignored as it ought to be
if (svp) settings->zoom_rect = *SvGdkRectangle (*svp);
Which leaves me pretty much in the dark.
In general, the "dereferencing a `void*' pointer warning means that
your pointer isn't cast to a valid type. I notice now that
gperl_get_boxed_check() returns a void*, and Glib::CodeGen creates
macros like this:
#define SvGtkBorder(sv) (gperl_get_boxed_check ((sv),
GTK_TYPE_BORDER))
That is, the generated SvStructType() macros don't contain the cast
like you'd expect. In the general case of
Foo * foo = SvFoo (sv);
this works fine, because C (unlike C++) says that a void* may be used
where any pointer type is wanted; that is, the conversion is implicit
in C. But, the construct
Foo foo = *SvFoo (sv);
turns into
Foo foo = * ((void*) something)
which is *not* valid. The two solutions are
a) Foo * foo = * (Foo*) SvFoo (sv);
b) change Glib::CodeGen to insert the cast into the macro like this:
#define SvFoo(sv) ((Foo*) gperl_get_boxed_check ((sv),
TYPE_FOO))
In reality, you may as well go for a) to make things work until we get
b) vetted and rolled out.
Now, the error message,
IImageTool.xs:62: error: void value not ignored as it ought to be
makes me go back and realize that you are using a hand-written
function for SvDrawSettings() instead of a Glib::CodeGen-created
macro. I don't see anything related to this at http://trac.bjourne.webfactional.com/browser/plgtkimageview/
, so, from the message, it sounds like your function has the prototype
void SvDrawSettings (SV * sv);
That means that it returns nothing, and the compiler will complain
that you're attempting to use a non-existent value. This is
incorrect. Change it to
DrawSettings * SvDrawSettings (SV * sv);
(note the parallel with the discussion of the macro definitions,
above), and everything should Just Work.
If that still doesn't work, give us the url of an svn branch that has
the current code.
--
It's all very complicated and would take a scientist to explain it.
-- MST3K
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]