Fix #1569587 for PHP. Don't use sizeof() except with string literals. Change

some "//" comments to "/* */" for portability.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9404 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2006-10-04 12:40:04 +00:00
commit adf46e4378
2 changed files with 18 additions and 12 deletions

View file

@ -1,6 +1,13 @@
Version 1.3.30 (in progress)
============================
10/04/2006: olly
[php] Fix #1569587 for PHP. Don't use sizeof() except with string
literals. Change some "//" comments to "/* */" for portability.
10/04/2006: mgossage
[Lua] Partial Fix #1569587. The type is now correct, but the name is still not correct.
10/03/2006: wsfulton
[Ruby] Fix #1527885 - Overloaded director virtual methods sometimes produced
uncompileable code when used with the director:except feature.
@ -9,9 +16,6 @@ Version 1.3.30 (in progress)
Directors: Directors are output in the order in which they are declared in
the C++ class rather than in some pseudo-random order.
10/04/2006: mgossage
[Lua] Partial Fix #1569587. The type is now correct, but the name is still not correct.
10/03/2006: mmatus
Fix #1486281 and #1471039.

View file

@ -17,35 +17,37 @@
signed char,
bool,
enum SWIGTYPE
"REGISTER_LONG_CONSTANT( \"$symname\", $value, CONST_CS | CONST_PERSISTENT);";
"REGISTER_LONG_CONSTANT(\"$symname\", $value, CONST_CS | CONST_PERSISTENT);";
%typemap(consttab) float,
double
"REGISTER_DOUBLE_CONSTANT(\"$symname\", $value, CONST_CS | CONST_PERSISTENT);";
%typemap(consttab) char
"REGISTER_STRING_CONSTANT(\"$symname\", \"$value\", CONST_CS | CONST_PERSISTENT );";
%typemap(consttab) char {
char swig_char = $value;
REGISTER_STRINGL_CONSTANT("$symname", &swig_char, 1, CONST_CS | CONST_PERSISTENT);
}
%typemap(consttab) char *,
const char *,
char [],
const char []
"REGISTER_STRINGL_CONSTANT(\"$symname\", \"$value\", sizeof(\"$value\") - 1, CONST_CS | CONST_PERSISTENT);";
"REGISTER_STRINGL_CONSTANT(\"$symname\", $value, strlen($value), CONST_CS | CONST_PERSISTENT);";
%typemap(consttab) SWIGTYPE *,
SWIGTYPE &,
SWIGTYPE [] {
// This actually registers it as a global variable and constant. I don't like it, but I can't figure out
// the zend_constant code...
/* This actually registers it as a global variable and constant. I don't
* like it, but I can't figure out the zend_constant code... */
zval *z_var;
MAKE_STD_ZVAL(z_var);
SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0);
//zend_hash_add(&EG(symbol_table), "$1", strlen("$1")+1, (void *)&z_var,sizeof(zval *), NULL);
/* zend_hash_add(&EG(symbol_table), "$1", sizeof("$1"), (void *)&z_var,sizeof(zval *), NULL); */
zend_constant c;
c.value = *z_var;
zval_copy_ctor(&c.value);
size_t len = strlen("$1");
c.name = zend_strndup( "$1", len );
size_t len = sizeof("$1") - 1;
c.name = zend_strndup("$1", len);
c.name_len = len+1;
c.flags = CONST_CS | CONST_PERSISTENT;
c.module_number = module_number;