mirror of https://github.com/swig/swig
Conditionalise math.i for PHP
PHP already provides all the wrapped constants and all the wrapped functions except fabs() (PHP provides abs() instead). Rewrapping the constants causes warnings or errors (depending on PHP version) and the rewrapped functions seem to be hidden by the built-in versions, so only wrap fabs() for PHP. (Even a wrapper for fabs() seems of little use since abs() is already provided, but really math.i seems of little use more generally since any general purpose programming language will provide its own maths functions and constants - the key motivation here is to eliminate warnings and errors from running the testsuite.)
This commit is contained in:
parent
6afc3e3504
commit
4e0997cd5a
|
@ -1,7 +1,2 @@
|
|||
%module li_math
|
||||
#ifdef SWIGPHP
|
||||
// PHP already provides these functions with the same names, so just kill that
|
||||
// warning.
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD);
|
||||
#endif
|
||||
%include math.i
|
||||
|
|
13
Lib/math.i
13
Lib/math.i
|
@ -9,6 +9,8 @@
|
|||
#include <math.h>
|
||||
%}
|
||||
|
||||
#ifndef SWIGPHP /* PHP already provides all these functions except fabs() */
|
||||
|
||||
extern double cos(double x);
|
||||
/* Cosine of x */
|
||||
|
||||
|
@ -54,9 +56,6 @@ extern double pow(double x, double y);
|
|||
extern double sqrt(double x);
|
||||
/* Square root. x >= 0 */
|
||||
|
||||
extern double fabs(double x);
|
||||
/* Absolute value of x */
|
||||
|
||||
extern double ceil(double x);
|
||||
/* Smallest integer not less than x, as a double */
|
||||
|
||||
|
@ -66,6 +65,13 @@ extern double floor(double x);
|
|||
extern double fmod(double x, double y);
|
||||
/* Floating-point remainder of x/y, with the same sign as x. */
|
||||
|
||||
#endif
|
||||
|
||||
extern double fabs(double x);
|
||||
/* Absolute value of x */
|
||||
|
||||
#ifndef SWIGPHP /* PHP already provides these constants and it's an error to redefine them */
|
||||
|
||||
#define M_E 2.7182818284590452354
|
||||
#define M_LOG2E 1.4426950408889634074
|
||||
#define M_LOG10E 0.43429448190325182765
|
||||
|
@ -80,3 +86,4 @@ extern double fmod(double x, double y);
|
|||
#define M_SQRT2 1.41421356237309504880
|
||||
#define M_SQRT1_2 0.70710678118654752440
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue