Skip to content

Fix: merge subscriptions from multiple #[processor] attributes#787

Merged
HaoboGu merged 1 commit intomainfrom
fix/multi_processor_macro
Apr 2, 2026
Merged

Fix: merge subscriptions from multiple #[processor] attributes#787
HaoboGu merged 1 commit intomainfrom
fix/multi_processor_macro

Conversation

@HaoboGu
Copy link
Copy Markdown
Owner

@HaoboGu HaoboGu commented Apr 2, 2026

Previously, when multiple #[processor] attributes appeared on a struct (e.g. via cfg_attr for conditional subscriptions), only the first attribute's subscribe list was honored. The macro removed all #[processor] attributes before the compiler could invoke the macro for subsequent ones, silently discarding conditional subscriptions.

Now the macro scans sibling #[processor] attributes on the struct and merges their event types into a single subscription list, enabling patterns like:

    #[processor(subscribe = [KeyboardEvent])]
    #[cfg_attr(feature = "_ble", processor(subscribe = [BleStatusChangeEvent]))]
    struct DisplayProcessor;

Previously, when multiple #[processor] attributes appeared on a struct (e.g. via cfg_attr for conditional subscriptions), only the first attribute's subscribe list was honored. The macro removed all #[processor] attributes before the compiler could invoke the macro for subsequent ones, silently discarding conditional subscriptions.

Now the macro scans sibling #[processor] attributes on the struct and merges their event types into a single subscription list, enabling patterns like:

    #[processor(subscribe = [KeyboardEvent])]
    #[cfg_attr(feature = "_ble", processor(subscribe = [BleStatusChangeEvent]))]
    struct DisplayProcessor;

Signed-off-by: Haobo Gu <[email protected]>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Binary Size Report

use_config/nrf52832_ble

   text	   data	    bss	    dec	    hex	filename
 323784	   5104	  34672	 363560	  58c28	rmk-nrf52832
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_config/nrf52840_ble

   text	   data	    bss	    dec	    hex	filename
 361468	   5104	  48744	 415316	  65654	rmk-nrf52840
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_config/nrf52840_ble_split

   text	   data	    bss	    dec	    hex	filename
 440520	   6428	  46752	 493700	  78884	central

   text	   data	    bss	    dec	    hex	filename
 280272	   5792	  26480	 312544	  4c4e0	peripheral
Diff

Central Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

Peripheral Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_rust/nrf52840_ble_split

   text	   data	    bss	    dec	    hex	filename
 445552	   6428	  52464	 504444	  7b27c	central

   text	   data	    bss	    dec	    hex	filename
 278492	   5232	  25224	 308948	  4b6d4	peripheral
Diff

Central Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

Peripheral Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_config/pi_pico_w_ble

   text	   data	    bss	    dec	    hex	filename
 605256	      0	  55800	 661056	  a1640	rmk-pi-pico-w
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_config/pi_pico_w_ble_split

   text	   data	    bss	    dec	    hex	filename
 637372	      0	  62416	 699788	  aad8c	central

   text	   data	    bss	    dec	    hex	filename
 495596	      0	  41756	 537352	  83308	peripheral
Diff

Central Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

Peripheral Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_rust/pi_pico_w_ble_split

   text	   data	    bss	    dec	    hex	filename
 638184	      0	  62736	 700920	  ab1f8	central

   text	   data	    bss	    dec	    hex	filename
 496200	      0	  41756	 537956	  83564	peripheral
Diff

Central Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

Peripheral Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_config/rp2040

   text	   data	    bss	    dec	    hex	filename
 134168	      0	  15664	 149832	  24948	rmk-rp2040
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_config/rp2040_split

   text	   data	    bss	    dec	    hex	filename
 145352	      0	  16660	 162012	  278dc	central

   text	   data	    bss	    dec	    hex	filename
  23680	     56	   2380	  26116	   6604	peripheral
Diff

Central Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

Peripheral Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_rust/rp2040_split

   text	   data	    bss	    dec	    hex	filename
 144244	      0	  16280	 160524	  2730c	central

   text	   data	    bss	    dec	    hex	filename
  24320	     56	   2644	  27020	   698c	peripheral
Diff

Central Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

Peripheral Diff

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_config/stm32f1

   text	   data	    bss	    dec	    hex	filename
  56900	     24	   8048	  64972	   fdcc	rmk-stm32f1
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_config/stm32f4

   text	   data	    bss	    dec	    hex	filename
 129740	    320	  16192	 146252	  23b4c	rmk-stm32f4
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

use_config/stm32h7

   text	   data	    bss	    dec	    hex	filename
  92252	    264	  10456	 102972	  1923c	rmk-stm32h7
Diff
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

@HaoboGu HaoboGu merged commit ba71a2a into main Apr 2, 2026
121 of 140 checks passed
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