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

Develop clang format java #1653

Merged
merged 4 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
32 changes: 18 additions & 14 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
---
Language: Cpp
BasedOnStyle: LLVM
AlignConsecutiveAssignments: true
BraceWrapping:
AfterFunction: true
#llvm10-11: AfterControlStatement: false - Never
BeforeCatch: true
BeforeElse: true
#llvm11: BeforeLambdaBody: false
#llvm11: BeforeWhile: false
BreakBeforeBraces: Stroustrup
BreakAfterJavaFieldAnnotations: true
BreakStringLiterals: true
ColumnLimit: 110 # Update $max_trace_macro_line_len in bin/trace also
IndentWidth: 4
---
Language: Cpp
#llvm11: AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: true
AlignConsecutiveMacros: true
Expand All @@ -22,17 +35,6 @@ AlwaysBreakAfterReturnType: AllDefinitions
# - H5_ATTR_CONST
# - H5_ATTR_PURE
# - H5_ATTR_FALLTHROUGH
BraceWrapping:
AfterFunction: true
#llvm10-11: AfterControlStatement: false - Never
BeforeCatch: true
BeforeElse: true
#llvm11: BeforeLambdaBody: false
#llvm11: BeforeWhile: false
BreakBeforeBraces: Stroustrup
BreakAfterJavaFieldAnnotations: true
BreakStringLiterals: true
ColumnLimit: 110 # Update $max_trace_macro_line_len in bin/trace also
ForEachMacros: ['ALL_MEMBERS', 'UNIQUE_MEMBERS']
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Expand All @@ -55,7 +57,6 @@ IndentCaseLabels: true
#llvm11: IndentCaseBlocks: false
IndentGotoLabels: false
#llvm11: IndentExternBlock: AfterExternBlock
IndentWidth: 4
#llvm11: InsertTrailingCommas: None
MacroBlockBegin: "^BEGIN_FUNC"
MacroBlockEnd: "^END_FUNC"
Expand Down Expand Up @@ -92,5 +93,8 @@ StatementMacros:
#llvm11: WhitespaceSensitiveMacros:
#llvm11: - STRINGIZE
#llvm11: - PP_STRINGIZE
---
Language: Java
BreakAfterJavaFieldAnnotations: true
JavaImportGroups: ['java', 'hdf', 'hdf.hdf5lib', 'org']
...

4 changes: 2 additions & 2 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
if: "!contains(github.event.head_commit.message, 'skip-ci')"
steps:
- uses: actions/checkout@v2
- name: Run clang-format style check for C programs.
- name: Run clang-format style check for C and java programs.
uses: DoozyX/[email protected]
with:
source: '.'
extensions: 'c,h,cpp,hpp'
extensions: 'c,h,cpp,hpp,java'
clangFormatVersion: 10
style: file
exclude: './config ./hl/src/H5LTanalyze.c ./hl/src/H5LTparse.c ./hl/src/H5LTparse.h ./src/H5Epubgen.h ./src/H5Einit.h ./src/H5Eterm.h ./src/H5Edefin.h ./src/H5version.h ./src/H5overflow.h'
4 changes: 2 additions & 2 deletions .github/workflows/clang-format-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
if: "!contains(github.event.head_commit.message, 'skip-ci')"
steps:
- uses: actions/checkout@v2
- name: Run clang-format style check for C programs.
- name: Run clang-format style check for C and Java programs.
uses: DoozyX/[email protected]
with:
source: '.'
extensions: 'c,h,cpp,hpp'
extensions: 'c,h,cpp,hpp,java'
clangFormatVersion: 10
inplace: True
style: file
Expand Down
2 changes: 1 addition & 1 deletion bin/format_source
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ find . \( -type d -path ./config -prune -and -not -path ./config \) \
-or -name H5version.h \
-or -name H5overflow.h \
\) \) \
-and \( -iname *.h -or -iname *.c -or -iname *.cpp -or -iname *.hpp \) \) \
-and \( -iname *.h -or -iname *.c -or -iname *.cpp -or -iname *.hpp -or -iname *.java \) \) \
| xargs clang-format -style=file -i -fallback-style=none

exit 0
7 changes: 7 additions & 0 deletions java/examples/datasets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ foreach (example ${HDF_JAVA_EXAMPLES})
# install_jar (${example} ${HJAVA_INSTALL_DATA_DIR}/examples examples)
get_target_property (${example}_CLASSPATH ${example} CLASSDIR)
add_dependencies (${example} ${HDF5_JAVA_HDF5_LIB_TARGET})

#-----------------------------------------------------------------------------
# Add Target to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
clang_format (HDF5_JAVA_${example}_SRC_FORMAT ${example}.java)
endif ()
endforeach ()

