poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Added struct functionality on pk-val


From: Konstantinos Chasialis
Subject: [PATCH] Added struct functionality on pk-val
Date: Thu, 28 May 2020 19:17:12 +0300
User-agent: SquirrelMail/1.4.23 [email.uoa.gr]

Author: kostasch <sdi1600195@di.uoa.gr>
Date:   Thu May 28 19:13:19 2020

* libpoke/pk-val.c: Added interface for pvm struct
* libpoke/pk-val.c: Added pk_val_type for arrays and structs

diff --git a/libpoke/pk-val.c b/libpoke/pk-val.c
index d5043d93..522883c3 100644
--- a/libpoke/pk-val.c
+++ b/libpoke/pk-val.c
@@ -131,6 +131,12 @@ pk_val_mapped_p (pk_val val)
 }

 pk_val
+pk_val_type (pk_val val)
+{
+  return PVM_VAL_TYPE (val);
+}
+
+pk_val
 pk_val_ios (pk_val val)
 {
   return PVM_VAL_IOS (val);
@@ -232,6 +238,85 @@ pk_make_any_type (void)
 }

 pk_val
+pk_make_struct_type (pk_val nfields, pk_val name,
+                      pk_val *fnames, pk_val *ftypes)
+{
+  return pvm_make_struct_type(nfields, name, fnames, ftypes);
+}
+
+pk_val
+pk_struct_type_name (pk_val type)
+{
+  return PVM_VAL_TYP_S_NAME (type);
+}
+
+pk_val
+pk_struct_type_nfields (pk_val type)
+{
+  return PVM_VAL_TYP_S_NFIELDS (type);
+}
+
+pk_val
+pk_struct_type_fnames (pk_val type)
+{
+  return PVM_VAL_TYP_S_FNAMES (type);
+}
+
+pk_val
+pk_struct_type_ftypes (pk_val type)
+{
+  return PVM_VAL_TYP_S_FTYPES (type);
+}
+
+pk_val
+pk_struct_type_fname (pk_val type, uint64_t idx)
+{
+  return PVM_VAL_TYP_S_FNAME (type, idx);
+}
+
+pk_val
+pk_struct_type_ftype (pk_val type, uint64_t idx)
+{
+  return PVM_VAL_TYP_S_FTYPE (type, idx);
+}
+
+pk_val
+pk_struct_nfields (pk_val sct)
+{
+  return PVM_VAL_SCT_NFIELDS (sct);
+}
+
+pk_val
+pk_struct_field (pk_val sct, uint64_t idx)
+{
+  return PVM_VAL_SCT_FIELD (sct, idx);
+}
+
+void
+pk_struct_set_field (pk_val sct, uint64_t idx, pk_val val)
+{
+  PVM_VAL_SCT_FIELD (sct, idx) = val;
+}
+
+pk_val
+pk_struct_nmethods (pk_val sct)
+{
+  return PVM_VAL_SCT_NMETHODS (sct);
+}
+
+pk_val
+pk_struct_method (pk_val sct, uint64_t idx)
+{
+  return PVM_VAL_SCT_METHOD (sct, idx);
+}
+
+void
+pk_struct_set_method (pk_val sct, uint64_t index, pk_val val)
+{
+  PVM_VAL_SCT_METHOD (sct, idx) = val;
+}
+
+pk_val
 pk_make_array_type (pk_val etype, pk_val bound)
 {
   return pvm_make_array_type (etype, bound);


* libpoke/pvm-val.h: Added a macro PVM_VAL_TYPE(V) which
returns the type of array or struct

diff --git a/libpoke/pvm-val.h b/libpoke/pvm-val.h
index ec3cbda1..8183bc44 100644
--- a/libpoke/pvm-val.h
+++ b/libpoke/pvm-val.h
@@ -566,6 +566,11 @@ typedef struct pvm_off *pvm_off;
    : PVM_IS_SCT ((V)) ? PVM_VAL_SCT_WRITER ((V))        \
    : PVM_NULL)

+#define PVM_VAL_TYPE(V)                         \
+  (PVM_IS_ARR ((V)) ? PVM_VAL_ARR_TYPE ((V)))   \
+  : PVM_IS_SCT ((V)) ? PVM_VAL_SCT_TYPE ((V))   \
+  : PVM_NULL
+
 #define PVM_VAL_SET_WRITER(V,O)                 \
   do                                            \
     {                                           \




reply via email to

[Prev in Thread] Current Thread [Next in Thread]