File: zl.h

package info (click to toggle)
pdp 1%3A0.14.1%2Bdarcs20180201-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 3,220 kB
  • sloc: ansic: 22,424; asm: 2,088; makefile: 532; perl: 145; sh: 108; cpp: 4
file content (37 lines) | stat: -rw-r--r-- 1,123 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef _ZL_H_
#define _ZL_H_

#include <stdarg.h>

/* ZL uses the "tagged va_list" approach:

   To facilitate data transfer to a different programming system, it
   supports a generic data structure modeled after Lisp tagged lists.

   * Lists are encoded using a standard datastructure: va_lists.  This
     prevents re-invention and makes it very easy to use on both the
     sending and receiving end.

   * Tags are encoded as const char *.  This allows fast C pointer
     comparisons and makes bridging to interned symbols (hashed
     strings) common in dynamically typed languages.  */

typedef const char * zl_tag;
typedef void (*zl_receiver)(void *ctx, int nb_args, zl_tag tag, va_list args);

static inline void zl_send(zl_receiver fn, void *ctx, int nb_args, zl_tag tag, ...) {
    va_list args;
    va_start(args, tag);
    fn(ctx, nb_args, tag, args);
    va_end(args);
}

typedef unsigned int uint;

/* The <name>_p postfix is for pointers to struct <name>.  The main
   reason to use pointer typedefs is to allow for lexical tricks in
   .api files. */
typedef void* void_p;
typedef char* char_p;

#endif