File: magicInit.h

package info (click to toggle)
magic 7.5.220-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 17,860 kB
file content (98 lines) | stat: -rw-r--r-- 2,319 bytes parent folder | download | duplicates (6)
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
/*******************/
/*   Defines       */
/*******************/

#ifndef _magicinit_h_
#define _magicinit_h_

#include <tcl.h>

#if defined(__cplusplus)
extern "C" {
#endif

#define CATCH \
catch (oaException &excp) {\
Tcl_SetObjResult(interp,Tcl_NewStringObj((const oaChar *)excp.getMsg(),-1));\
return TCL_ERROR;\
}


#define getArgString(index) Tcl_GetStringFromObj(objv[index],NULL)
#define getArgInt(index,Int) Tcl_GetIntFromObj(interp,objv[index],&Int)
#define getArgDouble(index,Double) Tcl_GetDoubleFromObj(interp,objv[index],&Double)

extern Tcl_Interp *REX_interp;
extern FILE *REX_debug_file;

#define USE_TCL_STUBS 1

#define TCL_ARGS _ANSI_ARGS_((ClientData clientData, \
    Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv))

#define TCLENTRY() {REX_interp = interp;}

#define TCLFUNC(name) int name TCL_ARGS

#define TCLCMD(name, func) Tcl_CreateObjCommand(REX_interp, name, func, NULL, NULL);

//#define TCLLINK(name, addr, type) Tcl_LinkVar(REX_interp, name, addr, type)

/* Error Macros */

#define INFO(fmt, msg...) \
do {fprintf(stdout,"%s: ",__FUNCTION__); \
fprintf(stdout,fmt, ## msg); \
fputc('\n',stdout);} while (0)

#define WARNING(fmt, msg...) \
do {fprintf(stderr,"Warning in %s at %s:%d: ",__FUNCTION__,__FILE__,__LINE__); \
fprintf(stderr,fmt, ## msg); \
fputc('\n',stderr);} while (0)

#define ERROR(fmt, msg...) \
do { fprintf(stderr,"Error in %s at %s:%d:\n",__FUNCTION__,__FILE__,__LINE__); \
fprintf(stderr,fmt, ## msg); \
fputc('\n',stderr); \
abort(); } while(0)

#define ASSERT(test) \
do {if(!(test)) ERROR("Assertion: %s", #test );} while (0)


extern int __Tcl_Rtn_Error(const char *function,const char *file,unsigned int line,
			   const char *fmt, ...);

#define TCL_RTN_ERROR(fmt, msg...) \
do {\
  __Tcl_Rtn_Error(__FUNCTION__,__FILE__,__LINE__,fmt, ## msg);\
  return TCL_ERROR;\
} while(0)

extern int REX_Tcl_Eval(char *fmt, ...);

extern int REX_Tcl_Error(const char *fmt, ...);

#define TCL_EVAL(fmt, msg...) \
do {\
    if(REX_Tcl_Eval(fmt, ## msg) == TCL_ERROR)\
	TCL_RTN_ERROR(fmt, ## msg);\
} while(0)

#define CHECK_ERR(func) \
if((func) == TCL_ERROR) \
TCL_RTN_ERROR(#func)

/* Return Codes */
#define rOK TCL_OK
#define rERROR TCL_ERROR

#ifndef offsetof
#define offsetof(t,m) (int)(&((t*)0)->m)
#endif

#if defined(__cplusplus)
}
#endif

#endif