Skip to content

Commit

Permalink
Update Mako Files with new init & formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Spruit, Neil R <neil.r.spruit@intel.com>
  • Loading branch information
nrspruit committed Aug 8, 2023
1 parent c38a775 commit d68e4bf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
47 changes: 44 additions & 3 deletions scripts/templates/libapi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,56 @@ ${th.make_func_name(n, tags, obj)}(
std::call_once(${x}_lib::context->initOnce, [flags]() {
%if re.match("zes", n):
result = ${x}_lib::context->Init(flags, true);
%else:
result = ${x}_lib::context->Init(flags, false);
%endif

});

if( ${X}_RESULT_SUCCESS != result )
return result;

if(ze_lib::context->inTeardown) {
return ${X}_RESULT_ERROR_UNINITIALIZED;
}

auto ${th.make_pfn_name(n, tags, obj)} = ${x}_lib::context->${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)};
if( nullptr == ${th.make_pfn_name(n, tags, obj)} ) {
if(!ze_lib::context->isInitialized)
return ${X}_RESULT_ERROR_UNINITIALIZED;
else
return ${X}_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

return ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} );
}
%else:
result = ${x}_lib::context->Init(flags, false);

if( ${X}_RESULT_SUCCESS != result )
return result;

if(ze_lib::context->inTeardown) {
return ${X}_RESULT_ERROR_UNINITIALIZED;
}

auto ${th.make_pfn_name(n, tags, obj)} = ${x}_lib::context->${n}DdiTable.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)};
if( nullptr == ${th.make_pfn_name(n, tags, obj)} ) {
if(!ze_lib::context->isInitialized)
return ${X}_RESULT_ERROR_UNINITIALIZED;
else
return ${X}_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

result = ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} );
return result;
});

if(ze_lib::context->inTeardown) {
result = ${X}_RESULT_ERROR_UNINITIALIZED;
}

return result;
}
%endif
%else:
if(ze_lib::context->inTeardown) {
return ${X}_RESULT_ERROR_UNINITIALIZED;
}
Expand All @@ -83,6 +123,7 @@ ${th.make_func_name(n, tags, obj)}(

return ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} );
}
%endif
%if 'condition' in obj:
#endif // ${th.subt(n, tags, obj['condition'])}
%endif
Expand Down
2 changes: 1 addition & 1 deletion scripts/templates/validation/valddi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ${line} \
auto result = ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} );
%if generate_post_call:

if( result==${X}_RESULT_SUCCESS && context.enableHandleLifetime ){
if( result == ${X}_RESULT_SUCCESS && context.enableHandleLifetime ){
%for i, item in enumerate(th.get_loader_epilogue(n, tags, obj, meta)):
%if 'range' in item:
for (size_t i = ${item['range'][0]}; ( nullptr != ${item['name']}) && (i < ${item['range'][1]}); ++i){
Expand Down

0 comments on commit d68e4bf

Please # to comment.