1
|
/*
|
2
|
This source file is part of Scol
|
3
|
For the latest info, see http://www.scolring.org
|
4
|
|
5
|
Copyright (c) 2010 Stephane Bisaro, aka Iri <iri@irizone.net>
|
6
|
|
7
|
This program is free software; you can redistribute it and/or modify it under
|
8
|
the terms of the GNU Lesser General Public License as published by the Free Software
|
9
|
Foundation; either version 2 of the License, or (at your option) any later
|
10
|
version.
|
11
|
|
12
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
13
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
14
|
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
15
|
|
16
|
You should have received a copy of the GNU Lesser General Public License along with
|
17
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
18
|
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
19
|
http://www.gnu.org/copyleft/lesser.txt
|
20
|
|
21
|
For others informations, please contact us from http://www.scolring.org/
|
22
|
*/
|
23
|
|
24
|
|
25
|
|
26
|
/*
|
27
|
// File: macros.h
|
28
|
// Temporary macros (mostly used by debugger agent)
|
29
|
// from F.J. Alberti
|
30
|
*/
|
31
|
|
32
|
|
33
|
#ifndef _MACROS_H_
|
34
|
#define _MACROS_H_
|
35
|
|
36
|
#define SAFEdelete(p) { if (p) { free (p); (p) = NULL; } }
|
37
|
|
38
|
|
39
|
#define _SEPTRBIT 0x00000001
|
40
|
|
41
|
|
42
|
/* SE conversions*/
|
43
|
#define SEW2I(w) ((w)>>1)
|
44
|
#define SEW2P(w) ((w)>>1)
|
45
|
#define SEI2W(n) ((n)<<1)
|
46
|
#define SEP2W(p) ((p)<<1 | _SEPTRBIT)
|
47
|
|
48
|
#define MTOI( mot ) ((mot)>>1)
|
49
|
#define MTOP( mot ) ((mot)>>1)
|
50
|
#define ITOM( mot ) ((mot)<<1)
|
51
|
#define PTOM( mot ) (((mot)<<1)+1)
|
52
|
/*#ifndef SCOL_FLOAT_DEFINITION
|
53
|
typedef float float32;
|
54
|
#define SCOL_FLOAT_DEFINITION
|
55
|
#endif*/
|
56
|
|
57
|
/* Invert two positions in the stack*/
|
58
|
#define INVERT(m, a, b) {tmp_res=MMget(m,a);MMset(m,a,MMget(m,b));MMset(m,b,tmp_res);}
|
59
|
|
60
|
/*Stack management*/
|
61
|
#define SEDROP(m, n) ((m)->pp += (n))
|
62
|
|
63
|
/* String management*/
|
64
|
#define SEPUSHSTR(m, s) (Mpushstrbloc((m), (s)))
|
65
|
|
66
|
#define CHECK(m) if ((tmp_res=m)) return tmp_res
|
67
|
|
68
|
/* #define CHAR2WCHAR(c) (c == NIL ? NULL : (PtrObjWChar) MMstart (mm,((PtrObjVoid)MMstart(mm,c))->Buffer>>1))*/
|
69
|
|
70
|
/* $Iri : convert any string to utf-8 (should be used with gtk ...) Don't forget to free after used !*/
|
71
|
#define SCOLUTF8(string) g_locale_to_utf8 (string, -1, NULL, NULL, NULL)
|
72
|
/* $Iri : convert any string from utf-8 Don't forget to free after used !*/
|
73
|
#define UTF8SCOL(string) g_locale_from_utf8 (string, -1, NULL, NULL, NULL)
|
74
|
/* $Iri : length of the int (234 -> 3)*/
|
75
|
#define SIZEINT(x) floor (log10 (x)) + 1
|
76
|
/* $ Iri : float support */
|
77
|
#define FSET(val, f) { \
|
78
|
float g = (f); \
|
79
|
(val) = (*(int*)&g) & 0xfffffffe; \
|
80
|
}
|
81
|
#define FGET(val) (*(float*)&(val))
|
82
|
|
83
|
#endif
|