poke-devel
[Top][All Lists]
Advanced

[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
struct:

 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. */  
 343    
 344    /* Print the given character to the pointed underlying channel.  If the 
 
 345       underlying primitive is interrupted by a recoverable error (of the 
kind  
 346       where errno is set to EAGAIN) retry until success. */  
 347    int (* print_char) (jitter_print_context_data d, char c);  
 348    
 349    /* Begin using the named class in the pointed underlying channel. */  
 350    int (* begin_class) (jitter_print_context_data d, jitter_print_class 
c);  
 351    
 352    /* Stop using the named class in the pointed underlying channel.  This 
is  
 353       always called with a class name correctly matching a previous call 
to  
 354       begin_class at the appropriate nesting level. */  
 355    int (* end_class) (jitter_print_context_data d, jitter_print_class c);  
 356    
 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 
url);  
 360    
 361    /* Close the current hyperlink in the pointed underlying channel.  This 
is  
 362       only called if a current hyperlink does in fact exist. */  
 363    int (* end_hyperlink) (jitter_print_context_data d);  
 364    
 365    /* Flush the pointed underlying channel. */  
 366    int (* flush) (jitter_print_context_data d);  
 367    
 368    /* Destroy the pointed print context data, without closing the 
underlying  
 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-).

Thanks!



reply via email to

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