Releasing version 3-2015061300
[notion.git] / libextl / private.h
blobde9400e718992ed01bb6e26dd3ab6880c44f68e4
1 /*
2 * libextl/private.h
4 * Copyright (c) Tuomo Valkonen 2004-2005.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
12 #ifndef LIBEXTL_PRIVATE_H
13 #define LIBEXTL_PRIVATE_H
15 #include <libtu/types.h>
16 #include <libtu/misc.h>
17 #include <libtu/locale.h>
18 #include <libtu/output.h>
19 #include <libtu/debug.h>
20 #include <libtu/objp.h>
22 #include "types.h"
25 * String routines
28 #define extl_scopy(S) scopy(S)
29 #define extl_scopyn(S, N) scopyn(S, N)
30 #define extl_scat3(S1, S2, S3) scat3(S1, S2, S3)
31 #define extl_asprintf libtu_asprintf
34 * Error display
37 #if 1
38 #include <libtu/errorlog.h>
39 #define EXTL_LOG_ERRORS
40 /* This part has not been abstracted away from libtu dependence. */
41 #endif
43 #define extl_warn warn
44 #define extl_warn_err_obj(NM) warn_err_obj(NM)
46 /*#define extl_warn(FMT, ...)
47 ({fprintf(stderr, FMT, __VA_ARGS__); fputc('\n', stderr);})*/
48 /*#define extl_warn_obj_err(O) perror(O) */
50 /*
51 * Level2 type checking
54 /* Always returns FALSE. */
55 extern bool extl_obj_error(int ndx, const char *got, const char *wanted);
57 #define EXTL_CHKO1(IN, NDX, TYPE) \
58 (OBJ_IS(IN[NDX].o, TYPE) \
59 ? TRUE \
60 : extl_obj_error(NDX, OBJ_TYPESTR(IN[NDX].o), #TYPE))
62 #define EXTL_CHKO(IN, NDX, TYPE) \
63 (IN[NDX].o==NULL || OBJ_IS(IN[NDX].o, TYPE) \
64 ? TRUE \
65 : extl_obj_error(NDX, OBJ_TYPESTR(IN[NDX].o), #TYPE))
67 #define EXTL_DEFCLASS(C) INTRCLASS(C)
71 * Objects.
74 typedef Watch ExtlProxy;
76 #define EXTL_OBJ_CACHED(OBJ) ((OBJ)->flags&OBJ_EXTL_CACHED)
77 #define EXTL_OBJ_OWNED(OBJ) ((OBJ)->flags&OBJ_EXTL_OWNED)
78 #define EXTL_OBJ_TYPENAME(OBJ) OBJ_TYPESTR(OBJ)
79 #define EXTL_OBJ_IS(OBJ, NAME) obj_is_str(OBJ, NAME)
81 #define EXTL_PROXY_OBJ(PROXY) ((PROXY)->obj)
83 #define EXTL_BEGIN_PROXY_OBJ(PROXY, OBJ) \
84 watch_init(PROXY); \
85 watch_setup(PROXY, OBJ, NULL); \
86 (OBJ)->flags|=OBJ_EXTL_CACHED;
88 #define EXTL_END_PROXY_OBJ(PROXY, OBJ) \
89 assert((PROXY)->obj==OBJ); \
90 watch_reset(PROXY); \
91 (OBJ)->flags&=~OBJ_EXTL_CACHED;
93 #define EXTL_DESTROY_OWNED_OBJ(OBJ) destroy_obj(OBJ)
95 extern void extl_uncache(Obj *obj);
98 static void obj_dest_handler(Watch *watch, Obj *obj)
100 extl_uncache(obj);
101 obj->flags&=~OBJ_EXTL_CACHED;
106 * Miscellaneous.
109 /* Translate string X to locale. */
110 /*#define TR(X) X */
112 /* Debugging. */
113 /*#define D(X) */
116 #endif /* LIBEXTL_PRIVATE_H */