Merge pull request #970 from nihal95/master

Adds pragma version directive for php5 and php7.  Fixes #360.
This commit is contained in:
Olly Betts 2017-05-16 17:47:35 +12:00 committed by GitHub
commit 9a0180c56c
12 changed files with 77 additions and 7 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;
@ -294,7 +295,7 @@ public:
f_runtime = NewStringEmpty();
/* sections of the output file */
s_init = NewString("/* init section */\n");
s_init = NewStringEmpty();
r_init = NewString("/* rinit section */\n");
s_shutdown = NewString("/* shutdown section */\n");
r_shutdown = NewString("/* rshutdown section */\n");
@ -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 */
@ -528,7 +530,14 @@ public:
Printf(s_entry, "/* Every non-class user visible function must have an entry here */\n");
Printf(s_entry, "static zend_function_entry %s_functions[] = {\n", module);
/* Emit all of the code */
Language::top(n);
SwigPHP_emit_resource_registrations();
/* start the init section */
String * s_init_old = s_init;
s_init = NewString("/* init section */\n");
Append(s_init, "#if ZEND_MODULE_API_NO <= 20090626\n");
Append(s_init, "#undef ZEND_MODULE_BUILD_ID\n");
Append(s_init, "#define ZEND_MODULE_BUILD_ID (char*)\"API\" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA\n");
@ -542,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);
@ -562,11 +575,9 @@ public:
* things are being called in the wrong order
*/
Printf(s_init, "#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\n", module);
Printv(s_init, s_init_old, NIL);
Delete(s_init_old);
/* Emit all of the code */
Language::top(n);
SwigPHP_emit_resource_registrations();
// Printv(s_init,s_resourcetypes,NIL);
/* We need this after all classes written out by ::top */
Printf(s_oinit, "CG(active_class_entry) = NULL;\n");
@ -1988,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);
}