From 23f15ebdd0a2252e4e6212be71edfa0722d9233f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Fri, 4 Mar 2016 10:37:16 +0100 Subject: [PATCH] Added copyright message from section in vk.xml --- VkCppGenerator.cpp | 45 ++++++++++++++++++++++++++++++++++++--------- vulkan/vk_cpp.h | 24 ++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 9 deletions(-) diff --git a/VkCppGenerator.cpp b/VkCppGenerator.cpp index 26f8d96..5b06b84 100644 --- a/VkCppGenerator.cpp +++ b/VkCppGenerator.cpp @@ -38,7 +38,7 @@ #include -const std::string licenseHeader( +const std::string nvidiaLicenseHeader( "// Copyright(c) 2015-2016, NVIDIA CORPORATION. All rights reserved.\n" "//\n" "// Redistribution and use in source and binary forms, with or without\n" @@ -315,6 +315,7 @@ bool readCommandParam( tinyxml2::XMLElement * element, DependencyData & typeData std::map::iterator readCommandProto(tinyxml2::XMLElement * element, std::list & dependencies, std::map & commands); void readCommands( tinyxml2::XMLElement * element, std::list & dependencies, std::map & commands, std::map & handles, std::set const& tags ); void readCommandsCommand(tinyxml2::XMLElement * element, std::list & dependencies, std::map & commands, std::map & handles, std::set const& tags); +void readComment(tinyxml2::XMLElement * element, std::string & header); void readEnums( tinyxml2::XMLElement * element, std::list & dependencies, std::map & enums, std::set const& tags, std::set & vkTypes ); void readEnumsEnum( tinyxml2::XMLElement * element, EnumData & enumData, std::string const& tag ); void readExtensionRequire(tinyxml2::XMLElement * element, std::string const& protect, std::string const& tag, std::map & commands, std::map & enums, std::map & flags, std::map & scalars, std::map & structs); @@ -820,6 +821,25 @@ void readCommandsCommand(tinyxml2::XMLElement * element, std::listGetText()); + assert(header.empty()); + header = element->GetText(); + assert(header.find("\nCopyright") == 0); + + size_t pos = header.find("\n\n-----"); + assert(pos != std::string::npos); + header.erase(pos); + + for (size_t pos = header.find('\n'); pos != std::string::npos; pos = header.find('\n', pos + 1)) + { + header.replace(pos, 1, "\n// "); + } + + header += "\n\n// This header is generated from the Khronos Vulkan XML API Registry."; +} + void readEnums( tinyxml2::XMLElement * element, std::list & dependencies, std::map & enums, std::set const& tags, std::set & vkTypes ) { assert( element->Attribute( "name" ) ); @@ -2817,6 +2837,7 @@ int main( int argc, char **argv ) std::map structs; std::set tags; std::set vkTypes; + std::string vulkanLicenseHeader; tinyxml2::XMLElement * child = registryElement->FirstChildElement(); do @@ -2827,6 +2848,10 @@ int main( int argc, char **argv ) { readCommands( child, dependencies, commands, handles, tags ); } + else if (value == "comment") + { + readComment(child, vulkanLicenseHeader); + } else if ( value == "enums" ) { readEnums( child, dependencies, enums, tags, vkTypes ); @@ -2845,7 +2870,7 @@ int main( int argc, char **argv ) } else { - assert( ( value == "comment" ) || ( value == "feature" ) || ( value == "vendorids" ) ); + assert( ( value == "feature" ) || ( value == "vendorids" ) ); } } while ( child = child->NextSiblingElement() ); @@ -2856,13 +2881,14 @@ int main( int argc, char **argv ) createDefaults( sortedDependencies, enums, defaultValues ); std::ofstream ofs( "vk_cpp.h" ); - ofs << licenseHeader << std::endl; - - ofs << std::endl << "#ifndef VK_CPP_H_" << std::endl - << "#define VK_CPP_H_" << std::endl - << std::endl; - - ofs << "#include " << std::endl + ofs << nvidiaLicenseHeader << std::endl + << vulkanLicenseHeader << std::endl + << std::endl + << std::endl + << "#ifndef VK_CPP_H_" << std::endl + << "#define VK_CPP_H_" << std::endl + << std::endl + << "#include " << std::endl << "#include " << std::endl << "#include " << std::endl << "#include " << std::endl @@ -2871,6 +2897,7 @@ int main( int argc, char **argv ) << "# include " << std::endl << "#endif /*VKCPP_ENHANCED_MODE*/" << std::endl << std::endl; + writeVersionCheck( ofs, version ); writeTypesafeCheck(ofs, typesafeCheck ); ofs << "namespace vk" << std::endl diff --git a/vulkan/vk_cpp.h b/vulkan/vk_cpp.h index 972182b..7b65980 100644 --- a/vulkan/vk_cpp.h +++ b/vulkan/vk_cpp.h @@ -25,6 +25,30 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Copyright (c) 2015-2016 The Khronos Group Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and/or associated documentation files (the +// "Materials"), to deal in the Materials without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Materials, and to +// permit persons to whom the Materials are furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Materials. +// +// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +// This header is generated from the Khronos Vulkan XML API Registry. + + #ifndef VK_CPP_H_ #define VK_CPP_H_