You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

681 lines
23 KiB

  1. ############################################################
  2. # Created: 21st June 2005
  3. # Updated: 10th January 2011
  4. require 'recls' # Download from http://synesis.com.au/software
  5. require 'synsoft/srcutil' # Download from http://synesis.com.au/software
  6. ############################################################
  7. # functions
  8. def declare_template_parameter_list(f, i)
  9. if false
  10. f << "template< typename T0" << ENDL
  11. (1 ... i).each do |j|
  12. f << " , typename T#{j}" << ENDL
  13. end
  14. f << " >" << ENDL
  15. else
  16. s = "template<typename T0";
  17. (1 ... i).each do |j|
  18. s = s + ", typename T#{j}"
  19. end
  20. s = s + ">"
  21. f << s << ENDL
  22. end
  23. end # declare_template_parameter_list
  24. def declare_function_parameter_list(f, from, to)
  25. if false
  26. (from ... to - 1).each do |j|
  27. f << " , T#{j} const &v#{j}" << ENDL
  28. end
  29. f << " , T#{to - 1} const &v#{to - 1})" << ENDL
  30. else
  31. s = " "
  32. (from ... to - 1).each do |j|
  33. s = s + ", T#{j} const& v#{j}"
  34. end
  35. s = s + ", T#{to - 1} const& v#{to - 1})"
  36. f << s << ENDL
  37. end
  38. end # declare_function_parameter_list
  39. def round_up(n, granularity)
  40. ((n + (granularity - 1)) / granularity) * granularity
  41. end
  42. ############################################################
  43. numParams = 32
  44. if ARGV.length > 0
  45. n = Integer(ARGV[0])
  46. if n > 0 && n < 256
  47. numParams = n
  48. end
  49. end
  50. NUM_PARAMS = numParams
  51. PARAM_RANGE = (1 .. NUM_PARAMS)
  52. TAB_SIZE = 1 #4
  53. TAB = " " * TAB_SIZE
  54. SHORT_ARG_LMARGIN = 2
  55. USE_USING_DECLARATION = true
  56. USE_SHIM_PAIR_MACRO = true
  57. USE_SHORT_ARG_LMARGIN = true
  58. INITIALISERS_INLINE = true
  59. #CALL_LMARGIN = " "
  60. #CALL_LMARGIN = " "
  61. CALL_LMARGIN = "#{TAB}#{TAB}"
  62. PARAMS_LIMIT_SYMBOL = "PANTHEIOS_APPL_PARAMS_LIMIT"
  63. SEVERITY_LEVELS = %w{ EMERGENCY ALERT CRITICAL ERROR WARNING NOTICE INFORMATIONAL DEBUG }
  64. ############################################################
  65. d = Recls::stat(".")
  66. if d.fileName == "scripts"
  67. d = Recls::stat("../include/pantheios")
  68. end
  69. if !d or d.fileName != "pantheios"
  70. abort "Not running in the correct directory; needs to be /???/include/pantheios"
  71. end
  72. SEP = Recls::pathNameSeparator
  73. ENDL = "\n"
  74. C_LOG_FUNCTIONS_HEADER_NAME = "internal/generated/log_functions.h"
  75. C_LOG_FUNCTIONS_IMPL_NAME = "internal/generated/log_functions.c"
  76. C_LOG_DISPATCH_FUNCTIONS_HEADER_NAME = "internal/generated/log_dispatch_functions.h"
  77. Cpp_LOG_DISPATCH_FUNCTIONS_HEADER_NAME = "internal/generated/log_dispatch_functions.hpp"
  78. Cpp_LOG_FUNCTIONS_HEADER_NAME = "internal/generated/log_functions.hpp"
  79. Cpp_LOG_SEV_FUNCTIONS_HEADER_NAME = "internal/generated/log_sev_functions.hpp"
  80. C_LOG_FUNCTIONS_HEADER = "#{d.path}#{SEP}" + C_LOG_FUNCTIONS_HEADER_NAME.gsub('/', SEP)
  81. C_LOG_FUNCTIONS_IMPL = "#{d.path}#{SEP}" + C_LOG_FUNCTIONS_IMPL_NAME.gsub('/', SEP)
  82. C_LOG_DISPATCH_FUNCTIONS_HEADER = "#{d.path}#{SEP}" + C_LOG_DISPATCH_FUNCTIONS_HEADER_NAME.gsub('/', SEP)
  83. Cpp_LOG_DISPATCH_FUNCTIONS_HEADER = "#{d.path}#{SEP}" + Cpp_LOG_DISPATCH_FUNCTIONS_HEADER_NAME.gsub('/', SEP)
  84. Cpp_LOG_FUNCTIONS_HEADER = "#{d.path}#{SEP}" + Cpp_LOG_FUNCTIONS_HEADER_NAME.gsub('/', SEP)
  85. Cpp_LOG_SEV_FUNCTIONS_HEADER = "#{d.path}#{SEP}" + Cpp_LOG_SEV_FUNCTIONS_HEADER_NAME.gsub('/', SEP)
  86. num_pantheios_log_N_declarations = 0
  87. num_pantheios_log_N_no_test_declarations = 0
  88. num_pantheios_log_N_no_test_definitions = 0
  89. num_pantheios_log_N_definitions = 0
  90. num_log_dispatch_N_definitions = 0
  91. num_log_definitions = 0
  92. num_log_sev_definitions = 0
  93. ############################################################
  94. # C_LOG_FUNCTIONS_HEADER_NAME
  95. puts C_LOG_FUNCTIONS_HEADER_NAME
  96. f = File::new(C_LOG_FUNCTIONS_HEADER, "w")
  97. f << "/* /////////////////////////////////////////////////////////////////////////" << "" << ENDL
  98. f << " * File: pantheios/" << C_LOG_FUNCTIONS_HEADER_NAME << "" << ENDL
  99. f << " *" << "" << ENDL
  100. f << " * Purpose: Declarations of the pantheios_log_<N>() functions" << ENDL
  101. f << " *" << "" << ENDL
  102. f << " * Generated: #{SrcUtil::currentDate}" << "" << ENDL
  103. f << " *" << "" << ENDL
  104. f << " * Status: This file is auto-generated: DO NOT EDIT!" << "" << ENDL
  105. f << " *" << "" << ENDL
  106. f << " * Copyright: The copyright restrictions of the Pantheios library," << "" << ENDL
  107. f << " * enumerated in the header file <pantheios/pantheios.h>," << "" << ENDL
  108. f << " * apply to this file" << "" << ENDL
  109. f << " *" << "" << ENDL
  110. f << " * ////////////////////////////////////////////////////////////////////// */" << "" << ENDL
  111. f << "" << ENDL
  112. # f << "/** \\file pantheios/#{C_LOG_FUNCTIONS_HEADER_NAME} [C, C++] INTERNAL, AUTO-GENERATED FILE: Do not include directly */" << ENDL
  113. f << "" << ENDL
  114. f << "#ifndef PANTHEIOS_INCLUDING_C_API_FUNCTIONS" << "" << ENDL
  115. f << "# error This file is included by the Pantheios API, and cannot be included directly" << "" << ENDL
  116. f << "#endif /* !PANTHEIOS_INCLUDING_C_API_FUNCTIONS */" << "" << ENDL
  117. f << "" << ENDL
  118. f << "#define PANTHEIOS_APPL_PARAMS_LIMIT_MAX_GENERATED (#{NUM_PARAMS})" << "" << ENDL
  119. f << "" << ENDL
  120. PARAM_RANGE.each do |i|
  121. sig = "PANTHEIOS_CALL(int) pantheios_log_#{i}("
  122. if USE_SHORT_ARG_LMARGIN
  123. len = SHORT_ARG_LMARGIN
  124. else
  125. len = round_up(sig.length, TAB_SIZE)
  126. end
  127. len0 = len - TAB_SIZE
  128. sig = sig.ljust(len)
  129. plural = (i > 1) ? "s" : ""
  130. # Documentation comment
  131. f << "/** Logs #{i} parameter#{plural}, subject to external (not in \\ref group__core_library) severity-level filtering " << ENDL
  132. f << " * \\ingroup group__application_layer_interface__generated" << ENDL
  133. f << " */" << ENDL
  134. # Function signature
  135. f << "#{sig}pan_sev_t severity" << ENDL
  136. (0 ... i). each do |j|
  137. f << "".ljust(len0) + ", pan_char_t const* p#{j}, int l#{j} /* -1 => 'strlen(p#{j})' */" << ENDL
  138. end
  139. f << ");" << ENDL;
  140. f << "" << ENDL
  141. num_pantheios_log_N_declarations = 1 + num_pantheios_log_N_declarations
  142. end
  143. f.close()
  144. f = nil
  145. ############################################################
  146. # C_LOG_FUNCTIONS_IMPL_NAME
  147. puts C_LOG_FUNCTIONS_IMPL_NAME
  148. f = File::new(C_LOG_FUNCTIONS_IMPL, "w")
  149. f << "/* /////////////////////////////////////////////////////////////////////////" << "" << ENDL
  150. f << " * File: pantheios/" << C_LOG_FUNCTIONS_IMPL_NAME << "" << ENDL
  151. f << " *" << "" << ENDL
  152. f << " * Purpose: Definitions of the pantheios_log_<N>() and" << ENDL
  153. f << " * pantheios_log_<N>_no_test() functions" << ENDL
  154. f << " *" << "" << ENDL
  155. f << " * Generated: #{SrcUtil::currentDate}" << "" << ENDL
  156. f << " *" << "" << ENDL
  157. f << " * Status: This file is auto-generated: DO NOT EDIT!" << "" << ENDL
  158. f << " *" << "" << ENDL
  159. f << " * Copyright: The copyright restrictions of the Pantheios library," << "" << ENDL
  160. f << " * enumerated in the header file <pantheios/pantheios.h>," << "" << ENDL
  161. f << " * apply to this file" << "" << ENDL
  162. f << " *" << "" << ENDL
  163. f << " * ////////////////////////////////////////////////////////////////////// */" << "" << ENDL
  164. f << "" << ENDL
  165. # f << "/** \\file pantheios/#{C_LOG_FUNCTIONS_IMPL_NAME} [C++ only] INTERNAL, AUTO-GENERATED FILE: Do not include directly */" << ENDL
  166. f << "" << ENDL
  167. f << "#ifndef __cplusplus" << ENDL
  168. f << "# error This file cannot be used independently, nor as part of a C compilation unit. It should only be included from within pantheios_core.cpp" << ENDL
  169. f << "#endif /* __cplusplus */" << ENDL
  170. f << "" << ENDL
  171. f << "" << ENDL
  172. PARAM_RANGE.each do |i|
  173. sig = "PANTHEIOS_CALL(int) pantheios_log_#{i}_no_test("
  174. if USE_SHORT_ARG_LMARGIN
  175. len = SHORT_ARG_LMARGIN
  176. else
  177. len = round_up(sig.length, TAB_SIZE)
  178. end
  179. len0 = len - TAB_SIZE
  180. sig = sig.ljust(len)
  181. f << "#{sig}pan_sev_t severity" << ENDL
  182. (0 ... i - 1). each do |j|
  183. f << "".ljust(len0) + ", pan_slice_t const& slice#{j}" << ENDL
  184. end
  185. f << "".ljust(len0) + ", pan_slice_t const& slice#{i - 1})" << ENDL
  186. f << "{" << ENDL
  187. f << "#{TAB}const pan_slice_t slices[#{i}] =" << ENDL
  188. f << "#{TAB}{" << ENDL
  189. if INITIALISERS_INLINE
  190. f << "#{TAB}#{TAB}slice0"
  191. (1 ... i). each do |j|
  192. f << ", slice#{j}"
  193. end
  194. f << "" << ENDL
  195. else
  196. f << "#{TAB}#{TAB} slice0" << ENDL
  197. (1 ... i). each do |j|
  198. f << "#{TAB}#{TAB}, slice#{j}" << ENDL
  199. end
  200. end
  201. f << "#{TAB}};" << ENDL
  202. f << "" << ENDL
  203. f << "#{TAB}return pantheios_log_n(severity, STLSOFT_NUM_ELEMENTS(slices), slices);" << ENDL
  204. f << "}" << ENDL
  205. f << "" << ENDL
  206. num_pantheios_log_N_no_test_definitions = 1 + num_pantheios_log_N_no_test_definitions
  207. end
  208. PARAM_RANGE.each do |i|
  209. sig = "PANTHEIOS_CALL(int) pantheios_log_#{i}("
  210. if USE_SHORT_ARG_LMARGIN
  211. len = SHORT_ARG_LMARGIN
  212. else
  213. len = round_up(sig.length, TAB_SIZE)
  214. end
  215. len0 = len - TAB_SIZE
  216. sig = sig.ljust(len)
  217. f << "#{sig}pan_sev_t severity" << ENDL
  218. (0 ... i - 1). each do |j|
  219. f << "".ljust(len0) + ", pan_char_t const* p#{j}, int l#{j}" << ENDL
  220. end
  221. f << "".ljust(len0) + ", pan_char_t const* p#{i - 1}, int l#{i - 1})" << ENDL
  222. f << "{" << ENDL
  223. f << "#{TAB}if(!pantheios_isSeverityLogged(severity))" << ENDL
  224. f << "#{TAB}{" << ENDL
  225. f << "#{TAB}#{TAB}#{TAB}return 0;" << ENDL
  226. f << "#{TAB}}" << ENDL
  227. f << "#{TAB}else" << ENDL
  228. f << "#{TAB}{" << ENDL
  229. f << "#{TAB}#{TAB}const pan_slice_t slices[#{i}] =" << ENDL
  230. f << "#{TAB}#{TAB}{" << ENDL
  231. if INITIALISERS_INLINE
  232. f << "#{TAB}#{TAB}#{TAB}pan_slice_t(l0, p0)"
  233. else
  234. f << "#{TAB}#{TAB}#{TAB}pan_slice_t(l0, p0)" << ENDL
  235. end
  236. (1 ... i). each do |j|
  237. if INITIALISERS_INLINE
  238. f << ", pan_slice_t(l#{j}, p#{j})"
  239. else
  240. f << "#{TAB}#{TAB}#{TAB}, pan_slice_t(l#{j}, p#{j})" << ENDL
  241. end
  242. end
  243. if INITIALISERS_INLINE
  244. f << "" << ENDL
  245. end
  246. f << "#{TAB}#{TAB}};" << ENDL
  247. f << "" << ENDL
  248. f << "#{TAB}#{TAB}return pantheios_log_n(severity, STLSOFT_NUM_ELEMENTS(slices), slices);" << ENDL
  249. f << "#{TAB}}" << ENDL
  250. f << "}" << ENDL
  251. f << "" << ENDL
  252. num_pantheios_log_N_definitions = 1 + num_pantheios_log_N_definitions
  253. end
  254. f.close()
  255. f = nil
  256. ############################################################
  257. # C_LOG_DISPATCH_FUNCTIONS_HEADER_NAME
  258. puts C_LOG_DISPATCH_FUNCTIONS_HEADER_NAME
  259. f = File::new(C_LOG_DISPATCH_FUNCTIONS_HEADER, "w")
  260. f << "/* /////////////////////////////////////////////////////////////////////////" << "" << ENDL
  261. f << " * File: pantheios/" << C_LOG_DISPATCH_FUNCTIONS_HEADER_NAME << "" << ENDL
  262. f << " *" << "" << ENDL
  263. f << " * Purpose: Declarations of the pantheios_log_<N>_no_test() functions" << ENDL
  264. f << " *" << "" << ENDL
  265. f << " * Generated: #{SrcUtil::currentDate}" << "" << ENDL
  266. f << " *" << "" << ENDL
  267. f << " * Status: This file is auto-generated: DO NOT EDIT!" << "" << ENDL
  268. f << " *" << "" << ENDL
  269. f << " * Copyright: The copyright restrictions of the Pantheios library," << "" << ENDL
  270. f << " * enumerated in the header file <pantheios/pantheios.h>," << "" << ENDL
  271. f << " * apply to this file" << "" << ENDL
  272. f << " *" << "" << ENDL
  273. f << " * ////////////////////////////////////////////////////////////////////// */" << "" << ENDL
  274. f << "" << ENDL
  275. # f << "/** \\file pantheios/#{C_LOG_DISPATCH_FUNCTIONS_HEADER_NAME} [C, C++] INTERNAL, AUTO-GENERATED FILE: Do not include directly */" << ENDL
  276. f << "" << ENDL
  277. f << "#ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS" << "" << ENDL
  278. f << "# error This file is included by the Pantheios API, and cannot be included directly" << "" << ENDL
  279. f << "#endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */" << "" << ENDL
  280. f << "" << ENDL
  281. f << "" << ENDL
  282. PARAM_RANGE.each do |i|
  283. sig = "PANTHEIOS_CALL(int) pantheios_log_#{i}_no_test("
  284. if USE_SHORT_ARG_LMARGIN
  285. len = SHORT_ARG_LMARGIN
  286. else
  287. len = round_up(sig.length, TAB_SIZE)
  288. end
  289. len0 = len - TAB_SIZE
  290. sig = sig.ljust(len)
  291. # Template parameter list
  292. # Function signature
  293. f << "#{sig}" << ENDL
  294. f << "".ljust(len0) + " pan_sev_t severity" << ENDL
  295. (0 ... i). each do |j|
  296. f << "".ljust(len0) + ", pan_slice_t const& s#{j}" << ENDL
  297. end
  298. f << ");" << ENDL
  299. f << "" << ENDL
  300. num_pantheios_log_N_no_test_declarations = 1 + num_pantheios_log_N_no_test_declarations
  301. end
  302. f.close()
  303. f = nil
  304. ############################################################
  305. # Cpp_LOG_DISPATCH_FUNCTIONS_HEADER_NAME
  306. puts Cpp_LOG_DISPATCH_FUNCTIONS_HEADER_NAME
  307. f = File::new(Cpp_LOG_DISPATCH_FUNCTIONS_HEADER, "w")
  308. f << "/* /////////////////////////////////////////////////////////////////////////" << "" << ENDL
  309. f << " * File: pantheios/" << Cpp_LOG_DISPATCH_FUNCTIONS_HEADER_NAME << "" << ENDL
  310. f << " *" << "" << ENDL
  311. f << " * Purpose: Inline definitions of the log_dispatch_<N>() functions" << ENDL
  312. f << " *" << "" << ENDL
  313. f << " * Generated: #{SrcUtil::currentDate}" << "" << ENDL
  314. f << " *" << "" << ENDL
  315. f << " * Status: This file is auto-generated: DO NOT EDIT!" << "" << ENDL
  316. f << " *" << "" << ENDL
  317. f << " * Copyright: The copyright restrictions of the Pantheios library," << "" << ENDL
  318. f << " * enumerated in the header file <pantheios/pantheios.h>," << "" << ENDL
  319. f << " * apply to this file" << "" << ENDL
  320. f << " *" << "" << ENDL
  321. f << " * ////////////////////////////////////////////////////////////////////// */" << "" << ENDL
  322. f << "" << ENDL
  323. # f << "/** \\file pantheios/#{Cpp_LOG_DISPATCH_FUNCTIONS_HEADER_NAME} [C++ only] INTERNAL, AUTO-GENERATED FILE: Do not include directly */" << ENDL
  324. f << "" << ENDL
  325. f << "#ifndef PANTHEIOS_INCL_PANTHEIOS_HPP_PANTHEIOS" << "" << ENDL
  326. f << "# error This file is included by the Pantheios API, and cannot be included directly" << "" << ENDL
  327. f << "#endif /* !PANTHEIOS_INCL_PANTHEIOS_HPP_PANTHEIOS */" << "" << ENDL
  328. f << "" << ENDL
  329. f << "" << ENDL
  330. PARAM_RANGE.each do |i|
  331. sig = "inline int log_dispatch_#{i}("
  332. if USE_SHORT_ARG_LMARGIN
  333. len = SHORT_ARG_LMARGIN
  334. else
  335. len = round_up(sig.length, TAB_SIZE)
  336. end
  337. len0 = len - TAB_SIZE
  338. sig = sig.ljust(len)
  339. plural = (i > 1) ? "s" : ""
  340. # Pre-processor limits
  341. f << "#if #{PARAMS_LIMIT_SYMBOL} >= #{i}" << ENDL << ENDL
  342. # Template parameter list
  343. # Function signature
  344. f << "#{sig}pan_sev_t severity" << ENDL
  345. (0 ... i). each do |j|
  346. f << "".ljust(len0) + ", size_t l#{j}, pan_char_t const* p#{j}" << ENDL
  347. end
  348. f << ")" << ENDL
  349. f << "{" << ENDL
  350. stm = " return pantheios_log_#{i}_no_test("
  351. if USE_SHORT_ARG_LMARGIN
  352. len = SHORT_ARG_LMARGIN
  353. else
  354. len = round_up(sig.length, TAB_SIZE)
  355. end
  356. len0 = len - TAB_SIZE
  357. stm = stm.ljust(len)
  358. f << "#{stm}severity" << ENDL
  359. (0 ... i).each do |j|
  360. f << "".ljust(len0) + ", pan_slice_t(p#{j}, l#{j})" << ENDL
  361. end
  362. f << "".ljust(len0) + ");" << ENDL
  363. f << "}" << ENDL
  364. f << "" << ENDL
  365. num_log_dispatch_N_definitions = 1 + num_log_dispatch_N_definitions
  366. end
  367. PARAM_RANGE.each { |i| f << "#endif /* #{PARAMS_LIMIT_SYMBOL} >= #{NUM_PARAMS - i + 1} */" << ENDL }
  368. f.close()
  369. f = nil
  370. ############################################################
  371. # Cpp_LOG_FUNCTIONS_HEADER_NAME
  372. puts Cpp_LOG_FUNCTIONS_HEADER_NAME
  373. f = File::new(Cpp_LOG_FUNCTIONS_HEADER, "w")
  374. f << "/* /////////////////////////////////////////////////////////////////////////" << "" << ENDL
  375. f << " * File: pantheios/" << Cpp_LOG_FUNCTIONS_HEADER_NAME << "" << ENDL
  376. f << " *" << "" << ENDL
  377. f << " * Purpose: Definitions of the log() functions" << ENDL
  378. f << " *" << "" << ENDL
  379. f << " * Generated: #{SrcUtil::currentDate}" << "" << ENDL
  380. f << " *" << "" << ENDL
  381. f << " * Status: This file is auto-generated: DO NOT EDIT!" << "" << ENDL
  382. f << " *" << "" << ENDL
  383. f << " * Copyright: The copyright restrictions of the Pantheios library," << "" << ENDL
  384. f << " * enumerated in the header file <pantheios/pantheios.h>," << "" << ENDL
  385. f << " * apply to this file" << "" << ENDL
  386. f << " *" << "" << ENDL
  387. f << " * ////////////////////////////////////////////////////////////////////// */" << "" << ENDL
  388. f << "" << ENDL
  389. # f << "/** \\file pantheios/#{Cpp_LOG_FUNCTIONS_HEADER_NAME} [C++ only] INTERNAL, AUTO-GENERATED FILE: Do not include directly */" << ENDL
  390. f << "" << ENDL
  391. f << "#ifndef PANTHEIOS_INCL_PANTHEIOS_HPP_PANTHEIOS" << "" << ENDL
  392. f << "# error This file is included by the Pantheios API, and cannot be included directly" << "" << ENDL
  393. f << "#endif /* !PANTHEIOS_INCL_PANTHEIOS_HPP_PANTHEIOS */" << "" << ENDL
  394. f << "" << ENDL
  395. f << "" << ENDL
  396. PARAM_RANGE.each do |i|
  397. plural = (i > 1) ? "s" : ""
  398. # Pre-processor limits
  399. f << "#if #{PARAMS_LIMIT_SYMBOL} >= #{i}" << ENDL << ENDL
  400. # Documentation comment
  401. f << "/** Logs #{i} object#{plural} of arbitrary type, subject to severity-level filtering" << ENDL
  402. f << " * \\ingroup group__application_layer_interface__generated" << ENDL
  403. f << " * \\note The \\c c_str_data_a() and \\c c_str_len_a() string access shims are applied to each parameter, to form a string slice" << ENDL
  404. f << " */" << ENDL
  405. # Template parameter list
  406. declare_template_parameter_list(f, i)
  407. # Function signature
  408. f << "inline int log( pan_sev_t severity" << ENDL
  409. declare_function_parameter_list(f, 0, i)
  410. # Function body
  411. f << "{" << ENDL
  412. # isSeverityLogged() test
  413. f << "#{TAB}if(!pantheios_isSeverityLogged(severity))" << ENDL
  414. f << "#{TAB}{" << ENDL
  415. f << "#{TAB}#{TAB}return 0;" << ENDL
  416. f << "#{TAB}}" << ENDL
  417. f << "#{TAB}else" << ENDL
  418. f << "#{TAB}{" << ENDL
  419. # log_dispatch_N() call
  420. if USE_USING_DECLARATION
  421. f << "#{TAB}#{TAB}PANTHEIOS_DECLARE_SHIM_PAIR_();" << ENDL
  422. f << ENDL
  423. end
  424. f << "#ifndef PANTHEIOS_FORCE_ALLOW_FUNDAMENTAL_ARGUMENTS" << ENDL;
  425. f << "#{TAB}#{TAB}// NOTE: if one of the following lines causes a compile error," << ENDL;
  426. f << "#{TAB}#{TAB}// you have passed a fundamental type to the log() statement." << ENDL;
  427. (0 ... i).each do |j|
  428. f << "#{TAB}#{TAB}PANTHEIOS_VALIDATE_TYPE_NOT_FUNDAMENTAL_(T#{j});" << ENDL;
  429. end
  430. f << "#endif /* PANTHEIOS_FORCE_ALLOW_FUNDAMENTAL_ARGUMENTS */" << ENDL;
  431. f << ENDL
  432. f << "#{TAB}#{TAB}return internal::log_dispatch_#{i}(severity" << ENDL
  433. (0 ... i).each do |j|
  434. if USE_SHIM_PAIR_MACRO
  435. f << "#{CALL_LMARGIN}, PANTHEIOS_INVOKE_SHIM_PAIR_(v#{j})" << ENDL
  436. elsif USE_USING_DECLARATION
  437. f << "#{CALL_LMARGIN}, c_str_len_a(v#{j}), c_str_data_a(v#{j})" << ENDL
  438. else
  439. f << "#{CALL_LMARGIN}, ::stlsoft::c_str_len_a(v#{j}), ::stlsoft::c_str_data_a(v#{j})" << ENDL
  440. end
  441. end
  442. f << "#{TAB}#{TAB});" << ENDL
  443. f << "#{TAB}}" << ENDL
  444. f << "}" << ENDL
  445. f << "" << ENDL
  446. num_log_definitions = 1 + num_log_definitions
  447. end
  448. PARAM_RANGE.each { |i| f << "#endif /* #{PARAMS_LIMIT_SYMBOL} >= #{NUM_PARAMS - i + 1} */" << ENDL }
  449. f.close()
  450. f = nil
  451. ############################################################
  452. # Cpp_LOG_SEV_FUNCTIONS_HEADER_NAME
  453. puts Cpp_LOG_SEV_FUNCTIONS_HEADER_NAME
  454. f = File::new(Cpp_LOG_SEV_FUNCTIONS_HEADER, "w")
  455. f << "/* /////////////////////////////////////////////////////////////////////////" << "" << ENDL
  456. f << " * File: pantheios/" << Cpp_LOG_SEV_FUNCTIONS_HEADER_NAME << "" << ENDL
  457. f << " *" << "" << ENDL
  458. f << " * Purpose: Definitions of the log_<LEVEL>() functions" << ENDL
  459. f << " *" << "" << ENDL
  460. f << " * Generated: #{SrcUtil::currentDate}" << "" << ENDL
  461. f << " *" << "" << ENDL
  462. f << " * Status: This file is auto-generated: DO NOT EDIT!" << "" << ENDL
  463. f << " *" << "" << ENDL
  464. f << " * Copyright: The copyright restrictions of the Pantheios library," << "" << ENDL
  465. f << " * enumerated in the header file <pantheios/pantheios.h>," << "" << ENDL
  466. f << " * apply to this file" << "" << ENDL
  467. f << " *" << "" << ENDL
  468. f << " * ////////////////////////////////////////////////////////////////////// */" << "" << ENDL
  469. f << "" << ENDL
  470. # f << "/** \\file pantheios/#{Cpp_LOG_SEV_FUNCTIONS_HEADER_NAME} [C++ only] INTERNAL, AUTO-GENERATED FILE: Do not include directly */" << ENDL
  471. f << "" << ENDL
  472. f << "#ifndef PANTHEIOS_INCL_PANTHEIOS_HPP_PANTHEIOS" << "" << ENDL
  473. f << "# error This file is included by the Pantheios API, and cannot be included directly" << "" << ENDL
  474. f << "#endif /* !PANTHEIOS_INCL_PANTHEIOS_HPP_PANTHEIOS */" << "" << ENDL
  475. f << "" << ENDL
  476. f << "" << ENDL
  477. SEVERITY_LEVELS.each do |severityLevel|
  478. PARAM_RANGE.each do |i|
  479. plural = (i > 1) ? "s" : ""
  480. # Pre-processor limits
  481. f << "#if #{PARAMS_LIMIT_SYMBOL} >= #{i}" << ENDL << ENDL
  482. # Documentation comment
  483. f << "/** Logs #{i} object#{plural} of arbitrary type, subject to severity-level filtering, at severity level \\link pantheios::SEV_#{severityLevel} #{severityLevel}\\endlink" << ENDL
  484. f << " * \\ingroup group__application_layer_interface__generated" << ENDL
  485. f << " * \\note The \\c c_str_data_a() and \\c c_str_len_a() string access shims are applied to each parameter, to form a string slice" << ENDL
  486. f << " */" << ENDL
  487. # Template parameter list
  488. declare_template_parameter_list(f, i)
  489. # Function signature
  490. if i == 1
  491. f << "inline int log_#{severityLevel}(T0 const& v0)" << ENDL
  492. else
  493. sig = "inline int log_#{severityLevel}("
  494. len = ((sig.length + 3) / TAB_SIZE) * TAB_SIZE
  495. len0 = len - 2
  496. sig = sig.ljust(len)
  497. f << "#{sig}T0 const &v0" << ENDL
  498. declare_function_parameter_list(f, 1, i)
  499. end
  500. # Function body
  501. f << "{" << ENDL
  502. # isSeverityLogged() test
  503. f << "#{TAB}if(!pantheios_isSeverityLogged(PANTHEIOS_SEV_#{severityLevel}))" << ENDL
  504. f << "#{TAB}{" << ENDL
  505. f << "#{TAB}#{TAB}return 0;" << ENDL
  506. f << "#{TAB}}" << ENDL
  507. f << "#{TAB}else" << ENDL
  508. f << "#{TAB}{" << ENDL
  509. # log_dispatch_N() call
  510. if USE_USING_DECLARATION
  511. f << "#{TAB}#{TAB}PANTHEIOS_DECLARE_SHIM_PAIR_();" << ENDL
  512. f << ENDL
  513. end
  514. f << "#ifndef PANTHEIOS_FORCE_ALLOW_FUNDAMENTAL_ARGUMENTS" << ENDL;
  515. f << "#{TAB}#{TAB}// NOTE: if one of the following lines causes a compile error," << ENDL;
  516. f << "#{TAB}#{TAB}// you have passed a fundamental type to the log_#{severityLevel}() statement." << ENDL;
  517. (0 ... i).each do |j|
  518. f << "#{TAB}#{TAB}PANTHEIOS_VALIDATE_TYPE_NOT_FUNDAMENTAL_(T#{j});" << ENDL;
  519. end
  520. f << "#endif /* PANTHEIOS_FORCE_ALLOW_FUNDAMENTAL_ARGUMENTS */" << ENDL;
  521. f << ENDL
  522. f << "#{TAB}#{TAB}return internal::log_dispatch_#{i}(PANTHEIOS_SEV_#{severityLevel}" << ENDL
  523. (0 ... i).each do |j|
  524. if USE_SHIM_PAIR_MACRO
  525. f << "#{CALL_LMARGIN}, PANTHEIOS_INVOKE_SHIM_PAIR_(v#{j})" << ENDL
  526. elsif USE_USING_DECLARATION
  527. f << "#{CALL_LMARGIN}, c_str_len_a(v#{j}), c_str_data_a(v#{j})" << ENDL
  528. else
  529. f << "#{CALL_LMARGIN}, ::stlsoft::c_str_len_a(v#{j}), ::stlsoft::c_str_data_a(v#{j})" << ENDL
  530. end
  531. end
  532. f << "#{TAB}#{TAB});" << ENDL;
  533. f << "#{TAB}}" << ENDL
  534. f << "}" << ENDL
  535. f << "" << ENDL
  536. num_log_sev_definitions = 1 + num_log_sev_definitions
  537. end
  538. PARAM_RANGE.each { |i| f << "#endif /* #{PARAMS_LIMIT_SYMBOL} >= #{NUM_PARAMS - i + 1} */" << ENDL }
  539. f << ENDL;
  540. end
  541. f.close()
  542. f = nil
  543. puts
  544. puts "# of pantheios_log_N() declarations: #{num_pantheios_log_N_declarations}"
  545. puts "# of pantheios_log_N_no_test() declarations: #{num_pantheios_log_N_no_test_declarations}"
  546. puts "# of pantheios_log_N_no_test() definitions: #{num_pantheios_log_N_no_test_definitions}"
  547. puts "# of pantheios_log_N() definitions: #{num_pantheios_log_N_definitions}"
  548. puts "# of log_dispatch_N() definitions: #{num_log_dispatch_N_definitions}"
  549. puts "# of log() definitions: #{num_log_definitions}"
  550. puts "# of log_SEV() definitions: #{num_log_sev_definitions}"
  551. puts "--------------------------------------------"
  552. puts "# of function declarations: #{num_pantheios_log_N_declarations + num_pantheios_log_N_no_test_declarations}"
  553. puts "# of function definitions: #{num_pantheios_log_N_no_test_definitions + num_pantheios_log_N_definitions + num_log_dispatch_N_definitions + num_log_definitions + num_log_sev_definitions}"