Add new pragma to specify version to PHP5 and PHP7 extensions.

See issue #360, feature request to have version in php5 and php7 extensions.
This commit is contained in:
Nihal 2017-05-08 11:43:38 +05:30
parent 3adf88e9ef
commit eb9e72f3b2
2 changed files with 22 additions and 2 deletions

View File

@ -96,6 +96,7 @@ static String *all_cs_entry;
static String *pragma_incl;
static String *pragma_code;
static String *pragma_phpinfo;
static String *pragma_version;
static String *s_oowrappers;
static String *s_fakeoowrappers;
static String *s_phpclasses;
@ -359,6 +360,7 @@ public:
/* sub-sections of the php file */
pragma_code = NewStringEmpty();
pragma_incl = NewStringEmpty();
pragma_version = NULL;
/* Initialize the rest of the module */
@ -515,7 +517,11 @@ public:
} else {
Printf(s_init, " NULL, /* No MINFO code */\n");
}
Printf(s_init, " NO_VERSION_YET,\n");
if (Len(pragma_version) > 0) {
Printf(s_init, " \"%s\",\n", pragma_version);
} else {
Printf(s_init, " NO_VERSION_YET,\n");
}
Printf(s_init, " STANDARD_MODULE_PROPERTIES\n");
Printf(s_init, "};\n");
Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module);
@ -2007,6 +2013,10 @@ done:
if (value) {
Printf(pragma_phpinfo, "%s\n", value);
}
} else if (Strcmp(type, "version") == 0) {
if (value) {
pragma_version = value;
}
} else {
Swig_warning(WARN_PHP_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type);
}

View File

@ -96,6 +96,7 @@ static String *all_cs_entry;
static String *pragma_incl;
static String *pragma_code;
static String *pragma_phpinfo;
static String *pragma_version;
static String *s_oowrappers;
static String *s_fakeoowrappers;
static String *s_phpclasses;
@ -391,6 +392,7 @@ public:
/* sub-sections of the php file */
pragma_code = NewStringEmpty();
pragma_incl = NewStringEmpty();
pragma_version = NULL;
/* Initialize the rest of the module */
@ -549,7 +551,11 @@ public:
Printf(s_init, " PHP_RINIT(%s),\n", module);
Printf(s_init, " PHP_RSHUTDOWN(%s),\n", module);
Printf(s_init, " PHP_MINFO(%s),\n", module);
Printf(s_init, " NO_VERSION_YET,\n");
if (Len(pragma_version) > 0) {
Printf(s_init, " \"%s\",\n", pragma_version);
} else {
Printf(s_init, " NO_VERSION_YET,\n");
}
Printf(s_init, " STANDARD_MODULE_PROPERTIES\n");
Printf(s_init, "};\n");
Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module);
@ -1993,6 +1999,10 @@ done:
if (value) {
Printf(pragma_phpinfo, "%s\n", value);
}
} else if (Strcmp(type, "version") == 0) {
if (value) {
pragma_version = value;
}
} else {
Swig_warning(WARN_PHP_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type);
}