Update of /cvsroot/playerstage/code/player/libplayerxdr
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1460/libplayerxdr

Modified Files:
        functiontable.c playerxdrgen.py .cvsignore functiontable.h 
Log Message:
Added entries to .cvsignore for eclipse CVS setup
Modified playerxdrgen to generate clone and free methods
Renamed dpcpy methods to copy and made argument order match memcpy
simplified vectormap interface a little
fixed misc warnings
cleanup tests

Index: .cvsignore
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayerxdr/.cvsignore,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** .cvsignore  20 Aug 2007 06:37:26 -0000      1.4
--- .cvsignore  17 Sep 2007 02:18:51 -0000      1.5
***************
*** 5,6 ****
--- 5,11 ----
  playerxdr.pc
  functiontable_gen.c
+ .deps
+ .libs
+ *.lo
+ *.la
+ *.a

Index: playerxdrgen.py
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayerxdr/playerxdrgen.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** playerxdrgen.py     16 Sep 2007 05:34:22 -0000      1.13
--- playerxdrgen.py     17 Sep 2007 02:18:51 -0000      1.14
***************
*** 20,24 ****
                      # be created and called.
  
! class DataTypeMember():
    arraypattern = re.compile('\[(.*?)\]')
    pointerpattern = re.compile('\*')
--- 20,24 ----
                      # be created and called.
  
! class DataTypeMember:
    arraypattern = re.compile('\[(.*?)\]')
    pointerpattern = re.compile('\*')
***************
*** 47,51 ****
    
  # multiple variables can occur with single type, i.e. int a,b,c so we first 
get the type and then add each variable to the entry
! class DataTypeMemberSet():
    typepattern = re.compile('\s*\w+')
    variablepattern = re.compile('\s*([^,;]+?)\s*[,;]')
--- 47,51 ----
    
  # multiple variables can occur with single type, i.e. int a,b,c so we first 
get the type and then add each variable to the entry
! class DataTypeMemberSet:
    typepattern = re.compile('\s*\w+')
    variablepattern = re.compile('\s*([^,;]+?)\s*[,;]')
***************
*** 76,80 ****
            
  
! class DataType():
    contentspattern = re.compile('.*\{\s*(.*?)\s*\}', re.MULTILINE | re.DOTALL)
    declpattern = re.compile('\s*([^;]*?;)', re.MULTILINE)
--- 76,80 ----
            
  
! class DataType:
    contentspattern = re.compile('.*\{\s*(.*?)\s*\}', re.MULTILINE | re.DOTALL)
    declpattern = re.compile('\s*([^;]*?;)', re.MULTILINE)
***************
*** 126,130 ****
  
  
! class MethodGenerator():
    def __init__(self,headerfile,sourcefile):
      self.headerfile = headerfile
--- 126,130 ----
  
  
! class MethodGenerator:
    def __init__(self,headerfile,sourcefile):
      self.headerfile = headerfile
***************
*** 238,242 ****
                                var.Name + ') != 1)\n    return(0);\n')
          #varlist.append(varstring)
!     sourcefile.write('  return(1);\n}\n\n')
      
      
--- 238,242 ----
                                var.Name + ') != 1)\n    return(0);\n')
          #varlist.append(varstring)
!     sourcefile.write('  return(1);\n}\n')
      
      
***************
*** 244,249 ****
      self.headerfile.write("int %(prefix)s_pack(void* buf, size_t buflen, 
%(typename)s * msg, int op);\n" % {"typename":datatype.typename, 
"prefix":datatype.prefix})
      
!     self.sourcefile.write("""
! int 
  %(prefix)s_pack(void* buf, size_t buflen, %(typename)s * msg, int op)
  {
--- 244,248 ----
      self.headerfile.write("int %(prefix)s_pack(void* buf, size_t buflen, 
%(typename)s * msg, int op);\n" % {"typename":datatype.typename, 
"prefix":datatype.prefix})
      
!     self.sourcefile.write("""int 
  %(prefix)s_pack(void* buf, size_t buflen, %(typename)s * msg, int op)
  {
***************
*** 266,274 ****
    def gen_copy(self,datatype):
      # If type is not in hasdynamic, not going to write a function so may as 
well just continue with the next struct
      if datatype.typename not in hasdynamic:
!       self.headerfile.write('#define ' + datatype.typename + '_dpcpy NULL\n')
      else:
-       self.headerfile.write("unsigned int %(typename)s_dpcpy(const 
%(typename)s *src, %(typename)s *dest);\n" % {"typename":datatype.typename, 
"prefix":datatype.prefix})
-       
        if datatype.HasDynamicArray():
          itrdec = "unsigned ii;"
