00001 00005 /* 00006 This source file is part of Scol 00007 For the latest info, see http://www.scolring.org 00008 00009 Copyright (c) 2010 Stephane Bisaro, aka Iri <iri@irizone.net> 00010 00011 This program is free software; you can redistribute it and/or modify it under 00012 the terms of the GNU Lesser General Public License as published by the Free Software 00013 Foundation; either version 2 of the License, or (at your option) any later 00014 version. 00015 00016 This program is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00018 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public License along with 00021 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00022 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00023 http://www.gnu.org/copyleft/lesser.txt 00024 00025 For others informations, please contact us from http://www.scolring.org/ 00026 */ 00027 00028 00029 00030 /* 00031 // File: macros.h 00032 // Temporary macros (mostly used by debugger agent) 00033 // from F.J. Alberti 00034 */ 00035 00036 00037 #ifndef _MACROS_H_ 00038 #define _MACROS_H_ 00039 00040 #define SAFEdelete(p) { if (p) { free (p); (p) = NULL; } } 00041 00042 00043 #define _SEPTRBIT 0x00000001 00044 00045 00046 /* SE conversions*/ 00047 #define SEW2I(w) ((w)>>1) 00048 #define SEW2P(w) ((w)>>1) 00049 #define SEI2W(n) ((n)<<1) 00050 #define SEP2W(p) ((p)<<1 | _SEPTRBIT) 00051 00052 #define MTOI( mot ) ((mot)>>1) 00053 #define MTOP( mot ) ((mot)>>1) 00054 #define ITOM( mot ) ((mot)<<1) 00055 #define PTOM( mot ) (((mot)<<1)+1) 00056 /*#ifndef SCOL_FLOAT_DEFINITION 00057 typedef float float32; 00058 #define SCOL_FLOAT_DEFINITION 00059 #endif*/ 00060 00061 /* Invert two positions in the stack*/ 00062 #define INVERT(m, a, b) {tmp_res=MMget(m,a);MMset(m,a,MMget(m,b));MMset(m,b,tmp_res);} 00063 00064 /*Stack management*/ 00065 #define SEDROP(m, n) ((m)->pp += (n)) 00066 00067 /* String management*/ 00068 #define SEPUSHSTR(m, s) (Mpushstrbloc((m), (s))) 00069 00070 #define CHECK(m) if ((tmp_res=m)) return tmp_res 00071 00072 /* #define CHAR2WCHAR(c) (c == NIL ? NULL : (PtrObjWChar) MMstart (mm,((PtrObjVoid)MMstart(mm,c))->Buffer>>1))*/ 00073 00074 /* $Iri : convert any string to utf-8 (should be used with gtk ...) Don't forget to free after used !*/ 00075 #define SCOLUTF8(string, len) g_locale_to_utf8 (string, len, NULL, NULL, NULL) 00076 /* $Iri : convert any string from utf-8 Don't forget to free after used !*/ 00077 #define UTF8SCOL(string, len) g_locale_from_utf8 (string, len, NULL, NULL, NULL) 00078 /* $Iri : length of the int (234 -> 3)*/ 00079 #define SIZEINT(x) floor (log10 (x)) + 1 00080 /* $ Iri : float support */ 00081 #define FSET(val, f) { \ 00082 float g = (f); \ 00083 (val) = (*(int*)&g) & 0xfffffffe; \ 00084 } 00085 #define FGET(val) (*(float*)&(val)) 00086 00087 #endif