The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipc: Add C++ guards to generated headers

+28 -3
+15
src/xrt/ipc/shared/ipcproto/common.py
··· 6 6 import json 7 7 import re 8 8 9 + def write_cpp_header_guard_start(f): 10 + """Write the starting C in C++ header guard""" 11 + f.write(''' 12 + #ifdef __cplusplus 13 + extern "C" { 14 + #endif 15 + ''') 16 + 17 + def write_cpp_header_guard_end(f): 18 + """Write the ending C in C++ header guard""" 19 + f.write(''' 20 + #ifdef __cplusplus 21 + } 22 + #endif 23 + ''') 9 24 10 25 def write_with_wrapped_args(f, start, args, indent): 11 26 """Write something like a declaration or call."""
+13 -3
src/xrt/ipc/shared/proto.py
··· 6 6 import argparse 7 7 8 8 from ipcproto.common import (Proto, write_decl, write_invocation, 9 - write_result_handler) 9 + write_result_handler, write_cpp_header_guard_start, 10 + write_cpp_header_guard_end) 10 11 11 12 header = '''// Copyright 2020, Collabora, Ltd. 12 13 // SPDX-License-Identifier: BSL-1.0 ··· 221 222 #include "ipc_protocol_generated.h" 222 223 #include "client/ipc_client.h" 223 224 224 - 225 - 226 225 ''') 226 + write_cpp_header_guard_start(f) 227 + f.write("\n") 227 228 228 229 for call in p.calls: 229 230 call.write_call_decl(f) 230 231 f.write(";\n") 232 + 233 + write_cpp_header_guard_end(f) 234 + 231 235 f.close() 232 236 233 237 ··· 383 387 384 388 385 389 ''') 390 + 391 + write_cpp_header_guard_start(f) 392 + f.write("\n") 393 + 386 394 # This decl is constant, but we must write it here 387 395 # because it depends on a generated enum. 388 396 write_decl( ··· 399 407 for call in p.calls: 400 408 call.write_handler_decl(f) 401 409 f.write(";\n") 410 + 411 + write_cpp_header_guard_end(f) 402 412 f.close() 403 413 404 414