#NEWLINE# def generate_header( self ) : #NEWLINE# #INDENT# self . _cg . reset ( ) #NEWLINE# dt = datetime . datetime . now ( ) . isoformat ( ) #NEWLINE# bh_filename = self . get_bitfield_header_filename ( ) #NEWLINE# prefix_def = '' #NEWLINE# default_stream_def = '' #NEWLINE# if self . _cfg . options . gen_prefix_def : #NEWLINE# #INDENT# prefix_def = '#define _BARECTF_PREFIX {}' . format ( self . _cfg . prefix ) #NEWLINE# #UNINDENT# if ( self . _cfg . options . gen_default_stream_def and ( self . _cfg . metadata . default_stream_name is not None ) ) : #NEWLINE# #INDENT# default_stream_def = '#define _BARECTF_DEFAULT_STREAM {}' . format ( self . _cfg . metadata . default_stream_name ) #NEWLINE# #UNINDENT# default_stream_trace_defs = '' #NEWLINE# default_stream_name = self . _cfg . metadata . default_stream_name #NEWLINE# if ( default_stream_name is not None ) : #NEWLINE# #INDENT# default_stream = self . _cfg . metadata . streams [ default_stream_name ] #NEWLINE# lines = [ ] #NEWLINE# for ev_name in default_stream . events . keys ( ) : #NEWLINE# #INDENT# tmpl = templates . _DEFINE_DEFAULT_STREAM_TRACE #NEWLINE# define = tmpl . format ( prefix = self . _cfg . prefix , sname = default_stream_name , evname = ev_name ) #NEWLINE# lines . append ( define ) #NEWLINE# #UNINDENT# default_stream_trace_defs = '\n' . join ( lines ) #NEWLINE# #UNINDENT# tmpl = templates . _HEADER_BEGIN #NEWLINE# self . _cg . add_lines ( tmpl . format ( prefix = self . _cfg . prefix , ucprefix = self . _cfg . prefix . upper ( ) , bitfield_header_filename = bh_filename , version = barectf . __version__ , date = dt , prefix_def = prefix_def , default_stream_def = default_stream_def , default_stream_trace_defs = default_stream_trace_defs ) ) #NEWLINE# self . _cg . add_empty_line ( ) #NEWLINE# self . _generate_platform_callbacks ( ) #NEWLINE# self . _cg . add_empty_line ( ) #NEWLINE# self . _generate_ctx_parent ( ) #NEWLINE# self . _cg . add_empty_line ( ) #NEWLINE# self . _generate_ctxs ( ) #NEWLINE# self . _cg . add_empty_line ( ) #NEWLINE# self . _generate_func_init_proto ( ) #NEWLINE# self . _punctuate_proto ( ) #NEWLINE# self . _cg . add_empty_line ( ) #NEWLINE# for stream in self . _cfg . metadata . streams . values ( ) : #NEWLINE# #INDENT# self . _generate_func_open_proto ( stream ) #NEWLINE# self . _punctuate_proto ( ) #NEWLINE# self . _cg . add_empty_line ( ) #NEWLINE# self . _generate_func_close_proto ( stream ) #NEWLINE# self . _punctuate_proto ( ) #NEWLINE# self . _cg . add_empty_line ( ) #NEWLINE# for ev in stream . events . values ( ) : #NEWLINE# #INDENT# self . _generate_func_trace_proto ( stream , ev ) #NEWLINE# self . _punctuate_proto ( ) #NEWLINE# self . _cg . add_empty_line ( ) #NEWLINE# #UNINDENT# #UNINDENT# tmpl = templates . _HEADER_END #NEWLINE# self . _cg . add_lines ( tmpl . format ( ucprefix = self . _cfg . prefix . upper ( ) ) ) #NEWLINE# return self . _cg . code