--- 265,279 ----
    def gen_copy(self,datatype):
      # If type is not in hasdynamic, not going to write a function so may as 
well just continue with the next struct
+     self.headerfile.write("unsigned int %(typename)s_copy(%(typename)s *dest, 
const %(typename)s *src);\n" % {"typename":datatype.typename, 
"prefix":datatype.prefix})
      if datatype.typename not in hasdynamic:
!       self.sourcefile.write("""
! unsigned int %(typename)s_copy(%(typename)s *dest, const %(typename)s *src)
! {
!   if (dest == NULL || src == NULL)
!     return 0;
!   memcpy(dest,src,sizeof(%(typename)s));
!   return sizeof(%(typename)s);
! } """ % {"typename":datatype.typename})
      else:
        if datatype.HasDynamicArray():
          itrdec = "unsigned ii;"
***************
*** 276,280 ****
          itrdec = ""
        self.sourcefile.write("""
! unsigned int %(typename)s_dpcpy(const %(typename)s *src, %(typename)s *dest)
  {      
    %(itrdec)s
--- 281,285 ----
          itrdec = ""
        self.sourcefile.write("""
! unsigned int %(typename)s_copy(%(typename)s *dest, const %(typename)s *src)
  {      
    %(itrdec)s
***************
*** 313,317 ****
    for(ii = 0; ii < %(arraysize)s; ii++)""" % subs)
              sourcefile.write("""
!   {size += %(typestring)s_dpcpy(&src->%(varstring)s%(index)s, 
&dest->%(varstring)s%(index)s);}""" % subs)
    
    
--- 318,322 ----
    for(ii = 0; ii < %(arraysize)s; ii++)""" % subs)
              sourcefile.write("""
!   {size += %(typestring)s_copy(&dest->%(varstring)s%(index)s, 
&src->%(varstring)s%(index)s);}""" % subs)
    
    
***************
*** 329,337 ****
    def gen_cleanup(self,datatype):
      # If type is not in hasdynamic, not going to write a function so may as 
well just continue with the next struct
      if datatype.typename not in hasdynamic:
!       self.headerfile.write('#define ' + datatype.typename + '_cleanup 
NULL\n')
      else:
-       self.headerfile.write("void %(typename)s_cleanup(const %(typename)s 
*msg);\n" % {"typename":datatype.typename, "prefix":datatype.prefix})
-       
        if datatype.HasDynamicArray():
          itrdec = "unsigned ii;"
--- 334,344 ----
    def gen_cleanup(self,datatype):
      # If type is not in hasdynamic, not going to write a function so may as 
well just continue with the next struct
+     self.headerfile.write("void %(typename)s_cleanup(const %(typename)s 
*msg);\n" % {"typename":datatype.typename})
      if datatype.typename not in hasdynamic:
!       self.sourcefile.write("""
! void %(typename)s_cleanup(const %(typename)s *msg)
! {
! } """ % {"typename":datatype.typename})      
      else:
        if datatype.HasDynamicArray():
          itrdec = "unsigned ii;"
***************
*** 370,377 ****
      
    def gen_clone(self,datatype):
!     pass
      
    def gen_free(self,datatype):
!     pass
  
      
--- 377,400 ----
      
    def gen_clone(self,datatype):
!     # If type is not in hasdynamic, not going to write a function so may as 
well just continue with the next struct
!     self.headerfile.write("%(typename)s * %(typename)s_clone(const 
%(typename)s *msg);\n" % {"typename":datatype.typename})
!     self.sourcefile.write("""
! %(typename)s * %(typename)s_clone(const %(typename)s *msg)
! {      
!   %(typename)s * clone = malloc(sizeof(%(typename)s));
!   if (clone)
!     %(typename)s_copy(clone,msg);
!   return clone;
! }""" % {"typename":datatype.typename})
      
    def gen_free(self,datatype):
!     # If type is not in hasdynamic, not going to write a function so may as 
well just continue with the next struct
!     self.headerfile.write("void %(typename)s_free(%(typename)s *msg);\n" % 
{"typename":datatype.typename})
!     self.sourcefile.write("""
! void %(typename)s_free(%(typename)s *msg)
! {      
!   %(typename)s_cleanup(msg);
!   free(msg);
! }""" % {"typename":datatype.typename})
  
      
***************
*** 487,501 ****
    gen = MethodGenerator(headerfile,sourcefile)
    
-   i = 0
    for s in structs:
-     #i += 1
-     #if i > 5:
-       #break
      # extract prefix for packing function name and type of struct
-     #try:
      current = DataType(s)
-     #except:
-      # print "Got Exception"
-       #continue
  
      # Generate the methods
--- 510,516 ----
***************
*** 504,509 ****
      gen.gen_copy(current)
      gen.gen_cleanup(current)
!     #gen.gen_clone(current)
!     #gen.gen_free(current)    
      
    headerfile.write('\n#ifdef __cplusplus\n}\n#endif\n\n')
--- 519,525 ----
      gen.gen_copy(current)
      gen.gen_cleanup(current)
!     gen.gen_clone(current)
!     gen.gen_free(current)    
!     sourcefile.write('\n')
      
    headerfile.write('\n#ifdef __cplusplus\n}\n#endif\n\n')
***************
*** 511,515 ****
    if distro:
      headerfile.write('/** @} */\n')
-   sourcefile.write('\n')
  
    sourcefile.close()
--- 527,530 ----

Index: functiontable.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayerxdr/functiontable.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -C2 -d -r1.89 -r1.90
*** functiontable.c     20 Aug 2007 06:37:26 -0000      1.89
--- functiontable.c     17 Sep 2007 02:18:51 -0000      1.90
***************
*** 64,78 ****
     (player_pack_fn_t)player_capabilities_req_pack, NULL, NULL},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_GET_INTPROP_REQ,
!    (player_pack_fn_t)player_intprop_req_pack, 
(player_dpcpy_fn_t)player_intprop_req_t_dpcpy, 
(player_cleanup_fn_t)player_intprop_req_t_cleanup},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_SET_INTPROP_REQ,
!    (player_pack_fn_t)player_intprop_req_pack, 
(player_dpcpy_fn_t)player_intprop_req_t_dpcpy, 
(player_cleanup_fn_t)player_intprop_req_t_cleanup},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_GET_DBLPROP_REQ,
!    (player_pack_fn_t)player_dblprop_req_pack, 
(player_dpcpy_fn_t)player_dblprop_req_t_dpcpy, 
(player_cleanup_fn_t)player_dblprop_req_t_cleanup},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_SET_DBLPROP_REQ,
!    (player_pack_fn_t)player_dblprop_req_pack, 
(player_dpcpy_fn_t)player_dblprop_req_t_dpcpy, 
(player_cleanup_fn_t)player_dblprop_req_t_cleanup},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_GET_STRPROP_REQ,
!    (player_pack_fn_t)player_strprop_req_pack, 
(player_dpcpy_fn_t)player_strprop_req_t_dpcpy, 
(player_cleanup_fn_t)player_strprop_req_t_cleanup},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_SET_STRPROP_REQ,
!    (player_pack_fn_t)player_strprop_req_pack, 
(player_dpcpy_fn_t)player_strprop_req_t_dpcpy, 
(player_cleanup_fn_t)player_strprop_req_t_cleanup},
  
    /* Special messages */
--- 64,78 ----
     (player_pack_fn_t)player_capabilities_req_pack, NULL, NULL},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_GET_INTPROP_REQ,
!    (player_pack_fn_t)player_intprop_req_pack, 
(player_copy_fn_t)player_intprop_req_t_copy, 
(player_cleanup_fn_t)player_intprop_req_t_cleanup},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_SET_INTPROP_REQ,
!    (player_pack_fn_t)player_intprop_req_pack, 
(player_copy_fn_t)player_intprop_req_t_copy, 
(player_cleanup_fn_t)player_intprop_req_t_cleanup},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_GET_DBLPROP_REQ,
!    (player_pack_fn_t)player_dblprop_req_pack, 
(player_copy_fn_t)player_dblprop_req_t_copy, 
(player_cleanup_fn_t)player_dblprop_req_t_cleanup},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_SET_DBLPROP_REQ,
!    (player_pack_fn_t)player_dblprop_req_pack, 
(player_copy_fn_t)player_dblprop_req_t_copy, 
(player_cleanup_fn_t)player_dblprop_req_t_cleanup},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_GET_STRPROP_REQ,
!    (player_pack_fn_t)player_strprop_req_pack, 
(player_copy_fn_t)player_strprop_req_t_copy, 
(player_cleanup_fn_t)player_strprop_req_t_cleanup},
    {0, PLAYER_MSGTYPE_REQ, PLAYER_SET_STRPROP_REQ,
!    (player_pack_fn_t)player_strprop_req_pack, 
(player_copy_fn_t)player_strprop_req_t_copy, 
(player_cleanup_fn_t)player_strprop_req_t_cleanup},
  
    /* Special messages */
