Skip to content

Make it possible to control the visibility of created enums.#16

Merged
maleadt merged 1 commit intomainfrom
tb/enum_visibility
Mar 24, 2026
Merged

Make it possible to control the visibility of created enums.#16
maleadt merged 1 commit intomainfrom
tb/enum_visibility

Conversation

@maleadt
Copy link
Copy Markdown
Member

@maleadt maleadt commented Mar 24, 2026

No description provided.

@github-actions
Copy link
Copy Markdown

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/enum.jl b/src/enum.jl
index 4f3b93a..7470c1f 100644
--- a/src/enum.jl
+++ b/src/enum.jl
@@ -7,8 +7,8 @@ export @enum_without_prefix
 # lack of namespacing in C, are to be used in Julia where we do have module namespacing.
 macro enum_without_prefix(ex...)
     # destructure keyword arguments
-    call = ex[end-1:end]
-    kwargs = map(ex[1:end-2]) do kwarg
+    call = ex[(end - 1):end]
+    kwargs = map(ex[1:(end - 2)]) do kwarg
         if kwarg isa Symbol
             :($kwarg = $kwarg)
         elseif Meta.isexpr(kwarg, :(=))
@@ -45,7 +45,7 @@ macro enum_without_prefix(ex...)
     for instance in instances(enum)
         name = String(Symbol(instance))
         @assert startswith(name, prefix)
-        short = Symbol(name[length(prefix)+1:end])
+        short = Symbol(name[(length(prefix) + 1):end])
         push!(ex.args, :(const $short = $(mod).$(Symbol(name))))
         if visibility == :export
             push!(ex.args, :(export $short))
diff --git a/test/runtests.jl b/test/runtests.jl
index fa2669b..9010233 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -89,9 +89,9 @@ using IOCapture
 
         # test with visibility=:export
         mod_export = @eval module $(gensym())
-            using GPUToolbox
-            @enum MY_ENUM MY_ENUM_A MY_ENUM_B
-            @enum_without_prefix visibility=:export MY_ENUM MY_ENUM_
+        using GPUToolbox
+        @enum MY_ENUM MY_ENUM_A MY_ENUM_B
+        @enum_without_prefix visibility = :export MY_ENUM MY_ENUM_
         end
         @test mod_export.A == mod_export.MY_ENUM_A
         @test mod_export.B == mod_export.MY_ENUM_B
@@ -102,9 +102,9 @@ using IOCapture
         # test with visibility=:public
         @static if VERSION >= v"1.11"
             mod_public = @eval module $(gensym())
-                using GPUToolbox
-                @enum MY_ENUM MY_ENUM_P MY_ENUM_Q
-                @enum_without_prefix visibility=:public MY_ENUM MY_ENUM_
+            using GPUToolbox
+            @enum MY_ENUM MY_ENUM_P MY_ENUM_Q
+            @enum_without_prefix visibility = :public MY_ENUM MY_ENUM_
             end
             @test mod_public.P == mod_public.MY_ENUM_P
             @test mod_public.Q == mod_public.MY_ENUM_Q

@maleadt maleadt merged commit 05626cb into main Mar 24, 2026
20 of 26 checks passed
@maleadt maleadt deleted the tb/enum_visibility branch March 24, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant