diff options
author | David Pirotte <david@altosw.be> | 2022-12-08 23:08:18 -0300 |
---|---|---|
committer | David Pirotte <david@altosw.be> | 2022-12-08 23:08:18 -0300 |
commit | 644a8d042c965aa28d8a3f27f4b6f112e59c2bcb (patch) | |
tree | ce639f5d0b41dcc6e4d1ffec94e4ca5ff18333ca | |
parent | 01c193365c84e77dcc933205892dcf867230ba74 (diff) | |
parent | 8b080aa08d76312d7d7325d98fbcf39a5ebe1f08 (diff) |
Prepare 0.8.0-a.1v0.8.0-a.1
-rw-r--r-- | INSTALL | 14 | ||||
-rw-r--r-- | NEWS | 18 | ||||
-rw-r--r-- | README | 59 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | doc/introduction.texi | 66 | ||||
-rw-r--r-- | doc/variables.texi | 5 | ||||
-rw-r--r-- | examples/gtk-4/peg-solitaire.png | bin | 7854 -> 8294 bytes | |||
-rw-r--r-- | g-golf/gi/common-types.scm | 10 | ||||
-rw-r--r-- | g-golf/gi/registered-type-info.scm | 4 | ||||
-rw-r--r-- | g-golf/gi/repository.scm | 5 | ||||
-rw-r--r-- | g-golf/gi/utils.scm | 41 | ||||
-rw-r--r-- | g-golf/gobject/boxed-types.scm | 4 | ||||
-rw-r--r-- | g-golf/gobject/generic-values.scm | 6 | ||||
-rw-r--r-- | g-golf/gobject/gobject.scm | 5 | ||||
-rw-r--r-- | g-golf/gobject/signals.scm | 28 | ||||
-rw-r--r-- | g-golf/gobject/type-info.scm | 43 | ||||
-rw-r--r-- | g-golf/hl-api/callable.scm | 4 | ||||
-rw-r--r-- | g-golf/hl-api/gobject.scm | 19 | ||||
-rw-r--r-- | g-golf/override/gtk.scm | 4 | ||||
-rw-r--r-- | g-golf/support/bytevector.scm | 120 | ||||
-rw-r--r-- | g-golf/support/libg-golf.scm | 2 | ||||
-rw-r--r-- | g-golf/support/utils.scm | 2 | ||||
-rw-r--r-- | test-suite/tests/override.scm | 26 |
23 files changed, 353 insertions, 136 deletions
@@ -4,7 +4,7 @@ #+BEGIN_COMMENT -Copyright (C) 2016 - 2020 +Copyright (C) 2016 - 2022 Free Software Foundation, Inc. This document is part of GNU G-Golf. @@ -39,8 +39,8 @@ GNU G-Golf needs the following software to run: G-Golf release are [[http://ftp.gnu.org/gnu/g-golf/][here]]. The latest tarballs are: - g-golf-0.1.0.tar.gz - g-golf-0.1.0.tar.gz.sig + g-golf-0.8.0-a.1.tar.gz + g-golf-0.8.0-a.1.tar.gz.sig [ GPG Key: A3057AD7 [ gpg --keyserver keys.gnupg.net --recv-keys A3057AD7 @@ -49,8 +49,8 @@ Assuming you have satisfied the dependencies, open a terminal and proceed with the following steps: cd <download-path> - tar zxf g-golf-0.1.0.tar.gz - cd g-golf-0.1.0 + tar zxf g-golf-0.8.0-a.1.tar.gz + cd g-golf-0.8.0-a.1 ./configure [--prefix=/your/prefix] [--with-guile-site=yes] make make install @@ -115,8 +115,8 @@ Happy hacking! may consult these variables using pkg-config: pkg-config g-golf-1.0 --variable=prefix - pkg-config g-golf-1.0 --variable=exec_prefix - pkg-config g-golf-1.0 --variable=libdir + pkg-config g-golf-1.0 --variable=exec_prefix + pkg-config g-golf-1.0 --variable=libdir You will need - unless the $(libdir) location is already ’known’ by your system - to either define or augment your $LD_LIBRARY_PATH @@ -4,7 +4,7 @@ #+BEGIN_COMMENT -Copyright (C) 2016 - 2018, 2021 +Copyright (C) 2016 - 2022 Free Software Foundation, Inc. This document is part of GNU G-Golf. @@ -26,14 +26,24 @@ warranty. * Latest News -** March 2021 +** December 2022 -[[http://www.gnu.org/software/g-golf][GNU G-Golf]] version 0.1.0 is released. +[[http://www.gnu.org/software/g-golf][GNU G-Golf]] version 0.8.0-a.1 is released. + +This is the first release of the upcoming 0.8.0 release, now available +for testing. + +#+BEGIN_COMMENT +This is the first release of G-Golf. Here is a summary of the changes since version 0.0.0. See GNU G-Golf [[http://git.savannah.gnu.org/cgit/g-golf.git][git summary]] and [[http://git.savannah.gnu.org/cgit/g-golf.git/log/][git log]] for a complete description: - +#+END_COMMENT * Older News +#+BEGIN_COMMENT +This is the first release of G-Golf. + For older News, see [[http://www.gnu.org/software/g-golf/news.html][here]] +#+END_COMMENT @@ -4,7 +4,7 @@ #+BEGIN_COMMENT -Copyright (C) 2016 - 2021 +Copyright (C) 2016 - 2022 Free Software Foundation, Inc. This document is part of GNU G-Golf. @@ -27,24 +27,59 @@ warranty. * GNU G-Golf [[http://www.gnu.org/software/g-golf][GNU G-Golf]] -Gnome: ([[http://www.gnu.org/software/guile][Guile]] Object Library for). +GNOME: ([[http://www.gnu.org/software/guile][Guile]] Object Library for). ** Description -G-Golf is a Guile Object Library for Gnome. - -G-Golf is a library, composed of a direct binding to [[https://developer.gnome.org/gi/][GObject -Introspection]] plus a higher functionality layer, which, importing Gnome -libraries, makes GOBject classes and methods [[http://www.gnu.org/software/guile/manual/html_node/GOOPS.html#GOOPS][GOOPS]] citizen. - -G-Golf is a tool to develop modern graphical applications in Guile -Scheme. +G-Golf is a Guile Object Library for [[https://www.gnome.org/][GNOME]]. + +G-Golf is tool to develop fast and feature-rich graphical applications, +with a recognizable look and feel. + +Here is an overview of the [[https://developer.gnome.org/documentation/introduction/overview/libraries.html][GNOME platform libraries]], accessible using +G-Golf. + +G-Golf uses [[https://docs.gtk.org/glib/index.html][GLib]], [[https://docs.gtk.org/gobject/index.html][GObject]] and [[https://gi.readthedocs.io/en/latest/][GObject Introspection]]. As it imports a +[[https://gi.readthedocs.io/en/latest/][Typelib]] (a GObject introspectable library), G-Golf defines GObject +classes as Guile Object Oriented System ([[https://www.gnu.org/software/guile/manual/html_node/GOOPS.html#GOOPS][GOOPS]]) classes. GObject methods +are defined and added to their corresponding generic function. Simple +functions are defined as scheme procedures. + +Here is an example, an excerpt taken from the peg-solitaire game, that +shows the implementation of GtkApplication activate signal callback +in G-Golf: + +#+BEGIN_SRC scheme +(define (activate app) + (let ((window (make <gtk-application-window> + #:title "Peg Solitaire" + #:default-width 420 + #:default-height 420 + #:application app)) + (header-bar (make <gtk-header-bar>)) + (restart (make <gtk-button> + #:icon-name "view-refresh-symbolic"))) + + (connect restart + 'clicked + (lambda (bt) + (restart-game window))) + + (set-titlebar window header-bar) + (pack-start header-bar restart) + (create-board window) + (show window))) +#+END_SRC + +G-Golf comes with some examples, listed on the [[https://www.gnu.org/software/g-golf/learn.html][learn page]] of the G-Golf +web site. Each example comes with a screenshot and has a link that +points to its source code, in the G-Golf sources [[http://git.savannah.gnu.org/cgit/g-golf.git][repository]]. ** Latest News -XXX 2018 +December 2022 -GNU G-Golf version 0.1.0 is released. +GNU G-Golf version 0.8.0-a.1 is released. Visit the NEWS file or see the [[http://git.savannah.gnu.org/cgit/g-golf.git/tree/NEWS][News]] page for the list of visible changes since the last release, as well as older news. diff --git a/configure.ac b/configure.ac index 1d86113..b4bac88 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ dnl define(G_GOLF_CONFIGURE_COPYRIGHT,[[ -Copyright (C) 2016 - 2021 +Copyright (C) 2016 - 2022 Free Software Foundation, Inc. This file is part of GNU G-Golf @@ -31,7 +31,7 @@ AC_PREREQ(2.69) AC_INIT( [g-golf], - [0.1.0], + [0.8.0-a.1], [bug-g-golf@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/doc/introduction.texi b/doc/introduction.texi index feaddf6..b6bdaae 100644 --- a/doc/introduction.texi +++ b/doc/introduction.texi @@ -1,6 +1,6 @@ @c -*-texinfo-*- @c This is part of the GNU G-Golf Reference Manual. -@c Copyright (C) 2016 - 2021 Free Software Foundation, Inc. +@c Copyright (C) 2016 - 2022 Free Software Foundation, Inc. @c See the file g-golf.texi for copying conditions. @@ -33,25 +33,49 @@ G-Golf is a Guile@footnote{GNU @uref{@value{UGUILE}, Guile}@*an interpreter and compiler for the @uref{@value{USCHEME}, Scheme} programming language.} Object Library for @uref{@value{UGNOME}, GNOME}. -G-Golf low level API comprises a binding to - (most of) the -@uref{@value{UGI}, GObject Introspection} and (some of) the -@uref{@value{UGOBJECT}, GObject} and @uref{@value{UGLIB}, Glib} -libraries, as well as additional (G-Golf) utilities - used to import -GObject libraries and build their corresponding G-Golf high level API. - -@indentedblock -@strong{Note:} to be precise, G-Golf imports (and depends on the -exitence of) a @uref{@value{UGI-OVERVIEW}, Typelib} - a binary, -readonly, memory-mappable database containing reflective information -about a GObject library. -@end indentedblock - -G-Golf high level API makes (imported) GObject classes and methods -available using GOOPS, the Guile Object Oriented System (@pxref{GOOPS,,, -guile, The GNU Guile Reference Manual}). - -G-Golf is a tool to develop modern graphical applications. - +G-Golf is a tool to develop fast and feature-rich graphical +applications, with a clean and recognizable look and feel. Here is an +overview of the @uref{@value{UGNOME-Libraries}, GNOME platform +libraries}, accessible using G-Golf. + +G-Golf uses @uref{@value{UGLIB}, Glib}, @uref{@value{UGOBJECT}, GObject} +and @uref{@value{UGI-OVERVIEW}, GObject Introspection}. As it imports a +@uref{@value{UGI-OVERVIEW}, Typelib} (a GObject introspectable library), +G-Golf defines GObject classes as GOOPS@footnote{The Guile Object +Oriented System, @xref{GOOPS,,, guile, The GNU Guile Reference Manual}} +classes. GObject methods are defined and added to their corresponding +generic function. Simple functions are defined as scheme procedures. + +Here is an example, an excerpt taken from the peg-solitaire game, that +shows the implementation, for the peg-solitaire game, of the +GtkApplication activate signal callback in G-Golf: + +@lisp +(define (activate app) + (let ((window (make <gtk-application-window> + #:title "Peg Solitaire" + #:default-width 420 + #:default-height 420 + #:application app)) + (header-bar (make <gtk-header-bar>)) + (restart (make <gtk-button> + #:icon-name "view-refresh-symbolic"))) + + (connect restart + 'clicked + (lambda (bt) + (restart-game window))) + + (set-titlebar window header-bar) + (pack-start header-bar restart) + (create-board window) + (show window))) +@end lisp + +G-Golf comes with some examples, listed on the +@uref{@value{UG-GOLF-learn}, learn page} of the G-Golf web site. Each +example comes with a screenshot and has a link that points to its source +code, in the G-Golf sources @uref{@value{UG-GOLF-GIT}, repository}. @subheading Savannah @@ -86,7 +110,7 @@ Automake >= 1.14 Makeinfo >= 6.6 @item -@uref{@value{UGUILE}, Guile} >= 2.0.14 [allows 2.2 3.0] +@uref{@value{UGUILE}, Guile} >= 2.0.14 [allows 2.2 3.0 (>= 3.0.7)] @item @uref{@value{UGUILE-LIB}, Guile-Lib} >= 0.2.5 diff --git a/doc/variables.texi b/doc/variables.texi index aa56bb8..7c83ad8 100644 --- a/doc/variables.texi +++ b/doc/variables.texi @@ -1,6 +1,6 @@ @c -*-texinfo-*- @c This is part of the GNU G-Golf Reference Manual. -@c Copyright (C) 2016 - 2021 Free Software Foundation, Inc. +@c Copyright (C) 2016 - 2022 Free Software Foundation, Inc. @c See the file g-golf.texi for copying conditions. @@ -18,6 +18,7 @@ @set USCHEME http://schemers.org @set UG-GOLF http://www.gnu.org/software/g-golf/ +@set UG-GOLF-learn https://www.gnu.org/software/g-golf/learn.html @set UG-GOLF-RELEASES http://ftp.gnu.org/gnu/g-golf/ @set UG-GOLF-LATEST http://ftp.gnu.org/gnu/g-golf/g-golf-@value{VERSION}.tar.gz @set UG-GOLF-SAVANNAH https://savannah.gnu.org/projects/g-golf @@ -62,6 +63,8 @@ @set UGITypeInfo https://developer.gnome.org/gi/stable/gi-GITypeInfo.html @set UGIValueInfo https://developer.gnome.org/gi/stable/gi-GIValueInfo.html +@set UGNOME-Libraries https://developer.gnome.org/documentation/introduction/overview/libraries.html + @set UGLIB https://developer.gnome.org/glib/stable/ @set UGLIB-Mem-Alloc https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html @set UGLIB-Main-Event-Loop https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html diff --git a/examples/gtk-4/peg-solitaire.png b/examples/gtk-4/peg-solitaire.png Binary files differindex 1b1861f..96e37f2 100644 --- a/examples/gtk-4/peg-solitaire.png +++ b/examples/gtk-4/peg-solitaire.png diff --git a/g-golf/gi/common-types.scm b/g-golf/gi/common-types.scm index a1f00f6..4d42d42 100644 --- a/g-golf/gi/common-types.scm +++ b/g-golf/gi/common-types.scm @@ -36,6 +36,7 @@ #:use-module (g-golf init) #:use-module (g-golf support enum) #:use-module (g-golf support union) + #:use-module (g-golf support bytevector) #:use-module (g-golf gi utils) #:duplicates (merge-generics @@ -196,7 +197,10 @@ add as a comment)." ((uint64) 'v-uint64) ((float) 'v-float) ((double) 'v-double) - ((gtype) 'v-ulong) + ((gtype) (case (sizeof size_t) + ((4) 'v-uint32) + ((8) 'v-uint64) + (else (error "what machine is this?")))) ((short) 'v-short) ;; <- from CL implementtion ((ushort) 'v-ushort) ((int) 'v-int) @@ -232,8 +236,8 @@ add as a comment)." int32) s32vector-ref) ((uint32) u32vector-ref) ((int64) s64vector-ref) - ((uint64 - gtype) u64vector-ref) + ((uint64) u64vector-ref) + ((gtype) gtypevector-ref) ((float) f32vector-ref) ((double) f64vector-ref) (else diff --git a/g-golf/gi/registered-type-info.scm b/g-golf/gi/registered-type-info.scm index d4921b7..99eea25 100644 --- a/g-golf/gi/registered-type-info.scm +++ b/g-golf/gi/registered-type-info.scm @@ -1,7 +1,7 @@ ;; -*- mode: scheme; coding: utf-8 -*- ;;;; -;;;; Copyright (C) 2016, 2021 +;;;; Copyright (C) 2016, 2022 ;;;; Free Software Foundation, Inc. ;;;; This file is part of GNU G-Golf @@ -84,7 +84,7 @@ (list '*))) (define g_registered_type_info_get_g_type - (pointer->procedure int64 + (pointer->procedure size_t (dynamic-func "g_registered_type_info_get_g_type" %libgirepository) (list '*))) diff --git a/g-golf/gi/repository.scm b/g-golf/gi/repository.scm index 51134db..d3fd563 100644 --- a/g-golf/gi/repository.scm +++ b/g-golf/gi/repository.scm @@ -1,7 +1,7 @@ ;; -*- mode: scheme; coding: utf-8 -*- ;;;; -;;;; Copyright (C) 2016, 2020 +;;;; Copyright (C) 2016, 2022 ;;;; Free Software Foundation, Inc. ;;;; This file is part of GNU G-Golf @@ -217,7 +217,8 @@ (pointer->procedure '* (dynamic-func "g_irepository_find_by_gtype" %libgirepository) - (list '* unsigned-long))) + (list '* + size_t))) (define g_irepository_find_by_name (pointer->procedure '* diff --git a/g-golf/gi/utils.scm b/g-golf/gi/utils.scm index 8b8a24c..9184e38 100644 --- a/g-golf/gi/utils.scm +++ b/g-golf/gi/utils.scm @@ -1,7 +1,7 @@ ;; -*- mode: scheme; coding: utf-8 -*- ;;;; -;;;; Copyright (C) 2016 - 2021 +;;;; Copyright (C) 2016 - 2022 ;;;; Free Software Foundation, Inc. ;;;; This file is part of GNU G-Golf @@ -251,16 +251,16 @@ (if (or (not pointer) (null-pointer? pointer)) '() - (letrec* ((u64-size (sizeof unsigned-long)) + (letrec* ((s-size_t (sizeof size_t)) (gi-gtypes->scm-1 (lambda (pointer result) (receive (d-pointer) (dereference-pointer pointer) (if (null-pointer? d-pointer) (reverse! result) - (let ((u64 (pointer->bytevector pointer u64-size))) - (gi-gtypes->scm-1 (gi-pointer-inc pointer u64-size) - (cons (u64vector-ref u64 0) + (let ((bv (pointer->bytevector pointer s-size_t))) + (gi-gtypes->scm-1 (gi-pointer-inc pointer s-size_t) + (cons (gtypevector-ref bv 0) result)))))))) (gi-gtypes->scm-1 pointer '())))) @@ -269,15 +269,14 @@ (null-pointer? pointer) (= n-gtype 0)) '() - (let ((u64 (pointer->bytevector pointer - (* n-gtype - (sizeof unsigned-long))))) + (let ((bv (pointer->bytevector pointer + (* n-gtype (sizeof size_t))))) (let loop ((i 0) (results '())) (if (= i n-gtype) (reverse! results) (loop (+ i 1) - (cons (u64vector-ref u64 i) + (cons (gtypevector-ref bv i) results))))))) @@ -417,17 +416,17 @@ (if (null? lst) %null-pointer (let* ((n-gtype (or n-gtype (length lst))) - (u64 (make-u64vector n-gtype 0))) + (bv (make-gtypevector n-gtype 0))) (let loop ((lst lst) (i 0)) (match lst (() - (bytevector->pointer u64)) + (bytevector->pointer bv)) ((g-type . rest) - (u64vector-set! u64 i - (if (symbol? g-type) - (symbol->g-type g-type) - g-type)) + (gtypevector-set! bv i + (if (symbol? g-type) + (symbol->g-type g-type) + g-type)) (loop rest (+ i 1)))))))) @@ -435,16 +434,16 @@ (if (null? lst) %null-pointer (let* ((n-gtype (length lst)) - (u64 (make-u64vector (+ n-gtype 1) 0))) + (bv (make-gtypevector (+ n-gtype 1) 0))) (let loop ((lst lst) (i 0)) (match lst (() - (bytevector->pointer u64)) + (bytevector->pointer bv)) ((g-type . rest) - (u64vector-set! u64 i - (if (symbol? g-type) - (symbol->g-type g-type) - g-type)) + (gtypevector-set! bv i + (if (symbol? g-type) + (symbol->g-type g-type) + g-type)) (loop rest (+ i 1)))))))) diff --git a/g-golf/gobject/boxed-types.scm b/g-golf/gobject/boxed-types.scm index da7be46..e961ebc 100644 --- a/g-golf/gobject/boxed-types.scm +++ b/g-golf/gobject/boxed-types.scm @@ -62,11 +62,11 @@ (pointer->procedure void (dynamic-func "g_boxed_free" %libgobject) - (list unsigned-long ;; g-type + (list size_t ;; g-type '*))) ;; g-pointer (define g_strv_get_type - (pointer->procedure unsigned-long + (pointer->procedure size_t (dynamic-func "g_strv_get_type" %libgobject) (list ))) ;; void diff --git a/g-golf/gobject/generic-values.scm b/g-golf/gobject/generic-values.scm index 0049f67..5e31d8d 100644 --- a/g-golf/gobject/generic-values.scm +++ b/g-golf/gobject/generic-values.scm @@ -1,7 +1,7 @@ ;; -*- mode: scheme; coding: utf-8 -*- ;;;; -;;;; Copyright (C) 2016 - 2020 +;;;; Copyright (C) 2016 - 2022 ;;;; Free Software Foundation, Inc. ;;;; This file is part of GNU G-Golf @@ -53,7 +53,7 @@ ;;; (define %g-value-struct - (list unsigned-long double double)) + (list size_t double double)) ;; from libg-golf (define (g-value-size) @@ -85,7 +85,7 @@ (dynamic-func "g_value_init" %libgobject) (list '* - unsigned-long))) + size_t))) (define g_value_unset (pointer->procedure void diff --git a/g-golf/gobject/gobject.scm b/g-golf/gobject/gobject.scm index a24665a..01fedf6 100644 --- a/g-golf/gobject/gobject.scm +++ b/g-golf/gobject/gobject.scm @@ -133,13 +133,14 @@ (pointer->procedure '* (dynamic-func "g_object_new" %libgobject) - (list unsigned-long '*))) + (list size_t ;; g-type + '*))) ;; properties... (define g_object_new_with_properties (pointer->procedure '* (dynamic-func "g_object_new_with_properties" %libgobject) - (list unsigned-long ;; the g-type + (list size_t ;; g-type unsigned-int ;; n-properties '* ;; *names[] '*))) ;; values[] diff --git a/g-golf/gobject/signals.scm b/g-golf/gobject/signals.scm index 6118982..e6bdc1c 100644 --- a/g-golf/gobject/signals.scm +++ b/g-golf/gobject/signals.scm @@ -35,6 +35,7 @@ #:use-module (g-golf support utils) #:use-module (g-golf support enum) #:use-module (g-golf support flags) + #:use-module (g-golf support bytevector) #:use-module (g-golf glib mem-alloc) #:use-module (g-golf glib quarks) #:use-module (g-golf gobject type-info) @@ -63,9 +64,9 @@ (define %g-signal-query-struct (list unsigned-int ;; id '* ;; name - unsigned-long ;; g-type + size_t ;; g-type unsigned-int ;; flags - unsigned-long ;; return-type + size_t ;; return-type unsigned-int ;; n-param '*)) ;; param-types @@ -158,10 +159,9 @@ (if (= n-param 0) '() (map g-type->symbol - (u64vector->list + (gtypevector->list (pointer->bytevector param-types - (* n-param - (sizeof unsigned-long))))))) + (* n-param (sizeof size_t))))))) ;;; @@ -175,19 +175,19 @@ (list unsigned-int ;; id '*))) ;; query -(define g_signal_list_ids - (pointer->procedure '* - (dynamic-func "g_signal_list_ids" - %libgobject) - (list unsigned-long ;; g-type - '*))) ;; n-id (pointer to guint) - (define g_signal_lookup (pointer->procedure unsigned-int (dynamic-func "g_signal_lookup" %libgobject) (list '* ;; name - unsigned-long))) ;; g-type + size_t))) ;; g-type + +(define g_signal_list_ids + (pointer->procedure '* + (dynamic-func "g_signal_list_ids" + %libgobject) + (list size_t ;; g-type + '*))) ;; n-id (pointer to guint) (define g_signal_connect_closure_by_id (pointer->procedure unsigned-long @@ -204,7 +204,7 @@ (dynamic-func "g_signal_parse_name" %libgobject) (list '* ;; detailed signal - unsigned-long ;; g-type + size_t ;; g-type '* ;; signal id '* ;; detail (g-quark) int))) ;; force detail quark (boolean) diff --git a/g-golf/gobject/type-info.scm b/g-golf/gobject/type-info.scm index 8657948..605d0b2 100644 --- a/g-golf/gobject/type-info.scm +++ b/g-golf/gobject/type-info.scm @@ -34,6 +34,7 @@ #:use-module (rnrs arithmetic bitwise) #:use-module (g-golf init) #:use-module (g-golf support flags) + #:use-module (g-golf support bytevector) #:use-module (g-golf glib mem-alloc) #:use-module (g-golf gi cache-gi) #:use-module (g-golf gi utils) @@ -132,19 +133,19 @@ (define (g-type-interfaces g-type) (let* ((s-uint (sizeof unsigned-int)) - (s-ulong (sizeof unsigned-long)) + (s-size_t (sizeof size_t)) (n-iface-bv (make-bytevector s-uint 0)) (ifaces (g_type_interfaces g-type (bytevector->pointer n-iface-bv))) (n-iface (u32vector-ref n-iface-bv 0)) - (results (u64vector->list + (results (gtypevector->list (pointer->bytevector ifaces - (* n-iface s-ulong) 0)))) + (* n-iface s-size_t))))) (g-free ifaces) results)) (define %g-type-query-struct - (list unsigned-long ;; g-type + (list size_t ;; g-type '* ;; type-name unsigned-int ;; class-size unsigned-int)) ;; instance-size @@ -246,38 +247,38 @@ (pointer->procedure '* (dynamic-func "g_type_name" %libgobject) - (list unsigned-long))) + (list size_t))) (define g_type_from_name - (pointer->procedure unsigned-long + (pointer->procedure size_t (dynamic-func "g_type_from_name" %libgobject) (list '*))) (define g_type_parent - (pointer->procedure unsigned-long + (pointer->procedure size_t (dynamic-func "g_type_parent" %libgobject) - (list unsigned-long))) + (list size_t))) (define g_type_is_a (pointer->procedure int (dynamic-func "g_type_is_a" %libgobject) - (list unsigned-long - unsigned-long))) + (list size_t + size_t))) (define g_type_class_ref (pointer->procedure '* (dynamic-func "g_type_class_ref" %libgobject) - (list unsigned-long))) + (list size_t))) (define g_type_class_peek (pointer->procedure '* (dynamic-func "g_type_class_peek" %libgobject) - (list unsigned-long))) + (list size_t))) (define g_type_class_unref (pointer->procedure void @@ -290,27 +291,27 @@ (dynamic-func "g_type_interface_peek" %libgobject) (list '* ;; g-class - unsigned-long))) ;; iface-type + size_t))) ;; iface-type (define g_type_interfaces (pointer->procedure '* (dynamic-func "g_type_interfaces" %libgobject) - (list unsigned-long ;; g-type + (list size_t ;; g-type '*))) ;; n-iface (pointer to guint) (define g_type_query (pointer->procedure void (dynamic-func "g_type_query" %libgobject) - (list unsigned-long + (list size_t '*))) (define g_type_register_static_simple - (pointer->procedure unsigned-long + (pointer->procedure size_t (dynamic-func "g_type_register_static_simple" %libgobject) - (list unsigned-long ;; parent-type + (list size_t ;; parent-type '* ;; type-name unsigned-int ;; class-size '* ;; class-init (func) @@ -322,21 +323,21 @@ (pointer->procedure void (dynamic-func "g_type_add_interface_static" %libgobject) - (list unsigned-long ;; g-type - unsigned-long ;; iface-type + (list size_t ;; g-type + size_t ;; iface-type '*))) ;; iface-info (define g_type_fundamental (pointer->procedure size_t (dynamic-func "g_type_fundamental" %libgobject) - (list unsigned-long))) + (list size_t))) (define g_type_ensure (pointer->procedure void (dynamic-func "g_type_ensure" %libgobject) - (list unsigned-long))) + (list size_t))) ;;; diff --git a/g-golf/hl-api/callable.scm b/g-golf/hl-api/callable.scm index dbc38cd..cbc966a 100644 --- a/g-golf/hl-api/callable.scm +++ b/g-golf/hl-api/callable.scm @@ -726,8 +726,8 @@ gi-arg-val))) (gi->scm foreign 'string))) ((gtype) - (let ((val (gi-argument-ref gi-argument 'v-ulong))) - (g-type->symbol val))) + (gi-argument-ref gi-argument + (gi-type-tag->field 'gtype))) ((void) (let* ((gi-arg-val (gi-argument-ref gi-argument 'v-pointer)) (foreign (if is-pointer? diff --git a/g-golf/hl-api/gobject.scm b/g-golf/hl-api/gobject.scm index 841d307..7f88f13 100644 --- a/g-golf/hl-api/gobject.scm +++ b/g-golf/hl-api/gobject.scm @@ -62,6 +62,7 @@ g-object-find-class-by-g-type g-object-find-class g-object-make-class + g-interface-make-class gi-add-method gi-add-method-gf)) @@ -503,10 +504,24 @@ (m-var (module-variable module name))) (or (and m-var (variable-ref m-var)) - (scm-error 'unbound-variable #f "No such GInterface : ~S" - (list name) #f)))) + (g-interface-make-class g-type)))) ifaces))) +(define (g-interface-make-class g-type) + (let* ((module (resolve-module '(g-golf hl-api gobject))) + (public-i (module-public-interface module)) + (g-name (or (g-type-name g-type) ;; we use 0 as a g-type + "AGInterfaceRuntimeClass")) ;; to test/debug + (c-name (g-name->class-name g-name)) + (c-inst (make-class `(,<ginterface>) + '() + #:name c-name + #:g-type g-type))) + (module-define! module c-name c-inst) + (module-add! public-i c-name + (module-variable module c-name)) + c-inst)) + (define (gi-add-method generic specializers procedure) (for-each (lambda (xp-spec) (add-method! generic diff --git a/g-golf/override/gtk.scm b/g-golf/override/gtk.scm index 6415ce5..37cb905 100644 --- a/g-golf/override/gtk.scm +++ b/g-golf/override/gtk.scm @@ -100,7 +100,7 @@ (g-value-set-value ,(@@ (g-golf hl-api gobject) %g-inst-set-property-value)) (g-type (gtk-tree-model-get-column-type store column)) - (g-value (g-value-init (symbol->g-type g-type)))) + (g-value (g-value-init g-type))) (g-value-set! g-value (g-value-set-value g-type value)) (i-func store iter column g-value) @@ -116,7 +116,7 @@ (g-value-set-value ,(@@ (g-golf hl-api gobject) %g-inst-set-property-value)) (g-type (gtk-tree-model-get-column-type store column)) - (g-value (g-value-init (symbol->g-type g-type)))) + (g-value (g-value-init g-type))) (g-value-set! g-value (g-value-set-value g-type value)) (i-func store iter column g-value) diff --git a/g-golf/support/bytevector.scm b/g-golf/support/bytevector.scm index c5309dc..a97b0b6 100644 --- a/g-golf/support/bytevector.scm +++ b/g-golf/support/bytevector.scm @@ -1,7 +1,7 @@ ;; -*- mode: scheme; coding: utf-8 -*- ;;;; -;;;; Copyright (C) 2019 +;;;; Copyright (C) 2019 - 2022 ;;;; Free Software Foundation, Inc. ;;;; This file is part of GNU G-Golf @@ -27,11 +27,24 @@ (define-module (g-golf support bytevector) + #:use-module (ice-9 match) #:use-module (system foreign) #:use-module (rnrs bytevectors) #:export (bv-ptr-ref - bv-ptr-set!)) + bv-ptr-set! + + make-gtypevector + gtypevector-ref + gtypevector-set! + gtypevector->list + list->gtypevector + + make-ulongvector + ulongvector-ref + ulongvector-set! + ulongvector->list + list->ulongvector)) (define %align @@ -54,3 +67,106 @@ (bv (pointer->bytevector foreign size)) (offset (%align 0 (alignof '*)))) (%bv-ptr-set! bv offset val))) + + +;;; +;;; Support for GLib and C types that varies in length +;;; depending on the platform +;;; + +;;; +;;; GType +;;; + +(define make-gtypevector + (case (sizeof size_t) + ((8) (lambda (n . value) + (match value + (() (make-u64vector n)) + ((val) (make-u64vector n val))))) + ((4) (lambda (n . value) + (match value + (() (make-u32vector n)) + ((val) (make-u32vector n val))))) + (else (error "what machine is this?")))) + +(define gtypevector-ref + (case (sizeof size_t) + ((8) (lambda (bv offset) + (u64vector-ref bv offset))) + ((4) (lambda (bv offset) + (u32vector-ref bv offset))) + (else (error "what machine is this?")))) + +(define gtypevector-set! + (case (sizeof size_t) + ((8) (lambda (bv offset value) + (u64vector-set! bv offset value))) + ((4) (lambda (bv offset value) + (u32vector-set! bv offset value))) + (else (error "what machine is this?")))) + +(define gtypevector->list + (case (sizeof size_t) + ((8) (lambda (bv) + (u64vector->list bv))) + ((4) (lambda (bv) + (u32vector->list bv))) + (else (error "what machine is this?")))) + +(define list->gtypevector + (case (sizeof size_t) + ((8) (lambda (lst) + (list->u64vector lst))) + ((4) (lambda (lst) + (list->u32vector lst))) + (else (error "what machine is this?")))) + + +;;; +;;; unsigned-long +;;; + +(define make-ulongvector + (case (sizeof unsigned-long) + ((8) (lambda (n . value) + (match value + (() (make-u64vector n)) + ((val) (make-u64vector n val))))) + ((4) (lambda (n . value) + (match value + (() (make-u32vector n)) + ((val) (make-u32vector n val))))) + (else (error "what machine is this?")))) + +(define ulongvector-ref + (case (sizeof unsigned-long) + ((8) (lambda (bv offset) + (u64vector-ref bv offset))) + ((4) (lambda (bv offset) + (u32vector-ref bv offset))) + (else (error "what machine is this?")))) + +(define ulongvector-set! + (case (sizeof unsigned-long) + ((8) (lambda (bv offset value) + (u64vector-set! bv offset value))) + ((4) (lambda (bv offset value) + (u32vector-set! bv offset value))) + (else (error "what machine is this?")))) + +(define ulongvector->list + (case (sizeof unsigned-long) + ((8) (lambda (bv) + (u64vector->list bv))) + ((4) (lambda (bv) + (u32vector->list bv))) + (else (error "what machine is this?")))) + +(define list->ulongvector + (case (sizeof unsigned-long) + ((8) (lambda (lst) + (list->u64vector lst))) + ((4) (lambda (lst) + (list->u32vector lst))) + (else (error "what machine is this?")))) diff --git a/g-golf/support/libg-golf.scm b/g-golf/support/libg-golf.scm index d6ddaf5..539d252 100644 --- a/g-golf/support/libg-golf.scm +++ b/g-golf/support/libg-golf.scm @@ -119,7 +119,7 @@ (list))) (define g_object_type - (pointer->procedure unsigned-long + (pointer->procedure size_t (dynamic-func "g_object_type" %libg-golf) (list '*))) diff --git a/g-golf/support/utils.scm b/g-golf/support/utils.scm index 7324398..1d0458e 100644 --- a/g-golf/support/utils.scm +++ b/g-golf/support/utils.scm @@ -470,7 +470,7 @@ renamer must be defined: " snp-prefix snp-postfix snp-renamer))))) float double) (eval type-tag (current-module))) - ((gtype) unsigned-long) + ((gtype) size_t) ((utf8 filename array diff --git a/test-suite/tests/override.scm b/test-suite/tests/override.scm index ef2d58b..e524186 100644 --- a/test-suite/tests/override.scm +++ b/test-suite/tests/override.scm @@ -1,7 +1,7 @@ ;; -*- mode: scheme; coding: utf-8 -*- ;;;; -;;;; Copyright (C) 2020 +;;;; Copyright (C) 2020 - 2022 ;;;; Free Software Foundation, Inc. ;;;; This file is part of GNU G-Golf @@ -37,15 +37,23 @@ warn last)) +(eval-when (expand load eval) + (use-modules (oop goops)) -(for-each (lambda (item) - (gi-import-by-name "Gtk" item #:version "3.0")) - '("HPaned" - "VPaned" - "TreeView" - "ListStore" - "TextBuffer" - "init")) + (default-duplicate-binding-handler + '(merge-generics replace warn-override-core warn last)) + + (use-modules (g-golf)) + + (g-irepository-require "Gtk" #:version "3.0") + (for-each (lambda (item) + (gi-import-by-name "Gtk" item)) + '("HPaned" + "VPaned" + "TreeView" + "ListStore" + "TextBuffer" + "init"))) (gtk-init 0 '()) |