@@ -133,25 +133,23 @@ def _write_server_stream_stop_request_shims(self, server_streams: list[LrpcStrea
133133 self ._file .write ("// Server stream start/stop shims" )
134134
135135 for stream in server_streams :
136- with self ._file .block (f"void { stream .name ()} _start_stop_shim(Reader& reader)" ):
136+ with self ._file .block (
137+ f"void { stream .name ()} _start_stop_shim(Reader& reader)" , trailing_newline = True ,
138+ ):
137139 self ._file .write ("const auto start = reader.read_unchecked<bool>();" )
138140 with self ._file .block ("if (start)" ):
139141 self ._file .write (f"{ stream .name ()} ();" )
140142 with self ._file .block ("else" ):
141143 self ._file .write (f"{ stream .name ()} _stop();" )
142144
143- self ._file .newline ()
144-
145145 def _write_client_stream_stop_requests (self , client_streams : list [LrpcStream ]) -> None :
146146 if len (client_streams ) != 0 :
147147 self ._file .write ("// Client stream stop requests" )
148148
149149 for stream in client_streams :
150- with self ._file .block (f"void { stream .name ()} _requestStop()" ):
150+ with self ._file .block (f"void { stream .name ()} _requestStop()" , trailing_newline = True ):
151151 self ._file (f"requestStop({ stream .id ()} );" )
152152
153- self ._file .newline ()
154-
155153 def _write_shim_array (
156154 self ,
157155 functions : list [LrpcFun ],
@@ -161,16 +159,16 @@ def _write_shim_array(
161159 max_function_or_stream_id = self ._max_function_or_stream_id (functions , client_streams , server_streams )
162160
163161 self ._file .write (f"using ShimType = void ({ self ._class_name ()} ::*)(Reader &);" )
164- with self ._file .block ("void missingFunction_shim(Reader& reader)" ):
162+ with self ._file .block ("void missingFunction_shim(Reader& reader)" , trailing_newline = True ):
165163 self ._file .write ("const auto data = reader.data();" )
166164 self ._file .write ("const auto functionOrStreamId = static_cast<uint8_t>(data.at(2));" )
167165 self ._file .write ("server().error(LrpcMetaError::UnknownFunctionOrStream, id(), functionOrStreamId);" )
168- self ._file .newline ()
169166
170167 with self ._file .block ("static ShimType shim(const size_t functionId)" ):
171168 with self ._file .block (
172169 f"static constexpr lrpc::array<ShimType, { max_function_or_stream_id + 1 } > shims" ,
173170 ";" ,
171+ trailing_newline = True ,
174172 ):
175173 function_info = {function .id (): function .name () for function in functions }
176174 client_stream_info = {stream .id (): stream .name () for stream in client_streams }
@@ -183,13 +181,9 @@ def _write_shim_array(
183181 name = server_stream_info .get (fid , name )
184182 self ._file (f"&{ self ._class_name ()} ::{ name } _shim," )
185183
186- self ._file .newline ()
187-
188- with self ._file .block ("if (functionId >= shims.size())" ):
184+ with self ._file .block ("if (functionId >= shims.size())" , trailing_newline = True ):
189185 self ._file .write (f"return &{ self ._class_name ()} ::missingFunction_shim;" )
190186
191- self ._file .newline ()
192-
193187 self ._file .write ("return shims.at(functionId);" )
194188
195189 @staticmethod
@@ -219,12 +213,12 @@ def _max_function_or_stream_id(
219213 return max (server_stream_ids + client_stream_ids + function_ids )
220214
221215 def _write_include_guard (self ) -> None :
222- self ._file ( "#pragma once" )
216+ self ._file . pragma_once ( )
223217
224218 def _write_includes (self ) -> None :
225- self ._file ( '#include "lrpccore/Service.hpp"' )
226- self ._file ( '#include "lrpccore/EtlRwExtensions.hpp"' )
227- self ._file (f'#include "{ self ._service .name ()} _includes.hpp"' )
219+ self ._file . include ( ' "lrpccore/Service.hpp"' )
220+ self ._file . include ( ' "lrpccore/EtlRwExtensions.hpp"' )
221+ self ._file . include (f'"{ self ._service .name ()} _includes.hpp"' )
228222
229223 self ._file .newline ()
230224
0 commit comments