Skip to content

Commit d4a37b1

Browse files
committed
refs #426
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.
1 parent e3ff67c commit d4a37b1

3 files changed

Lines changed: 30 additions & 28 deletions

File tree

bindings/cpp/NeXusFile.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,16 +1102,6 @@ AttrInfo File::getNextAttr() {
11021102
char name[NX_MAXNAMELEN];
11031103
int type;
11041104

1105-
#if defined(WITH_HDF4) || defined(WITH_MXML)
1106-
int length;
1107-
NXstatus status = NXgetnextattr(this->m_file_id, name, &length, &type);
1108-
if (status == NX_OK) {
1109-
AttrInfo info;
1110-
info.type = static_cast<NXnumtype>(type);
1111-
info.length = length;
1112-
info.name = string(name);
1113-
return info;
1114-
#else
11151105
int rank;
11161106
int dim[NX_MAXRANK];
11171107
NXstatus status = NXgetnextattra(this->m_file_id, name, &rank, dim, &type);
@@ -1145,15 +1135,13 @@ AttrInfo File::getNextAttr() {
11451135
// TODO - AttrInfo cannot handle more complex ranks/dimensions, we need to throw an error
11461136
std::cerr << "ERROR iterating through attributes found array attribute not understood by this api" << std::endl;
11471137
throw Exception("getNextAttr failed", NX_ERROR);
1148-
#endif
1149-
}
1150-
else if (status == NX_EOD) {
1138+
1139+
} else if (status == NX_EOD) {
11511140
AttrInfo info;
11521141
info.name = NULL_STR;
11531142
info.length = 0;
11541143
return info;
1155-
}
1156-
else {
1144+
} else {
11571145
throw Exception("NXgetnextattra failed", status);
11581146
}
11591147
}

src/napi4.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,15 +1953,22 @@ static int findNapiClass(pNexusFile pFile, int groupRef, NXname nxclass)
19531953
/*--------------------------------------------------------------------*/
19541954
NXstatus NX4putattra(NXhandle handle, CONSTCHAR* name, const void* data, const int rank, const int dim[], const int iType)
19551955
{
1956-
NXReportError("This is a HDF4 file, attribute array API is not supported here");
1957-
return NX_ERROR;
1956+
if (rank > 1) {
1957+
NXReportError("This is a HDF4 file, there is only rudimentary support for attribute arrays wirh rank <=1");
1958+
return NX_ERROR;
1959+
}
1960+
1961+
return NX4putattr(handle, name, data, dim[0], iType);
19581962
}
19591963

19601964
/*--------------------------------------------------------------------*/
19611965
NXstatus NX4getnextattra(NXhandle handle, NXname pName, int *rank, int dim[], int *iType)
19621966
{
1963-
NXReportError("This is a HDF4 file, attribute array API is not supported here");
1964-
return NX_ERROR;
1967+
NXstatus ret = NX4getnextattr(handle, pName, dim, iType);
1968+
if (ret != NX_OK) return ret;
1969+
(*rank) = 1;
1970+
if (dim[0] <= 1 ) (*rank) = 0;
1971+
return NX_OK;
19651972
}
19661973

19671974
/*--------------------------------------------------------------------*/

src/nxxml.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,15 +1968,22 @@ int NXXcompress(NXhandle fid, int comp){
19681968
/*--------------------------------------------------------------------*/
19691969
NXstatus NXXputattra(NXhandle handle, CONSTCHAR* name, const void* data, const int rank, const int dim[], const int iType)
19701970
{
1971-
NXReportError("This is an XML file, attribute array API is not supported here");
1972-
return NX_ERROR;
1971+
if (rank > 1) {
1972+
NXReportError("This is an XML file, there is only rudimentary support for attribute arrays wirh rank <=1");
1973+
return NX_ERROR;
1974+
}
1975+
1976+
return NXXputattr(handle, name, data, dim[0], iType);
19731977
}
19741978

19751979
/*--------------------------------------------------------------------*/
19761980
NXstatus NXXgetnextattra(NXhandle handle, NXname pName, int *rank, int dim[], int *iType)
19771981
{
1978-
NXReportError("This is an XML file, attribute array API is not supported here");
1979-
return NX_ERROR;
1982+
NXstatus ret = NXXgetnextattr(handle, pName, dim, iType);
1983+
if (ret != NX_OK) return ret;
1984+
(*rank) = 1;
1985+
if (dim[0] <= 1 ) (*rank) = 0;
1986+
return NX_OK;
19801987
}
19811988

19821989
/*--------------------------------------------------------------------*/
@@ -1996,7 +2003,7 @@ NXstatus NXXgetattrainfo(NXhandle handle, NXname pName, int *rank, int dim[], i
19962003
/*----------------------------------------------------------------------*/
19972004
void NXXassignFunctions(pNexusFunction fHandle){
19982005
fHandle->nxclose=NXXclose;
1999-
fHandle->nxreopen=NULL;
2006+
fHandle->nxreopen=NULL;
20002007
fHandle->nxflush=NXXflush;
20012008
fHandle->nxmakegroup=NXXmakegroup;
20022009
fHandle->nxopengroup=NXXopengroup;
@@ -2027,10 +2034,10 @@ void NXXassignFunctions(pNexusFunction fHandle){
20272034
fHandle->nxsetnumberformat=NXXsetnumberformat;
20282035
fHandle->nxprintlink=NXXprintlink;
20292036
fHandle->nxnativeexternallink=NULL;
2030-
fHandle->nxputattra = NXXputattra;
2031-
fHandle->nxgetnextattra = NXXgetnextattra;
2032-
fHandle->nxgetattra = NXXgetattra;
2033-
fHandle->nxgetattrainfo = NXXgetattrainfo;
2037+
fHandle->nxputattra = NXXputattra;
2038+
fHandle->nxgetnextattra = NXXgetnextattra;
2039+
fHandle->nxgetattra = NXXgetattra;
2040+
fHandle->nxgetattrainfo = NXXgetattrainfo;
20342041
}
20352042

20362043
#endif /*NXXML*/

0 commit comments

Comments
 (0)