logo       


Re: rework of the Gtk2-Perl type system: msg#00066

Subject: Re: rework of the Gtk2-Perl type system
On fre, 2003-03-21 at 03:52, muppet wrote:
> As i have mentioned before and you are probably sick of hearing, i have
> an independent, GObject-based C library that i wish to bind to perl in
> such a way that i can use its objects seamlessly with gtk objects, e.g.,
> binding callbacks and packing my library's widgets into windows and
> other normal gobject/gtk things, similar to how the Gnome2 package
> works.

I'm hoping to wrap Evolutions CalClient once gtk2 evolution is stable
enough for everyday use (it may be already - but thats not the).
So I'd really like to see something like this.

[massive snipage]

> I propose something like
> 
>    void gtk2_perl_register_class_mapping (const char * class,
>                                           const char * package,
>                                           gboolean require);
> 
> Using a string for the class name instead of a GType allows us to
> specify mappings for non GObject types (structs and boxed types).  The
> "require" parameter lets you specify whether the class has a pm that
> must be loaded.

This fills the requirements I can imagine, at the moment.

> For simplicity, i imagine the class mappings as being one-to-one:
> 
>    GtkWidget <=> Gtk2::Widget
>    GdkWindow <=> Gtk2::Gdk::Window
>    GdkEventKey <=> Gtk2::Gdk::Event::Key
>    PangoFontDescription <=> Gtk2::Pango::FontDescription
>    GnomeAbout <=> Gnome2::About
>    MylibFooBar <=> Mylib::FooBar
> 
> With one-to-one mappings, get_class_from_classname could return a
> pointer that need not be freed, and thus avoid memory leaks.
> 
> On the other hand, it might also be possible to do something like
> 
>    void gtk2_perl_register_class_mapping_rule (char * perl_code_to_eval)
> 
> which would allow you somehow to specify a substitution pattern for a
> whole set of mappings, to be run as a code reference, and successful
> results cached to avoid running it again.  I am willing to implement
> this, but i want help designing that portion of the interface.

This would be very Perl'ish, but I don't see an immediate need for it.

> get_class and get_class_from_classname should be renamed to avoid both
> symbol clashes (the module must be loaded with RTLD_GLOBAL!) and the
> confusion of calling everything classes.  i propose:
> 
>   char * gtk2_perl_get_package_from_gobject (GObject *)
>   char * gtk2_perl_get_package_from_gtype (GType)
>   char * gtk2_perl_get_package_from_classname (char *)
>      retrieve package names
> 
>   GType gtk2_perl_get_type_from_package (char *)
>   char * gtk2_perl_get_classname_from_package (char *)
>      the other way 'round

Your proposal seems sound to me.
Could get_class and get_class_from_classname not be kept as defines, to
let the existing code live on?

> Also, we could let the GType system do a lot of work for us by
> implementing @ISA as a tied variable which uses
> gtk2_perl_get_package_from_class, g_type_parent, and
> g_type_get_class_from_package.

Sounds cool.
How would it perform? 
And would it mess up the optimisations of method lookups? I assume not
as the mappings should be pretty much stable. 
Not sure how it would work though (which @ISA should be tied), have you
got any examples of modules doing this?  

Sorry for the late reply.

./borup


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe