Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
2004-07-26 Martin Quinson
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 27 Jul 2004 01:43:26 +0000 (01:43 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 27 Jul 2004 01:43:26 +0000 (01:43 +0000)
  Version 0.3 (protocol not changed; ABI changed)
  - Major overhault of the datadesc interface to simplify it:
    - shorted the function names:
      s/gras_datadesc_declare_struct/gras_datadesc_struct/ and so on
    - add a trivial way to push/pop integers into the cbps without malloc.
      This allows to make really generic sub_type description, which simply
        pop their size of the stack.
    - add a function gras_datadesc_ref_pop_arr() which does what users want
      most of the time: Declare a dynamic array (which pops its size of the
      stack) and declare a reference to it. Poor name, but anyway.
    - kill the post-send callback, add a post-receive one

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@350 48e7efb5-ca39-0410-a469-dd3cf9ba447f

19 files changed:
ChangeLog
Makefile.am
NEWS
configure.ac
cruft/doc/gras-sections.txt
cruft/doc/gtk-doc.make
cruft/doc/tmpl/comm_datadesc.sgml
cruft/doc/tmpl/gras-unused.sgml
examples/ping/test_rl
include/gras/datadesc.h
src/gras/DataDesc/cbps.c
src/gras/DataDesc/datadesc.c
src/gras/DataDesc/datadesc_interface.h
src/gras/DataDesc/datadesc_private.h
src/gras/DataDesc/ddt_create.c
src/gras/DataDesc/ddt_exchange.c
src/gras/DataDesc/ddt_parse.c
src/gras/Msg/msg.c
testsuite/gras/datadesc_usage.c

index a991eb6..55e8a74 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
+2004-07-26 Martin Quinson
+  Version 0.3 (protocol not changed; ABI changed)
+  - Major overhault of the datadesc interface to simplify it:
+    - shorted the function names:
+      s/gras_datadesc_declare_struct/gras_datadesc_struct/ and so on
+    - add a trivial way to push/pop integers into the cbps without malloc.
+      This allows to make really generic sub_type description, which simply
+        pop their size of the stack.
+    - add a function gras_datadesc_ref_pop_arr() which does what users want
+      most of the time: Declare a dynamic array (which pops its size of the
+      stack) and declare a reference to it. Poor name, but anyway.
+    - kill the post-send callback, add a post-receive one
+    
 2004-07-23 Martin Quinson
-  Version 0.2
+  Version 0.2 (protocol changed; ABI changed)
   - add some testing for cpbs in the test cases, and fix some more bugs.
     This invalidate again the little64 data file, since I cannot regenerate
     it myself.
index 3687d7c..aa76f36 100644 (file)
@@ -3,6 +3,7 @@ DISTCLEANFILES =  *~
 
 ACLOCAL = aclocal -I acmacro -I /usr/share/aclocal/gnome2-macros
 AUTOMAKE_OPTIONS = gnu
+DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
 
 EXTRA_DIST = bootstrap COPYING INSTALL NEWS README README.IEEE TODO AUTHORS ChangeLog\
        acmacro/aci.m4 \
diff --git a/NEWS b/NEWS
index 313eb40..0f4a4b6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
 This is a shortened version of the changelog.
 
+0.2 (2004-07-24)
+ - Bug fixes, API and build process polishing, documentation improvement
+ - build shared libs
+
 0.1 (2004-07-13)
  - No major issue discovered, time to change the versionning schema
 
index 63c9fed..a1b1d1d 100644 (file)
@@ -3,7 +3,7 @@ AC_PREREQ(2.59)
 #We need a recent ACI
 ACI_PREREQ(2003.01.16)
 
-AC_INIT([GRAS],[0.2],[martin.quinson@ens-lyon.fr])
+AC_INIT([GRAS],[0.3],[martin.quinson@ens-lyon.fr])
 AC_CONFIG_SRCDIR([src/include/gras.h])
 AC_CONFIG_HEADERS([src/gras_config.h])
 
index 58a72ee..72e1836 100644 (file)
@@ -261,16 +261,17 @@ gras_datadesc_by_name
 GRAS_DEFINE_TYPE
 gras_datadesc_by_symbol
 
-gras_datadesc_declare_array_fixed
-gras_datadesc_declare_array_dyn
-gras_datadesc_declare_ref
-gras_datadesc_declare_ref_generic
-gras_datadesc_declare_struct
-gras_datadesc_declare_struct_append
-gras_datadesc_declare_struct_close
-gras_datadesc_declare_union
-gras_datadesc_declare_union_append
-gras_datadesc_declare_union_close
+gras_datadesc_array_fixed
+gras_datadesc_array_dyn
+gras_datadesc_ref
+gras_datadesc_ref_generic
+gras_datadesc_struct
+gras_datadesc_struct_append
+gras_datadesc_struct_close
+gras_datadesc_union
+gras_datadesc_union_append
+gras_datadesc_union_close
+gras_datadesc_ref_pop_arr
 
 gras_datadesc_cb_set_pre
 gras_datadesc_cb_set_post
index 7cf9c4f..59c115b 100644 (file)
@@ -112,7 +112,18 @@ clean-local:
 maintainer-clean-local: clean
        cd $(srcdir) && rm -rf xml html $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
 
-dist-hook: dist-hook-local
+#
+# Require gtk-doc when making dist
+#
+if ENABLE_GTK_DOC
+dist-check-gtkdoc:
+else
+dist-check-gtkdoc:
+       @echo "*** gtk-doc must be installed and enabled in order to make dist"
+       @false
+endif
+       
+dist-hook: dist-check-gtkdoc dist-hook-local
        mkdir $(distdir)/tmpl
        mkdir $(distdir)/xml
        mkdir $(distdir)/html
index b163d8d..bc66682 100644 (file)
@@ -20,9 +20,10 @@ Describing data to be exchanged
 </para>
 
 @vars: 
-@p_type: 
 @data: 
 @Returns: 
+<!-- # Unused Parameters # -->
+@p_type: 
 
 
 <!-- ##### USER_FUNCTION gras_datadesc_type_cb_void_t ##### -->
@@ -31,8 +32,9 @@ Describing data to be exchanged
 </para>
 
 @vars: 
-@p_type: 
 @data: 
+<!-- # Unused Parameters # -->
+@p_type: 
 
 
 <!-- ##### FUNCTION gras_datadesc_by_name ##### -->
@@ -63,7 +65,7 @@ Describing data to be exchanged
 @name: 
 
 
-<!-- ##### FUNCTION gras_datadesc_declare_array_fixed ##### -->
+<!-- ##### FUNCTION gras_datadesc_array_fixed ##### -->
 <para>
 
 </para>
@@ -75,7 +77,7 @@ Describing data to be exchanged
 @Returns: 
 
 
-<!-- ##### FUNCTION gras_datadesc_declare_array_dyn ##### -->
+<!-- ##### FUNCTION gras_datadesc_array_dyn ##### -->
 <para>
 
 </para>
@@ -85,12 +87,9 @@ Describing data to be exchanged
 @dynamic_size: 
 @dst: 
 @Returns: 
-<!-- # Unused Parameters # -->
-@elm_type: 
-@code: 
 
 
-<!-- ##### FUNCTION gras_datadesc_declare_ref ##### -->
+<!-- ##### FUNCTION gras_datadesc_ref ##### -->
 <para>
 
 </para>
@@ -99,12 +98,9 @@ Describing data to be exchanged
 @referenced_type: 
 @dst: 
 @Returns: 
-<!-- # Unused Parameters # -->
-@ref_type: 
-@code: 
 
 
-<!-- ##### FUNCTION gras_datadesc_declare_ref_generic ##### -->
+<!-- ##### FUNCTION gras_datadesc_ref_generic ##### -->
 <para>
 
 </para>
@@ -115,7 +111,7 @@ Describing data to be exchanged
 @Returns: 
 
 
-<!-- ##### FUNCTION gras_datadesc_declare_struct ##### -->
+<!-- ##### FUNCTION gras_datadesc_struct ##### -->
 <para>
 
 </para>
@@ -123,11 +119,9 @@ Describing data to be exchanged
 @name: 
 @dst: 
 @Returns: 
-<!-- # Unused Parameters # -->
-@code: 
 
 
-<!-- ##### FUNCTION gras_datadesc_declare_struct_append ##### -->
+<!-- ##### FUNCTION gras_datadesc_struct_append ##### -->
 <para>
 
 </para>
@@ -138,7 +132,7 @@ Describing data to be exchanged
 @Returns: 
 
 
-<!-- ##### FUNCTION gras_datadesc_declare_struct_close ##### -->
+<!-- ##### FUNCTION gras_datadesc_struct_close ##### -->
 <para>
 
 </para>
@@ -146,7 +140,7 @@ Describing data to be exchanged
 @struct_type: 
 
 
-<!-- ##### FUNCTION gras_datadesc_declare_union ##### -->
+<!-- ##### FUNCTION gras_datadesc_union ##### -->
 <para>
 
 </para>
@@ -155,11 +149,9 @@ Describing data to be exchanged
 @selector: 
 @dst: 
 @Returns: 
-<!-- # Unused Parameters # -->
-@code: 
 
 
-<!-- ##### FUNCTION gras_datadesc_declare_union_append ##### -->
+<!-- ##### FUNCTION gras_datadesc_union_append ##### -->
 <para>
 
 </para>
@@ -170,7 +162,7 @@ Describing data to be exchanged
 @Returns: 
 
 
-<!-- ##### FUNCTION gras_datadesc_declare_union_close ##### -->
+<!-- ##### FUNCTION gras_datadesc_union_close ##### -->
 <para>
 
 </para>
@@ -178,80 +170,14 @@ Describing data to be exchanged
 @union_type: 
 
 
-<!-- ##### FUNCTION gras_datadesc_cb_set_pre ##### -->
-<para>
-
-</para>
-
-@type: 
-@pre: 
-
-
-<!-- ##### FUNCTION gras_datadesc_cb_set_post ##### -->
-<para>
-
-</para>
-
-@type: 
-@post: 
-
-
-<!-- ##### FUNCTION gras_dd_cbps_pop ##### -->
+<!-- ##### FUNCTION gras_datadesc_ref_pop_arr ##### -->
 <para>
 
 </para>
 
-@ps: 
-@name: 
-@ddt: 
-
-
-<!-- ##### FUNCTION gras_dd_cbps_push ##### -->
-<para>
-
-</para>
-
-@ps: 
-@name: 
-@data: 
-@ddt: 
-
-
-<!-- ##### FUNCTION gras_dd_cbps_set ##### -->
-<para>
-
-</para>
-
-@ps: 
-@name: 
-@data: 
-@ddt: 
-
-
-<!-- ##### FUNCTION gras_dd_cbps_get ##### -->
-<para>
-
-</para>
-
-@ps: 
-@name: 
-@ddt: 
-
-
-<!-- ##### FUNCTION gras_dd_cbps_block_begin ##### -->
-<para>
-
-</para>
-
-@ps: 
-
-
-<!-- ##### FUNCTION gras_dd_cbps_block_end ##### -->
-<para>
-
-</para>
-
-@ps: 
+@element_type: 
+@dst: 
+@Returns: 
 
 
 <!-- ##### FUNCTION gras_arch_selfid ##### -->
index 3d47f80..ccac7da 100644 (file)
@@ -1871,6 +1871,22 @@ Sockets
 
 @ud: 
 
+<!-- ##### FUNCTION gras_datadesc_cb_set_post ##### -->
+<para>
+
+</para>
+
+@type: 
+@post: 
+
+<!-- ##### FUNCTION gras_datadesc_cb_set_pre ##### -->
+<para>
+
+</para>
+
+@type: 
+@pre: 
+
 <!-- ##### FUNCTION gras_datadesc_cmp ##### -->
 <para>
 
@@ -1916,6 +1932,42 @@ Sockets
 @code: 
 @Returns: 
 
+<!-- ##### FUNCTION gras_datadesc_declare_array_dyn ##### -->
+<para>
+
+</para>
+
+@name: 
+@element_type: 
+@dynamic_size: 
+@dst: 
+@Returns: 
+@elm_type: 
+@code: 
+
+<!-- ##### FUNCTION gras_datadesc_declare_array_fixed ##### -->
+<para>
+
+</para>
+
+@name: 
+@element_type: 
+@fixed_size: 
+@dst: 
+@Returns: 
+
+<!-- ##### FUNCTION gras_datadesc_declare_ref ##### -->
+<para>
+
+</para>
+
+@name: 
+@referenced_type: 
+@dst: 
+@Returns: 
+@ref_type: 
+@code: 
+
 <!-- ##### FUNCTION gras_datadesc_declare_ref_cb ##### -->
 <para>
 
@@ -1937,6 +1989,26 @@ Sockets
 @discriminant: 
 @code: 
 
+<!-- ##### FUNCTION gras_datadesc_declare_ref_generic ##### -->
+<para>
+
+</para>
+
+@name: 
+@discriminant: 
+@dst: 
+@Returns: 
+
+<!-- ##### FUNCTION gras_datadesc_declare_struct ##### -->
+<para>
+
+</para>
+
+@name: 
+@dst: 
+@Returns: 
+@code: 
+
 <!-- ##### MACRO gras_datadesc_declare_struct_add_code ##### -->
 <para>
 
@@ -1979,6 +2051,16 @@ Sockets
 @post_cb: 
 @Returns: 
 
+<!-- ##### FUNCTION gras_datadesc_declare_struct_append ##### -->
+<para>
+
+</para>
+
+@struct_type: 
+@name: 
+@field_type: 
+@Returns: 
+
 <!-- ##### FUNCTION gras_datadesc_declare_struct_append_name ##### -->
 <para>
 
@@ -2000,6 +2082,24 @@ Sockets
 @code: 
 @Returns: 
 
+<!-- ##### FUNCTION gras_datadesc_declare_struct_close ##### -->
+<para>
+
+</para>
+
+@struct_type: 
+
+<!-- ##### FUNCTION gras_datadesc_declare_union ##### -->
+<para>
+
+</para>
+
+@name: 
+@selector: 
+@dst: 
+@Returns: 
+@code: 
+
 <!-- ##### MACRO gras_datadesc_declare_union_add_code ##### -->
 <para>
 
@@ -2042,6 +2142,16 @@ Sockets
 @post_cb: 
 @Returns: 
 
+<!-- ##### FUNCTION gras_datadesc_declare_union_append ##### -->
+<para>
+
+</para>
+
+@union_type: 
+@name: 
+@field_type: 
+@Returns: 
+
 <!-- ##### FUNCTION gras_datadesc_declare_union_append_name ##### -->
 <para>
 
@@ -2063,6 +2173,13 @@ Sockets
 @code: 
 @Returns: 
 
+<!-- ##### FUNCTION gras_datadesc_declare_union_close ##### -->
+<para>
+
+</para>
+
+@union_type: 
+
 <!-- ##### FUNCTION gras_datadesc_from_nws ##### -->
 <para>
 
@@ -2098,6 +2215,58 @@ Sockets
 @code: 
 @def: 
 
+<!-- ##### FUNCTION gras_dd_cbps_block_begin ##### -->
+<para>
+
+</para>
+
+@ps: 
+
+<!-- ##### FUNCTION gras_dd_cbps_block_end ##### -->
+<para>
+
+</para>
+
+@ps: 
+
+<!-- ##### FUNCTION gras_dd_cbps_get ##### -->
+<para>
+
+</para>
+
+@ps: 
+@name: 
+@ddt: 
+
+<!-- ##### FUNCTION gras_dd_cbps_pop ##### -->
+<para>
+
+</para>
+
+@ps: 
+@name: 
+@ddt: 
+
+<!-- ##### FUNCTION gras_dd_cbps_push ##### -->
+<para>
+
+</para>
+
+@ps: 
+@name: 
+@data: 
+@ddt: 
+
+<!-- ##### FUNCTION gras_dd_cbps_set ##### -->
+<para>
+
+</para>
+
+@ps: 
+@name: 
+@data: 
+@ddt: 
+
 <!-- ##### FUNCTION gras_ddt_free ##### -->
 <para>
 
index 4c4c12d..b0ce91e 100755 (executable)
@@ -1,3 +1,3 @@
 #! /bin/sh
-./ping_server 4000&
-./ping_client 127.0.0.1 4000
+./ping_server 4000 $@&
+./ping_client 127.0.0.1 4000 $@
index edb0daa..e2827df 100644 (file)
@@ -45,13 +45,11 @@ BEGIN_DECL
  */
 typedef struct s_gras_datadesc_type gras_datadesc_type_t;
 
+typedef struct s_gras_cbps gras_cbps_t;
+
 /* callbacks prototypes */
-typedef void (*gras_datadesc_type_cb_void_t)(void                 *vars,
-                                            gras_datadesc_type_t *p_type,
-                                            void                 *data);
-typedef int (*gras_datadesc_type_cb_int_t)(void                 *vars,
-                                          gras_datadesc_type_t *p_type,
-                                          void                 *data);
+typedef void (*gras_datadesc_type_cb_void_t)(gras_cbps_t *vars, void *data);
+typedef int (*gras_datadesc_type_cb_int_t)(gras_cbps_t *vars, void *data);
 
 /***********************************************
  **** Search and retrieve declared datatype ****
@@ -63,52 +61,54 @@ gras_datadesc_type_t *gras_datadesc_by_name(const char *name);
  ******************************************/
 
 gras_error_t 
-gras_datadesc_declare_struct(const char            *name,
+gras_datadesc_struct(const char            *name,
                             gras_datadesc_type_t **dst);
 gras_error_t 
-gras_datadesc_declare_struct_append(gras_datadesc_type_t          *struct_type,
+gras_datadesc_struct_append(gras_datadesc_type_t          *struct_type,
                                    const char                    *name,
                                    gras_datadesc_type_t          *field_type);
 void
-gras_datadesc_declare_struct_close(gras_datadesc_type_t          *struct_type);
+gras_datadesc_struct_close(gras_datadesc_type_t          *struct_type);
 gras_error_t 
-gras_datadesc_declare_union(const char                      *name,
+gras_datadesc_union(const char                      *name,
                            gras_datadesc_type_cb_int_t      selector,
                            gras_datadesc_type_t           **dst);
 gras_error_t 
-gras_datadesc_declare_union_append(gras_datadesc_type_t          *union_type,
+gras_datadesc_union_append(gras_datadesc_type_t          *union_type,
                                   const char                    *name,
                                   gras_datadesc_type_t          *field_type);
 void
-gras_datadesc_declare_union_close(gras_datadesc_type_t          *union_type);
+gras_datadesc_union_close(gras_datadesc_type_t          *union_type);
 gras_error_t 
-gras_datadesc_declare_ref(const char                      *name,
+gras_datadesc_ref(const char                      *name,
                          gras_datadesc_type_t            *referenced_type,
                          gras_datadesc_type_t           **dst);
 gras_error_t
-gras_datadesc_declare_ref_generic(const char                   *name,
+gras_datadesc_ref_generic(const char                   *name,
                                  gras_datadesc_type_cb_int_t   discriminant,
                                  gras_datadesc_type_t        **dst);
 gras_error_t 
-gras_datadesc_declare_array_fixed(const char                    *name,
+gras_datadesc_array_fixed(const char                    *name,
                                  gras_datadesc_type_t          *element_type,
                                  long int                       fixed_size,
                                  gras_datadesc_type_t         **dst);
 gras_error_t 
-gras_datadesc_declare_array_dyn(const char                      *name,
+gras_datadesc_array_dyn(const char                      *name,
                                gras_datadesc_type_t            *element_type,
                                gras_datadesc_type_cb_int_t      dynamic_size,
                                gras_datadesc_type_t           **dst);
+gras_error_t 
+gras_datadesc_ref_pop_arr(gras_datadesc_type_t  *element_type,
+                                 gras_datadesc_type_t **dst);
 
 /*********************************
  * Change stuff within datadescs *
  *********************************/
 
-typedef struct s_gras_dd_cbps gras_dd_cbps_t;
-void gras_datadesc_cb_set_pre (gras_datadesc_type_t    *type,
-                              gras_datadesc_type_cb_void_t  pre);
-void gras_datadesc_cb_set_post(gras_datadesc_type_t    *type,
-                              gras_datadesc_type_cb_void_t  post);
+void gras_datadesc_cb_send (gras_datadesc_type_t    *type,
+                           gras_datadesc_type_cb_void_t  pre);
+void gras_datadesc_cb_recv(gras_datadesc_type_t    *type,
+                          gras_datadesc_type_cb_void_t  post);
 
 /******************************
  * Get stuff within datadescs *
@@ -119,32 +119,39 @@ int gras_datadesc_get_id(gras_datadesc_type_t *ddt);
 /********************************************************
  * Advanced data describing: callback persistent states *
  ********************************************************/
+/* simple one: push/pop sizes of arrays */
+void
+gras_cbps_i_push(gras_cbps_t *ps, int val);
+int 
+gras_cbps_i_pop(gras_cbps_t *ps);
+int gras_datadesc_cb_pop(gras_cbps_t *vars, void *data);
 
+/* complex one: complete variable environment support */
 gras_error_t
-gras_dd_cbps_pop (gras_dd_cbps_t        *ps, 
-                 const char            *name,
-                 gras_datadesc_type_t **ddt,
+gras_cbps_v_pop (gras_cbps_t        *ps, 
+                   const char            *name,
+                   gras_datadesc_type_t **ddt,
                  void                 **res);
 gras_error_t
-gras_dd_cbps_push(gras_dd_cbps_t        *ps,
-                 const char            *name,
-                 void                  *data,
-                 gras_datadesc_type_t  *ddt);
+gras_cbps_v_push(gras_cbps_t        *ps,
+                   const char            *name,
+                   void                  *data,
+                   gras_datadesc_type_t  *ddt);
 void
-gras_dd_cbps_set (gras_dd_cbps_t        *ps,
-                 const char            *name,
-                 void                  *data,
-                 gras_datadesc_type_t  *ddt);
+gras_cbps_v_set (gras_cbps_t        *ps,
+                   const char            *name,
+                   void                  *data,
+                   gras_datadesc_type_t  *ddt);
 
 void *
-gras_dd_cbps_get (gras_dd_cbps_t        *ps, 
-                 const char            *name,
-                 gras_datadesc_type_t **ddt);
+gras_cbps_v_get (gras_cbps_t        *ps, 
+                   const char            *name,
+                   gras_datadesc_type_t **ddt);
 
 void
-gras_dd_cbps_block_begin(gras_dd_cbps_t *ps);
+gras_cbps_block_begin(gras_cbps_t *ps);
 void
-gras_dd_cbps_block_end(gras_dd_cbps_t *ps);
+gras_cbps_block_end(gras_cbps_t *ps);
 
 
 
index c289976..2e59fae 100644 (file)
@@ -14,10 +14,12 @@ GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(cbps,datadesc);
 typedef struct {
   gras_datadesc_type_t *type;
   void                 *data;
-} gras_dd_cbps_elm_t;
+} gras_cbps_elm_t;
 
-struct s_gras_dd_cbps {
-  gras_dict_t  *space; /* varname x dynar of gras_dd_cbps_elm_t */
+struct s_gras_cbps {
+  gras_dynar_t *lints; /* simple stack of long integers (easy interface) */
+
+  gras_dict_t  *space; /* varname x dynar of gras_cbps_elm_t */
   gras_dynar_t *frames; /* of dynar of names defined within this frame
                           (and to pop when we leave it) */
   gras_dynar_t *globals;
@@ -30,27 +32,31 @@ static void free_string(void *d){
 }
 
 gras_error_t
-gras_dd_cbps_new(gras_dd_cbps_t **dst) {
+gras_cbps_new(gras_cbps_t **dst) {
   gras_error_t errcode;
-  gras_dd_cbps_t *res;
+  gras_cbps_t *res;
 
-  if (!(res=malloc(sizeof(gras_dd_cbps_t))))
+  if (!(res=malloc(sizeof(gras_cbps_t))))
     RAISE_MALLOC;
 
+  TRY(gras_dynar_new(&(res->lints), sizeof(int), NULL));
+
   TRY(gras_dict_new(&(res->space)));
   /* no leak, the content is freed manually on block_end */
   TRY(gras_dynar_new(&(res->frames), sizeof(gras_dynar_t*), NULL));
   TRY(gras_dynar_new(&(res->globals), sizeof(char*), NULL));
 
-  gras_dd_cbps_block_begin(res);
+  gras_cbps_block_begin(res);
   *dst = res;
   return no_error;
 }
 
 void
-gras_dd_cbps_free(gras_dd_cbps_t **state) {
+gras_cbps_free(gras_cbps_t **state) {
+
+  gras_dynar_free(    (*state)->lints   );
 
-  gras_dd_cbps_block_end(*state);
+  gras_cbps_block_end(*state);
   gras_dict_free ( &( (*state)->space   ) );
   gras_dynar_free(    (*state)->frames    );
   gras_dynar_free(    (*state)->globals   );
@@ -60,20 +66,20 @@ gras_dd_cbps_free(gras_dd_cbps_t **state) {
 }
 
 /**
- * gras_dd_cbps_push:
+ * gras_cbps_v_push:
  *
  * Declare a new element in the PS, and give it a value. If an element of that
  * name already exists, it is masked by the one given here, and will be 
  * seeable again only after a pop to remove the value this push adds.
  */
 gras_error_t
-gras_dd_cbps_push(gras_dd_cbps_t        *ps,
-                 const char            *name,
-                 void                  *data,
-                 gras_datadesc_type_t  *ddt) {
+gras_cbps_v_push(gras_cbps_t        *ps,
+                   const char            *name,
+                   void                  *data,
+                   gras_datadesc_type_t  *ddt) {
 
   gras_dynar_t            *varstack,*frame;
-  gras_dd_cbps_elm_t      *p_var;
+  gras_cbps_elm_t      *p_var;
   gras_error_t errcode;
   char *varname = strdup(name);
 
@@ -82,14 +88,14 @@ gras_dd_cbps_push(gras_dd_cbps_t        *ps,
  
   if (errcode == mismatch_error) {
     DEBUG1("Create a new variable stack for '%s' into the space",name);
-    gras_dynar_new(&varstack, sizeof (gras_dd_cbps_elm_t *), NULL);
+    gras_dynar_new(&varstack, sizeof (gras_cbps_elm_t *), NULL);
     gras_dict_set(ps->space, varname, (void **)varstack, NULL);
     /* leaking, you think? only if you do not close all the openned blocks ;)*/
   } else if (errcode != no_error) {
     return errcode;
   }
  
-  p_var       = calloc(1, sizeof(gras_dd_cbps_elm_t));
+  p_var       = calloc(1, sizeof(gras_cbps_elm_t));
   p_var->type = ddt;
   p_var->data = data;
   
@@ -103,19 +109,19 @@ gras_dd_cbps_push(gras_dd_cbps_t        *ps,
 }
 
 /**
- * gras_dd_cbps_pop:
+ * gras_cbps_v_pop:
  *
  * Retrieve an element from the PS, and remove it from the PS. If it's not
  * present in the current block, it will fail (with abort) and not search
  * in upper blocks since this denotes a programmation error.
  */
 gras_error_t
-gras_dd_cbps_pop (gras_dd_cbps_t        *ps, 
-                 const char            *name,
-                 gras_datadesc_type_t **ddt,
-                 void                 **res) {
+gras_cbps_v_pop (gras_cbps_t        *ps, 
+                   const char            *name,
+                   gras_datadesc_type_t **ddt,
+                   void                 **res) {
   gras_dynar_t            *varstack,*frame;
-  gras_dd_cbps_elm_t      *var          = NULL;
+  gras_cbps_elm_t      *var          = NULL;
   void                    *data           = NULL;
   gras_error_t errcode;
 
@@ -162,7 +168,7 @@ gras_dd_cbps_pop (gras_dd_cbps_t        *ps,
 }
 
 /**
- * gras_dd_cbps_set:
+ * gras_cbps_v_set:
  *
  * Change the value of an element in the PS.  
  * If it's not present in the current block, look in the upper ones.
@@ -173,23 +179,23 @@ gras_dd_cbps_pop (gras_dd_cbps_t        *ps,
  *   its value is changed.
  */
 void
-gras_dd_cbps_set (gras_dd_cbps_t        *ps,
-                 const char            *name,
-                 void                  *data,
-                 gras_datadesc_type_t  *ddt) {
+gras_cbps_v_set (gras_cbps_t        *ps,
+                   const char            *name,
+                   void                  *data,
+                   gras_datadesc_type_t  *ddt) {
 
   gras_dynar_t            *p_dynar        = NULL;
-  gras_dd_cbps_elm_t      *p_elm          = NULL;
+  gras_cbps_elm_t      *p_elm          = NULL;
   gras_error_t errcode;
   
   DEBUG1("set(%s)",name);
   errcode = gras_dict_get(ps->space, name, (void **)&p_dynar);
   
   if (errcode == mismatch_error) {
-    gras_dynar_new(&p_dynar, sizeof (gras_dd_cbps_elm_t *), NULL);
+    gras_dynar_new(&p_dynar, sizeof (gras_cbps_elm_t *), NULL);
     gras_dict_set(ps->space, name, (void **)p_dynar, NULL);
     
-    p_elm   = calloc(1, sizeof(gras_dd_cbps_elm_t));
+    p_elm   = calloc(1, sizeof(gras_cbps_elm_t));
     gras_dynar_push(ps->globals, &name);
   } else {
     gras_dynar_pop(p_dynar, &p_elm);
@@ -203,7 +209,7 @@ gras_dd_cbps_set (gras_dd_cbps_t        *ps,
 }
 
 /**
- * gras_dd_cbps_get:
+ * gras_cbps_v_get:
  *
  * Get the value of an element in the PS without modifying it. 
  * (note that you get the content of the data struct and not a copy to it)
@@ -212,12 +218,12 @@ gras_dd_cbps_set (gras_dd_cbps_t        *ps,
  * If not present there neither, the code may segfault (Oli?).
  */
 void *
-gras_dd_cbps_get (gras_dd_cbps_t        *ps, 
-                 const char            *name,
-                 gras_datadesc_type_t **ddt) {
+gras_cbps_v_get (gras_cbps_t        *ps, 
+                   const char            *name,
+                   gras_datadesc_type_t **ddt) {
   
   gras_dynar_t            *p_dynar        = NULL;
-  gras_dd_cbps_elm_t      *p_elm          = NULL;
+  gras_cbps_elm_t      *p_elm          = NULL;
   
   DEBUG1("get(%s)",name);
   /* FIXME: Error handling */
@@ -234,7 +240,7 @@ gras_dd_cbps_get (gras_dd_cbps_t        *ps,
 }
 
 /**
- * gras_dd_cbps_block_begin:
+ * gras_cbps_block_begin:
  *
  * Begins a new block. 
  *
@@ -248,7 +254,7 @@ gras_dd_cbps_get (gras_dd_cbps_t        *ps,
  */
 
 void
-gras_dd_cbps_block_begin(gras_dd_cbps_t *ps) {
+gras_cbps_block_begin(gras_cbps_t *ps) {
 
   gras_dynar_t            *p_dynar        = NULL;
 
@@ -258,12 +264,12 @@ gras_dd_cbps_block_begin(gras_dd_cbps_t *ps) {
 }
 
 /**
- * gras_dd_cbps_block_begin:
+ * gras_cbps_block_begin:
  *
  * End the current block, and go back to the upper one.
  */
 void
-gras_dd_cbps_block_end(gras_dd_cbps_t *ps) {
+gras_cbps_block_end(gras_cbps_t *ps) {
 
   gras_dynar_t            *frame        = NULL;
   int                      cursor         =    0;
@@ -276,7 +282,7 @@ gras_dd_cbps_block_end(gras_dd_cbps_t *ps) {
   gras_dynar_foreach(frame, cursor, name) {
 
     gras_dynar_t            *varstack    = NULL;
-    gras_dd_cbps_elm_t      *var         = NULL;
+    gras_cbps_elm_t      *var         = NULL;
  
     DEBUG2("Get ride of %s (%p)",name,name);
     gras_dict_get(ps->space, name, (void **)&varstack);
@@ -296,4 +302,37 @@ gras_dd_cbps_block_end(gras_dd_cbps_t *ps) {
 }
 
 
+/**
+ * gras_cbps_i_push:
+ *
+ * Push a new long integer value into the cbps.
+ */
+void
+gras_cbps_i_push(gras_cbps_t        *ps, 
+                   int val) {
+  gras_error_t errcode;
+  TRYFAIL(gras_dynar_push(ps->lints,&val));
+}
+/**
+ * gras_cbps_i_pop:
+ *
+ * Pop the lastly pushed long integer value from the cbps.
+ */
+int
+gras_cbps_i_pop(gras_cbps_t        *ps) {
+  int ret;
+
+  gras_assert0(gras_dynar_length(ps->lints) > 0,
+              "gras_cbps_i_pop: no value to pop");
+  gras_dynar_pop(ps->lints, &ret);
+  return ret;
+}
 
+/**
+ * gras_dd_cb_pop:
+ *
+ * Generic cb returning the lastly pushed value
+ */
+int gras_datadesc_cb_pop(gras_cbps_t *vars, void *data) {
+  return gras_cbps_i_pop(vars);
+}
index d580709..85a8e1b 100644 (file)
@@ -17,9 +17,7 @@ gras_set_t *gras_datadesc_set_local=NULL;
 
 /* callback for array size when sending strings */
 static int
-_strlen_cb(void                        *vars,
-           gras_datadesc_type_t        *type,
-           void                        *data) {
+_strlen_cb(gras_cbps_t *vars, void *data) {
 
   return 1+(long int)strlen(data);
 }
@@ -45,95 +43,95 @@ gras_datadesc_init(void) {
   
   TRYFAIL(gras_set_new(&gras_datadesc_set_local));
   
-  TRYFAIL(gras_datadesc_declare_scalar("signed char", 
-                                      gras_ddt_scalar_char, 
-                                      e_gras_dd_scalar_encoding_sint, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("char", 
-                                      gras_ddt_scalar_char, 
-                                      e_gras_dd_scalar_encoding_sint, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("unsigned char", 
-                                      gras_ddt_scalar_char, 
-                                      e_gras_dd_scalar_encoding_uint, 
-                                      NULL, &ddt));
+  TRYFAIL(gras_datadesc_scalar("signed char", 
+                              gras_ddt_scalar_char, 
+                              e_gras_dd_scalar_encoding_sint, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("char", 
+                              gras_ddt_scalar_char, 
+                              e_gras_dd_scalar_encoding_sint, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("unsigned char", 
+                              gras_ddt_scalar_char, 
+                              e_gras_dd_scalar_encoding_uint, 
+                              &ddt));
   
-  TRYFAIL(gras_datadesc_declare_scalar("signed short int", 
-                                      gras_ddt_scalar_short, 
-                                      e_gras_dd_scalar_encoding_sint, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("short int", 
-                                      gras_ddt_scalar_short, 
-                                      e_gras_dd_scalar_encoding_sint, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("unsigned short int", 
-                                      gras_ddt_scalar_short, 
-                                      e_gras_dd_scalar_encoding_uint, 
-                                      NULL, &ddt));
+  TRYFAIL(gras_datadesc_scalar("signed short int", 
+                              gras_ddt_scalar_short, 
+                              e_gras_dd_scalar_encoding_sint, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("short int", 
+                              gras_ddt_scalar_short, 
+                              e_gras_dd_scalar_encoding_sint, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("unsigned short int", 
+                              gras_ddt_scalar_short, 
+                              e_gras_dd_scalar_encoding_uint, 
+                              &ddt));
   
-  TRYFAIL(gras_datadesc_declare_scalar("signed int", 
-                                      gras_ddt_scalar_int, 
-                                      e_gras_dd_scalar_encoding_sint, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("int", 
-                                      gras_ddt_scalar_int, 
-                                      e_gras_dd_scalar_encoding_sint, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("unsigned int", 
-                                      gras_ddt_scalar_int, 
-                                      e_gras_dd_scalar_encoding_uint, 
-                                      NULL, &ddt));
+  TRYFAIL(gras_datadesc_scalar("signed int", 
+                              gras_ddt_scalar_int, 
+                              e_gras_dd_scalar_encoding_sint, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("int", 
+                              gras_ddt_scalar_int, 
+                              e_gras_dd_scalar_encoding_sint, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("unsigned int", 
+                              gras_ddt_scalar_int, 
+                              e_gras_dd_scalar_encoding_uint, 
+                              &ddt));
   
-  TRYFAIL(gras_datadesc_declare_scalar("signed long int", 
-                                      gras_ddt_scalar_long, 
-                                      e_gras_dd_scalar_encoding_sint, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("long int", 
-                                      gras_ddt_scalar_long, 
-                                      e_gras_dd_scalar_encoding_sint, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("unsigned long int", 
-                                      gras_ddt_scalar_long, 
-                                      e_gras_dd_scalar_encoding_uint, 
-                                      NULL, &ddt));
+  TRYFAIL(gras_datadesc_scalar("signed long int", 
+                              gras_ddt_scalar_long, 
+                              e_gras_dd_scalar_encoding_sint, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("long int", 
+                              gras_ddt_scalar_long, 
+                              e_gras_dd_scalar_encoding_sint, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("unsigned long int", 
+                              gras_ddt_scalar_long, 
+                              e_gras_dd_scalar_encoding_uint, 
+                              &ddt));
   
-  TRYFAIL(gras_datadesc_declare_scalar("signed long long int", 
-                                      gras_ddt_scalar_long_long, 
-                                      e_gras_dd_scalar_encoding_sint, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("long long int", 
-                                      gras_ddt_scalar_long_long, 
-                                      e_gras_dd_scalar_encoding_sint, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("unsigned long long int", 
-                                      gras_ddt_scalar_long_long, 
-                                      e_gras_dd_scalar_encoding_uint, 
-                                      NULL, &ddt));
+  TRYFAIL(gras_datadesc_scalar("signed long long int", 
+                              gras_ddt_scalar_long_long, 
+                              e_gras_dd_scalar_encoding_sint, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("long long int", 
+                              gras_ddt_scalar_long_long, 
+                              e_gras_dd_scalar_encoding_sint, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("unsigned long long int", 
+                              gras_ddt_scalar_long_long, 
+                              e_gras_dd_scalar_encoding_uint, 
+                              &ddt));
   
-  TRYFAIL(gras_datadesc_declare_scalar("data pointer", 
-                                      gras_ddt_scalar_pdata, 
-                                      e_gras_dd_scalar_encoding_uint, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("function pointer", 
-                                      gras_ddt_scalar_pfunc, 
-                                      e_gras_dd_scalar_encoding_uint, 
-                                      NULL, &ddt));
+  TRYFAIL(gras_datadesc_scalar("data pointer", 
+                              gras_ddt_scalar_pdata, 
+                              e_gras_dd_scalar_encoding_uint, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("function pointer", 
+                              gras_ddt_scalar_pfunc, 
+                              e_gras_dd_scalar_encoding_uint, 
+                              &ddt));
   
-  TRYFAIL(gras_datadesc_declare_scalar("float", 
-                                      gras_ddt_scalar_float, 
-                                      e_gras_dd_scalar_encoding_float, 
-                                      NULL, &ddt));
-  TRYFAIL(gras_datadesc_declare_scalar("double", 
-                                      gras_ddt_scalar_double, 
-                                      e_gras_dd_scalar_encoding_float, 
-                                      NULL,&ddt));
-
-  TRYFAIL(gras_datadesc_declare_array_dyn("char[]", 
-                                         gras_datadesc_by_name("char"), 
-                                         _strlen_cb,&ddt));
-  TRYFAIL(gras_datadesc_declare_ref("string", 
-                                   gras_datadesc_by_name("char[]"), 
-                                   &ddt));
+  TRYFAIL(gras_datadesc_scalar("float", 
+                              gras_ddt_scalar_float, 
+                              e_gras_dd_scalar_encoding_float, 
+                              &ddt));
+  TRYFAIL(gras_datadesc_scalar("double", 
+                              gras_ddt_scalar_double, 
+                              e_gras_dd_scalar_encoding_float, 
+                              &ddt));
+
+  TRYFAIL(gras_datadesc_array_dyn("char[]", 
+                                 gras_datadesc_by_name("char"), 
+                                 _strlen_cb,&ddt));
+  TRYFAIL(gras_datadesc_ref("string", 
+                           gras_datadesc_by_name("char[]"), 
+                           &ddt));
 
 }
 
index 26c3ae8..0e68b0b 100644 (file)
@@ -40,7 +40,7 @@ gras_datadesc_recv(gras_socket_t *sock, gras_datadesc_type_t *type,
                   int r_arch, void *dst);
 
 /* Indicate (lack of) interest in datatype */
-void gras_datadesc_ref(gras_datadesc_type_t *type);
+void gras_datadesc_addref(gras_datadesc_type_t *type);
 void gras_datadesc_unref(gras_datadesc_type_t *type);
    
 #endif /* GRAS_DATADESC_INTERFACE_H */
index 37075aa..d80b2aa 100644 (file)
@@ -225,27 +225,26 @@ struct s_gras_datadesc_type {
   enum  e_gras_datadesc_type_category  category_code;
   union u_gras_datadesc_category       category;
   
-  gras_datadesc_type_cb_void_t         pre;
-  gras_datadesc_type_cb_void_t         post;
+  gras_datadesc_type_cb_void_t         send;
+  gras_datadesc_type_cb_void_t         recv;
 };
 
 /***************************
  * Type creation functions *
  ***************************/
 gras_error_t 
-gras_datadesc_declare_scalar(const char                       *name,
-                            gras_ddt_scalar_type_t           type,
-                            enum e_gras_dd_scalar_encoding   encoding,
-                            gras_datadesc_type_cb_void_t     cb,
-                            gras_datadesc_type_t           **dst);
+gras_datadesc_scalar(const char                       *name,
+                    gras_ddt_scalar_type_t           type,
+                    enum e_gras_dd_scalar_encoding   encoding,
+                    gras_datadesc_type_t           **dst);
 
 /****************************************************
  * Callback persistant state constructor/destructor *
  ****************************************************/
 gras_error_t
-gras_dd_cbps_new(gras_dd_cbps_t **dst);
+gras_cbps_new(gras_cbps_t **dst);
 void
-gras_dd_cbps_free(gras_dd_cbps_t **state);
+gras_cbps_free(gras_cbps_t **state);
 
 /***************
  * Convertions *
index c0adbf3..d69fe8f 100644 (file)
@@ -77,16 +77,15 @@ gras_error_t gras_datadesc_by_id(long int               code,
 }
 
 /**
- * gras_datadesc_declare_scalar:
+ * gras_datadesc_scalar:
  *
  * Create a new scalar and give a pointer to it 
  */
 gras_error_t 
-gras_datadesc_declare_scalar(const char                      *name,
-                       gras_ddt_scalar_type_t           type,
-                       enum e_gras_dd_scalar_encoding   encoding,
-                       gras_datadesc_type_cb_void_t     cb,
-                       gras_datadesc_type_t           **dst) {
+gras_datadesc_scalar(const char                      *name,
+                    gras_ddt_scalar_type_t           type,
+                    enum e_gras_dd_scalar_encoding   encoding,
+                    gras_datadesc_type_t           **dst) {
 
   gras_error_t errcode;
   gras_datadesc_type_t *res;
@@ -133,7 +132,6 @@ gras_datadesc_declare_scalar(const char                      *name,
   res->category_code                 = e_gras_datadesc_type_cat_scalar;
   res->category.scalar_data.encoding = encoding;
 
-  res->pre = cb;
   return no_error;
 }
 
@@ -153,13 +151,13 @@ void gras_dd_cat_field_free(void *f) {
 }
 
 /**
- * gras_datadesc_declare_struct:
+ * gras_datadesc_struct:
  *
  * Create a new struct and give a pointer to it 
  */
 gras_error_t 
-gras_datadesc_declare_struct(const char                      *name,
-                       gras_datadesc_type_t           **dst) {
+gras_datadesc_struct(const char            *name,
+                    gras_datadesc_type_t **dst) {
 
   gras_error_t errcode;
   gras_datadesc_type_t *res;
@@ -182,14 +180,14 @@ gras_datadesc_declare_struct(const char                      *name,
 }
 
 /**
- * gras_datadesc_declare_struct_append:
+ * gras_datadesc_struct_append:
  *
  * Append a field to the struct
  */
 gras_error_t 
-gras_datadesc_declare_struct_append(gras_datadesc_type_t  *struct_type,
-                                   const char            *name,
-                                   gras_datadesc_type_t  *field_type) {
+gras_datadesc_struct_append(gras_datadesc_type_t  *struct_type,
+                           const char            *name,
+                           gras_datadesc_type_t  *field_type) {
 
   gras_error_t errcode;
   gras_dd_cat_field_t *field;
@@ -246,20 +244,20 @@ gras_datadesc_declare_struct_append(gras_datadesc_type_t  *struct_type,
   return no_error;
 }
 void
-gras_datadesc_declare_struct_close(gras_datadesc_type_t  *struct_type) {
+gras_datadesc_struct_close(gras_datadesc_type_t  *struct_type) {
    struct_type->category.struct_data.closed = 1;
-   //   INFO0("FIXME: Do something in gras_datadesc_declare_struct_close");
+   //   INFO0("FIXME: Do something in gras_datadesc_struct_close");
 }
 
 /**
- * gras_datadesc_declare_union:
+ * gras_datadesc_union:
  *
  * Create a new union and give a pointer to it 
  */
 gras_error_t 
-gras_datadesc_declare_union(const char                   *name,
-                           gras_datadesc_type_cb_int_t   selector,
-                           gras_datadesc_type_t        **dst) {
+gras_datadesc_union(const char                   *name,
+                   gras_datadesc_type_cb_int_t   selector,
+                   gras_datadesc_type_t        **dst) {
 
   gras_error_t errcode;
   gras_datadesc_type_t *res;
@@ -287,14 +285,14 @@ gras_datadesc_declare_union(const char                   *name,
 }
 
 /**
- * gras_datadesc_declare_union_append:
+ * gras_datadesc_union_append:
  *
  * Append a field to the union
  */
 gras_error_t 
-gras_datadesc_declare_union_append(gras_datadesc_type_t  *union_type,
-                                  const char            *name,
-                                  gras_datadesc_type_t  *field_type) {
+gras_datadesc_union_append(gras_datadesc_type_t  *union_type,
+                          const char            *name,
+                          gras_datadesc_type_t  *field_type) {
 
   gras_error_t errcode;
   gras_dd_cat_field_t *field;
@@ -333,19 +331,19 @@ gras_datadesc_declare_union_append(gras_datadesc_type_t  *union_type,
 }
 
 void
-gras_datadesc_declare_union_close(gras_datadesc_type_t  *union_type) {
+gras_datadesc_union_close(gras_datadesc_type_t  *union_type) {
    union_type->category.union_data.closed = 1;
-   //   INFO0("FIXME: Do something in gras_datadesc_declare_union_close");
+   //   INFO0("FIXME: Do something in gras_datadesc_union_close");
 }
 /**
- * gras_datadesc_declare_ref:
+ * gras_datadesc_ref:
  *
  * Create a new ref to a fixed type and give a pointer to it 
  */
 gras_error_t 
-gras_datadesc_declare_ref(const char             *name,
-                         gras_datadesc_type_t   *referenced_type,
-                         gras_datadesc_type_t  **dst) {
+gras_datadesc_ref(const char             *name,
+                 gras_datadesc_type_t   *referenced_type,
+                 gras_datadesc_type_t  **dst) {
 
   gras_error_t errcode;
   gras_datadesc_type_t *res;
@@ -371,14 +369,14 @@ gras_datadesc_declare_ref(const char             *name,
   return no_error;
 }
 /**
- * gras_datadesc_declare_ref_generic:
+ * gras_datadesc_ref_generic:
  *
  * Create a new ref to a type given at use time, and give a pointer to it 
  */
 gras_error_t 
-gras_datadesc_declare_ref_generic(const char                      *name,
-                        gras_datadesc_type_cb_int_t      selector,
-                        gras_datadesc_type_t           **dst) {
+gras_datadesc_ref_generic(const char                      *name,
+                         gras_datadesc_type_cb_int_t      selector,
+                         gras_datadesc_type_t           **dst) {
 
   gras_error_t errcode;
   gras_datadesc_type_t *res;
@@ -405,15 +403,15 @@ gras_datadesc_declare_ref_generic(const char                      *name,
 }
 
 /**
- * gras_datadesc_declare_array_fixed:
+ * gras_datadesc_array_fixed:
  *
  * Create a new array and give a pointer to it 
  */
 gras_error_t 
-gras_datadesc_declare_array_fixed(const char              *name,
-                                 gras_datadesc_type_t    *element_type,
-                                 long int                 fixed_size,
-                                 gras_datadesc_type_t   **dst) {
+gras_datadesc_array_fixed(const char              *name,
+                         gras_datadesc_type_t    *element_type,
+                         long int                 fixed_size,
+                         gras_datadesc_type_t   **dst) {
 
   gras_error_t errcode;
   gras_datadesc_type_t *res;
@@ -438,15 +436,15 @@ gras_datadesc_declare_array_fixed(const char              *name,
   return no_error;
 }
 /**
- * gras_datadesc_declare_array_dyn:
+ * gras_datadesc_array_dyn:
  *
  * Create a new array and give a pointer to it 
  */
 gras_error_t 
-gras_datadesc_declare_array_dyn(const char                      *name,
-                      gras_datadesc_type_t            *element_type,
-                      gras_datadesc_type_cb_int_t      dynamic_size,
-                      gras_datadesc_type_t           **dst) {
+gras_datadesc_array_dyn(const char                      *name,
+                       gras_datadesc_type_t            *element_type,
+                       gras_datadesc_type_cb_int_t      dynamic_size,
+                       gras_datadesc_type_t           **dst) {
 
   gras_error_t errcode;
   gras_datadesc_type_t *res;
@@ -474,6 +472,47 @@ gras_datadesc_declare_array_dyn(const char                      *name,
   return no_error;
 }
 
+/**
+ * gras_datadesc_ref_pop_arr:
+ *
+ * Most of the time, you want to include a reference in your structure which
+ * is a pointer to a dynamic array whose size is fixed by another field of 
+ * your structure.
+ *
+ * This case pops up so often that this function was created to take care of
+ * this case. It creates a dynamic array type whose size is poped from the 
+ * current cbps, and then create a reference to it.
+ *
+ * The name of the created datatype will be the name of the element type, with
+ * '[]*' appended to it.
+ *
+ * Then to use it, you just have to make sure that your structure pre-callback
+ * does push the size of the array in the cbps (using #gras_cbps_i_push), and 
+ * you are set. 
+ *
+ * But be remember that this is a stack. If you have two different pop_arr, you
+ * should push the second one first, so that the first one is on the top of the 
+ * list when the first field gets transfered.
+ *
+ */
+gras_error_t 
+gras_datadesc_ref_pop_arr(gras_datadesc_type_t  *element_type,
+                         gras_datadesc_type_t **dst) {
+  gras_error_t errcode;
+  char *name=malloc(strlen(element_type->name) + 4);
+
+  sprintf(name,"%s[]",element_type->name);
+
+  TRY(gras_datadesc_array_dyn(name,element_type,
+                                     gras_datadesc_cb_pop, dst));
+
+  sprintf(name,"%s[]*",element_type->name);
+  TRY(gras_datadesc_ref(name,*dst,dst));
+
+  free(name);
+
+  return no_error;
+}
 gras_error_t
 gras_datadesc_import_nws(const char           *name,
                         const DataDescriptor *desc,
@@ -483,38 +522,40 @@ gras_datadesc_import_nws(const char           *name,
 }
 
 /**
- * gras_datadesc_cb_set_pre:
+ * gras_datadesc_cb_send:
  *
- * Add a pre-send callback to this datadexc
+ * Add a pre-send callback to this datadexc.
+ * (useful to push the sizes of the upcoming arrays, for example)
  */
-void gras_datadesc_cb_set_pre (gras_datadesc_type_t         *type,
-                              gras_datadesc_type_cb_void_t  pre) {
-  type->pre = pre;
+void gras_datadesc_cb_send (gras_datadesc_type_t         *type,
+                           gras_datadesc_type_cb_void_t  send) {
+  type->send = send;
 }
 /**
- * gras_datadesc_cb_set_post:
+ * gras_datadesc_cb_recv:
  *
- * Add a post-send callback to this datadexc
+ * Add a post-receive callback to this datadesc.
+ * (useful to put the function pointers to the rigth value, for example)
  */
-void gras_datadesc_cb_set_post(gras_datadesc_type_t         *type,
-                              gras_datadesc_type_cb_void_t  post) {
-  type->post = post;
+void gras_datadesc_cb_recv(gras_datadesc_type_t         *type,
+                          gras_datadesc_type_cb_void_t  recv) {
+  type->recv = recv;
 }
 
 /**
- * gras_datadesc_ref:
+ * gras_datadesc_addref:
  *
  * Adds a reference to the datastruct. 
  * ddt will be freed only when the refcount becomes 0.
  */
-void gras_datadesc_ref(gras_datadesc_type_t *type) {
+void gras_datadesc_addref(gras_datadesc_type_t *type) {
   type->refcounter ++;
 }
 
 /**
  * gras_datadesc_unref:
  *
- * Adds a reference to the datastruct. 
+ * Removes a reference to the datastruct. 
  * ddt will be freed only when the refcount becomes 0.
  */
 void gras_datadesc_unref(gras_datadesc_type_t *type) {
index 62400ba..353d0e5 100644 (file)
@@ -31,13 +31,13 @@ gras_dd_is_r_null(char **r_ptr, long int length);
 
 static gras_error_t 
 gras_datadesc_send_rec(gras_socket_t        *sock,
-                      gras_dd_cbps_t       *state,
+                      gras_cbps_t       *state,
                       gras_dict_t          *refs,
                       gras_datadesc_type_t *type, 
                       char                 *data);
 static gras_error_t
 gras_datadesc_recv_rec(gras_socket_t        *sock, 
-                      gras_dd_cbps_t       *state,
+                      gras_cbps_t       *state,
                       gras_dict_t          *refs,
                       gras_datadesc_type_t *type,
                       int                   r_arch,
@@ -192,16 +192,16 @@ int gras_datadesc_type_cmp(const gras_datadesc_type_t *d1,
     return d1->category_code > d2->category_code ? 1 : -1;
   }
 
-  if (d1->pre != d2->pre) {
-    DEBUG4("ddt_cmp: %s->pre=%p  !=  %s->pre=%p",
-          d1->name,d1->pre, d2->name,d2->pre);
-    return d1->pre > d2->pre ? 1 : -1;
+  if (d1->send != d2->send) {
+    DEBUG4("ddt_cmp: %s->send=%p  !=  %s->send=%p",
+          d1->name,d1->send, d2->name,d2->send);
+    return d1->send > d2->send ? 1 : -1;
   }
 
-  if (d1->post != d2->post) {
-    DEBUG4("ddt_cmp: %s->post=%p  !=  %s->post=%p",
-          d1->name,d1->post, d2->name,d2->post);
-    return d1->post > d2->post ? 1 : -1;
+  if (d1->recv != d2->recv) {
+    DEBUG4("ddt_cmp: %s->recv=%p  !=  %s->recv=%p",
+          d1->name,d1->recv, d2->name,d2->recv);
+    return d1->recv > d2->recv ? 1 : -1;
   }
 
   switch (d1->category_code) {
@@ -305,7 +305,7 @@ gras_error_t gras_datadesc_cpy(gras_datadesc_type_t *type,
 
 static gras_error_t 
 gras_datadesc_send_rec(gras_socket_t        *sock,
-                      gras_dd_cbps_t       *state,
+                      gras_cbps_t       *state,
                       gras_dict_t          *refs,
                       gras_datadesc_type_t *type, 
                       char                 *data) {
@@ -317,8 +317,8 @@ gras_datadesc_send_rec(gras_socket_t        *sock,
   VERB2("Send a %s (%s)", 
        type->name, gras_datadesc_cat_names[type->category_code]);
 
-  if (type->pre) {
-    type->pre(state,type,data);
+  if (type->send) {
+    type->send(state,data);
   }
 
   switch (type->category_code) {
@@ -347,13 +347,13 @@ gras_datadesc_send_rec(gras_socket_t        *sock,
               gras_error_name(errcode),field->code,cpt,type->name);
       
       if (field->pre)
-       field->pre(state,sub_type,field_data);
+       field->pre(state,field_data);
       
       VERB1("Send field %s",field->name);
       TRY(gras_datadesc_send_rec(sock,state,refs,sub_type, field_data));
       
       if (field->post)
-       field->post(state,sub_type,field_data);
+       field->post(state,field_data);
     }
     VERB1("<< Sent all fields of the structure %s", type->name);
     
@@ -371,7 +371,7 @@ gras_datadesc_send_rec(gras_socket_t        *sock,
                "Please call gras_datadesc_declare_union_close on %s before sending it",
                type->name);
     /* retrieve the field number */
-    field_num = union_data.selector(state, type, data);
+    field_num = union_data.selector(state, data);
     
     gras_assert1(field_num > 0,
                 "union field selector of %s gave a negative value", 
@@ -389,12 +389,12 @@ gras_datadesc_send_rec(gras_socket_t        *sock,
     TRY(gras_datadesc_by_id(field->code, &sub_type));
     
     if (field->pre)
-      field->pre(state,sub_type,data);
+      field->pre(state,data);
     
     TRY(gras_datadesc_send_rec(sock,state,refs, sub_type, data));
       
     if (field->post)
-      field->post(state,sub_type,data);
+      field->post(state,data);
     
     break;
   }
@@ -411,7 +411,7 @@ gras_datadesc_send_rec(gras_socket_t        *sock,
     /* Detect the referenced type and send it to peer if needed */
     ref_code = ref_data.code;
     if (ref_code < 0) {
-      ref_code = ref_data.selector(state,type,data);
+      ref_code = ref_data.selector(state,data);
       TRY(gras_dd_send_int(sock, ref_code));
     }
     
@@ -456,7 +456,7 @@ gras_datadesc_send_rec(gras_socket_t        *sock,
     /* determine and send the element count */
     count = array_data.fixed_size;
     if (count <= 0) {
-      count = array_data.dynamic_size(state,type,data);
+      count = array_data.dynamic_size(state,data);
       gras_assert1(count >=0,
                   "Invalid (negative) array size for type %s",type->name);
       TRY(gras_dd_send_int(sock, count));
@@ -482,10 +482,6 @@ gras_datadesc_send_rec(gras_socket_t        *sock,
     gras_assert0(0, "Invalid type");
   }
 
-  if (type->post) {
-    type->post(state,type,data);
-  }
-
   return no_error;
 }
 
@@ -500,16 +496,16 @@ gras_error_t gras_datadesc_send(gras_socket_t *sock,
                                void *src) {
 
   gras_error_t errcode;
-  gras_dd_cbps_t *state = NULL;
+  gras_cbps_t *state = NULL;
   gras_dict_t    *refs; /* all references already sent */
  
   TRY(gras_dict_new(&refs));
-  TRY(gras_dd_cbps_new(&state));
+  TRY(gras_cbps_new(&state));
 
   errcode = gras_datadesc_send_rec(sock,state,refs,type,(char*)src);
 
   gras_dict_free(&refs);
-  gras_dd_cbps_free(&state);
+  gras_cbps_free(&state);
 
   return errcode;
 }
@@ -528,7 +524,7 @@ gras_error_t gras_datadesc_send(gras_socket_t *sock,
  */
 gras_error_t
 gras_datadesc_recv_rec(gras_socket_t        *sock, 
-                      gras_dd_cbps_t       *state,
+                      gras_cbps_t          *state,
                       gras_dict_t          *refs,
                       gras_datadesc_type_t *type,
                       int                   r_arch,
@@ -752,6 +748,9 @@ gras_datadesc_recv_rec(gras_socket_t        *sock,
     gras_assert0(0, "Invalid type");
   }
   
+  if (type->recv)
+    type->recv(state,l_data);
+
   return no_error;
 }
 
@@ -769,18 +768,18 @@ gras_datadesc_recv(gras_socket_t *sock,
                   void *dst) {
 
   gras_error_t errcode;
-  gras_dd_cbps_t *state = NULL; /* callback persistent state */
+  gras_cbps_t *state = NULL; /* callback persistent state */
   gras_dict_t    *refs;         /* all references already sent */
 
   TRY(gras_dict_new(&refs));
-  TRY(gras_dd_cbps_new(&state));
+  TRY(gras_cbps_new(&state));
 
   errcode = gras_datadesc_recv_rec(sock, state, refs, type, 
                                   r_arch, NULL, 0,
                                   (char *) dst,-1);
 
   gras_dict_free(&refs);
-  gras_dd_cbps_free(&state);
+  gras_cbps_free(&state);
 
   return errcode;
 }
index 0ee9b7c..88b452f 100644 (file)
@@ -187,7 +187,7 @@ static gras_error_t parse_statement(char            *definition,
     sprintf(buffname,"struct %s",identifier.type_name);
     identifier.type = gras_datadesc_by_name(buffname);
     if (!identifier.type) {
-      TRY(gras_datadesc_declare_struct(buffname,&identifier.type));
+      TRY(gras_datadesc_struct(buffname,&identifier.type));
     }
 
   } else if (tm.is_unsigned) {
@@ -292,9 +292,8 @@ static gras_error_t parse_statement(char            *definition,
          free(identifier.type_name);
          array.type = gras_datadesc_by_name(array.type_name);
          if (array.type==NULL) {
-           TRY(gras_datadesc_declare_array_fixed(array.type_name,
-                                                 identifier.type,
-                                                 size, &array.type));
+           TRY(gras_datadesc_array_fixed(array.type_name, identifier.type,
+                                         size, &array.type));
          }
          array.name = identifier.name;
          TRY(gras_dynar_push(*dynar,&array));
@@ -376,13 +375,13 @@ static gras_datadesc_type_t *parse_struct(char *definition) {
 
   /* Create the struct descriptor */
   if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
-    TRYFAIL(gras_datadesc_declare_struct(gras_ddt_parse_text,&struct_type));
+    TRYFAIL(gras_datadesc_struct(gras_ddt_parse_text,&struct_type));
     DEBUG1("Parse the struct '%s'", gras_ddt_parse_text);
     gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
   } else {
     sprintf(buffname,"anonymous struct %d",anonymous_struct++); 
     DEBUG1("Parse the anonymous struct nb %d", anonymous_struct);
-    TRYFAIL(gras_datadesc_declare_struct(buffname,&struct_type));
+    TRYFAIL(gras_datadesc_struct(buffname,&struct_type));
   }
 
   if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_LP) {
@@ -399,13 +398,12 @@ static gras_datadesc_type_t *parse_struct(char *definition) {
     DEBUG1("This statement contained %d fields",gras_dynar_length(fields));
     gras_dynar_foreach(fields,i, field) {
       DEBUG1("Append field %s",field.name);      
-      TRYFAIL(gras_datadesc_declare_struct_append(struct_type,field.name,
-                                                 field.type));
+      TRYFAIL(gras_datadesc_struct_append(struct_type, field.name, field.type));
       free(field.name);
       free(field.type_name);
     }
   }
-  gras_datadesc_declare_struct_close(struct_type);
+  gras_datadesc_struct_close(struct_type);
   if (errcode != mismatch_error)
     return NULL; /* FIXME: LEAK! */
 
@@ -464,7 +462,7 @@ static gras_datadesc_type_t * parse_typedef(char *definition) {
 
 
 /**
- * gras_datadesc_declare_parse:
+ * gras_datadesc_parse:
  *
  * Create a datadescription from the result of parsing the C type description
  */
index 91d5aca..85e50e0 100644 (file)
@@ -145,7 +145,7 @@ gras_msgtype_declare_v(const char            *name,
   msgtype->name_len = strlen(namev);
   msgtype->version = version;
   msgtype->ctn_type = payload;
-  gras_datadesc_ref(payload);
+  gras_datadesc_addref(payload);
 
   TRY(gras_set_add(_gras_msgtype_set, (gras_set_elm_t*)msgtype,
                   &gras_msgtype_free));
@@ -201,7 +201,7 @@ gras_msg_send(gras_socket_t  *sock,
     gras_assert(string_type);
   }
 
-  DEBUG3("send %s to %s:%d", msgtype->name, 
+  DEBUG3("send '%s' to %s:%d", msgtype->name, 
         gras_socket_peer_name(sock),gras_socket_peer_port(sock));
   TRY(gras_trp_chunk_send(sock, GRAS_header, 6));
 
index bb82397..2de6e60 100644 (file)
@@ -118,9 +118,9 @@ gras_error_t test_array(gras_socket_t *sock, int direction) {
 
   INFO0("---- Test on fixed array ----");
 
-  TRY(gras_datadesc_declare_array_fixed("fixed int array", 
-                                       gras_datadesc_by_name("int"),
-                                       SIZE, &my_type));
+  TRY(gras_datadesc_array_fixed("fixed int array", 
+                               gras_datadesc_by_name("int"),
+                               SIZE, &my_type));
 
   TRY(write_read(my_type, &i,&j, sock,direction));
   if (direction == READ || direction == RW) {
@@ -143,7 +143,7 @@ gras_error_t test_intref(gras_socket_t *sock, int direction) {
 
   INFO1("---- Test on a reference to an integer (%p) ----",i);
 
-  TRY(gras_datadesc_declare_ref("int*",gras_datadesc_by_name("int"),&my_type));
+  TRY(gras_datadesc_ref("int*",gras_datadesc_by_name("int"),&my_type));
 
   TRY(write_read(my_type, &i,&j, sock,direction));
   if (direction == READ || direction == RW) {
@@ -190,19 +190,19 @@ gras_error_t test_homostruct(gras_socket_t *sock, int direction) {
 
   INFO0("---- Test on homogeneous structure ----");
   /* create descriptor */
-  TRY(gras_datadesc_declare_struct("homostruct",&my_type));
-  TRY(gras_datadesc_declare_struct_append(my_type,"a",
-                                         gras_datadesc_by_name("signed int")));
-  TRY(gras_datadesc_declare_struct_append(my_type,"b",
-                                         gras_datadesc_by_name("int")));
-  TRY(gras_datadesc_declare_struct_append(my_type,"c",
-                                         gras_datadesc_by_name("int")));
-  TRY(gras_datadesc_declare_struct_append(my_type,"d",
-                                         gras_datadesc_by_name("int")));
-  gras_datadesc_declare_struct_close(my_type);
-  TRY(gras_datadesc_declare_ref("homostruct*",
-                               gras_datadesc_by_name("homostruct"),
-                               &my_type));
+  TRY(gras_datadesc_struct("homostruct",&my_type));
+  TRY(gras_datadesc_struct_append(my_type,"a",
+                                 gras_datadesc_by_name("signed int")));
+  TRY(gras_datadesc_struct_append(my_type,"b",
+                                 gras_datadesc_by_name("int")));
+  TRY(gras_datadesc_struct_append(my_type,"c",
+                                 gras_datadesc_by_name("int")));
+  TRY(gras_datadesc_struct_append(my_type,"d",
+                                 gras_datadesc_by_name("int")));
+  gras_datadesc_struct_close(my_type);
+  TRY(gras_datadesc_ref("homostruct*",
+                       gras_datadesc_by_name("homostruct"),
+                       &my_type));
 
   /* init a value, exchange it and check its validity*/
   if (! (i=malloc(sizeof(homostruct))) )
@@ -238,19 +238,18 @@ gras_error_t test_hetestruct(gras_socket_t *sock, int direction) {
 
   INFO0("---- Test on heterogeneous structure ----");
   /* create descriptor */
-  TRY(gras_datadesc_declare_struct("hetestruct",&my_type));
-  TRY(gras_datadesc_declare_struct_append(my_type,"c1",
-                                         gras_datadesc_by_name("unsigned char")));
-  TRY(gras_datadesc_declare_struct_append(my_type,"l1",
-                                         gras_datadesc_by_name("unsigned long int")));
-  TRY(gras_datadesc_declare_struct_append(my_type,"c2",
-                                         gras_datadesc_by_name("unsigned char")));
-  TRY(gras_datadesc_declare_struct_append(my_type,"l2",
-                                         gras_datadesc_by_name("unsigned long int")));
-  gras_datadesc_declare_struct_close(my_type);
-  TRY(gras_datadesc_declare_ref("hetestruct*",
-                               gras_datadesc_by_name("hetestruct"),
-                               &my_type));
+  TRY(gras_datadesc_struct("hetestruct",&my_type));
+  TRY(gras_datadesc_struct_append(my_type,"c1",
+                                 gras_datadesc_by_name("unsigned char")));
+  TRY(gras_datadesc_struct_append(my_type,"l1",
+                                 gras_datadesc_by_name("unsigned long int")));
+  TRY(gras_datadesc_struct_append(my_type,"c2",
+                                 gras_datadesc_by_name("unsigned char")));
+  TRY(gras_datadesc_struct_append(my_type,"l2",
+                                 gras_datadesc_by_name("unsigned long int")));
+  gras_datadesc_struct_close(my_type);
+  TRY(gras_datadesc_ref("hetestruct*", gras_datadesc_by_name("hetestruct"),
+                       &my_type));
 
   /* init a value, exchange it and check its validity*/
   if (! (i=malloc(sizeof(hetestruct))) )
@@ -284,16 +283,15 @@ gras_error_t test_nestedstruct(gras_socket_t *sock, int direction) {
 
   INFO0("---- Test on nested structures ----");
   /* create descriptor */
-  TRY(gras_datadesc_declare_struct("nestedstruct",&my_type));
+  TRY(gras_datadesc_struct("nestedstruct",&my_type));
 
-  TRY(gras_datadesc_declare_struct_append(my_type,"hete",
-                                         gras_datadesc_by_name("hetestruct")));
-  TRY(gras_datadesc_declare_struct_append(my_type,"homo",
-                                         gras_datadesc_by_name("homostruct")));
-  gras_datadesc_declare_struct_close(my_type);
-  TRY(gras_datadesc_declare_ref("nestedstruct*",
-                               gras_datadesc_by_name("nestedstruct"),
-                               &my_type));
+  TRY(gras_datadesc_struct_append(my_type,"hete",
+                                 gras_datadesc_by_name("hetestruct")));
+  TRY(gras_datadesc_struct_append(my_type,"homo",
+                                 gras_datadesc_by_name("homostruct")));
+  gras_datadesc_struct_close(my_type);
+  TRY(gras_datadesc_ref("nestedstruct*", gras_datadesc_by_name("nestedstruct"),
+                       &my_type));
 
   /* init a value, exchange it and check its validity*/
   if (! (i=malloc(sizeof(nestedstruct))) )
@@ -336,13 +334,12 @@ gras_error_t declare_chained_list_type(void) {
   gras_error_t errcode;
   gras_datadesc_type_t *my_type,*ref_my_type;
 
-  TRY(gras_datadesc_declare_struct("chained_list_t",&my_type));
-  TRY(gras_datadesc_declare_ref("chained_list_t*",my_type,&ref_my_type));
+  TRY(gras_datadesc_struct("chained_list_t",&my_type));
+  TRY(gras_datadesc_ref("chained_list_t*",my_type,&ref_my_type));
 
-  TRY(gras_datadesc_declare_struct_append(my_type,"v",
-                                         gras_datadesc_by_name("int")));
-  TRY(gras_datadesc_declare_struct_append(my_type,"l",ref_my_type));
-  gras_datadesc_declare_struct_close(my_type);
+  TRY(gras_datadesc_struct_append(my_type,"v", gras_datadesc_by_name("int")));
+  TRY(gras_datadesc_struct_append(my_type,"l", ref_my_type));
+  gras_datadesc_struct_close(my_type);
 
   return no_error;
 }
@@ -528,31 +525,10 @@ typedef struct {
    int* literals;
 } Clause;
 
-void Clause_pre_cb  (void *vars,gras_datadesc_type_t *p_type,void *data);
-int  Clause_num_lits(void *vars,gras_datadesc_type_t *p_type,void *data);
+void Clause_pre_cb  (gras_cbps_t *vars,void *data);
 
-void Clause_pre_cb(void *vars,
-                  gras_datadesc_type_t *p_type,
-                  void *data) {
-  Clause c=*(Clause*)data;
-  int *count=malloc(sizeof(int));
-  *count=c.num_lits;
-
-  gras_dd_cbps_push(vars,"num_lits",count,
-                   gras_datadesc_by_name("int"));
-  DEBUG2("writen data=%p (got %p)",count,data);
-  DEBUG1("writen count=%d",*count);
-}
-
-int Clause_num_lits(void *vars,
-                   gras_datadesc_type_t *p_type,
-                   void *data) {
-  //  int *res;
-  gras_datadesc_type_t *ddt;
-  void *d = gras_dd_cbps_get (vars,"num_lits",&ddt);
-  DEBUG1("read data=%p",d);
-  DEBUG1("read count=%d",*(int*)d);
-  return *(int*)d;
+void Clause_pre_cb(gras_cbps_t *vars, void *data) {
+  gras_cbps_i_push(vars, (long int) ((Clause*)data)->num_lits);
 }
 
 gras_error_t test_clause(gras_socket_t *sock, int direction) {
@@ -576,20 +552,17 @@ gras_error_t test_clause(gras_socket_t *sock, int direction) {
   DEBUG1("created count=%d",i->num_lits);
 
   /* create the damn type descriptor */
-  TRYFAIL(gras_datadesc_declare_struct("Clause",&ddt));
-  gras_datadesc_cb_set_pre(ddt,Clause_pre_cb);
+  TRYFAIL(gras_datadesc_struct("Clause",&ddt));
+
+  gras_datadesc_cb_send(ddt,Clause_pre_cb); /* push the size of the arrray */
   
-  TRYFAIL(gras_datadesc_declare_struct_append(ddt,"num_lits",
-                                             gras_datadesc_by_name("int")));
-
-  TRYFAIL(gras_datadesc_declare_array_dyn("Clause{int[]}",
-                                         gras_datadesc_by_name("int"),
-                                         Clause_num_lits,
-                                         &array_t));
-  TRYFAIL(gras_datadesc_declare_ref("Clause{int[]}*",array_t,&array_t));
-  TRYFAIL(gras_datadesc_declare_struct_append(ddt,"literals",array_t));
-  gras_datadesc_declare_struct_close(ddt);
-  TRYFAIL(gras_datadesc_declare_ref("Clause*",ddt,&ddt));
+  TRYFAIL(gras_datadesc_struct_append(ddt,"num_lits", 
+                                     gras_datadesc_by_name("int")));
+
+  TRYFAIL(gras_datadesc_ref_pop_arr(gras_datadesc_by_name("int"), &array_t));
+  TRYFAIL(gras_datadesc_struct_append(ddt,"literals",array_t));
+  gras_datadesc_struct_close(ddt);
+  TRYFAIL(gras_datadesc_ref("Clause*",ddt,&ddt));
 
   TRY(write_read(ddt, &i,&j, sock,direction));
   if (direction == READ || direction == RW) {