From 1d4b9844fe9a2c934cd7efe4e7fab8dc15ed60cb Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 2 Apr 2023 21:26:03 +0200 Subject: feat: make for_each_opengl_command exclude remove commands --- src/repeat.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/repeat.rs b/src/repeat.rs index 8191500..f8ab228 100644 --- a/src/repeat.rs +++ b/src/repeat.rs @@ -1,6 +1,7 @@ use std::str::FromStr; use convert_case::{Case, Casing}; +use opengl_registry::api_interface_definition::FeatureKind; use opengl_registry::Registry; use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; @@ -20,9 +21,26 @@ pub fn for_each_opengl_command_impl( opengl_registry: &Registry, ) -> TokenStream { + let removed_commands = opengl_registry + .api_interface_definitions() + .iter() + .flat_map(|api_interface_def| { + api_interface_def.removals().iter().flat_map(|removal| { + removal.features().iter().filter_map(|feature| { + if feature.kind() != FeatureKind::Command { + return None; + } + + Some(feature.name()) + }) + }) + }) + .collect::>(); + let out: TokenStream = opengl_registry .commands() .iter() + .filter(|gl_command| !removed_commands.contains(&gl_command.prototype().name())) .map(|gl_command| { let stream = input_stream.replace_ident( &Ident::new(OPENGL_CMD_NAME_REPLACE, Span::call_site()), -- cgit v1.2.3-18-g5258