Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[meta] Make notifications and pointers enum stable #1913

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions meta/parse.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4758,6 +4758,33 @@ sub CheckStatEnum
}
}

sub GetSwitchPointersInOrder
{
my $num = scalar @_;

my @all = @{ $SAI_ENUMS{sai_switch_attr_t}{values} };

my @ordered = ();

my $regex = "(" . join("|",@_) . ")";

for my $attr (@all)
{
next if not $METADATA{sai_switch_attr_t}{$attr}{type} =~ /$regex/;

push@ordered,$1;
}

my $got = scalar @ordered;

if ($got != $num)
{
LogError "missing attributes, expected $num, got $got";
}

return @ordered;
}

sub CreateNotificationStruct
{
#
Expand All @@ -4769,7 +4796,7 @@ sub CreateNotificationStruct

WriteHeader "typedef struct _sai_switch_notifications_t {";

for my $name (sort keys %NOTIFICATIONS)
for my $name (GetSwitchPointersInOrder(keys %NOTIFICATIONS))
{
if (not $name =~ /^sai_(\w+)_notification_fn/)
{
Expand Down Expand Up @@ -4802,7 +4829,7 @@ sub CreateNotificationEnum

my @values = ();

for my $name (sort keys %NOTIFICATIONS)
for my $name (GetSwitchPointersInOrder(keys %NOTIFICATIONS))
{
if (not $name =~ /^sai_(\w+)_notification_fn/)
{
Expand Down Expand Up @@ -4838,7 +4865,7 @@ sub CreateNotificationNames

WriteSectionComment "SAI notifications names";

for my $name (sort keys %NOTIFICATIONS)
for my $name (GetSwitchPointersInOrder(keys %NOTIFICATIONS))
{
if (not $name =~ /^sai_(\w+)_notification_fn/)
{
Expand All @@ -4865,7 +4892,7 @@ sub CreateSwitchNotificationAttributesList
WriteHeader "extern const sai_attr_metadata_t* const sai_metadata_switch_notify_attr[];";
WriteSource "const sai_attr_metadata_t* const sai_metadata_switch_notify_attr[] = {";

for my $name (sort keys %NOTIFICATIONS)
for my $name (GetSwitchPointersInOrder(keys %NOTIFICATIONS))
{
next if not $name =~ /^sai_(\w+)_notification_fn/;

Expand Down Expand Up @@ -4899,7 +4926,7 @@ sub CreateSwitchPointersStruct
my @pointers = keys %NOTIFICATIONS;
push @pointers, values %ATTR_TO_CALLBACK;

for my $name (sort @pointers)
for my $name (GetSwitchPointersInOrder(@pointers))
{
if (not $name =~ /^sai_(\w+)_fn/)
{
Expand Down Expand Up @@ -4941,7 +4968,7 @@ sub CreateSwitchPointersEnum
my @pointers = keys %NOTIFICATIONS;
push @pointers, values %ATTR_TO_CALLBACK;

for my $name (sort @pointers)
for my $name (GetSwitchPointersInOrder(@pointers))
{
if (not $name =~ /^sai_(\w+)_fn/)
{
Expand Down