Skip to content

Commit

Permalink
refs #426
Browse files Browse the repository at this point in the history
this fixes the tests properly

The tests do not exercise all routes to the unsupported API in the leagcy backends,
so some more work required to fix all client applications.
  • Loading branch information
zjttoefs committed Aug 15, 2016
1 parent e3ff67c commit d4a37b1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
18 changes: 3 additions & 15 deletions bindings/cpp/NeXusFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,16 +1102,6 @@ AttrInfo File::getNextAttr() {
char name[NX_MAXNAMELEN];
int type;

#if defined(WITH_HDF4) || defined(WITH_MXML)
int length;
NXstatus status = NXgetnextattr(this->m_file_id, name, &length, &type);
if (status == NX_OK) {
AttrInfo info;
info.type = static_cast<NXnumtype>(type);
info.length = length;
info.name = string(name);
return info;
#else
int rank;
int dim[NX_MAXRANK];
NXstatus status = NXgetnextattra(this->m_file_id, name, &rank, dim, &type);
Expand Down Expand Up @@ -1145,15 +1135,13 @@ AttrInfo File::getNextAttr() {
// TODO - AttrInfo cannot handle more complex ranks/dimensions, we need to throw an error
std::cerr << "ERROR iterating through attributes found array attribute not understood by this api" << std::endl;
throw Exception("getNextAttr failed", NX_ERROR);
#endif
}
else if (status == NX_EOD) {

} else if (status == NX_EOD) {
AttrInfo info;
info.name = NULL_STR;
info.length = 0;
return info;
}
else {
} else {
throw Exception("NXgetnextattra failed", status);
}
}
Expand Down
15 changes: 11 additions & 4 deletions src/napi4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1953,15 +1953,22 @@ static int findNapiClass(pNexusFile pFile, int groupRef, NXname nxclass)
/*--------------------------------------------------------------------*/
NXstatus NX4putattra(NXhandle handle, CONSTCHAR* name, const void* data, const int rank, const int dim[], const int iType)
{
NXReportError("This is a HDF4 file, attribute array API is not supported here");
return NX_ERROR;
if (rank > 1) {
NXReportError("This is a HDF4 file, there is only rudimentary support for attribute arrays wirh rank <=1");
return NX_ERROR;
}

return NX4putattr(handle, name, data, dim[0], iType);
}

/*--------------------------------------------------------------------*/
NXstatus NX4getnextattra(NXhandle handle, NXname pName, int *rank, int dim[], int *iType)
{
NXReportError("This is a HDF4 file, attribute array API is not supported here");
return NX_ERROR;
NXstatus ret = NX4getnextattr(handle, pName, dim, iType);
if (ret != NX_OK) return ret;
(*rank) = 1;
if (dim[0] <= 1 ) (*rank) = 0;
return NX_OK;
}

/*--------------------------------------------------------------------*/
Expand Down
25 changes: 16 additions & 9 deletions src/nxxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1968,15 +1968,22 @@ int NXXcompress(NXhandle fid, int comp){
/*--------------------------------------------------------------------*/
NXstatus NXXputattra(NXhandle handle, CONSTCHAR* name, const void* data, const int rank, const int dim[], const int iType)
{
NXReportError("This is an XML file, attribute array API is not supported here");
return NX_ERROR;
if (rank > 1) {
NXReportError("This is an XML file, there is only rudimentary support for attribute arrays wirh rank <=1");
return NX_ERROR;
}

return NXXputattr(handle, name, data, dim[0], iType);
}

/*--------------------------------------------------------------------*/
NXstatus NXXgetnextattra(NXhandle handle, NXname pName, int *rank, int dim[], int *iType)
{
NXReportError("This is an XML file, attribute array API is not supported here");
return NX_ERROR;
NXstatus ret = NXXgetnextattr(handle, pName, dim, iType);
if (ret != NX_OK) return ret;
(*rank) = 1;
if (dim[0] <= 1 ) (*rank) = 0;
return NX_OK;
}

/*--------------------------------------------------------------------*/
Expand All @@ -1996,7 +2003,7 @@ NXstatus NXXgetattrainfo(NXhandle handle, NXname pName, int *rank, int dim[], i
/*----------------------------------------------------------------------*/
void NXXassignFunctions(pNexusFunction fHandle){
fHandle->nxclose=NXXclose;
fHandle->nxreopen=NULL;
fHandle->nxreopen=NULL;
fHandle->nxflush=NXXflush;
fHandle->nxmakegroup=NXXmakegroup;
fHandle->nxopengroup=NXXopengroup;
Expand Down Expand Up @@ -2027,10 +2034,10 @@ void NXXassignFunctions(pNexusFunction fHandle){
fHandle->nxsetnumberformat=NXXsetnumberformat;
fHandle->nxprintlink=NXXprintlink;
fHandle->nxnativeexternallink=NULL;
fHandle->nxputattra = NXXputattra;
fHandle->nxgetnextattra = NXXgetnextattra;
fHandle->nxgetattra = NXXgetattra;
fHandle->nxgetattrainfo = NXXgetattrainfo;
fHandle->nxputattra = NXXputattra;
fHandle->nxgetnextattra = NXXgetnextattra;
fHandle->nxgetattra = NXXgetattra;
fHandle->nxgetattrainfo = NXXgetattrainfo;
}

#endif /*NXXML*/

0 comments on commit d4a37b1

Please sign in to comment.