[PHP] Add casts to the typemaps for long long and unsigned long

long to avoid issues when they are used with shorter types via
%apply.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12520 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2011-03-07 04:06:54 +00:00
commit 4fbb9e24d6
3 changed files with 15 additions and 10 deletions

View file

@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.3 (in progress) Version 2.0.3 (in progress)
=========================== ===========================
2011-03-06: olly
[PHP] Add casts to the typemaps for long long and unsigned long
long to avoid issues when they are used with shorter types via
%apply.
2011-03-02: wsfulton 2011-03-02: wsfulton
Templated smart pointers overloaded with both const and non const operator-> generated uncompilable Templated smart pointers overloaded with both const and non const operator-> generated uncompilable
code when the pointee was a class with either public member variables or static methods. code when the pointee was a class with either public member variables or static methods.

View file

@ -201,7 +201,7 @@
return_value->type = IS_LONG; return_value->type = IS_LONG;
} else { } else {
char temp[256]; char temp[256];
sprintf(temp, "%lld", $1); sprintf(temp, "%lld", (long long)$1);
ZVAL_STRING(return_value, temp, 1); ZVAL_STRING(return_value, temp, 1);
} }
%} %}
@ -212,7 +212,7 @@
return_value->type = IS_LONG; return_value->type = IS_LONG;
} else { } else {
char temp[256]; char temp[256];
sprintf(temp, "%llu", $1); sprintf(temp, "%llu", (unsigned long long)$1);
ZVAL_STRING(return_value, temp, 1); ZVAL_STRING(return_value, temp, 1);
} }
%} %}
@ -239,7 +239,7 @@
return_value->type = IS_LONG; return_value->type = IS_LONG;
} else { } else {
char temp[256]; char temp[256];
sprintf(temp, "%lld", *$1); sprintf(temp, "%lld", (long long)(*$1));
ZVAL_STRING(return_value, temp, 1); ZVAL_STRING(return_value, temp, 1);
} }
%} %}
@ -250,7 +250,7 @@
return_value->type = IS_LONG; return_value->type = IS_LONG;
} else { } else {
char temp[256]; char temp[256];
sprintf(temp, "%llu", *$1); sprintf(temp, "%llu", (unsigned long long)(*$1));
ZVAL_STRING(return_value, temp, 1); ZVAL_STRING(return_value, temp, 1);
} }
%} %}

View file

@ -134,7 +134,7 @@ INT_TYPEMAP(long long);
ZVAL_LONG(o, temp$argnum); ZVAL_LONG(o, temp$argnum);
} else { } else {
char temp[256]; char temp[256];
sprintf(temp, "%lld", temp$argnum); sprintf(temp, "%lld", (long long)temp$argnum);
ZVAL_STRING(o, temp, 1); ZVAL_STRING(o, temp, 1);
} }
t_output_helper( &$result, o ); t_output_helper( &$result, o );
@ -151,7 +151,7 @@ INT_TYPEMAP(long long);
(*$arg)->type = IS_LONG; (*$arg)->type = IS_LONG;
} else { } else {
char temp[256]; char temp[256];
sprintf(temp, "%lld", lvalue$argnum); sprintf(temp, "%lld", (long long)lvalue$argnum);
ZVAL_STRING((*$arg), temp, 1); ZVAL_STRING((*$arg), temp, 1);
} }
%} %}
@ -162,7 +162,7 @@ INT_TYPEMAP(long long);
($result)->type = IS_LONG; ($result)->type = IS_LONG;
} else { } else {
char temp[256]; char temp[256];
sprintf(temp, "%lld", *arg$argnum); sprintf(temp, "%lld", (long long)(*arg$argnum));
ZVAL_STRING($result, temp, 1); ZVAL_STRING($result, temp, 1);
} }
%} %}
@ -175,7 +175,7 @@ INT_TYPEMAP(unsigned long long);
ZVAL_LONG(o, temp$argnum); ZVAL_LONG(o, temp$argnum);
} else { } else {
char temp[256]; char temp[256];
sprintf(temp, "%llu", temp$argnum); sprintf(temp, "%llu", (unsigned long long)temp$argnum);
ZVAL_STRING(o, temp, 1); ZVAL_STRING(o, temp, 1);
} }
t_output_helper( &$result, o ); t_output_helper( &$result, o );
@ -192,7 +192,7 @@ INT_TYPEMAP(unsigned long long);
(*$arg)->type = IS_LONG; (*$arg)->type = IS_LONG;
} else { } else {
char temp[256]; char temp[256];
sprintf(temp, "%llu", lvalue$argnum); sprintf(temp, "%llu", (unsigned long long)lvalue$argnum);
ZVAL_STRING((*$arg), temp, 1); ZVAL_STRING((*$arg), temp, 1);
} }
%} %}
@ -203,7 +203,7 @@ INT_TYPEMAP(unsigned long long);
($result)->type = IS_LONG; ($result)->type = IS_LONG;
} else { } else {
char temp[256]; char temp[256];
sprintf(temp, "%llu", *arg$argnum); sprintf(temp, "%llu", (unsigned long long)(*arg$argnum));
ZVAL_STRING($result, temp, 1); ZVAL_STRING($result, temp, 1);
} }
%} %}