From 3d9c9d7ac68a439a29c8ad0a745a7e2a52234a44 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 5 Mar 2023 19:46:12 +0100 Subject: refactor: improve replacement syntax --- src/lib.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 0ec71be..555cd58 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,48 +9,49 @@ use proc_macro::TokenStream; use crate::repeat::for_each_opengl_command_impl; +mod iter; mod repeat; mod str; mod token_stream; -const OPENGL_CMD_IDENT_REPLACE: &str = "_gl_command_"; -const OPENGL_CMD_RET_TYPE_REPLACE: &str = "_gl_command_ret_type_"; -const OPENGL_CMD_ARGS_REPLACE: &str = "_gl_command_args_"; -const OPENGL_CMD_ARG_NAMES_REPLACE: &str = "_gl_command_arg_names_"; -const OPENGL_CMD_ARG_TYPES_REPLACE: &str = "_gl_command_arg_types_"; +const OPENGL_CMD_IDENT_REPLACE: &str = "gl_command"; +const OPENGL_CMD_RET_TYPE_REPLACE: &str = "gl_command_ret_type"; +const OPENGL_CMD_ARGS_REPLACE: &str = "gl_command_args"; +const OPENGL_CMD_ARG_NAMES_REPLACE: &str = "gl_command_arg_names"; +const OPENGL_CMD_ARG_TYPES_REPLACE: &str = "gl_command_arg_types"; static OPENGL_REGISTRY: Lazy = Lazy::new(|| Registry::retrieve().unwrap()); /// Repeats the input for each command in the [OpenGL API and Extension Registry]. /// /// # Replacements -/// This macro will replace some specific identifiers. These identifiers are to be put -/// between underscores. +/// This macro will replace some specific identifiers **prefixed with a hashtag**. /// /// ### The following identifiers will be replaced /// /// **`gl_command`**
-/// Will be replaced by the command name. +/// Will be replaced by the full command name. For example, `glViewport`. /// /// **`gl_command_ret_type`**
-/// Will be replaced by the command return type. +/// Will be replaced by the command return type. For example, `GLuint`. /// /// **`gl_command_args`**
-/// Will be replaced by the command arguments formatted as `name: type`. +/// Will be replaced by the command arguments formatted as `name: type`, seperated by +/// comma. /// /// **`gl_command_arg_names`**
-/// Will be replaced by the command argument names. +/// Will be replaced by the command argument names, seperated by comma. /// /// **`gl_command_arg_types`**
-/// Will be replaced by the command argument types. +/// Will be replaced by the command argument types, seperated by comma. /// /// # Examples /// ``` /// # use opengl_registry_macros::for_each_opengl_command; /// for_each_opengl_command! { -/// fn _gl_command_() +/// fn #gl_command() /// { -/// println!("Hello from {}", stringify!(_gl_command_)); +/// println!("Hello from {}", stringify!(#gl_command)); /// } /// } /// ``` -- cgit v1.2.3-18-g5258