[Top][All Lists]

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

Re: Request to abstract write operations to stdout and stderr in jitter

From: Jose E. Marchesi
Subject: Re: Request to abstract write operations to stdout and stderr in jitter
Date: Thu, 12 Nov 2020 11:28:20 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Luca!

> The new functionality is not yet used from the rest of the code base,
> but it will soon.  I have tested it with dirty code which is not worth
> committing to git.  Example:
>   jitter_print_context cx = jitter_print_context_make_file_star (stdout);
>   jitter_print_char_star (cx, "===========\n");
>   jitter_print_pointer (cx, main);
>   jitter_print_char_star (cx, "\n===========\n");
>   jitter_print_int (cx, 10, 0); jitter_print_char_star (cx, "\n");
>   jitter_print_begin_class (cx, "interesting");
>   jitter_print_int (cx, 2, 14); jitter_print_char_star (cx, "\n");
>   jitter_print_end_class (cx);
>   jitter_print_int (cx, 10, 1234567); jitter_print_char_star (cx, "\n");
>   jitter_print_ulong_long (cx, 10, 1234567); jitter_print_char_star (cx, 
> "\n");
>   jitter_print_long_long (cx, 10, -123456789012345LL); jitter_print_char_star 
> (cx, "\n");
>   jitter_print_destroy_context (cx);
> I welcome comments.

As far as I understand with this proposal we would need to provide
functions for the pointers in the jitter_print_context_kind_private

 339  struct jitter_print_context_kind_private  
 340  {  
 341    /* All the functions here return 0 on success and a non-zero result on  
 342       failure. */  
 344    /* Print the given character to the pointed underlying channel.  If the 
 345       underlying primitive is interrupted by a recoverable error (of the 
 346       where errno is set to EAGAIN) retry until success. */  
 347    int (* print_char) (jitter_print_context_data d, char c);  
 349    /* Begin using the named class in the pointed underlying channel. */  
 350    int (* begin_class) (jitter_print_context_data d, jitter_print_class 
 352    /* Stop using the named class in the pointed underlying channel.  This 
 353       always called with a class name correctly matching a previous call 
 354       begin_class at the appropriate nesting level. */  
 355    int (* end_class) (jitter_print_context_data d, jitter_print_class c);  
 357    /* Begin a hyperlink pointed to the given destination in the pointed  
 358       underlying channel. */  
 359    int (* begin_hyperlink) (jitter_print_context_data d, jitter_print_url 
 361    /* Close the current hyperlink in the pointed underlying channel.  This 
 362       only called if a current hyperlink does in fact exist. */  
 363    int (* end_hyperlink) (jitter_print_context_data d);  
 365    /* Flush the pointed underlying channel. */  
 366    int (* flush) (jitter_print_context_data d);  
 368    /* Destroy the pointed print context data, without closing the 
 369       channel. */  
 370    int (* destroy_without_flushing) (jitter_print_context_data d);  
 371  };  

Looks like a sensible interface, and similar to pk_term_if.  I like it.

However, I am afraid I don't get the print context thing.  Seems pretty
complicated.  Could you please explain print contexts for dummies?
i.e. for me 8-).


reply via email to

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