[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] pk_struct_type interface for libpoke.
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH] pk_struct_type interface for libpoke. |
Date: |
Mon, 13 Jul 2020 11:40:12 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hello! This is the pk_struct_type interface for libpoke.
Hi Kostas.
See some comments below.
From: kostasch <sdi1600195@di.uoa.gr>
Date: Fri, 3 Jul 2020 20:27:44 +0300
Subject: [PATCH] pk_struct_type interface for libpoke.
2020-07-03 Kostas Chasialis <sdi1600195@di.uoa.gr>
*libpoke/libpoke.h (pk_make_struct_type): Prototype.
(pk_struct_type): Likewise.
(pk_allocate_struct_attrs): Likewise.
(pk_struct_type_name): Likewise.
(pk_struct_type_nfields): Likewise.
(pk_struct_type_fname): Likewise.
(pk_struct_type_set_fname): Likewise.
(pk_struct_type_ftype): Likewise.
(pk_struct_type_set_ftype): Likewise.
*libpoke/pk-val.c (pk_make_struct_type): Define.
(pk_struct_type): Likewise.
(pk_allocate_struct_attrs): Likewise.
(pk_struct_type_name): Likewise.
(pk_struct_type_nfields): Likewise.
(pk_struct_type_fname): Likewise.
(pk_struct_type_set_fname): Likewise.
(pk_struct_type_ftype): Likewise.
(pk_struct_type_set_ftype): Likewise.
---
ChangeLog | 21 +++++++++++++
libpoke/libpoke.h | 75 +++++++++++++++++++++++++++++++++++++++++++++++
libpoke/pk-val.c | 62 +++++++++++++++++++++++++++++++++++++++
3 files changed, 158 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 8acc6882..a36c8ec9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2020-07-03 Kostas Chasialis <sdi1600195@di.uoa.gr>
+
+ *libpoke/libpoke.h (pk_make_struct_type): Prototype.
+ (pk_struct_type): Likewise.
+ (pk_allocate_struct_attrs): Likewise.
+ (pk_struct_type_name): Likewise.
+ (pk_struct_type_nfields): Likewise.
+ (pk_struct_type_fname): Likewise.
+ (pk_struct_type_set_fname): Likewise.
+ (pk_struct_type_ftype): Likewise.
+ (pk_struct_type_set_ftype): Likewise.
+ *libpoke/pk-val.c (pk_make_struct_type): Define.
+ (pk_struct_type): Likewise.
+ (pk_allocate_struct_attrs): Likewise.
+ (pk_struct_type_name): Likewise.
+ (pk_struct_type_nfields): Likewise.
+ (pk_struct_type_fname): Likewise.
+ (pk_struct_type_set_fname): Likewise.
+ (pk_struct_type_ftype): Likewise.
+ (pk_struct_type_set_ftype): Likewise.
+
2020-07-02 Kostas Chasialis <sdi1600195@di.uoa.gr>
* libpoke/libpoke.h (pk_make_struct): Prototype.
diff --git a/libpoke/libpoke.h b/libpoke/libpoke.h
index a0d4c23b..8fb8b48f 100644
--- a/libpoke/libpoke.h
+++ b/libpoke/libpoke.h
@@ -688,6 +688,80 @@ pk_val pk_offset_type_base_type (pk_val type);
pk_val pk_offset_type_unit (pk_val type);
+/* Struct types. */
+
+/* Build and return a struct type.
+
+ NFIELDS is the number of struct fields on this struct.
+
+ NAME is a string containing the name of a struct type.
+
+ FNAMES is a C array containing the name of each struct field.
+
+ FTYPES is a C array containing the types of each struct field. */
+
+pk_val pk_make_struct_type (pk_val nfields, pk_val name, pk_val *fnames,
pk_val *ftypes);
Line too long.
+
+/* Get the type of a struct. */
+
+pk_val pk_struct_type (pk_val sct);
+
+/* Allocate space for struct fields names and field types. */
+
+void pk_allocate_struct_attrs (pk_val nfields, pk_val **fnames, pk_val
**ftypes);
Likewise.
+
+/* Get the name of a struct type. */
+
+pk_val pk_struct_type_name (pk_val type);
Some struct types do not have names, i.e. they are anonymous. In this
case, I think PVM_VAL_TYP_S_NAME returns PVM_NULL. It would be good to
document it here for pk_struct_type_name.
+/* Get the number of fields of a struct type. */
Please specify that the returned value is an uint<64>.
+
+pk_val pk_struct_type_nfields (pk_val type);
+
+/* Get the name of a field in a struct type.
+
+ TYPE is a struct type.
+
+ IDX is the index of the field in a struct type.
+
+ If IDX is invalid, PK_NULL is returned. */
+
+pk_val pk_struct_type_fname (pk_val type, uint64_t idx);
Struct fields can be anonymous, i.e. have not name. In that case
PVM_VAL_TYP_S_FNAME returns PVM_NULL. Please document that.
+/* Set the name of a field of a struct type.
+
+ TYPE is a struct type.
+
+ IDX is the index of the field in a struct type.
+
+ NAME is a string containing the name of the field in a struct type.
+
+ If IDX is invalid, type remains unchanged. */
+
+void pk_struct_type_set_fname (pk_val type, uint64_t idx, pk_val
field_name);
+
+/* Get type of a field in the struct.
+
+ TYPE is a struct type.
+
+ IDX is the index of the struct field.
+
+ If IDX is invalid, PK_NULL is returned. */
+
+pk_val pk_struct_type_ftype (pk_val type, uint64_t idx);
+
+/* Set the type of a field of a struct type.
+
+ TYPE is a struct type.
+
+ IDX is the index of the field in a struct type.
+
+ TYPE is the type of the field in a struct type.
+
+ If IDX is invalid, type remains unchanged. */
+
+void pk_struct_type_set_ftype (pk_val type, uint64_t idx, pk_val
field_type);
Line too long.
+
/* Array types. */
/* Build and return an array type.
@@ -708,6 +782,7 @@ pk_val pk_array_type_etype (pk_val type);
pk_val pk_array_type_bound (pk_val type);
+
/* Mapped values. */
Spurious newline.