***************
*** 133,137 ****
          {
            curr->packfunc = f.packfunc;
!           curr->dpcpyfunc = f.dpcpyfunc;
            curr->cleanupfunc = f.cleanupfunc;
            return(0);
--- 133,137 ----
          {
            curr->packfunc = f.packfunc;
!           curr->copyfunc = f.copyfunc;
            curr->cleanupfunc = f.cleanupfunc;
            return(0);
***************
*** 223,233 ****
  }
  
! player_dpcpy_fn_t
! playerxdr_get_dpcpyfunc(uint16_t interf, uint8_t type, uint8_t subtype)
  {
    playerxdr_function_t* row=NULL;
  
    if ((row = playerxdr_get_ftrow (interf, type, subtype)) != NULL)
!     return(row->dpcpyfunc);
  
    return(NULL);
--- 223,233 ----
  }
  
! player_copy_fn_t
! playerxdr_get_copyfunc(uint16_t interf, uint8_t type, uint8_t subtype)
  {
    playerxdr_function_t* row=NULL;
  
    if ((row = playerxdr_get_ftrow (interf, type, subtype)) != NULL)
!     return(row->copyfunc);
  
    return(NULL);
***************
*** 249,258 ****
  playerxdr_deepcopy_message(void* src, void* dest, uint16_t interf, uint8_t 
type, uint8_t subtype)
  {
!   player_dpcpy_fn_t dpcpyfunc = NULL;
  
!   if ((dpcpyfunc = playerxdr_get_dpcpyfunc(interf, type, subtype)) == NULL)
      return 0;
  
!   return (*dpcpyfunc)(src, dest);
  }
  
--- 249,258 ----
  playerxdr_deepcopy_message(void* src, void* dest, uint16_t interf, uint8_t 
type, uint8_t subtype)
  {
!   player_copy_fn_t copyfunc = NULL;
  
!   if ((copyfunc = playerxdr_get_copyfunc(interf, type, subtype)) == NULL)
      return 0;
  
!   return (*copyfunc)(dest, src);
  }
  

Index: functiontable.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayerxdr/functiontable.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** functiontable.h     10 Jul 2007 09:01:52 -0000      1.12
--- functiontable.h     17 Sep 2007 02:18:51 -0000      1.13
***************
*** 59,63 ****
  typedef int (*player_pack_fn_t) (void* buf, size_t buflen, void* msg, int op);
  /** Generic Prototype for a player message structure deep copy function */
! typedef unsigned int (*player_dpcpy_fn_t) (const void* src, void* dest);
  /** Generic Prototype for a player message structure cleanup function */
  typedef void (*player_cleanup_fn_t) (void* msg);
--- 59,63 ----
  typedef int (*player_pack_fn_t) (void* buf, size_t buflen, void* msg, int op);
  /** Generic Prototype for a player message structure deep copy function */
! typedef unsigned int (*player_copy_fn_t) (void* dest, const void* src);
  /** Generic Prototype for a player message structure cleanup function */
  typedef void (*player_cleanup_fn_t) (void* msg);
***************
*** 71,75 ****
    uint8_t subtype;
    player_pack_fn_t packfunc;
!   player_dpcpy_fn_t dpcpyfunc;
    player_cleanup_fn_t cleanupfunc;
  } playerxdr_function_t;
--- 71,75 ----
    uint8_t subtype;
    player_pack_fn_t packfunc;
!   player_copy_fn_t copyfunc;
    player_cleanup_fn_t cleanupfunc;
  } playerxdr_function_t;
***************
*** 87,91 ****
                                      uint8_t subtype);
  
! player_dpcpy_fn_t playerxdr_get_dpcpyfunc(uint16_t interf, uint8_t type,
                                      uint8_t subtype);
  
--- 87,91 ----
                                      uint8_t subtype);
  
! player_copy_fn_t playerxdr_get_copyfunc(uint16_t interf, uint8_t type,
                                      uint8_t subtype);
  


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to