This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[patch] Better cleanup support for ui-out.


Hello,

The attached adds the cleanup utility function:

+ extern struct cleanup *ui_out_begin_cleanup_end (struct ui_out *uiout,
+                                                enum ui_out_type 
level_type,
+                                                const char *id);
+

to the ui-out interface.  It directly handles both tupple and list 
cleanups.  The old list only function:

extern struct cleanup *make_cleanup_ui_out_list_end (struct ui_out *uiout);

and this share common code.  If someone has a better name ....

	Andrew
2001-05-10  Andrew Cagney  <ac131313@redhat.com>

	* ui-out.h (ui_out_begin_cleanup_end): Declare.
	* ui-out.c (struct ui_out_end_cleanup_data): Define.
	(do_cleanup_end): New function.  Replace do_list_end.
	(make_cleanup_ui_out_end): New function.
	(ui_out_begin_cleanup_end): New function.
	(make_cleanup_ui_out_list_end): Use make_cleanup_ui_out_end.

Index: ui-out.c
===================================================================
RCS file: /cvs/src/src/gdb/ui-out.c,v
retrieving revision 1.10
diff -p -r1.10 ui-out.c
*** ui-out.c	2001/05/09 01:33:10	1.10
--- ui-out.c	2001/05/10 18:16:16
*************** ui_out_list_end (struct ui_out *uiout)
*** 352,367 ****
    ui_out_end (uiout, ui_out_type_list);
  }
  
  static void
! do_list_end (void *uiout)
  {
!   ui_out_list_end (uiout);
  }
  
  struct cleanup *
  make_cleanup_ui_out_list_end (struct ui_out *uiout)
  {
!   return make_cleanup (do_list_end, uiout);
  }
  
  void
--- 352,395 ----
    ui_out_end (uiout, ui_out_type_list);
  }
  
+ struct ui_out_end_cleanup_data
+ {
+   struct ui_out *uiout;
+   enum ui_out_type type;
+ };
+ 
  static void
! do_cleanup_end (void *data)
! {
!   struct ui_out_end_cleanup_data *end_cleanup_data = data;
!   ui_out_end (end_cleanup_data->uiout, end_cleanup_data->type);
!   xfree (end_cleanup_data);
! }
! 
! static struct cleanup *
! make_cleanup_ui_out_end (struct ui_out *uiout,
! 			 enum ui_out_type type)
! {
!   struct ui_out_end_cleanup_data *end_cleanup_data;
!   end_cleanup_data = XMALLOC (struct ui_out_end_cleanup_data);
!   end_cleanup_data->uiout = uiout;
!   end_cleanup_data->type = type;
!   return make_cleanup (do_cleanup_end, end_cleanup_data);
! }
! 
! struct cleanup *
! ui_out_begin_cleanup_end (struct ui_out *uiout,
! 			  enum ui_out_type type,
! 			  const char *id)
  {
!   ui_out_begin (uiout, type, id);
!   return make_cleanup_ui_out_end (uiout, type);
  }
  
  struct cleanup *
  make_cleanup_ui_out_list_end (struct ui_out *uiout)
  {
!   return make_cleanup_ui_out_end (uiout, ui_out_type_list);
  }
  
  void
Index: ui-out.h
===================================================================
RCS file: /cvs/src/src/gdb/ui-out.h,v
retrieving revision 1.7
diff -p -r1.7 ui-out.h
*** ui-out.h	2001/05/09 01:33:10	1.7
--- ui-out.h	2001/05/10 18:16:33
*************** extern void ui_out_begin (struct ui_out 
*** 80,85 ****
--- 80,89 ----
  
  extern void ui_out_end (struct ui_out *uiout, enum ui_out_type type);
  
+ extern struct cleanup *ui_out_begin_cleanup_end (struct ui_out *uiout,
+ 						 enum ui_out_type level_type,
+ 						 const char *id);
+ 
  /* A table can be considered a special tupple/list combination with
     the implied structure: ``table = { hdr = { header, ... } , body = [ {
     field, ... }, ... ] }'' */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]