Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test 4.4.4 #474

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ endif()
#-----------------------------------------------------------------------------
set (API_VERSION_MAJOR 4)
set (API_VERSION_MINOR 4)
set (API_VERSION_PATCH 3)
set (API_VERSION_PATCH 4)
set (API_VERSION "${API_VERSION_MAJOR}.${API_VERSION_MINOR}.${API_VERSION_PATCH}")
set (ABI_CURRENT 1)
set (ABI_REVISION 0)
Expand Down Expand Up @@ -224,10 +224,10 @@ find_package(LibXml2)
#find_package(PythonInterp)

#Find the java runtime and sdk
#if(ENABLE_JAVA_BINDINGS)
# find_package(Java 1.6)
# find_package(JNI)
#endif()
if(ENABLE_JAVA)
find_package(Java 1.6)
find_package(JNI)
endif()


find_library(PTHREAD pthread)
Expand Down
14 changes: 14 additions & 0 deletions Docker.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Docker file for an ubuntu image for testing NAPI with an up-to-date distro
FROM ubuntu:20.04

RUN apt update && apt-get install -y \
gcc \
g++ \
gfortran \
libhdf5-dev \
libmxml-dev \
cmake \
default-jdk


CMD /bin/bash
2 changes: 2 additions & 0 deletions applications/NXtranslate/text_xml/xml_retriever_dom.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <iostream>
#define LIBXML_LEGACY_ENABLED
#include <libxml/SAX.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <stdexcept>
Expand Down
2 changes: 2 additions & 0 deletions applications/NXtranslate/xml_parser.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define LIBXML_LEGACY_ENABLED
#include <libxml/SAX.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <iostream>
Expand Down
8 changes: 4 additions & 4 deletions applications/nxingest/nxingest_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
whitespace_cb(mxml_node_t *node, /* I - Element node */
int where) /* I - Open or close tag? */
{
if (strncmp(node->value.element.name, "?xml", 4) == 0)
if (strncmp(mxmlGetElement(node), "?xml", 4) == 0)
return(NULL);
if (where == MXML_WS_BEFORE_OPEN )
return ("\n");
Expand Down Expand Up @@ -112,11 +112,11 @@ int main (int argc, char *argv[])
outFp = fopen(outputFl, "w");
if( outFp == 0 ) throw log.set("main", "Can't open the output file!", outputFl, "", NXING_ERR_CANT_OPEN_OUTPUT);

if(inTree->type == MXML_ELEMENT && (strncmp(inTree->value.element.name, "?xml", 4) == 0)){
outTree = mxmlNewElement(MXML_NO_PARENT, inTree->value.element.name);
if(mxmlGetType(inTree) == MXML_ELEMENT && (strncmp(mxmlGetElement(inTree), "?xml", 4) == 0)){
outTree = mxmlNewElement(MXML_NO_PARENT, mxmlGetElement(inTree));
}

log.set("main", "Output Created, first tag added!", inTree->value.element.name).printLevel(NXING_LOG_DEBUG);
log.set("main", "Output Created, first tag added!", mxmlGetElement(inTree)).printLevel(NXING_LOG_DEBUG);
//

// Open the neXus file.
Expand Down
75 changes: 41 additions & 34 deletions applications/nxingest/nxingest_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,32 @@ mxml_node_t *parseXml(mxml_node_t *inNode, mxml_node_t *topNode, mxml_node_t **o

int type_descent = MXML_DESCEND;
const char *type;
const char *attName;
const char *attValue;

while( (inNode = mxmlWalkNext(inNode, topNode, type_descent)) != NULL )
{
inNextNode = inNode; // Get the last inNode to pass back to the calling function
if(inNode->type == MXML_ELEMENT)
if(mxmlGetType(inNode) == MXML_ELEMENT)
{
type_descent = MXML_DESCEND;

type = mxmlElementGetAttr(inNode, "type");
if(type != 0)
{
log.set("parseXml", "Found element : ", inNode->value.element.name).printLevel(NXING_LOG_DEBUG);
log.set("parseXml", "Found element : ", mxmlGetElement(inNode)).printLevel(NXING_LOG_DEBUG);
if(strcmp(type, "tbl") == 0 ) // Simple table.
{
log.set("parseXml", "Get new table", inNode->value.element.name).printLevel(NXING_LOG_DEBUG);
outNextNode = mxmlNewElement(*outNode, inNode->value.element.name );
log.set("parseXml", "Get new table", mxmlGetElement(inNode)).printLevel(NXING_LOG_DEBUG);
outNextNode = mxmlNewElement(*outNode, mxmlGetElement(inNode) );
// add the attributes of the input node :
if(inNode->value.element.num_attrs > 1)
for(int i = 0; i< inNode->value.element.num_attrs; i++)
if(strcmp(inNode->value.element.attrs[i].name, "type") != 0)
mxmlElementSetAttr(outNextNode, inNode->value.element.attrs[i].name, inNode->value.element.attrs[i].value);
if(mxmlElementGetAttrCount(inNode) > 1)
for(int i = 0; i< mxmlElementGetAttrCount(inNode); i++) {

attValue = mxmlElementGetAttrByIndex(inNode, i, &attName);
if(strcmp(attName, "type") != 0)
mxmlElementSetAttr(outNextNode, attName, attValue);
}
inNode = parseXml(inNode, inNode, &outNextNode, nx);
}
else if(strcmp(type, "user_tbl") == 0 ) // User table. There may be several user. Need to loop over the different NXusers.
Expand All @@ -103,50 +108,52 @@ mxml_node_t *parseXml(mxml_node_t *inNode, mxml_node_t *topNode, mxml_node_t **o
do{
userInNode = inNode;

log.set("parseXml", type, "Start", inNode->value.element.name).printLevel(NXING_LOG_DEBUG);
outNextNode = mxmlNewElement(*userOutNode, userInNode->value.element.name );
if(userInNode->value.element.num_attrs > 1)
for(int i = 0; i< userInNode->value.element.num_attrs; i++)
if(strcmp(userInNode->value.element.attrs[i].name, "type") != 0)
mxmlElementSetAttr(outNextNode, userInNode->value.element.attrs[i].name, userInNode->value.element.attrs[i].value);
log.set("parseXml", type, "Start", mxmlGetElement(inNode)).printLevel(NXING_LOG_DEBUG);
outNextNode = mxmlNewElement(*userOutNode, mxmlGetElement(userInNode) );
if(mxmlElementGetAttrCount(userInNode) > 1)
for(int i = 0; i< mxmlElementGetAttrCount(userInNode); i++) {
attValue = mxmlElementGetAttrByIndex(userInNode, i, &attName);
if(strcmp(attName, "type") != 0)
mxmlElementSetAttr(outNextNode, attName, attValue);
}

log.set("parseXml", type, "Element added",userInNode->value.element.name).printLevel(NXING_LOG_DEBUG);
log.set("parseXml", type, "Element added",mxmlGetElement(userInNode)).printLevel(NXING_LOG_DEBUG);
parseXml(userInNode, topNode, &outNextNode, nx);
log.set("parseXml", type, "Parsed", inNode->value.element.name).printLevel(NXING_LOG_DEBUG);
log.set("parseXml", type, "Parsed", mxmlGetElement(inNode)).printLevel(NXING_LOG_DEBUG);

}while(nx.nextUser() != -1);
inNode = mxmlWalkNext(inNode, topNode, MXML_NO_DESCEND);
}
else if(strcmp(type, "keyword_tag") == 0 ) // simple Tag record
{
log.set("parseXml", type, "Read",inNode->value.element.name).printLevel(NXING_LOG_DEBUG);
log.set("parseXml", type, "Read",mxmlGetElement(inNode)).printLevel(NXING_LOG_DEBUG);
inNode = readKeyword(inNode, outNode, nx);
type_descent = MXML_NO_DESCEND;
}
else if(strcmp(type, "tag") == 0 ) // simple Tag record
{
log.set("parseXml", type, "Read",inNode->value.element.name).printLevel(NXING_LOG_DEBUG);
log.set("parseXml", type, "Read",mxmlGetElement(inNode)).printLevel(NXING_LOG_DEBUG);
inNode = readRecord(inNode, outNode, nx);
type_descent = MXML_NO_DESCEND;
}
else if(strcmp(type, "param_str") == 0 ) // Parameter with a string value
{
log.set("parseXml", type, "Read", inNode->value.element.name).printLevel(NXING_LOG_DEBUG);
log.set("parseXml", type, "Read", mxmlGetElement(inNode)).printLevel(NXING_LOG_DEBUG);
inNode = readParam(inNode, outNode, nx, STR);
type_descent = MXML_NO_DESCEND;
}
else if(strcmp(type, "param_num") == 0 ) // Parameter with a numeric value
{
log.set("parseXml", type, "Read",inNode->value.element.name).printLevel(NXING_LOG_DEBUG);
log.set("parseXml", type, "Read",mxmlGetElement(inNode)).printLevel(NXING_LOG_DEBUG);
inNode = readParam(inNode, outNode, nx, NUM);
type_descent = MXML_NO_DESCEND;

}
}
}
if(inNode->type == MXML_TEXT && strlen(inNode->value.text.string) > 0)
if(mxmlGetType(inNode) == MXML_TEXT && strlen(mxmlGetText(inNode, NULL)) > 0)
{
log.set("parseXml", "Unexpected text (may be comments)", inNode->value.text.string).printLevel(NXING_LOG_DEBUG);
log.set("parseXml", "Unexpected text (may be comments)", mxmlGetText(inNode, NULL)).printLevel(NXING_LOG_DEBUG);
}
}
return (inNextNode);
Expand Down Expand Up @@ -174,15 +181,15 @@ mxml_node_t * readRecord(mxml_node_t *inNode, mxml_node_t **outNode, NxClass nx)
//
while( (inNode = mxmlWalkNext(inNode, topNode, MXML_DESCEND)) != NULL )
{
if(inNode->type == MXML_ELEMENT)
if(mxmlGetType(inNode) == MXML_ELEMENT)
{
if(strcmp(inNode->value.element.name, "icat_name") == 0)
if(strcmp(mxmlGetElement(inNode), "icat_name") == 0)
{
log.set("readRecord", "ICAT name",mxmlGetItem(inNode, name)).printLevel(NXING_LOG_DEBUG);
mxmlGetItem(inNode, name);
log.set("readRecord", "ICAT name",name).printLevel(NXING_LOG_DEBUG);
}
else if(strcmp(inNode->value.element.name, "value") == 0)
else if(strcmp(mxmlGetElement(inNode), "value") == 0)
{
getValue(inNode, nx, value);
}
Expand All @@ -209,19 +216,19 @@ mxml_node_t * readKeyword(mxml_node_t *inNode, mxml_node_t **outNode, NxClass nx
char keys[] = " ,;";

//
strcpy(keywordStr , inNode->value.element.name);
strcpy(keywordStr , mxmlGetElement(inNode));

while( (inNode = mxmlWalkNext(inNode, topNode, MXML_DESCEND)) != NULL )
{
if(inNode->type == MXML_ELEMENT)
if(mxmlGetType(inNode) == MXML_ELEMENT)
{
if(strcmp(inNode->value.element.name, "icat_name") == 0)
if(strcmp(mxmlGetElement(inNode), "icat_name") == 0)
{
log.set("readRecord", "ICAT name",mxmlGetItem(inNode, name)).printLevel(NXING_LOG_DEBUG);
mxmlGetItem(inNode, name);
log.set("readRecord", "ICAT name",name).printLevel(NXING_LOG_DEBUG);
}
else if(strcmp(inNode->value.element.name, "value") == 0)
else if(strcmp(mxmlGetElement(inNode), "value") == 0)
{
getValue(inNode, nx, value);
}
Expand Down Expand Up @@ -289,29 +296,29 @@ mxml_node_t * readParam(mxml_node_t *inNode, mxml_node_t **outNode, NxClass nx,

while( (inNode = mxmlWalkNext(inNode, topNode, MXML_DESCEND)) != NULL )
{
if(inNode->type == MXML_ELEMENT)
if(mxmlGetType(inNode) == MXML_ELEMENT)
{
if(strcmp(inNode->value.element.name, "icat_name") == 0)
if(strcmp(mxmlGetElement(inNode), "icat_name") == 0)
{
log.set("readParam", "ICAT name", mxmlGetItem(inNode, str)).printLevel(NXING_LOG_DEBUG);
buff = mxmlGetItem(inNode, str);
if(buff != 0) name = buff;
else name = ""; }
else if(strcmp(inNode->value.element.name, "value") == 0)
else if(strcmp(mxmlGetElement(inNode), "value") == 0)
{
log.set("readParam", "Value ", mxmlGetItem(inNode, str)).printLevel(NXING_LOG_DEBUG);
buff = getValue(inNode, nx, str);
if(buff != 0) value = buff;
else value = "";
}
else if(strcmp(inNode->value.element.name, "units") == 0)
else if(strcmp(mxmlGetElement(inNode), "units") == 0)
{
log.set("readParam", "Units", mxmlGetItem(inNode, str)).printLevel(NXING_LOG_DEBUG);
buff = getValue(inNode, nx, str);
if(buff != 0) units = buff;
else units = "";
}
else if(strcmp(inNode->value.element.name, "description") == 0)
else if(strcmp(mxmlGetElement(inNode), "description") == 0)
{
log.set("readParam", "Description", mxmlGetItem(inNode, str)).printLevel(NXING_LOG_DEBUG);
buff = getValue(inNode, nx, str);
Expand Down
8 changes: 4 additions & 4 deletions applications/nxingest/nxingest_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ char* mxmlGetItem(mxml_node_t *node, char* str){
topNode = node;

strcpy(str, "");
while( (node = mxmlWalkNext(node, topNode, MXML_DESCEND)) != NULL && node->type == MXML_TEXT)
while( (node = mxmlWalkNext(node, topNode, MXML_DESCEND)) != NULL && mxmlGetType(node) == MXML_TEXT)
{
strcat(str, node->value.text.string);
strcat(str, mxmlGetText(node, NULL));
strcat(str, " ");
}
while(strlen(str) > 0 && str[strlen(str)-1] == ' ')
Expand All @@ -89,9 +89,9 @@ char* mxmlGetItem(mxml_node_t *node){
topNode = node;
while( (node = mxmlWalkNext(node, topNode, MXML_DESCEND)) != NULL )
{
if(node->type == MXML_TEXT && strlen(node->value.text.string) > 0)
if(mxmlGetType(node) == MXML_TEXT && strlen(mxmlGetText(node, NULL)) > 0)
{
return node->value.text.string;
return strdup(mxmlGetText(node, NULL));
}
}
return 0;
Expand Down
6 changes: 3 additions & 3 deletions bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ if(ENABLE_FORTRAN90)
endif()

#add_subdirectory (idl)
#if (NOT(Java_JAVAC_EXECUTABLE MATCHES NOTFOUND))
# add_subdirectory (java)
#endif ()
if (NOT(Java_JAVAC_EXECUTABLE MATCHES NOTFOUND))
add_subdirectory (java)
endif ()
#add_subdirectory (matlab)
#if (PYTHONINTERP_FOUND)
# add_subdirectory (python)
Expand Down
3 changes: 2 additions & 1 deletion bindings/cpp/NeXusFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ void File::getAttr(const std::string& name, std::vector<std::string>& array) {
}

// get attrInfo
char attr_name[name.size()+1];
char * attr_name = new char[name.size()+1];
strcpy(attr_name, name.c_str());

int type;
Expand Down Expand Up @@ -1273,6 +1273,7 @@ void File::getAttr(const std::string& name, std::vector<std::string>& array) {
end = data.find(sep, start);
}
array.push_back(data.substr(start));
delete [] attr_name;
}

vector<AttrInfo> File::getAttrInfos() {
Expand Down
36 changes: 18 additions & 18 deletions bindings/java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ if(DEFINED Java_JAVAC_EXECUTABLE)
${PROJECT_SOURCE_DIR}/bindings/java/org/nexusformat/NexusFile.java
${JAVA_TEST})

SET(JAVA_CLASSES ${PROJECT_BINARY_DIR}/bindings/java/ncsa/hdf/hdflib/HDFException.class
${PROJECT_BINARY_DIR}/bindings/java/ncsa/hdf/hdflib/HDFJavaException.class
${PROJECT_BINARY_DIR}/bindings/java/ncsa/hdf/hdflib/HDFNotImplementedException.class
${PROJECT_BINARY_DIR}/bindings/java/ncsa/hdf/hdflib/HDFConstants.class
${PROJECT_BINARY_DIR}/bindings/java/ncsa/hdf/hdflib/HDFArray.class
${PROJECT_BINARY_DIR}/bindings/java/ncsa/hdf/hdflib/HDFNativeData.class
${PROJECT_BINARY_DIR}/bindings/java/org/nexusformat/NexusException.class
${PROJECT_BINARY_DIR}/bindings/java/org/nexusformat/NXlink.class
${PROJECT_BINARY_DIR}/bindings/java/org/nexusformat/NeXusFileInterface.class
${PROJECT_BINARY_DIR}/bindings/java/org/nexusformat/AttributeEntry.class
${PROJECT_BINARY_DIR}/bindings/java/org/nexusformat/NexusFile.class
${PROJECT_BINARY_DIR}/bindings/java/TestJapi.class)

SET(EXTRA_CLASSES ${PROJECT_BINARY_DIR}/bindings/java/ncsa/hdf/hdflib/ArrayDescriptor.class)
SET(JAVA_CLASSES ncsa/hdf/hdflib/HDFException.class
ncsa/hdf/hdflib/HDFJavaException.class
ncsa/hdf/hdflib/HDFNotImplementedException.class
ncsa/hdf/hdflib/HDFConstants.class
ncsa/hdf/hdflib/HDFArray.class
ncsa/hdf/hdflib/HDFNativeData.class
org/nexusformat/NexusException.class
org/nexusformat/NXlink.class
org/nexusformat/NeXusFileInterface.class
org/nexusformat/AttributeEntry.class
org/nexusformat/NexusFile.class
TestJapi.class)

SET(EXTRA_CLASSES ncsa/hdf/hdflib/ArrayDescriptor.class)

SET(JNI_HEADER native/org_nexusformat_NexusFile.h)

Expand All @@ -90,15 +90,15 @@ if(DEFINED Java_JAVAC_EXECUTABLE)
ADD_CUSTOM_COMMAND(
OUTPUT ${JAR_ARCHIVE}
COMMAND ${Java_JAR_EXECUTABLE}
ARGS cvf ${JAR_ARCHIVE} ${JAVA_CLASSES} ${EXTRA_CLASSES}
ARGS cvf ${JAR_ARCHIVE} -C ${PROJECT_BINARY_DIR}/bindings/java/ ${JAVA_CLASSES} ${EXTRA_CLASSES}
DEPENDS ${EXTRA_CLASSES}
COMMENT "Build JAR File"
)

ADD_CUSTOM_COMMAND(
OUTPUT ${JNI_HEADER}
COMMAND ${Java_JAVAH_EXECUTABLE}
ARGS -jni -d native -classpath . org.nexusformat.NexusFile
COMMAND ${Java_JAVAC_EXECUTABLE}
ARGS -h native ${PROJECT_SOURCE_DIR}/bindings/java/org/nexusformat/NexusFile.java
DEPENDS ${JAR_ARCHIVE}
COMMENT "Build JNI Header"
)
Expand All @@ -113,7 +113,7 @@ if(DEFINED Java_JAVAC_EXECUTABLE)
)

ADD_CUSTOM_TARGET(NexusJavaBuild ALL echo
DEPENDS ${JAR_ARCHIVE}
DEPENDS ${JAR_ARCHIVE} ${JNI_HEADER}
)

ADD_CUSTOM_TARGET(NexusJavadocBuild ALL echo
Expand Down
4 changes: 1 addition & 3 deletions bindings/java/ncsa/hdf/hdflib/HDFNativeData.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ public Object byteToNumber( byte[] barray, Object obj)
*
* @param dataType the type of the iamge data
* @param datasize the size of the image data array
* @returns an array of 'datasize' numbers of 'dataType
* @return an array of 'datasize' numbers of 'dataType
*
* @see ncsa.hdf.hdfobject.HDFGR
* @see ncsa.hdf.hdfobject.HDFSDS
*/
public static Object defineDataObject(int dataType, int datasize)
{
Expand Down
Loading