unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>
To: Matt Wette <matt.wette@gmail.com>
Cc: Guile User Mailing List <guile-user@gnu.org>,
	guile-devel <guile-devel@gnu.org>
Subject: Re: Website translations with Haunt
Date: Sun, 10 Dec 2017 20:21:43 +0100	[thread overview]
Message-ID: <20171210192143.GA1796@floriannotebook.localdomain> (raw)
In-Reply-To: <337C4CEB-E242-4D3B-B110-E19B485DA0AB@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3883 bytes --]

On Sun, Dec 10, 2017 at 07:22:55AM -0800, Matt Wette wrote:
> 
> > On Dec 9, 2017, at 10:06 AM, pelzflorian (Florian Pelz) <pelzflorian@pelzflorian.de> wrote:
> > (define xerror-handler-struct
> >  (make-struct-po_xerror_handler)) ; TODO SET HANDLERS:
> > ;; […]
> > 
> 
> First of all, FFI helper + Guile can't deal with this pattern: using varargs function 
> members in structs.  This would require things like `va_arg' in libffi and Guile.  I 
> have posted a request on the libffi dev site.  Your example also brought up some gaps
> in the ffi helper.

Thank you.  I’m sorry to say that it did not work.

Actually it is not the “struct po_error_handler” but the
“struct po_xerror_handler” which I need.  I believe the “struct
po_error_handler” is not used anymore in current Gettext but I am not
sure.  varargs are not needed for “struct po_xerror_handler” (even
though support for them is desirable in general).

Hmm I tried mostly the same as you propose before for the xerror
handler and it did not work: fh-object-set! apparently did not have
any effect, i.e. a subsequent fh-object-ref returned 0 and on error
the callback handler function was called at address 0, causing a
SIGSEGV.

Either way, I tried your code for “struct po_error_handler” and put it
in my dot.ffi to see if it works.


> I think I may have a workaround for you, though.  Try to add code
> like the following to your dot-ffi file.  In functions calls that want a error handler
> specified use std-po-error-handler.
> 
> 
> (define-ffi-module (gettext-po)
>   #:include '("gettext-po.h")
>   #:library '("libgettextpo"))
> 
> (define-public std-po-error-handler
>   (let* ((error
> 	  (lambda (status errnum format)
> 	    (simple-format #t "~A\n" (ffi:pointer->string format))))
> 	 (error-p
> 	  (ffi:procedure->pointer ffi:void error (list ffi:int ffi:int '*)))
> 	 ;;
> 	 (error_at_line
> 	  (lambda (status errnum filename lineno format)
> 	    (simple-format #t "~A\n" (ffi:pointer->string format))))
> 	 (error_at_line-p
> 	  (ffi:procedure->pointer ffi:void error_at_line
> 				  (list ffi:int ffi:int '* ffi:int '*)))
> 	 ;;
> 	 (multiline_warning
> 	  (lambda (prefix message)
> 	    (simple-format #t "~A ~A\n"
> 			   (ffi:pointer->string prefix)
> 			   (ffi:pointer->string message))))
> 	 (multiline_warning-p
> 	  (ffi:procedure->pointer ffi:void multiline_warning (list '* '*)))
> 	 ;;
> 	 (multiline_error
> 	  (lambda (prefix message)
> 	    (simple-format #t "~A ~A\n" prefix message)))
> 	 (multiline_error-p
> 	  (ffi:procedure->pointer ffi:void multiline_error (list '* '*)))
> 	 ;;
> 	 (eh-struct (make-struct-po_error_handler)))
>     
>     (fh-object-set! eh-struct 'error error-p)


I inserted an

    (display (fh-object-ref eh-struct 'error)) (newline)

at this point at this point in the dot.ffi file.  Then when I ran

(use-modules (gettext-po))

from the REPL it printed 0, so presumably this does not work either.
It seems like the same issue.

>     (fh-object-set! eh-struct 'error_at_line error_at_line-p)
>     (fh-object-set! eh-struct 'multiline_warning multiline_warning-p)
>     (fh-object-set! eh-struct 'multiline_error multiline_error-p)
>     ;;
>     (make-po_error_handler_t
>      (ffi:pointer-address
>       ((fht-unwrap struct-po_error_handler*)
>        (pointer-to eh-struct))))))
> 



By the way, what I forgot to mention is that I needed to replace

#include <stdlib.h>

in the gettext-po.h header file by

typedef long size_t;

otherwise “guild compile-ffi gettext-po.ffi” would fail with the error
message

ffi-help: WARNING: the FFI helper is experimental
(unknown):1: not found: "gnu/stubs-32.h"
compile-ffi: parse failed

So this change is needed in order to reproduce my issue.

Regards,
Florian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-12-10 19:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-09 18:06 Website translations with Haunt pelzflorian (Florian Pelz)
2017-12-09 18:15 ` ng0
2017-12-09 21:08   ` pelzflorian (Florian Pelz)
2017-12-09 22:29     ` ng0
2017-12-13 14:53       ` pelzflorian (Florian Pelz)
2017-12-10 15:22 ` Matt Wette
2017-12-10 19:21   ` pelzflorian (Florian Pelz) [this message]
2017-12-10 22:35     ` Matt Wette
2017-12-12  7:51       ` pelzflorian (Florian Pelz)
2017-12-12  8:03         ` ng0
2017-12-12  9:30           ` pelzflorian (Florian Pelz)
2017-12-12 13:45             ` Matt Wette
2017-12-12 18:47               ` pelzflorian (Florian Pelz)
2017-12-10 23:00     ` Matt Wette
2017-12-12  8:17       ` pelzflorian (Florian Pelz)
2017-12-14  9:16 ` Ludovic Courtès
2017-12-14 13:23   ` Thompson, David
2017-12-15 11:39     ` pelzflorian (Florian Pelz)
2017-12-15 14:01   ` pelzflorian (Florian Pelz)
2017-12-15  3:48 ` Christopher Lemmer Webber
2017-12-15  8:34   ` pelzflorian (Florian Pelz)
2017-12-15 12:06   ` ng0
2017-12-15 14:25     ` pelzflorian (Florian Pelz)
2017-12-16  9:54     ` Ricardo Wurmus
2017-12-16 12:37       ` pelzflorian (Florian Pelz)
2017-12-16 15:26 ` sirgazil
2017-12-16 19:30   ` pelzflorian (Florian Pelz)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171210192143.GA1796@floriannotebook.localdomain \
    --to=pelzflorian@pelzflorian.de \
    --cc=guile-devel@gnu.org \
    --cc=guile-user@gnu.org \
    --cc=matt.wette@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).