From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "pelzflorian (Florian Pelz)" Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: Re: Website translations with Haunt Date: Sun, 10 Dec 2017 20:21:43 +0100 Message-ID: <20171210192143.GA1796@floriannotebook.localdomain> References: <20171209180619.GA10254@floriannotebook.localdomain> <337C4CEB-E242-4D3B-B110-E19B485DA0AB@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WIyZ46R2i8wDzkSu" X-Trace: blaine.gmane.org 1512933718 29719 195.159.176.226 (10 Dec 2017 19:21:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 10 Dec 2017 19:21:58 +0000 (UTC) User-Agent: Mutt/1.9.1 (2017-09-22) Cc: Guile User Mailing List , guile-devel To: Matt Wette Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Dec 10 20:21:52 2017 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eO7Ae-0007WK-Kf for guile-devel@m.gmane.org; Sun, 10 Dec 2017 20:21:52 +0100 Original-Received: from localhost ([::1]:49468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eO7Al-0002YO-N9 for guile-devel@m.gmane.org; Sun, 10 Dec 2017 14:21:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eO7Ad-0002Y6-0a for guile-devel@gnu.org; Sun, 10 Dec 2017 14:21:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eO7AZ-0003Al-Rz for guile-devel@gnu.org; Sun, 10 Dec 2017 14:21:51 -0500 Original-Received: from pelzflorian.de ([5.45.111.108]:53314 helo=mail.pelzflorian.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eO7AZ-00039e-Cx; Sun, 10 Dec 2017 14:21:47 -0500 Original-Received: from floriannotebook.localdomain (ip5b431f77.dynamic.kabel-deutschland.de [91.67.31.119]) by mail.pelzflorian.de (Postfix) with ESMTPSA id B55BA36001B; Sun, 10 Dec 2017 20:21:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=pelzflorian.de; s=mail; t=1512933705; bh=dJJ+PMM3r7FfLRQyBtk0iwpOj4M8D7cYDmXOp09Ouss=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=iqmS/lqa0K7xnRiM9SmF+qZpVP+1lK++lLpr//71L/2EP37DLkGCserlXUy3b0jyw yLNAhOuZzKLVN/7Ty5KEBzaG7CzOm8d1mzlT1WosYQH001SOkqdOVjRkH/zXgJxzMj M+ab6rS++b5eTLrIDR2MN1rwEi1D99rguGwQmSSQ= Content-Disposition: inline In-Reply-To: <337C4CEB-E242-4D3B-B110-E19B485DA0AB@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 5.45.111.108 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19405 gmane.lisp.guile.user:14334 Archived-At: --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Dec 10, 2017 at 07:22:55AM -0800, Matt Wette wrote: >=20 > > On Dec 9, 2017, at 10:06 AM, pelzflorian (Florian Pelz) wrote: > > (define xerror-handler-struct > > (make-struct-po_xerror_handler)) ; TODO SET HANDLERS: > > ;; [=E2=80=A6] > >=20 >=20 > First of all, FFI helper + Guile can't deal with this pattern: using vara= rgs function=20 > members in structs. This would require things like `va_arg' in libffi an= d Guile. I=20 > have posted a request on the libffi dev site. Your example also brought = up some gaps > in the ffi helper. Thank you. I=E2=80=99m sorry to say that it did not work. Actually it is not the =E2=80=9Cstruct po_error_handler=E2=80=9D but the =E2=80=9Cstruct po_xerror_handler=E2=80=9D which I need. I believe the =E2= =80=9Cstruct po_error_handler=E2=80=9D is not used anymore in current Gettext but I am n= ot sure. varargs are not needed for =E2=80=9Cstruct po_xerror_handler=E2=80= =9D (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 =E2=80=9Cstruct po_error_handler=E2=80=9D= 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. >=20 >=20 > (define-ffi-module (gettext-po) > #:include '("gettext-po.h") > #:library '("libgettextpo")) >=20 > (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))) > =20 > (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)) =66rom 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)))))) >=20 By the way, what I forgot to mention is that I needed to replace #include in the gettext-po.h header file by typedef long size_t; otherwise =E2=80=9Cguild compile-ffi gettext-po.ffi=E2=80=9D would fail wit= h 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 --WIyZ46R2i8wDzkSu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEwRjGsqAMqXB4uw3y3T6EbElHBVsFAlotiUIACgkQ3T6EbElH BVsz8Q/9HbGBG5aoygyWU+YeB29M+nVu7OPTnouZ8x/FivrRVJvcoK7+CeKkLjP0 56+wY/HunWeSPctr07hPa/jPDhDuqBj9aJx3u0Wx8qgA8vAy5fJoi3BTcsgjr1po dNYamZAHEnELkvRaCcZiLz5IACpPw0gtc/ByZjdRxGR5Cj9fla4MUhXs7CXAhac+ mP84s8j5/ZZbawNoNRvEn0XR3YnXCy69Etk04PXBt6wc4pEOXLzOAELrI5i99DOr aKeXLVm0zk9ZyzCxhgY/oXJ3rpn5NktyC4PHN/PN+UM2C0Pm1eD3gN3YstTkQXYc 48DklEMCcAi2jjWe7zhPsIiOSNZcTQSdFsBPgMWFYZqF1VpD/+6pO3DYFU14qlZJ WlRQEfTRowXcJyctZ8H39it08rpQjIyjVHE2Go3HZtYQwyaDipYG8IvYVABjzUNH 6KK8BRejWNgGUImw49NZjgTQ01gm7m2Fog2r0Kyvrw2kLAFmMigP/sndrGXL2nDE 5xaRQyY/sti6/RmtLB2flqSY+8BZ8Z7XYR5dQ1HPmbNTrI7io57WUFTd7BF8mQyX /whu8NcQIvICaqLa5khCe5TJBYTbr4bwweiLSsNEyv25J3f+AnUB7x7WbjJ9OgKZ EUymYa5i9zWxVhhay9Dj3Vi8BJt5BBQAyGHepfW4NO1biYEHUPM= =0GRT -----END PGP SIGNATURE----- --WIyZ46R2i8wDzkSu--