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>
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
38 #include <libtu/errorlog.h>
39 #define EXTL_LOG_ERRORS
40 /* This part has not been abstracted away from libtu dependence. */
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) */
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) \
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) \
65 : extl_obj_error(NDX, OBJ_TYPESTR(IN[NDX].o), #TYPE))
67 #define EXTL_DEFCLASS(C) INTRCLASS(C)
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) \
85 watch_setup(PROXY, OBJ, obj_dest_handler); \
86 (OBJ)->flags|=OBJ_EXTL_CACHED;
88 #define EXTL_END_PROXY_OBJ(PROXY, OBJ) \
89 assert((PROXY)->obj==OBJ); \
91 (OBJ)->flags&=~OBJ_EXTL_CACHED;
93 #define EXTL_DESTROY_OWNED_OBJ(OBJ) destroy_obj(OBJ)
95 extern void extl_uncache(Obj *obj);
97 static void obj_dest_handler(Watch *watch, Obj *obj)
100 obj->flags&=~OBJ_EXTL_CACHED;
108 /* Translate string X to locale. */
115 #endif /* LIBEXTL_PRIVATE_H */