Skip to content
Snippets Groups Projects
Select Git revision
  • 61b2291fdda31e4131ae74b3b102194be2c1d9a6
  • master default
  • anders.blomdell
  • typeref
  • pragma
  • compiler-refactoring
  • labcomm2013
  • v2014.1
  • v2014.0
  • v2013.0
10 results

LabCommParser.parser

Blame
  • Forked from Anders Blomdell / LabComm
    Source project has a limited visibility.
    labcomm_private.h 7.30 KiB
    #ifndef _LABCOMM_PRIVATE_H_
    #define _LABCOMM_PRIVATE_H_
    
    #include <endian.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include "labcomm.h"
    
    /*
     * Predeclared aggregate type indices
     */
    #define LABCOMM_TYPEDEF  0x01
    #define LABCOMM_SAMPLE   0x02
    #define LABCOMM_ARRAY    0x10
    #define LABCOMM_STRUCT   0x11
    
    /*
     * Predeclared primitive type indices
     */
    #define LABCOMM_BOOLEAN  0x20 
    #define LABCOMM_BYTE     0x21
    #define LABCOMM_SHORT    0x22
    #define LABCOMM_INT      0x23
    #define LABCOMM_LONG     0x24
    #define LABCOMM_FLOAT    0x25
    #define LABCOMM_DOUBLE   0x26
    #define LABCOMM_STRING   0x27
    
    /*
     * Start index for user defined types
     */
    #define LABCOMM_USER     0x80
    
    /*
     * Semi private decoder declarations
     */
    typedef void (*labcomm_handler_typecast_t)(void *, void *);
    
    typedef void (*labcomm_decoder_typecast_t)(
      struct labcomm_decoder *,
      labcomm_handler_typecast_t,
      void *);
    
    typedef struct labcomm_decoder {
      void *context;
      labcomm_reader_t reader;
      void (*do_register)(struct labcomm_decoder *, 
    		      labcomm_signature_t *, 
    		      labcomm_decoder_typecast_t,
    		      labcomm_handler_typecast_t,
    		      void *context);
      int (*do_decode_one)(struct labcomm_decoder *decoder);
    } labcomm_decoder_t;
    
    /*
     * Non typesafe registration function to be called from
     * generated labcomm_decoder_register_* functions.
     */
    void labcomm_internal_decoder_register(
      labcomm_decoder_t *, 
      labcomm_signature_t *, 
      labcomm_decoder_typecast_t,
      labcomm_handler_typecast_t,
      void *context);
    
    #if __BYTE_ORDER == __LITTLE_ENDIAN
    
    #define LABCOMM_DECODE(name, type)					\
      static inline type labcomm_read_##name(labcomm_reader_t *r) {		\