Michal Maruška | 10 Sep 02:42 2004
Picon

Some more enhancements to gauche-gtk


i use several enhancements to gauche-gtk.

Here is my patch, which includes both new enhancement explained in this email,
and also those explained previously:

http://maruska.dyndns.org/comp/gentoo/portage/dev-scheme/gauche-gtk/files/0.4.1/total.patch

Modification for h2stub.scm contains some colored logging, so it needs
commenting out, or one of my external packages.

-*-outline-*-
Here is the list of new mini enhancements:

* recognizing more GValues:   ENUMS are integers, right?
** src/gauche-gtk.c
ScmObj Scm_UnboxGValue(const GValue *gv)
....
    default:
+       if (G_VALUE_HOLDS_ENUM(gv))
+          return Scm_MakeInteger(g_value_get_enum(gv));
....       

* gtk-widget-get-child-requisition   ...'returns' >1 C values (backfills):

** src/gtk-lib.hints
;;==================================================================
;; gtkwidget.h
......
(define-cproc-fix gtk-widget-get-child-requisition
(Continue reading)

Shiro Kawai | 10 Sep 03:29 2004
Picon

Re: Some more enhancements to gauche-gtk

Thanks, Michal.

I'd like to make some changes before adopting this patch.

- Since gtk-sourceview is a separate package, I feel it better
  to have it as an optional add-on, much like gtkglext.
- I want to make sure gtk-2.4 features are #ifdef-ed so that
  the source can be used for 2.2 as well.

I like to put your stuff and make it Gauche-gtk-0.5, but it
won't be very soon if I work on it.  Michal, do you have time
to work on these issues?  If so, I'll add you to the CVS committers.

--shiro

-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
Michal Maruška | 12 Sep 12:37 2004
Picon

modules (import vs use) & generics


i have these libraries, and i see different behaviour when using USE (in fact
quite unexpected behaviour) and IMPORT:

a.scm
----------------

;; this _exports_ the `gen'. That should be enough to use (all) the methods associated
;; 
(define-module a
  (export gen)
  )
(select-module a)

(define-generic gen)
(define-method gen ((a <integer>))
  (+ a 1))
-------------

b.scm
--------------
;; add a method. 
(define-module b
  (export)
  (use a)                            ;so we talk about the same generic
  )
(select-module b)

(define (x y)
  (string-append y "1"))
(Continue reading)

Michal Maruška | 12 Sep 12:42 2004
Picon

Re: modules (import vs use) & generics


Nevermind. I just learned why i have to  (provide "a") :)

Rethinking about the USE, i realized REQUIRE needs that.

-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
Michal Maruška | 13 Sep 00:50 2004
Picon

ref-counting of non-GTK-OBJECTs


I had problems with gdk-pixbufs, consuming memory.
So i started to try to unref them explicitely, as i should be doing, sure.
But (g-object-unref pixbuf) is not enough. Gauche-gtk keeps 2 references.

I think the right place to patch is in src/gauche-gtk.c:

static ScmGObject *make_gobject(ScmClass *klass, GObject *gobj)

..
-    g_object_ref(gobj);
   if (g_type_is_a(G_OBJECT_TYPE(gobj), GTK_TYPE_OBJECT)) {
+        g_object_ref(gobj);
        /* Take floating reference */
        gtk_object_sink(GTK_OBJECT(gobj));
        /* Drop the reference upon destruction. */
        g_signal_connect(GTK_OBJECT(gobj), "destroy",
                         (GCallback)gobject_destroy, (void*)g);
    }

-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
Shiro Kawai | 14 Sep 02:41 2004
Picon

Re: ref-counting of non-GTK-OBJECTs

Thanks, Michal.  I understand the problem.

I think avoiding g_object_ref() in make_gobject for non-gtk-object
isn't enough, though.  The routine is used for two purposes

 1. Gauche-gtk creates a new g_object, and wraps it for ScmObj
 2. Wraps the value returned from gtk routine for ScmObj

In the latter case, we need to increase refcount, since Gauche-gtk
keeps one more reference to the g_object; gtk may unref for some
time later.

I guess the right way is to distinguish the above two cases.

--shiro

-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
Michal Maruška | 17 Sep 11:21 2004
Picon

Re: ref-counting of non-GTK-OBJECTs


Shiro Kawai <shiro@...> writes:

> Thanks, Michal.  I understand the problem.
>
> I think avoiding g_object_ref() in make_gobject for non-gtk-object
> isn't enough, though.  The routine is used for two purposes
>
>  1. Gauche-gtk creates a new g_object, and wraps it for ScmObj

Are you talking about Scm_GtkObjectAllocate?  I didn't know about that way of
creating g-objects. So, i didn't (and stil don't) consider that case.

>  2. Wraps the value returned from gtk routine for ScmObj
>
> In the latter case, we need to increase refcount, since Gauche-gtk
> keeps one more reference to the g_object; gtk may unref for some
> time later.

in this (latter) case,

quoting from http://euler.aero.iitb.ac.in/docs/Graphics/GTK-2.0/gtk/gtkobject.html:

  The most interesting difference between GtkObject and GObject is the "floating" reference 
  count. A GObject is created with a reference count of 1, owned by the creator of the GObject.
  (The owner of a reference is the code section that has the right to call g_object_unref() in     
   order to remove that reference.) A GtkObject is created with a reference count of 1 also, but    
   it isn't owned by anyone; calling g_object_unref() on the newly-created GtkObject is             
   incorrect. Instead, the initial reference count of a GtkObject is "floating". The floating       
   reference can be removed by anyone at any time, by calling gtk_object_sink().                    
(Continue reading)

Shiro Kawai | 18 Sep 01:41 2004
Picon

Specifying character encoding of source code

I've just committed the changes to enable loading source code
of different character encoding than Gauche's native encoding.

This mail describes the feature, how it is implemented, and
an incomatibility with the previous C API.  I'm planning to support
this feature officially in the 0.8.2 release coming in a couple
of weeks.  If you have opinions, let me know.

[Feature]

If the souce code contains a "magic comment" as follows in the first
or second line, the rest of source code is read as it is writtein
in <ces-name>.

 ;; coding: <ces-name>

More precisely, a comment in either first or second line that matches
#/coding[:=]\s*([\w.-]+)/ is recognized.  If there are multiple matches,
only the first one is effective.   The first two lines must not contain
characters other than us-ascii.

Example:

 #!/usr/bin/gosh
 ;; -*- coding: utf-8 -*-

 ... source code in utf-8 ...

If the specified encoding doesn't match the Gauche's native encoding,
Gauche automatically loads gauche.charconv module to do the conversion.
(Continue reading)


Gmane