[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] pickles: leb128.pk: use computed field for value
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH 1/3] pickles: leb128.pk: use computed field for value |
Date: |
Wed, 18 Jan 2023 23:37:59 +0100 |
2023-01-17 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* pickles/leb128.pk (ULEB128): Make `value' a `computed' field.
(LEB128): Likewise.
(ULEB128::get_value): New method for computed field.
(ULEB128::set_value): Likewise.
(LEB128::set_value): Likewise.
(LEB128::get_value): Likewise.
(ULEB128::_print): Adapt.
(LEB128::_print): Likewise.
---
ChangeLog | 11 +++++++++++
pickles/leb128.pk | 24 ++++++++++++++++++------
2 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cb33df44..cb9d702e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-01-17 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * pickles/leb128.pk (ULEB128): Make `value' a `computed' field.
+ (LEB128): Likewise.
+ (ULEB128::get_value): New method for computed field.
+ (ULEB128::set_value): Likewise.
+ (LEB128::set_value): Likewise.
+ (LEB128::get_value): Likewise.
+ (ULEB128::_print): Adapt.
+ (LEB128::_print): Likewise.
+
2023-01-18 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* poked/poked.c (VUCMD_*): Re-enumerate the view (vu) commands.
diff --git a/pickles/leb128.pk b/pickles/leb128.pk
index 48cf0835..a8e161cc 100644
--- a/pickles/leb128.pk
+++ b/pickles/leb128.pk
@@ -32,7 +32,9 @@ type ULEB128 =
LEB128_Byte[] variable;
byte last;
- method value = uint<64>:
+ computed uint<64> value;
+
+ method get_value = uint<64>:
{
var shift = 0;
var result = 0UL;
@@ -51,12 +53,16 @@ type ULEB128 =
return result;
}
+ method set_value = (uint<64> v) void:
+ {
+ raise E_inval;
+ }
method _print = void:
{
var val = 0UL;
- try val = value;
+ try val = get_value;
catch
{
print "#<uleb128:";
@@ -68,7 +74,7 @@ type ULEB128 =
}
printf ("%<leb128:#<uleb128:%<integer:%u64d%>>%>",
- value);
+ get_value);
}
};
@@ -78,7 +84,9 @@ type LEB128 =
LEB128_Byte[] variable;
byte last;
- method value = int<64>:
+ computed int<64> value;
+
+ method get_value = int<64>:
{
var shift = 0;
var result = 0UL;
@@ -100,12 +108,16 @@ type LEB128 =
return result;
}
+ method set_value = (int<64> v) void:
+ {
+ raise E_inval;
+ }
method _print = void:
{
var val = 0UL;
- try val = value;
+ try val = get_value;
catch
{
print "#<leb128:";
@@ -117,6 +129,6 @@ type LEB128 =
}
printf ("%<leb128:#<leb128:%<integer:%u64d%>>%>",
- value);
+ get_value);
}
};
--
2.39.0
- [PATCH 1/3] pickles: leb128.pk: use computed field for value,
Mohammad-Reza Nabipoor <=
[PATCH 3/3] pickles: add pickle for pdap (poked application protocol), Mohammad-Reza Nabipoor, 2023/01/18
Re: [PATCH 1/3] pickles: leb128.pk: use computed field for value, Jose E. Marchesi, 2023/01/19