2019-10-03 11:12:32 -05:00
|
|
|
#!/usr/bin/env perl
|
2007-07-12 15:21:57 -05:00
|
|
|
require 5.003;
|
2019-10-03 11:12:32 -05:00
|
|
|
use warnings;
|
2007-07-12 15:21:57 -05:00
|
|
|
|
|
|
|
# Global settings
|
|
|
|
|
2024-12-10 00:34:40 -08:00
|
|
|
# Supported version strings. "16" = HDF5 1.6.0, "200" = HDF5 2.0.0, etc.
|
|
|
|
#
|
|
|
|
# Note that the scheme changed with 2.0.0, when we went to semantic versioning.
|
|
|
|
# We use 200 instead of 20 so that HDF5 11.0.0 will get 1100 instead of 110,
|
|
|
|
# which would conflict with HDF5 1.10.
|
|
|
|
#
|
|
|
|
# Also, note that this scheme started at the 1.6/1.8 transition, so earlier
|
|
|
|
# versions of the API aren't versioned.
|
|
|
|
@versions = ("16", "18", "110", "112", "114", "200");
|
2007-07-12 15:21:57 -05:00
|
|
|
|
2011-07-01 15:09:44 -05:00
|
|
|
# Number of spaces to indent preprocessor commands inside ifdefs
|
|
|
|
$indent = 2;
|
|
|
|
|
2024-12-10 00:34:40 -08:00
|
|
|
# Global hash of functions ==> # symbol versions parsed from H5vers.txt
|
|
|
|
$functions = {};
|
|
|
|
|
|
|
|
# Global hash of functions ==> versioned function params parsed from H5vers.txt
|
|
|
|
$func_params = {};
|
|
|
|
|
|
|
|
# Global hash of typedefs ==> # symbol versions parsed from H5vers.txt
|
|
|
|
$typedefs = {};
|
|
|
|
|
|
|
|
# Hash of API versions to a hash of (API call name --> symbol version)
|
|
|
|
#
|
|
|
|
# There is one hash for each version in @versions and the (API call name
|
|
|
|
# --> symbol version) hash maps an API name like H5Dopen to the symbol version
|
|
|
|
# (e.g. H5Dopen --> 1 or 2).
|
|
|
|
#
|
|
|
|
# So...
|
|
|
|
#
|
|
|
|
# 200 --> {H5Dopen --> 2, H5Iregister_type --> 2, etc.}
|
|
|
|
my %api_vers_to_function_vers;
|
|
|
|
foreach my $key (@versions) {
|
|
|
|
$api_vers_to_function_vers{$key} = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
# Hash of API versions to a hash of (typedef name --> symbol version)
|
|
|
|
my %api_vers_to_type_vers;
|
|
|
|
foreach my $key (@versions) {
|
|
|
|
$api_vers_to_type_vers{$key} = {};
|
|
|
|
}
|
|
|
|
|
2007-07-12 15:21:57 -05:00
|
|
|
#
|
|
|
|
# Copyright by The HDF Group.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# This file is part of HDF5. The full HDF5 copyright notice, including
|
|
|
|
# terms governing use, modification, and redistribution, is contained in
|
2024-10-18 21:13:04 -07:00
|
|
|
# the LICENSE file, which can be found at the root of the source code
|
2021-02-17 08:52:36 -06:00
|
|
|
# distribution tree, or in https://www.hdfgroup.org/licenses.
|
2017-04-17 14:32:16 -05:00
|
|
|
# If you do not have access to either file, you may request a copy from
|
|
|
|
# help@hdfgroup.org.
|
2007-07-12 15:21:57 -05:00
|
|
|
#
|
|
|
|
|
|
|
|
# Create public symbol version headers
|
|
|
|
#
|
|
|
|
# Read in the public symbol version description text file and create the
|
|
|
|
# appropriate headers needed by the library.
|
|
|
|
#
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Print the copyright into an open file
|
|
|
|
#
|
|
|
|
sub print_copyright ($) {
|
|
|
|
my $fh = shift;
|
|
|
|
|
|
|
|
print $fh "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n";
|
|
|
|
print $fh " * Copyright by The HDF Group. *\n";
|
|
|
|
print $fh " * All rights reserved. *\n";
|
|
|
|
print $fh " * *\n";
|
|
|
|
print $fh " * This file is part of HDF5. The full HDF5 copyright notice, including *\n";
|
|
|
|
print $fh " * terms governing use, modification, and redistribution, is contained in *\n";
|
2024-10-18 21:13:04 -07:00
|
|
|
print $fh " * the LICENSE file, which can be found at the root of the source code *\n";
|
2021-02-17 08:52:36 -06:00
|
|
|
print $fh " * distribution tree, or in https://www.hdfgroup.org/licenses. *\n";
|
2017-04-17 14:32:16 -05:00
|
|
|
print $fh " * If you do not have access to either file, you may request a copy from *\n";
|
|
|
|
print $fh " * help\@hdfgroup.org. *\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
print $fh " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Print the "do not change this file" warning
|
|
|
|
#
|
|
|
|
sub print_warning ($) {
|
|
|
|
my $fh = shift;
|
|
|
|
|
|
|
|
print $fh "\n/* Generated automatically by bin/make_vers -- do not edit */\n";
|
|
|
|
print $fh "/* Add new versioned symbols to H5vers.txt file */\n\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Print start of ifdef's to prevent a file from being re-included
|
|
|
|
#
|
|
|
|
sub print_startprotect ($$) {
|
|
|
|
my ($fh, $file) = @_;
|
|
|
|
|
|
|
|
# Clip off the ".h" part of the name
|
|
|
|
$file =~ s/(\w*)\.h/$1/;
|
|
|
|
|
|
|
|
# Print the ifdef info
|
2021-02-22 23:29:56 -05:00
|
|
|
print $fh "\n#ifndef ${file}_H\n";
|
|
|
|
print $fh "#define ${file}_H\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Print check for conflicting version macro settings
|
|
|
|
#
|
|
|
|
sub print_checkoptions ($) {
|
2011-07-01 15:09:44 -05:00
|
|
|
my $fh = shift; # File handle for output file
|
2007-07-12 15:21:57 -05:00
|
|
|
|
|
|
|
# Print the option checking
|
2020-01-16 13:29:34 -08:00
|
|
|
print $fh "\n\n/* Issue error if contradicting macros have been defined. */\n";
|
|
|
|
print $fh "/* (Can't use an older (deprecated) API version if deprecated symbols have been disabled) */\n";
|
2011-07-01 15:09:44 -05:00
|
|
|
|
|
|
|
# Print the #ifdef
|
|
|
|
print $fh "#if (";
|
2024-12-10 00:34:40 -08:00
|
|
|
for my $i (0 .. $#versions - 1) {
|
|
|
|
print $fh "defined(H5_USE_", $versions[$i], "_API)";
|
|
|
|
|
|
|
|
# -2 because we're ignoring the last version in the array, and the
|
|
|
|
# last version we DO write out can't have an || after it
|
|
|
|
if ($i < @versions - 2) {
|
2011-07-01 15:09:44 -05:00
|
|
|
print $fh " || ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print $fh ") && defined(H5_NO_DEPRECATED_SYMBOLS)\n";
|
|
|
|
|
|
|
|
# Print the error for bad API version chosen
|
|
|
|
print $fh ' ' x $indent, "#error \"Can't choose old API versions when deprecated APIs are disabled\"\n";
|
|
|
|
|
|
|
|
# Print the #endif
|
|
|
|
print $fh "#endif /* (";
|
2024-12-10 00:34:40 -08:00
|
|
|
for my $i (0 .. $#versions - 1) {
|
|
|
|
print $fh "defined(H5_USE_", $versions[$i], "_API)";
|
|
|
|
|
|
|
|
if ($i < @versions - 2) {
|
2011-07-01 15:09:44 -05:00
|
|
|
print $fh " || ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print $fh ") && defined(H5_NO_DEPRECATED_SYMBOLS) */\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Print "global" API version macro settings
|
|
|
|
#
|
2020-01-16 13:29:34 -08:00
|
|
|
sub print_globalapidefvers ($) {
|
2007-07-12 15:21:57 -05:00
|
|
|
my $fh = shift; # File handle for output file
|
|
|
|
|
|
|
|
# Print the descriptive comment
|
2020-01-16 13:29:34 -08:00
|
|
|
print $fh "\n\n/* If a particular default \"global\" version of the library's interfaces is\n";
|
|
|
|
print $fh " * chosen, set the corresponding version macro for API symbols.\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
print $fh " *\n";
|
|
|
|
print $fh " */\n";
|
|
|
|
|
2024-12-10 00:34:40 -08:00
|
|
|
for my $api_vers (@versions) {
|
2008-10-30 15:49:08 -05:00
|
|
|
# Print API version ifdef
|
2024-12-10 00:34:40 -08:00
|
|
|
print $fh "\n#if defined(H5_USE_", $api_vers, "_API_DEFAULT) && !defined(H5_USE_", $api_vers, "_API)\n";
|
2008-10-30 15:49:08 -05:00
|
|
|
# Print API version definition
|
2024-12-10 00:34:40 -08:00
|
|
|
print $fh " " x $indent, "#define H5_USE_", $api_vers, "_API 1\n";
|
2008-10-30 15:49:08 -05:00
|
|
|
# Print API version endif
|
2024-12-10 00:34:40 -08:00
|
|
|
print $fh "#endif /* H5_USE_", $api_vers, "_API_DEFAULT && !H5_USE_", $api_vers, "_API */\n";
|
2008-10-30 15:49:08 -05:00
|
|
|
}
|
2020-01-16 13:29:34 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Print "global" API symbol version macro settings
|
|
|
|
#
|
|
|
|
sub print_globalapisymbolvers ($) {
|
|
|
|
my $fh = shift; # File handle for output file
|
|
|
|
|
|
|
|
# Print the descriptive comment
|
|
|
|
print $fh "\n\n/* If a particular \"global\" version of the library's interfaces is chosen,\n";
|
|
|
|
print $fh " * set the versions for the API symbols affected.\n";
|
|
|
|
print $fh " *\n";
|
|
|
|
print $fh " * Note: If an application has already chosen a particular version for an\n";
|
|
|
|
print $fh " * API symbol, the individual API version macro takes priority.\n";
|
|
|
|
print $fh " */\n";
|
2008-10-30 15:49:08 -05:00
|
|
|
|
2007-07-12 15:21:57 -05:00
|
|
|
# Loop over supported older library APIs and define the appropriate macros
|
2024-12-10 00:34:40 -08:00
|
|
|
foreach my $api_vers (@versions) {
|
2007-07-12 15:21:57 -05:00
|
|
|
# Print API version ifdef
|
2024-12-10 00:34:40 -08:00
|
|
|
print $fh "\n#ifdef H5_USE_", $api_vers, "_API\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
|
|
|
|
# Print the version macro info for each function that is defined for
|
|
|
|
# this API version
|
2007-08-21 16:08:27 -05:00
|
|
|
print $fh "\n/*************/\n";
|
|
|
|
print $fh "/* Functions */\n";
|
|
|
|
print $fh "/*************/\n";
|
2024-12-10 00:34:40 -08:00
|
|
|
for $name (sort keys %{$api_vers_to_function_vers{$api_vers}}) {
|
2007-08-23 15:25:25 -05:00
|
|
|
print $fh "\n#if !defined(", $name, "_vers)\n";
|
2024-12-10 00:34:40 -08:00
|
|
|
print $fh " " x $indent, "#define ", $name, "_vers $api_vers_to_function_vers{$api_vers}{$name}\n";
|
2007-08-21 16:08:27 -05:00
|
|
|
print $fh "#endif /* !defined(", $name, "_vers) */\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Print the version macro info for each typedef that is defined for
|
|
|
|
# this API version
|
|
|
|
print $fh "\n/************/\n";
|
|
|
|
print $fh "/* Typedefs */\n";
|
|
|
|
print $fh "/************/\n";
|
2024-12-10 00:34:40 -08:00
|
|
|
for $name (sort keys %{$api_vers_to_type_vers{$api_vers}}) {
|
2007-08-23 17:40:22 -05:00
|
|
|
print $fh "\n#if !defined(", $name, "_t_vers)\n";
|
2024-12-10 00:34:40 -08:00
|
|
|
print $fh " " x $indent, "#define ", $name, "_t_vers $api_vers_to_type_vers{$api_vers}{$name}\n";
|
2007-08-23 17:40:22 -05:00
|
|
|
print $fh "#endif /* !defined(", $name, "_t_vers) */\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# Print API version endif
|
2024-12-10 00:34:40 -08:00
|
|
|
print $fh "\n#endif /* H5_USE_", $api_vers, "_API */\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Print "default" API version macro settings
|
|
|
|
#
|
|
|
|
sub print_defaultapivers ($) {
|
|
|
|
my $fh = shift; # File handle for output file
|
|
|
|
my $curr_name; # Current API function
|
|
|
|
|
|
|
|
# Print the descriptive comment
|
2007-08-21 16:08:27 -05:00
|
|
|
print $fh "\n\n/* Choose the correct version of each API symbol, defaulting to the latest\n";
|
|
|
|
print $fh " * version of each. The \"best\" name for API parameters/data structures\n";
|
|
|
|
print $fh " * that have changed definitions is also set. An error is issued for\n";
|
|
|
|
print $fh " * specifying an invalid API version.\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
print $fh " */\n";
|
|
|
|
|
|
|
|
# Loop over function names that are versioned and set up the version macros
|
2007-08-21 16:08:27 -05:00
|
|
|
print $fh "\n/*************/\n";
|
|
|
|
print $fh "/* Functions */\n";
|
|
|
|
print $fh "/*************/\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
for $curr_name (sort keys %functions) {
|
|
|
|
my $curr_vers_name; # Name of version macro for current function
|
|
|
|
my $curr_vers; # Version of function
|
2007-08-21 16:08:27 -05:00
|
|
|
my @param_list; # Typedefs for the function parameters
|
2007-07-12 15:21:57 -05:00
|
|
|
|
|
|
|
# Set up variables for later use
|
|
|
|
$curr_vers_name = $curr_name . "_vers";
|
|
|
|
$curr_vers = $functions{$curr_name};
|
|
|
|
|
2007-08-21 16:08:27 -05:00
|
|
|
# Split up parameter info
|
|
|
|
@param_list = split(/\s*,\s*/, $func_params{$curr_name});
|
|
|
|
#print "print_defaultapivers: param_list=(@param_list)\n";
|
|
|
|
|
2007-07-12 15:21:57 -05:00
|
|
|
# Set up default/latest version name mapping
|
2007-08-21 16:08:27 -05:00
|
|
|
print $fh "\n#if !defined($curr_vers_name) || $curr_vers_name == $curr_vers\n";
|
2011-07-01 15:09:44 -05:00
|
|
|
print $fh " " x $indent, "#ifndef $curr_vers_name\n";
|
|
|
|
print $fh " " x ($indent * 2), "#define $curr_vers_name $curr_vers\n";
|
|
|
|
print $fh " " x $indent, "#endif /* $curr_vers_name */\n";
|
|
|
|
print $fh " " x $indent, "#define $curr_name $curr_name$curr_vers\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
|
2007-08-21 16:08:27 -05:00
|
|
|
# Print function's dependent parameter types
|
2024-12-10 00:34:40 -08:00
|
|
|
foreach (sort (@param_list)) {
|
2011-07-01 15:09:44 -05:00
|
|
|
print $fh " " x $indent, "#define ${_}_t $_${curr_vers}_t\n";
|
2007-08-21 16:08:27 -05:00
|
|
|
}
|
|
|
|
|
2007-07-12 15:21:57 -05:00
|
|
|
# Loop to print earlier version name mappings
|
|
|
|
$curr_vers--;
|
|
|
|
while($curr_vers > 0) {
|
|
|
|
print $fh "#elif $curr_vers_name == $curr_vers\n";
|
2011-07-01 15:09:44 -05:00
|
|
|
print $fh " " x $indent, "#define $curr_name $curr_name$curr_vers\n";
|
2007-08-21 16:08:27 -05:00
|
|
|
|
|
|
|
# Print function's dependent parameter types
|
2024-12-10 00:34:40 -08:00
|
|
|
foreach (sort (@param_list)) {
|
2011-07-01 15:09:44 -05:00
|
|
|
print $fh " " x $indent, "#define ${_}_t $_${curr_vers}_t\n";
|
2007-08-21 16:08:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$curr_vers--;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Finish up with error for unknown version and endif
|
|
|
|
print $fh "#else /* $curr_vers_name */\n";
|
2011-07-01 15:09:44 -05:00
|
|
|
print $fh " " x $indent, "#error \"$curr_vers_name set to invalid value\"\n";
|
2007-08-21 16:08:27 -05:00
|
|
|
print $fh "#endif /* $curr_vers_name */\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Loop over typedefs that are versioned and set up the version macros
|
|
|
|
print $fh "\n/************/\n";
|
|
|
|
print $fh "/* Typedefs */\n";
|
|
|
|
print $fh "/************/\n";
|
|
|
|
for $curr_name (sort keys %typedefs) {
|
|
|
|
my $curr_vers_name; # Name of version macro for current function
|
|
|
|
my $curr_vers; # Version of function
|
|
|
|
|
|
|
|
# Set up variables for later use
|
2007-08-23 17:40:22 -05:00
|
|
|
$curr_vers_name = $curr_name . "_t_vers";
|
2007-08-21 16:08:27 -05:00
|
|
|
$curr_vers = $typedefs{$curr_name};
|
|
|
|
|
|
|
|
# Set up default/latest version name mapping
|
2007-08-23 15:25:25 -05:00
|
|
|
print $fh "\n#if !defined($curr_vers_name) || $curr_vers_name == $curr_vers\n";
|
2011-07-01 15:09:44 -05:00
|
|
|
print $fh " " x $indent, "#ifndef $curr_vers_name\n";
|
|
|
|
print $fh " " x ($indent * 2), "#define $curr_vers_name $curr_vers\n";
|
|
|
|
print $fh " " x $indent, "#endif /* $curr_vers_name */\n";
|
|
|
|
print $fh " " x $indent, "#define ${curr_name}_t $curr_name${curr_vers}_t\n";
|
2007-08-21 16:08:27 -05:00
|
|
|
|
|
|
|
# Loop to print earlier version name mappings
|
|
|
|
$curr_vers--;
|
2024-12-10 00:34:40 -08:00
|
|
|
while ($curr_vers > 0) {
|
2007-08-21 16:08:27 -05:00
|
|
|
print $fh "#elif $curr_vers_name == $curr_vers\n";
|
2011-07-01 15:09:44 -05:00
|
|
|
print $fh " " x $indent, "#define ${curr_name}_t $curr_name${curr_vers}_t\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
$curr_vers--;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Finish up with error for unknown version and endif
|
|
|
|
print $fh "#else /* $curr_vers_name */\n";
|
2011-07-01 15:09:44 -05:00
|
|
|
print $fh " " x $indent, "#error \"$curr_vers_name set to invalid value\"\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
print $fh "#endif /* $curr_vers_name */\n\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Print end of ifdef's to prevent a file from being re-included
|
|
|
|
#
|
|
|
|
sub print_endprotect ($$) {
|
|
|
|
my ($fh, $file) = @_;
|
|
|
|
|
|
|
|
# Clip off the ".h" part of the name
|
|
|
|
$file =~ s/(\w*)\.h/$1/;
|
|
|
|
|
|
|
|
# Print the endif info
|
2007-08-21 16:08:27 -05:00
|
|
|
print $fh "#endif /* ${file}_H */\n\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
}
|
|
|
|
|
2024-12-10 00:34:40 -08:00
|
|
|
##############################################################################
|
|
|
|
# Validate a line from H5vers.txt
|
|
|
|
#
|
|
|
|
sub validate_line {
|
|
|
|
my $name = $_[0];
|
|
|
|
my $params = $_[1];
|
|
|
|
my $vers = $_[2];
|
|
|
|
|
|
|
|
my @vers_list; # Version strings ("v18", etc.)
|
|
|
|
my %sym_versions; # Versions already seen (for duplicate checks)
|
|
|
|
|
|
|
|
# Check if the name already exists in the list of symbols
|
|
|
|
if (exists ($functions{$name}) || exists($typedefs{$name})) {
|
|
|
|
die "duplicated symbol: $name";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check for no version info given
|
|
|
|
if ($vers eq "") {
|
|
|
|
die "no version information: $name";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Separate the versions on commas (produces string elements like "v18")
|
|
|
|
@vers_list = split (/\s*,\s*/, $vers);
|
|
|
|
|
|
|
|
# Check for invalid version data
|
|
|
|
foreach (@vers_list) {
|
|
|
|
# Note: v111 is allowed because H5O functions were prematurely versioned
|
|
|
|
# in HDF5 1.10. Because users were affected by this, the versioning
|
|
|
|
# was rescinded but the H5O version 2 functions were kept to be
|
|
|
|
# called directly. Now that the version macros are added in 1.12,
|
|
|
|
# along with a 3rd version of the H5O functions, the H5O function
|
|
|
|
# version for default api=v110 should be version 1 to work correctly
|
|
|
|
# with 1.10 applications that were using unversioned H5O functions,
|
|
|
|
# and the H5O function version should be version 3 for default api=v112
|
|
|
|
# (the default api version for 1.12). Allowing a v111 entry allows
|
|
|
|
# a version 2 that is never accessed via the H5O function macros.
|
|
|
|
if (!( $_ =~ /v1[02468]/ || $_ =~ /v11[02468]/ || $_ =~ /v111/ || $_ =~ /v200/ )) {
|
|
|
|
die "bad version information: $name";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Make sure we didn't specify duplicate versions on this line
|
|
|
|
if (exists($sym_versions{$_})) {
|
|
|
|
die "duplicate version information: $name";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Store the versions for the function in a local hash table, indexed by the version
|
|
|
|
# (this is only used to check for duplicates)
|
|
|
|
$sym_versions{$_}=$_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-12 15:21:57 -05:00
|
|
|
##############################################################################
|
|
|
|
# Parse a meaningful line (not a comment or blank line) into the appropriate
|
|
|
|
# data structure
|
|
|
|
#
|
|
|
|
sub parse_line ($) {
|
|
|
|
my $line = shift; # Get the line to parse
|
|
|
|
|
|
|
|
# Parse API function lines
|
2024-12-10 00:34:40 -08:00
|
|
|
#print "line=$line";
|
|
|
|
if ($line =~ /^\s*FUNCTION:/ || $line =~ /^\s*TYPEDEF:/) {
|
2007-07-12 15:21:57 -05:00
|
|
|
my $name; # The name of the function
|
2007-08-21 16:08:27 -05:00
|
|
|
my $params; # Typedefs for function parameters
|
2024-12-10 00:34:40 -08:00
|
|
|
my $vers_string; # The version info for the function
|
|
|
|
my @vers_list; # Version info, as a list (e.g., "112", "200", etc.
|
2007-08-21 16:08:27 -05:00
|
|
|
my $line_type; # Type of line we are parsing
|
|
|
|
|
|
|
|
# Determine the type of the line to parse
|
2024-12-10 00:34:40 -08:00
|
|
|
if ($line =~ /^\s*FUNCTION:/) {
|
2007-08-21 16:08:27 -05:00
|
|
|
$line_type = 1;
|
|
|
|
# Get the function's name & version info
|
2024-12-10 00:34:40 -08:00
|
|
|
($name, $params, $vers_string) = ($line =~ /^\s*FUNCTION:\s*(\w*);\s*(.*?)\s*;\s*(.*?)\s*$/);
|
|
|
|
#print "parse_line: name='$name', params='$params', vers_string='$vers_string'\n";
|
2007-08-21 16:08:27 -05:00
|
|
|
}
|
2024-12-10 00:34:40 -08:00
|
|
|
elsif ($line =~ /^\s*TYPEDEF:/) {
|
2007-08-21 16:08:27 -05:00
|
|
|
$line_type = 2;
|
2007-07-12 15:21:57 -05:00
|
|
|
|
2007-08-21 16:08:27 -05:00
|
|
|
# Get the typedefs's name & version info
|
2024-12-10 00:34:40 -08:00
|
|
|
($name, $vers_string) = ($line =~ /^\s*TYPEDEF:\s*(\w*);\s*(.*?)\s*$/);
|
|
|
|
#print "parse_line: name='$name', vers_string='$vers_string'\n";
|
|
|
|
} else {
|
|
|
|
die "unknown line type: $line";
|
2007-08-21 16:08:27 -05:00
|
|
|
}
|
|
|
|
#print "parse_line: line_type='$line_type'\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
|
2024-12-10 00:34:40 -08:00
|
|
|
validate_line($name, $params, $vers_string);
|
2007-08-21 16:08:27 -05:00
|
|
|
|
2024-12-10 00:34:40 -08:00
|
|
|
# Split the version info and strip off the leading "v"
|
|
|
|
@vers_list = split(/\s*,\s*/, $vers_string);
|
|
|
|
@vers_list = map { substr($_, 1) } @vers_list;
|
2007-08-21 16:08:27 -05:00
|
|
|
#print "parse_line: vers_list=(@vers_list)\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
|
2024-12-10 00:34:40 -08:00
|
|
|
# Parse the version list into the hashes of version and type info
|
|
|
|
my $curr_sym_number = 1;
|
|
|
|
foreach my $vers (@vers_list) {
|
|
|
|
foreach my $hash_vers (@versions) {
|
|
|
|
if ($vers > $hash_vers) {
|
|
|
|
next;
|
|
|
|
} else {
|
|
|
|
if ($line_type == 1) {
|
|
|
|
$api_vers_to_function_vers{$hash_vers}{$name} = $curr_sym_number;
|
2007-08-21 16:08:27 -05:00
|
|
|
} else {
|
2024-12-10 00:34:40 -08:00
|
|
|
$api_vers_to_type_vers{$hash_vers}{$name} = $curr_sym_number;
|
2007-08-21 16:08:27 -05:00
|
|
|
}
|
2007-07-12 15:21:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-10 00:34:40 -08:00
|
|
|
$curr_sym_number++;
|
2007-07-12 15:21:57 -05:00
|
|
|
}
|
|
|
|
|
2007-08-21 16:08:27 -05:00
|
|
|
# Store the number of symbol versions in a hash table, indexed by the name
|
2024-12-10 00:34:40 -08:00
|
|
|
if ($line_type == 1) {
|
2007-08-21 16:08:27 -05:00
|
|
|
$functions{$name} = $#vers_list + 1;
|
|
|
|
|
|
|
|
# Store the function's parameter types for later
|
|
|
|
$func_params{$name} = $params;
|
2024-12-10 00:34:40 -08:00
|
|
|
} elsif ($line_type == 2) {
|
2007-08-21 16:08:27 -05:00
|
|
|
$typedefs{$name} = $#vers_list + 1;
|
|
|
|
}
|
2024-12-10 00:34:40 -08:00
|
|
|
#print "\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
}
|
|
|
|
# Unknown keyword
|
|
|
|
else {
|
|
|
|
die "unknown keyword: $line";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Create the generated portion of the public header file
|
|
|
|
#
|
|
|
|
sub create_public ($) {
|
|
|
|
my $prefix = shift; # Get the prefix for the generated file
|
|
|
|
my $file = "H5version.h"; # Name of file to generate
|
|
|
|
my $name; # Name of function
|
|
|
|
|
|
|
|
# Rename previous file
|
|
|
|
# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup";
|
|
|
|
|
|
|
|
# Open new header file
|
|
|
|
open HEADER, ">${prefix}${file}" or die "unable to modify source";
|
|
|
|
|
|
|
|
# Create file contents
|
|
|
|
print_copyright(*HEADER);
|
|
|
|
print_warning(*HEADER);
|
|
|
|
print_startprotect(*HEADER, $file);
|
2020-01-16 13:29:34 -08:00
|
|
|
print_globalapidefvers(*HEADER);
|
2007-07-12 15:21:57 -05:00
|
|
|
print_checkoptions(*HEADER);
|
2020-01-16 13:29:34 -08:00
|
|
|
print_globalapisymbolvers(*HEADER);
|
2007-07-12 15:21:57 -05:00
|
|
|
print_defaultapivers(*HEADER);
|
|
|
|
print_endprotect(*HEADER, $file);
|
|
|
|
|
|
|
|
# Close header file
|
|
|
|
close HEADER;
|
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Read symbol version file (given as command-line argument) in and process it
|
|
|
|
# into internal data structures, then create header files.
|
|
|
|
#
|
|
|
|
for $file (@ARGV) {
|
|
|
|
my $prefix; # Local prefix for generated files
|
|
|
|
|
|
|
|
#print "file = '$file'\n";
|
2011-07-01 15:09:44 -05:00
|
|
|
# Check for directory prefix on input file
|
2024-12-10 00:34:40 -08:00
|
|
|
if ($file =~ /\//) {
|
2011-07-01 15:09:44 -05:00
|
|
|
($prefix) = ($file =~ /(^.*\/)/);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$prefix = "";
|
|
|
|
}
|
2007-07-12 15:21:57 -05:00
|
|
|
#print "prefix = '$prefix'\n";
|
|
|
|
# Read in the entire file
|
|
|
|
open SOURCE, $file or die "$file: $!\n";
|
2024-12-10 00:34:40 -08:00
|
|
|
while ( defined ($line = <SOURCE>) ) {
|
2007-07-12 15:21:57 -05:00
|
|
|
# Skip blank lines and those lines whose first character is a '#'
|
2024-12-10 00:34:40 -08:00
|
|
|
if (!($line =~ /(^\s*#.*$)|(^\s*$)/)) {
|
2007-07-12 15:21:57 -05:00
|
|
|
# Construct data structures for later printing
|
|
|
|
parse_line($line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close SOURCE;
|
2018-08-16 15:06:29 -05:00
|
|
|
|
2007-07-12 15:21:57 -05:00
|
|
|
# Create header files
|
2023-06-14 21:01:48 -05:00
|
|
|
print "Generating 'H5version.h'\n";
|
2007-07-12 15:21:57 -05:00
|
|
|
create_public($prefix);
|
|
|
|
}
|
|
|
|
|