/*

This source file is part of Scol
For the latest info, see http://www.scolring.org

Copyright (c) 2010 Stephane Bisaro, aka Iri <iri@irizone.net>

This source is under the terms of the Scol License. See the COPYING included file
for more informations.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.

For others informations, please contact us from http://www.scolring.org/

*/


/*
// File: macros.h
// Temporary macros (mostly used by debugger agent)
// from F.J. Alberti
*/


#ifndef _MACROS_H_
#define _MACROS_H_

#define SAFEdelete(p)      { if (p) { free (p); (p) = NULL; } }

#define _SEPTRBIT            0x00000001


/* SE conversions*/
#define SEW2I(w)             ((w)>>1)
#define SEW2P(w)             ((w)>>1)
#define SEI2W(n)             ((n)<<1)
#define SEP2W(p)             ((p)<<1 | _SEPTRBIT)

#define MTOI( mot )			 ((mot)>>1)
#define MTOP( mot )		     ((mot)>>1)
#define ITOM( mot )			 ((mot)<<1)
#define PTOM( mot )			 (((mot)<<1)+1)

/* Stack management*/
#define SEDROP(m, n)         ((m)->pp += (n))

/* String management*/
#define SEPUSHSTR(m, s)      (Mpushstrbloc((m), (s)))

/* $Iri : convert any string to utf-8 (should be used with gtk ...) Don't forget to free after used !*/
#define SCOLUTF8(string) g_locale_to_utf8 (string, -1, NULL, NULL, NULL)
/* $Iri : convert any string from utf-8 Don't forget to free after used !*/
#define UTF8SCOL(string) g_locale_from_utf8 (string, -1, NULL, NULL, NULL)

/* #define CHAR2WCHAR(c)        (c == NIL ? NULL : (PtrObjWChar) MMstart (mm,((PtrObjVoid)MMstart(mm,c))->Buffer>>1))*/

#endif
