Skip to content

Commit

Permalink
Refactor library messages into individual variables.
Browse files Browse the repository at this point in the history
Signed-off-by: Quincey Koziol <[email protected]>
  • Loading branch information
qkoziol committed May 1, 2024
1 parent 7df5fa1 commit 752d5cc
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 430 deletions.
20 changes: 4 additions & 16 deletions bin/make_err
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ sub create_majdef ($) {
my $prefix = shift; # Get the prefix for the generated file
my $file = "H5Emajdef.h"; # Name of file to generate
my $name; # Name of error message
my $idx = 0; # Index of major error message
my $num_keys; # Number of keys

# Rename previous file
# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup";
Expand All @@ -239,11 +237,8 @@ sub create_majdef ($) {
print HEADER "\n/***********************************/\n";
print HEADER "/* Major error message definitions */\n";
print HEADER "/***********************************/\n\n";
$num_keys = scalar keys %major;
foreach $name (sort keys %major) {
print HEADER "/* $name */\n";
printf HEADER "{false, \"${major{$name}}\", H5E_MAJOR, &H5E_err_cls_s}%s\n", $idx != ($num_keys - 1) ? "," : "";
$idx++;
printf HEADER "static const H5E_msg_t ${name}_msg_s = {false, \"${major{$name}}\", H5E_MAJOR, &H5E_err_cls_s};\n";
}

print_endprotect(*HEADER, $file);
Expand All @@ -259,11 +254,7 @@ sub create_mindef ($) {
my $prefix = shift; # Get the prefix for the generated file
my $file = "H5Emindef.h"; # Name of file to generate
my $name; # Name of error message
my $idx = 0; # Index of major error message
my $num_keys; # Number of keys
my $desc; # Description of error message
my $sect_name; # Section of minor error messages
my $sect_desc; # Description of section

# Rename previous file
# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup";
Expand All @@ -281,15 +272,12 @@ sub create_mindef ($) {
print HEADER "\n/***********************************/\n";
print HEADER "/* Minor error message definitions */\n";
print HEADER "/***********************************/\n\n";
$num_keys = scalar keys %minor;
foreach $sect_name (sort keys %section) {
print HEADER "\n/* $sect_name: $section{$sect_name} */\n";

# Iterate over all the minor errors in each section
for $name (sort @{$section_list{$sect_name}}) {
print HEADER "/* $name */\n";
printf HEADER "{false, \"${minor{$name}}\", H5E_MINOR, &H5E_err_cls_s}%s\n", $idx != ($num_keys - 1) ? "," : "";
$idx++;
printf HEADER "static const H5E_msg_t ${name}_msg_s = {false, \"${minor{$name}}\", H5E_MINOR, &H5E_err_cls_s};\n";
}
}

Expand Down Expand Up @@ -334,7 +322,7 @@ sub create_init ($) {
foreach $name (sort keys %major) {
print HEADER "/* $name */\n";
print HEADER " "x(0*$indent),"assert(H5I_INVALID_HID == ${name}_g);\n";
print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, &H5E_maj_msg_s[${num_msg}], false)) < 0)\n";
print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, &${name}_msg_s, false)) < 0)\n";
print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, \"can't register error message\");\n";
if ($first_major == 0) {
print HEADER " "x(0*$indent),"\n/* Remember first major error code ID */\n";
Expand All @@ -361,7 +349,7 @@ sub create_init ($) {
for $name (sort @{$section_list{$sect_name}}) {
print HEADER "/* $name */\n";
print HEADER " "x(0*$indent),"assert(H5I_INVALID_HID == ${name}_g);\n";
print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, &H5E_min_msg_s[${num_msg}], true)) < 0)\n";
print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, &${name}_msg_s, false)) < 0)\n";
print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, \"can't register error message\");\n";

