File: private.h

package info (click to toggle)
notion 4.0.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,676 kB
  • sloc: ansic: 47,508; sh: 2,096; makefile: 603; perl: 270
file content (118 lines) | stat: -rw-r--r-- 2,845 bytes parent folder | download | duplicates (3)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * libextl/private.h
 *
 * Copyright (c) Tuomo Valkonen 2004-2005.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 */

#ifndef LIBEXTL_PRIVATE_H
#define LIBEXTL_PRIVATE_H

#include <libtu/types.h>
#include <libtu/misc.h>
#include <libtu/locale.h>
#include <libtu/output.h>
#include <libtu/debug.h>
#include <libtu/objp.h>

#include "types.h"

/*
 * String routines
 */

#define extl_scopy(S) scopy(S)
#define extl_scopyn(S, N) scopyn(S, N)
#define extl_scat3(S1, S2, S3) scat3(S1, S2, S3)
#define extl_asprintf libtu_asprintf

/*
 * Error display
 */

#if 1
#include <libtu/errorlog.h>
#define EXTL_LOG_ERRORS
/* This part has not been abstracted away from libtu dependence. */
#endif

#define extl_warn warn
#define extl_warn_err_obj(NM) warn_err_obj(NM)

/*#define extl_warn(FMT, ...)
    ({fprintf(stderr, FMT, __VA_ARGS__); fputc('\n', stderr);})*/
/*#define extl_warn_obj_err(O) perror(O) */

/*
 * Level2 type checking
 */

/* Always returns FALSE. */
extern bool extl_obj_error(int ndx, const char *got, const char *wanted);

#define EXTL_CHKO1(IN, NDX, TYPE)                          \
    (OBJ_IS(IN[NDX].o, TYPE)                               \
     ? TRUE                                                \
     : extl_obj_error(NDX, OBJ_TYPESTR(IN[NDX].o), #TYPE))

#define EXTL_CHKO(IN, NDX, TYPE)                           \
    (IN[NDX].o==NULL || OBJ_IS(IN[NDX].o, TYPE)            \
     ? TRUE                                                \
     : extl_obj_error(NDX, OBJ_TYPESTR(IN[NDX].o), #TYPE))

#define EXTL_DEFCLASS(C) INTRCLASS(C)


/*
 * Objects.
 */

typedef Watch ExtlProxy;

#define EXTL_OBJ_CACHED(OBJ) ((OBJ)->flags&OBJ_EXTL_CACHED)
#define EXTL_OBJ_OWNED(OBJ) ((OBJ)->flags&OBJ_EXTL_OWNED)
#define EXTL_OBJ_TYPENAME(OBJ) OBJ_TYPESTR(OBJ)
#define EXTL_OBJ_IS(OBJ, NAME) obj_is_str(OBJ, NAME)

#define EXTL_PROXY_OBJ(PROXY) ((PROXY)->obj)

#define EXTL_BEGIN_PROXY_OBJ(PROXY, OBJ)       \
    watch_init(PROXY);                         \
    watch_setup(PROXY, OBJ, NULL);             \
    (OBJ)->flags|=OBJ_EXTL_CACHED;             \
    ((void)0)

#define EXTL_END_PROXY_OBJ(PROXY, OBJ) \
    assert((PROXY)->obj==OBJ);         \
    watch_reset(PROXY);                \
    (OBJ)->flags&=~OBJ_EXTL_CACHED;    \
    ((void)0)

#define EXTL_DESTROY_OWNED_OBJ(OBJ) destroy_obj(OBJ)

extern void extl_uncache(Obj *obj);

/*
static void obj_dest_handler(Watch *watch, Obj *obj)
{
    extl_uncache(obj);
    obj->flags&=~OBJ_EXTL_CACHED;
}
*/

/*
 * Miscellaneous.
 */

/* Translate string X to locale. */
/*#define TR(X) X */

/* Debugging. */
/*#define D(X) */


#endif /* LIBEXTL_PRIVATE_H */