Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qsoperations.h 1.1.5 edited 2006-02-23T15:39:57$ 00003 ** 00004 ** Copyright (C) 2001-2006 Trolltech AS. All rights reserved. 00005 ** 00006 ** This file is part of the Qt Script for Applications framework (QSA). 00007 ** 00008 ** This file may be distributed and/or modified under the terms of the 00009 ** GNU General Public License version 2 as published by the Free Software 00010 ** Foundation and appearing in the file LICENSE.GPL included in the 00011 ** packaging of this file. 00012 ** 00013 ** Licensees holding a valid Qt Script for Applications license may use 00014 ** this file in accordance with the Qt Script for Applications License 00015 ** Agreement provided with the Software. 00016 ** 00017 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00018 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00019 ** 00020 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00021 ** information about QSA Commercial License Agreements. 00022 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00023 ** 00024 ** Contact info@trolltech.com if any conditions of this licensing are 00025 ** not clear to you. 00026 ** 00027 *****************************************************************************/ 00028 00029 #ifndef QSOPERATIONS_H 00030 #define QSOPERATIONS_H 00031 00032 #include "qsobject.h" 00033 00034 //### AbanQ 00035 #ifdef HAVE_CONFIG_H 00036 #include "config.h" 00037 #endif 00038 #ifndef HAVE_FLOAT_H /* just for !Windows */ 00039 #define HAVE_FLOAT_H 0 00040 #define HAVE_FUNC__FINITE 0 00041 #endif 00042 00043 #include <stdio.h> 00044 #include <math.h> 00045 #include <stdlib.h> 00046 00047 #ifndef HAVE_FUNC_ISINF 00048 #ifdef HAVE_IEEEFP_H 00049 #include <ieeefp.h> 00050 #endif 00051 #endif /* HAVE_FUNC_ISINF */ 00052 00053 #ifdef HAVE_FLOAT_H 00054 #include <float.h> 00055 #endif 00056 00057 #if defined (__APPLE__) || defined (__FREEBSD__) 00058 extern "C" { 00059 int finite(double); 00060 } 00061 #endif 00062 //### AbanQ 00063 00064 namespace QS 00065 { 00066 00067 //### AbanQ 00068 00069 00073 inline bool isNaN(double d) 00074 { 00075 uchar *ch = (uchar *)&d; 00076 #if Q_BYTE_ORDER == Q_BIG_ENDIAN 00077 return (ch[0] & 0x7f) == 0x7f && ch[1] > 0xf0; 00078 #else 00079 return (ch[7] & 0x7f) == 0x7f && ch[6] > 0xf0; 00080 #endif 00081 } 00082 00083 00087 inline bool isInf(double d) 00088 { 00089 #if defined(HAVE_FUNC_ISINF) 00090 return isinf(d); 00091 #elif defined(HAVE_FUNC_FINITE) || defined(__APPLE__) 00092 return finite(d) == 0 && d == d; 00093 #elif defined(HAVE_FUNC__FINITE) 00094 return 00095 # if defined( Q_CC_BOR ) // Crashes with out this test... 00096 !isNaN(d) && 00097 # endif 00098 _finite(d) == 0 && d == d; 00099 #else 00100 return FALSE; 00101 #endif 00102 } 00103 00112 inline double max(double d1, double d2) 00113 { 00114 /* TODO: check for NaN */ 00115 return (d1 > d2) ? d1 : d2; 00116 } 00117 inline double min(double d1, double d2) 00118 { 00119 /* TODO: check for NaN */ 00120 return (d1 < d2) ? d1 : d2; 00121 } 00122 00129 QSObject add(const QSEnv *env, const QSObject &v1, const QSObject &v2, char oper); 00130 00138 QSObject mult(const QSEnv *env, const QSObject &v1, const QSObject &v2, char oper); 00139 }; 00140 00141 #endif