Skip to content

Commit 739965e

Browse files
committed
Add generic fast type decoder
1 parent 3184243 commit 739965e

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

extra/decimal_printer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from detail.decode_decimal32 import decode_decimal32
66
from detail.decode_decimal64 import decode_decimal64
77
from detail.decode_decimal128 import decode_decimal128
8+
from detail.decode_fast_type import decode_fast_type
89
import lldb
910

1011
def decimal32_summary(valobj, internal_dict):

extra/detail/decode_fast_type.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2025 Matt Borland
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# https://www.boost.org/LICENSE_1_0.txt
4+
5+
from generate_string import generate_string
6+
7+
def decode_fast_type(significand, exp, sign):
8+
return generate_string(significand, exp, sign)
9+

extra/detail/generate_string.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2025 Matt Borland
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# https://www.boost.org/LICENSE_1_0.txt
4+
5+
def generate_string(significand, exp, sign):
6+
if significand == 0:
7+
result = "0.0e+0"
8+
else:
9+
sig_str = str(significand)
10+
n_digits = len(sig_str)
11+
if n_digits == 1:
12+
normalized_str = sig_str
13+
total_exp = exp
14+
else:
15+
normalized_str = sig_str[0] + '.' + sig_str[1:]
16+
total_exp = exp + n_digits - 1
17+
result = f"{'-' if sign else ''}{normalized_str}e{total_exp:+}"
18+
19+
return result

0 commit comments

Comments
 (0)