if ($first_minor == 0) {
Expand Down
6 changes: 0 additions & 6 deletions src/H5Eint.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,11 @@ static const H5I_class_t H5I_ERRSTK_CLS[1] = {{
/* Library's error class */
static const H5E_cls_t H5E_err_cls_s = {false, H5E_CLS_NAME, H5E_CLS_LIB_NAME, H5_VERS_STR};

/* Major error messages */
static H5E_msg_t H5E_maj_msg_s[H5E_NUM_MAJ_ERRORS] = {
/* Include the automatically generated major error message definitions */
#include "H5Emajdef.h"
};

/* Minor error messages */
static H5E_msg_t H5E_min_msg_s[H5E_NUM_MIN_ERRORS] = {
/* Include the automatically generated minor error message definitions */
#include "H5Emindef.h"
};

/*-------------------------------------------------------------------------
* Function: H5E_init
Expand Down
123 changes: 41 additions & 82 deletions src/H5Emajdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,94 +13,53 @@
/* Generated automatically by bin/make_err -- do not edit */
/* Add new errors to H5err.txt file */


#ifndef H5Emajdef_H
#define H5Emajdef_H

/***********************************/
/* Major error message definitions */
/***********************************/

/* H5E_ARGS */
{false, "Invalid arguments to routine", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_ATTR */
{false, "Attribute", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_BTREE */
{false, "B-Tree node", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_CACHE */
{false, "Object cache", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_CONTEXT */
{false, "API Context", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_DATASET */
{false, "Dataset", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_DATASPACE */
{false, "Dataspace", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_DATATYPE */
{false, "Datatype", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_EARRAY */
{false, "Extensible Array", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_EFL */
{false, "External file list", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_ERROR */
{false, "Error API", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_EVENTSET */
{false, "Event Set", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_FARRAY */
{false, "Fixed Array", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_FILE */
{false, "File accessibility", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_FSPACE */
{false, "Free Space Manager", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_FUNC */
{false, "Function entry/exit", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_HEAP */
{false, "Heap", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_ID */
{false, "Object ID", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_INTERNAL */
{false, "Internal error (too specific to document in detail)", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_IO */
{false, "Low-level I/O", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_LIB */
{false, "General library infrastructure", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_LINK */
{false, "Links", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_MAP */
{false, "Map", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_NONE_MAJOR */
{false, "No error", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_OHDR */
{false, "Object header", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_PAGEBUF */
{false, "Page Buffering", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_PLINE */
{false, "Data filters", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_PLIST */
{false, "Property lists", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_PLUGIN */
{false, "Plugin for dynamically loaded library", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_REFERENCE */
{false, "References", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_RESOURCE */
{false, "Resource unavailable", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_RS */
{false, "Reference Counted Strings", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_SLIST */
{false, "Skip Lists", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_SOHM */
{false, "Shared Object Header Messages", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_STORAGE */
{false, "Data storage", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_SYM */
{false, "Symbol table", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_THREADSAFE */
{false, "Threadsafety", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_TST */
{false, "Ternary Search Trees", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_VFL */
{false, "Virtual File Layer", H5E_MAJOR, &H5E_err_cls_s},
/* H5E_VOL */
{
false, "Virtual Object Layer", H5E_MAJOR, &H5E_err_cls_s
}
static const H5E_msg_t H5E_ARGS_msg_s = {false, "Invalid arguments to routine", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_ATTR_msg_s = {false, "Attribute", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_BTREE_msg_s = {false, "B-Tree node", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_CACHE_msg_s = {false, "Object cache", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_CONTEXT_msg_s = {false, "API Context", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_DATASET_msg_s = {false, "Dataset", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_DATASPACE_msg_s = {false, "Dataspace", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_DATATYPE_msg_s = {false, "Datatype", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_EARRAY_msg_s = {false, "Extensible Array", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_EFL_msg_s = {false, "External file list", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_ERROR_msg_s = {false, "Error API", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_EVENTSET_msg_s = {false, "Event Set", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_FARRAY_msg_s = {false, "Fixed Array", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_FILE_msg_s = {false, "File accessibility", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_FSPACE_msg_s = {false, "Free Space Manager", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_FUNC_msg_s = {false, "Function entry/exit", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_HEAP_msg_s = {false, "Heap", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_ID_msg_s = {false, "Object ID", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_INTERNAL_msg_s = {false, "Internal error (too specific to document in detail)", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_IO_msg_s = {false, "Low-level I/O", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_LIB_msg_s = {false, "General library infrastructure", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_LINK_msg_s = {false, "Links", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_MAP_msg_s = {false, "Map", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_NONE_MAJOR_msg_s = {false, "No error", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_OHDR_msg_s = {false, "Object header", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_PAGEBUF_msg_s = {false, "Page Buffering", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_PLINE_msg_s = {false, "Data filters", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_PLIST_msg_s = {false, "Property lists", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_PLUGIN_msg_s = {false, "Plugin for dynamically loaded library", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_REFERENCE_msg_s = {false, "References", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_RESOURCE_msg_s = {false, "Resource unavailable", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_RS_msg_s = {false, "Reference Counted Strings", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_SLIST_msg_s = {false, "Skip Lists", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_SOHM_msg_s = {false, "Shared Object Header Messages", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_STORAGE_msg_s = {false, "Data storage", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_SYM_msg_s = {false, "Symbol table", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_THREADSAFE_msg_s = {false, "Threadsafety", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_TST_msg_s = {false, "Ternary Search Trees", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_VFL_msg_s = {false, "Virtual File Layer", H5E_MAJOR, &H5E_err_cls_s};
static const H5E_msg_t H5E_VOL_msg_s = {false, "Virtual Object Layer", H5E_MAJOR, &H5E_err_cls_s};

#endif /* H5Emajdef_H */
Loading

0 comments on commit 752d5cc

Please sign in to comment.