[PHP5] When we know the literal numeric value for a constant, use
that to initialise the const member in the PHP wrapper class. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9651 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a63013152c
commit
438195cfe9
2 changed files with 28 additions and 2 deletions
|
|
@ -1,6 +1,10 @@
|
|||
Version 1.3.32 (in progress)
|
||||
============================
|
||||
|
||||
03/03/2007: olly
|
||||
[PHP5] When we know the literal numeric value for a constant, use
|
||||
that to initialise the const member in the PHP wrapper class.
|
||||
|
||||
03/02/2007: olly
|
||||
[PHP5] Fix PHP wrapper code generated for certain cases of
|
||||
overloaded forms with default arguments.
|
||||
|
|
|
|||
|
|
@ -1938,14 +1938,36 @@ public:
|
|||
}
|
||||
|
||||
if (shadow && php_version == 5) {
|
||||
String *enumvalue = GetChar(n, "enumvalue");
|
||||
String *set_to = iname;
|
||||
|
||||
if (!enumvalue) {
|
||||
enumvalue = GetChar(n, "enumvalueex");
|
||||
}
|
||||
|
||||
if (enumvalue) {
|
||||
// Check for a simple constant expression which is valid in PHP.
|
||||
// If we find one, initialise the const member with it; otherwise
|
||||
// we initialise it using the C/C++ wrapped constant.
|
||||
const char *p;
|
||||
for (p = Char(enumvalue); *p; ++p) {
|
||||
if (!isdigit((unsigned char)*p) && !strchr(" +-", *p)) {
|
||||
// FIXME: enhance to handle `<previous_enum> + 1' which is what
|
||||
// we get for enums that don't have an explicit value set.
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!*p) set_to = enumvalue;
|
||||
}
|
||||
|
||||
if (wrapping_member_constant) {
|
||||
if (!s_oowrappers)
|
||||
s_oowrappers = NewStringEmpty();
|
||||
Printf(s_oowrappers, "\n\tconst %s = %s;\n", wrapping_member_constant, iname);
|
||||
Printf(s_oowrappers, "\n\tconst %s = %s;\n", wrapping_member_constant, set_to);
|
||||
} else {
|
||||
if (!s_fakeoowrappers)
|
||||
s_fakeoowrappers = NewStringEmpty();
|
||||
Printf(s_fakeoowrappers, "\n\tconst %s = %s;\n", name, iname);
|
||||
Printf(s_fakeoowrappers, "\n\tconst %s = %s;\n", name, set_to);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue