aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-03-05 19:46:12 +0100
committerHampusM <hampus@hampusmat.com>2023-03-05 20:05:22 +0100
commit3d9c9d7ac68a439a29c8ad0a745a7e2a52234a44 (patch)
treeae37e7242f2ed611ee862f046ae20d235df49e81 /src/lib.rs
parent57ab49b24ed34fcddadb1a293511ee74a066e026 (diff)
refactor: improve replacement syntax
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs29
1 files changed, 15 insertions, 14 deletions
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<Registry> = 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`**<br>
-/// Will be replaced by the command name.
+/// Will be replaced by the full command name. For example, `glViewport`.
///
/// **`gl_command_ret_type`**<br>
-/// Will be replaced by the command return type.
+/// Will be replaced by the command return type. For example, `GLuint`.
///
/// **`gl_command_args`**<br>
-/// 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`**<br>
-/// Will be replaced by the command argument names.
+/// Will be replaced by the command argument names, seperated by comma.
///
/// **`gl_command_arg_types`**<br>
-/// 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));
/// }
/// }
/// ```