[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Website translations with Haunt

From: Matt Wette
Subject: Re: Website translations with Haunt
Date: Sun, 10 Dec 2017 07:22:55 -0800

> On Dec 9, 2017, at 10:06 AM, pelzflorian (Florian Pelz) <address@hidden> 
> 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 
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.  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 
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))))
          (ffi:procedure->pointer ffi:void error (list ffi:int ffi:int '*)))
          (lambda (status errnum filename lineno format)
            (simple-format #t "~A\n" (ffi:pointer->string format))))
          (ffi:procedure->pointer ffi:void error_at_line
                                  (list ffi:int ffi:int '* ffi:int '*)))
          (lambda (prefix message)
            (simple-format #t "~A ~A\n"
                           (ffi:pointer->string prefix)
                           (ffi:pointer->string message))))
          (ffi:procedure->pointer ffi:void multiline_warning (list '* '*)))
          (lambda (prefix message)
            (simple-format #t "~A ~A\n" prefix message)))
          (ffi:procedure->pointer ffi:void multiline_error (list '* '*)))
         (eh-struct (make-struct-po_error_handler)))
    (fh-object-set! eh-struct 'error error-p)
    (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)
      ((fht-unwrap struct-po_error_handler*)
       (pointer-to eh-struct))))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]