Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
0x17 committed Nov 3, 2023
2 parents adb4356 + 667d578 commit 4e4ed3c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
20 changes: 10 additions & 10 deletions generated/cwrap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,29 +312,29 @@ GDX_INLINE int gdxDataReadRaw( TGXFileRec_t *pgx, int *KeyInt, double *Values, i
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxDataReadRaw(KeyInt, Values, *DimFrst );
}

GDX_INLINE int gdxDataReadRawFast( TGXFileRec_t *pgx, int SyNr, TDataStoreProc_t DP, int *NrRecs )
GDX_INLINE int gdxDataReadRawFast( TGXFileRec_t *pgx, int SyNr, ::TDataStoreProc_t DP, int *NrRecs )
{
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxDataReadRawFast(SyNr, DP, *NrRecs );
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxDataReadRawFast(SyNr, (gdx::TDataStoreProc_t) DP, *NrRecs );
}

GDX_INLINE int gdxDataReadRawFastEx( TGXFileRec_t *pgx, int SyNr, TDataStoreExProc_t DP, int *NrRecs, void *Uptr )
GDX_INLINE int gdxDataReadRawFastEx( TGXFileRec_t *pgx, int SyNr, ::TDataStoreExProc_t DP, int *NrRecs, void *Uptr )
{
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxDataReadRawFastEx(SyNr, DP, *NrRecs, Uptr );
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxDataReadRawFastEx(SyNr, (gdx::TDataStoreExProc_t) DP, *NrRecs, Uptr );
}

GDX_INLINE int gdxDataReadRawFastFilt( TGXFileRec_t *pgx, int SyNr, const char **UelFilterStr, TDataStoreFiltProc_t DP )
GDX_INLINE int gdxDataReadRawFastFilt( TGXFileRec_t *pgx, int SyNr, const char **UelFilterStr, ::TDataStoreFiltProc_t DP )
{
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxDataReadRawFastFilt(SyNr, UelFilterStr, DP );
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxDataReadRawFastFilt(SyNr, UelFilterStr, (gdx::TDataStoreFiltProc_t) DP );
}

GDX_INLINE int gdxDataReadRawStart( TGXFileRec_t *pgx, int SyNr, int *NrRecs )
{
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxDataReadRawStart(SyNr, *NrRecs );
}

GDX_INLINE int gdxDataReadSlice( TGXFileRec_t *pgx, const char **UelFilterStr, int *Dimen, TDataStoreProc_t DP )
GDX_INLINE int gdxDataReadSlice( TGXFileRec_t *pgx, const char **UelFilterStr, int *Dimen, ::TDataStoreProc_t DP )
{
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxDataReadSlice(UelFilterStr, *Dimen, DP );
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxDataReadSlice(UelFilterStr, *Dimen, (gdx::TDataStoreProc_t) DP );
}

GDX_INLINE int gdxDataReadSliceStart( TGXFileRec_t *pgx, int SyNr, int *ElemCounts )
Expand Down Expand Up @@ -642,9 +642,9 @@ GDX_INLINE int gdxUMUelInfo( TGXFileRec_t *pgx, int *UelCnt, int *HighMap )
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxUMUelInfo(*UelCnt, *HighMap );
}

GDX_INLINE int gdxGetDomainElements( TGXFileRec_t *pgx, int SyNr, int DimPos, int FilterNr, TDomainIndexProc_t DP, int *NrElem, void *Uptr )
GDX_INLINE int gdxGetDomainElements( TGXFileRec_t *pgx, int SyNr, int DimPos, int FilterNr, ::TDomainIndexProc_t DP, int *NrElem, void *Uptr )
{
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxGetDomainElements(SyNr, DimPos, FilterNr, DP, *NrElem, Uptr );
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->gdxGetDomainElements(SyNr, DimPos, FilterNr, (gdx::TDomainIndexProc_t) DP, *NrElem, Uptr );
}

GDX_INLINE int gdxCurrentDim( TGXFileRec_t *pgx)
Expand Down
4 changes: 2 additions & 2 deletions src/templates/cwrap.template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ GDX_INLINE void gdxDestroy( TGXFileRec_t **pgx )
GDX_INLINE {{ map_type(fobj|first, fvals.type) }}{{ fobj|first }}( TGXFileRec_t *pgx{% if fvals.parameters %}{{', '}}{% endif %}
{%- for parm in fvals.parameters -%}
{%- set parm_vals = parm.values()|first -%}
{{map_type(fobj|first, parm_vals.type)}}{{parm|first}}{% if not loop.last %}, {% endif %}{% endfor -%}
{{fp_decor(None, map_type(fobj|first, parm_vals.type))}}{{parm|first}}{% if not loop.last %}, {% endif %}{% endfor -%}
{%- if fvals.parameters %}{{' '}}{% endif %})
{
return reinterpret_cast<gdx::TGXFileObj *>( pgx )->{{fobj|first}}(
{%- for parm in fvals.parameters -%}
{%- set parm_vals = parm.values()|first -%}
{{maybe_deref(parm|first,parm_vals.type)}}{% if not loop.last %}, {% endif %}{% endfor -%}
{{fp_decor(map_type(fobj|first, parm_vals.type), maybe_deref(parm|first,parm_vals.type))}}{% if not loop.last %}, {% endif %}{% endfor -%}
{%- if fvals.parameters %}{{' '}}{% endif %});
}
{% endfor %}
Expand Down
10 changes: 10 additions & 0 deletions src/yaml2cwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@ def maybe_deref(arg_name, arg_type, deref_char='*'):
return (deref_char if arg_type == 'Oint' else '') + arg_name


def fp_decor(t, s):
if s.strip().endswith('Proc_t'):
return '::' + s
elif s == 'DP':
return f'(gdx::{t.rstrip()}) {s}'
else:
return s


def generate_c_wrapper(input, template_folder, template, output):
with open(input) as fp:
obj = yaml.load(fp, Loader=yaml.FullLoader)
env = Environment(loader=FileSystemLoader(template_folder))
cpp_wrap = template.endswith('gdxcppwrap.template.j2')
env.globals['map_type'] = yaml2doxy.map_type_gen(obj['functionpointers'], for_cpp=cpp_wrap)
env.globals['maybe_deref'] = maybe_deref
env.globals['fp_decor'] = fp_decor
template = env.get_template(template)
with open(output, 'w') as fp:
fp.write(template.render(obj=obj))
Expand Down

0 comments on commit 4e4ed3c

Please sign in to comment.