set (CMAKE_JAVA_INCLUDE_PATH "${HDF5_JAVA_JARS};${HDF5_JAVA_LOGGING_JAR};${HDF5_JAVA_LOGGING_NOP_JAR}")
Expand Down
66 changes: 31 additions & 35 deletions java/examples/datasets/H5Ex_D_Alloc.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,49 +29,47 @@ one with the default allocation time (late) and one with
import hdf.hdf5lib.HDF5Constants;

public class H5Ex_D_Alloc {
private static String FILENAME = "H5Ex_D_Alloc.h5";
private static String FILENAME = "H5Ex_D_Alloc.h5";
private static String DATASETNAME1 = "DS1";
private static String DATASETNAME2 = "DS2";
private static final int DIM_X = 4;
private static final int DIM_Y = 7;
private static final int FILLVAL = 99;
private static final int RANK = 2;
private static final int DIM_X = 4;
private static final int DIM_Y = 7;
private static final int FILLVAL = 99;
private static final int RANK = 2;

// Values for the status of space allocation
enum H5D_space_status {
H5D_SPACE_STATUS_ERROR(-1), H5D_SPACE_STATUS_NOT_ALLOCATED(0), H5D_SPACE_STATUS_PART_ALLOCATED(1), H5D_SPACE_STATUS_ALLOCATED(
2);
H5D_SPACE_STATUS_ERROR(-1),
H5D_SPACE_STATUS_NOT_ALLOCATED(0),
H5D_SPACE_STATUS_PART_ALLOCATED(1),
H5D_SPACE_STATUS_ALLOCATED(2);
private static final Map<Integer, H5D_space_status> lookup = new HashMap<Integer, H5D_space_status>();

static {
static
{
for (H5D_space_status s : EnumSet.allOf(H5D_space_status.class))
lookup.put(s.getCode(), s);
}

private int code;

H5D_space_status(int space_status) {
this.code = space_status;
}
H5D_space_status(int space_status) { this.code = space_status; }

public int getCode() {
return this.code;
}
public int getCode() { return this.code; }

public static H5D_space_status get(int code) {
return lookup.get(code);
}
public static H5D_space_status get(int code) { return lookup.get(code); }
}

private static void allocation() {
long file_id = HDF5Constants.H5I_INVALID_HID;
private static void allocation()
{
long file_id = HDF5Constants.H5I_INVALID_HID;
long filespace_id = HDF5Constants.H5I_INVALID_HID;
long dataset_id1 = HDF5Constants.H5I_INVALID_HID;
long dataset_id2 = HDF5Constants.H5I_INVALID_HID;
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
long[] dims = { DIM_X, DIM_Y };
long dataset_id1 = HDF5Constants.H5I_INVALID_HID;
long dataset_id2 = HDF5Constants.H5I_INVALID_HID;
long dcpl_id = HDF5Constants.H5I_INVALID_HID;
long[] dims = {DIM_X, DIM_Y};
int[][] dset_data = new int[DIM_X][DIM_Y];
int space_status = 0;
int space_status = 0;
long storage_size = 0;

// Initialize the dataset.
Expand All @@ -82,7 +80,7 @@ private static void allocation() {
// Create a file using default properties.
try {
file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT,
HDF5Constants.H5P_DEFAULT);
HDF5Constants.H5P_DEFAULT);
}
catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -125,7 +123,8 @@ private static void allocation() {
try {
if ((file_id >= 0) && (filespace_id >= 0))
dataset_id1 = H5.H5Dcreate(file_id, DATASETNAME1, HDF5Constants.H5T_NATIVE_INT, filespace_id,
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT,
HDF5Constants.H5P_DEFAULT);
}
catch (Exception e) {
e.printStackTrace();
Expand All @@ -135,7 +134,7 @@ private static void allocation() {
try {
if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
dataset_id2 = H5.H5Dcreate(file_id, DATASETNAME2, HDF5Constants.H5T_NATIVE_INT, filespace_id,
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT);
}
catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -190,16 +189,16 @@ private static void allocation() {
// Write the data to the datasets.
try {
if (dataset_id1 >= 0)
H5.H5Dwrite(dataset_id1, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
HDF5Constants.H5P_DEFAULT, dset_data[0]);
H5.H5Dwrite(dataset_id1, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data[0]);
}
catch (Exception e) {
e.printStackTrace();
}
try {
if (dataset_id2 >= 0)
H5.H5Dwrite(dataset_id2, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
HDF5Constants.H5P_DEFAULT, dset_data[0]);
H5.H5Dwrite(dataset_id2, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL,
HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data[0]);
}
catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -291,8 +290,5 @@ private static void allocation() {
}
}

public static void main(String[] args) {
H5Ex_D_Alloc.allocation();
}

public static void main(String[] args) { H5Ex_D_Alloc.allocation(); }
}
Loading