Skip to content

Commit

Permalink
Reorganize printing API helper script
Browse files Browse the repository at this point in the history
  • Loading branch information
PatKamin committed Nov 23, 2023
1 parent ce5f2b1 commit a99a452
Show file tree
Hide file tree
Showing 5 changed files with 346 additions and 94 deletions.
2 changes: 1 addition & 1 deletion include/ur_print.h
Original file line number Diff line number Diff line change
Expand Up @@ -3024,8 +3024,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintDeviceGetGlobalTimestampsParams(const
/// - ::UR_RESULT_SUCCESS
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// - `NULL == buffer`
/// - `NULL == params`
/// - `NULL == buffer`
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// - `buff_size < out_size`
UR_APIEXPORT ur_result_t UR_APICALL urPrintFunctionParams(ur_function_t function, const void *params, char *buffer, const size_t buff_size, size_t *out_size);
Expand Down
8 changes: 4 additions & 4 deletions scripts/templates/api_listing.mako
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ Print
============================================================
* Functions
%for func in api_types_funcs:
* :ref:`${func['name'].replace("_", "-")}`
* :ref:`${func.c_name.replace("_", "-")}`
%endfor
## 'Extras' functions
%for func in extras_funcs:
* :ref:`${func['c']['name']}`
* :ref:`${func.c_name}`
%endfor
<%def name="generate_api_doc(func_name)">\
Expand All @@ -300,10 +300,10 @@ ${func_name}
Print Functions
------------------------------------------------------------------------------
%for func in api_types_funcs:
${generate_api_doc(func['name'])}
${generate_api_doc(func.c_name)}
%endfor
%for func in extras_funcs:
## 'Extras' functions
${generate_api_doc(func['c']['name'])}
${generate_api_doc(func.c_name)}
%endfor
8 changes: 4 additions & 4 deletions scripts/templates/print.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,24 @@ ${x}_result_t str_copy(std::stringstream *ss, char *buff, const size_t buff_size
api_types_funcs = tph.get_api_types_funcs(specs, meta, n, tags)
%>
%for func in api_types_funcs:
${x}_result_t ${func['name']}(${",".join(func['args'])}) {
${x}_result_t ${func.c_name}(${func.c_args}) {
if (!buffer) {
return ${X}_RESULT_ERROR_INVALID_NULL_POINTER;
}

${ss_copy(func['arg_name'])}
${ss_copy(func.print_arg.name)}
}

%endfor

%for func in tph.get_extras_funcs(tags):
${x}_result_t ${func['c']['name']}(${",".join(func['c']['args'])}, char *buffer, const size_t buff_size, size_t *out_size) {
${x}_result_t ${func.c_name}(${func.c_args}) {
if (!buffer) {
return ${X}_RESULT_ERROR_INVALID_NULL_POINTER;
}

std::stringstream ss;
${x}_result_t result = ${x}::extras::${func['cpp']['name']}(ss, function, params);
${x}_result_t result = ${x}::extras::${func.cpp_name}(ss, function, params);
if (result != ${X}_RESULT_SUCCESS) {
return result;
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/templates/print.h.mako
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ extern "C" {
## Declarations ###############################################################
%for func in api_types_funcs:
///////////////////////////////////////////////////////////////////////////////
/// @brief Print ${func['ur_type_name']} ${func['base_type']}
/// @brief Print ${func.print_arg.type_name} ${func.print_arg.base_type}
/// @returns
/// - ::${X}_RESULT_SUCCESS
/// - ::${X}_RESULT_ERROR_INVALID_NULL_POINTER
/// - `NULL == buffer`
/// - ::${X}_RESULT_ERROR_INVALID_SIZE
/// - `buff_size < out_size`
${X}_APIEXPORT ${x}_result_t ${X}_APICALL ${func['name']}(${",".join(func['args'])});
${X}_APIEXPORT ${x}_result_t ${X}_APICALL ${func.c_name}(${func.c_args});

%endfor

%for func in tph.get_extras_funcs(tags):
${re.sub('\$\{X\}', X, func['comment'])} \
${X}_APIEXPORT ${x}_result_t ${X}_APICALL ${func['c']['name']}(${",".join(func['c']['args'])}, char *buffer, const size_t buff_size, size_t *out_size);
${re.sub('\$\{X\}', X, func.comment)} \
${X}_APIEXPORT ${x}_result_t ${X}_APICALL ${func.c_name}(${func.c_args});

%endfor
#if defined(__cplusplus)
Expand Down
Loading

0 comments on commit a99a452

Please sign in to comment.