From 555925e0d10ee93e9abcac96f4d8ddad71b8be0e Mon Sep 17 00:00:00 2001 From: FerroO2000 <30318301+FerroO2000@users.noreply.github.com> Date: Wed, 29 May 2024 18:11:22 +0200 Subject: [PATCH] stringify reference count --- canid_builder.go | 5 +++++ signal_enum.go | 5 +++++ signal_type.go | 5 +++++ signal_unit.go | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/canid_builder.go b/canid_builder.go index 12a478a..b5f1241 100644 --- a/canid_builder.go +++ b/canid_builder.go @@ -101,6 +101,11 @@ func (b *CANIDBuilder) stringify(builder *strings.Builder, tabs int) { for _, op := range b.operations { op.stringify(builder, tabs+1) } + + refCount := b.ReferenceCount() + if refCount > 0 { + builder.WriteString(fmt.Sprintf("%sreference_count: %d\n", tabStr, refCount)) + } } func (b *CANIDBuilder) String() string { diff --git a/signal_enum.go b/signal_enum.go index d7d0605..43e2021 100644 --- a/signal_enum.go +++ b/signal_enum.go @@ -178,6 +178,11 @@ func (se *SignalEnum) stringify(b *strings.Builder, tabs int) { enumVal.stringify(b, tabs+1) b.WriteRune('\n') } + + refCount := se.ReferenceCount() + if refCount > 0 { + b.WriteString(fmt.Sprintf("%sreference_count: %d\n", tabStr, refCount)) + } } func (se *SignalEnum) String() string { diff --git a/signal_type.go b/signal_type.go index 36d5282..371fb51 100644 --- a/signal_type.go +++ b/signal_type.go @@ -131,6 +131,11 @@ func (st *SignalType) stringify(b *strings.Builder, tabs int) { b.WriteString(fmt.Sprintf("%skind: %s\n", tabStr, st.kind)) b.WriteString(fmt.Sprintf("%ssize: %d; signed: %t; min: %g; max: %g; scale: %g; offset: %g\n", tabStr, st.size, st.signed, st.min, st.max, st.scale, st.offset)) + + refCount := st.ReferenceCount() + if refCount > 0 { + b.WriteString(fmt.Sprintf("%sreference_count: %d\n", tabStr, refCount)) + } } func (st *SignalType) String() string { diff --git a/signal_unit.go b/signal_unit.go index 95cee53..7670a0b 100644 --- a/signal_unit.go +++ b/signal_unit.go @@ -62,6 +62,11 @@ func (su *SignalUnit) stringify(b *strings.Builder, tabs int) { b.WriteString(fmt.Sprintf("%skind: %s\n", tabStr, su.kind)) b.WriteString(fmt.Sprintf("%ssymbol: %s\n", tabStr, su.symbol)) + + refCount := su.ReferenceCount() + if refCount > 0 { + b.WriteString(fmt.Sprintf("%sreference_count: %d\n", tabStr, refCount)) + } } func (su *SignalUnit) String() string {