Skip to content

Commit

Permalink
hds: hdsCopy wrapper now works
Browse files Browse the repository at this point in the history
Uses the newly created low level dat1Copy support routines.
  • Loading branch information
timj committed Oct 31, 2014
1 parent 31790f2 commit bfd3083
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 10 deletions.
38 changes: 28 additions & 10 deletions libraries/hds/hds_select.c
Expand Up @@ -2738,18 +2738,36 @@ datVec(const HDSLoc *locator1, HDSLoc **locator2, int *status) {

int
hdsCopy(const HDSLoc *locator, const char *file_str, const char name_str[DAT__SZNAM], int *status) {

int retval = 0;
int instat = *status;
int isv5 = ISHDSv5(locator);
int ndim = 0;
hdsdim dims[DAT__MXDIM];
char type_str[DAT__SZTYP+1];
HDSLoc * outloc = NULL;
hdsbool_t struc = 0;
EnterCheck("hdsCopy",*status);
if (isv5) {
retval = hdsCopy_v5(locator, file_str, name_str, status);
} else {
retval = hdsCopy_v4(locator, file_str, name_str, status);
}
HDS_CHECK_STATUS("hdsCopy",(isv5 ? "(v5)" : "(v4)"));
return retval;
if (*status != SAI__OK) return *status;
/* We always want to end up with output files that match
the format currently in use for hdsNew (which may depend
on an environment variable). We can not simply call hdsCopy_v5.
so we have to do some manual leg work. Would be a bit easier if
we had a function in this file that returned the default output
format version so we could call the native version.
*/
datType( locator, type_str, status );
datShape( locator, DAT__MXDIM, dims, &ndim, status );
/* Unfortunately this locator is one level down */
hdsNew(file_str, name_str, type_str, ndim, dims, &outloc, status );
/* So we need to walk through and can not simply use datCopy
- we can use two routines used by dat1CopyXtoY though. */
datStruc(locator, &struc, status);
if (struc) {
dat1CopyStrucXtoY( locator, outloc, status );
} else {
dat1CopyPrimXtoY( locator, outloc, status );
}
datAnnul(&outloc, status);
HDS_CHECK_STATUS("hdsCopy", (ISHDSv5(locator) ? "(v5)" : "(v4)"));
return *status;
}

/*=================================*/
Expand Down
35 changes: 35 additions & 0 deletions libraries/hds/helper/mkhdswrapper.py
Expand Up @@ -259,6 +259,38 @@ def func_hdsFlush(line):
HDS_CHECK_STATUS("hdsFlush", "(both)");
return *status;""")

def func_hdsCopy(line):
print(""" int instat = *status;
int ndim = 0;
hdsdim dims[DAT__MXDIM];
char type_str[DAT__SZTYP+1];
HDSLoc * outloc = NULL;
hdsbool_t struc = 0;
EnterCheck(\"hdsCopy\",*status);
if (*status != SAI__OK) return *status;
/* We always want to end up with output files that match
the format currently in use for hdsNew (which may depend
on an environment variable). We can not simply call hdsCopy_v5.
so we have to do some manual leg work. Would be a bit easier if
we had a function in this file that returned the default output
format version so we could call the native version.
*/
datType( locator, type_str, status );
datShape( locator, DAT__MXDIM, dims, &ndim, status );
/* Unfortunately this locator is one level down */
hdsNew(file_str, name_str, type_str, ndim, dims, &outloc, status );
/* So we need to walk through and can not simply use datCopy
- we can use two routines used by dat1CopyXtoY though. */
datStruc(locator, &struc, status);
if (struc) {
dat1CopyStrucXtoY( locator, outloc, status );
} else {
dat1CopyPrimXtoY( locator, outloc, status );
}
datAnnul(&outloc, status);
HDS_CHECK_STATUS("hdsCopy", (ISHDSv5(locator) ? "(v5)" : "(v4)"));
return *status;""")

# Dictionary indicating special cases
special = dict({
"datCcopy": "copy",
Expand All @@ -269,6 +301,7 @@ def func_hdsFlush(line):
"datMove": "datMove",
"datMsg": "void",
"datTemp": "v5",
"hdsCopy": "hdsCopy",
"hdsEwild": "special",
"hdsFlush": "hdsFlush",
"hdsGtune": "hdsGtune",
Expand Down Expand Up @@ -325,6 +358,8 @@ def func_hdsFlush(line):
func_hdsGtune(line)
elif mode == "hdsFlush":
func_hdsFlush(line)
elif mode == "hdsCopy":
func_hdsCopy(line)
elif mode == "copy":
func_copy(hds_function,line)
else:
Expand Down

0 comments on commit bfd3083

Please sign in to comment.