Merge pull request #970 from nihal95/master
Adds pragma version directive for php5 and php7. Fixes #360.
This commit is contained in:
commit
9a0180c56c
12 changed files with 77 additions and 7 deletions
|
|
@ -820,6 +820,15 @@ Results in the following in "example.php"
|
|||
echo "example.php execution\n";
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
The <b>version</b> pragma can be used to add version to generated PHP extension module. The version is inserted in the zend_module_entry block.
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
%module example
|
||||
%pragma(php) version="1.5"
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
The <b>include</b> pragma is a short cut to add include statements to
|
||||
the example.php file.
|
||||
|
|
|
|||
|
|
@ -27,5 +27,6 @@
|
|||
# This code is inserted into example.php
|
||||
echo \"this was php code\\n\";
|
||||
"
|
||||
%pragma(php) version="1.5"
|
||||
|
||||
%pragma(php) phpinfo="php_info_print_table_start();"
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
require "example.php";
|
||||
|
||||
echo "Version - " . ((new ReflectionExtension('example'))->getVersion());
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -27,5 +27,6 @@
|
|||
# This code is inserted into example.php
|
||||
echo \"this was php code\\n\";
|
||||
"
|
||||
%pragma(php) version="1.5"
|
||||
|
||||
%pragma(php) phpinfo="php_info_print_table_start();"
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
require "example.php";
|
||||
|
||||
echo "Version - " . ((new ReflectionExtension('example'))->getVersion());
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ CPP_TEST_CASES += \
|
|||
li_factory \
|
||||
php_iterator \
|
||||
php_namewarn_rename \
|
||||
php_pragma \
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
|
|
|
|||
12
Examples/test-suite/php/php_pragma_runme.php
Normal file
12
Examples/test-suite/php/php_pragma_runme.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "php_pragma.php";
|
||||
|
||||
|
||||
check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==version(php_pragma)");
|
||||
|
||||
check::done();
|
||||
|
||||
?>
|
||||
|
||||
|
|
@ -14,6 +14,7 @@ CPP_TEST_CASES += \
|
|||
li_factory \
|
||||
php_iterator \
|
||||
php_namewarn_rename \
|
||||
php_pragma \
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
|
|
|
|||
12
Examples/test-suite/php5/php_pragma_runme.php
Normal file
12
Examples/test-suite/php5/php_pragma_runme.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "php_pragma.php";
|
||||
|
||||
|
||||
check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==version(php_pragma)");
|
||||
|
||||
check::done();
|
||||
|
||||
?>
|
||||
|
||||
6
Examples/test-suite/php_pragma.i
Normal file
6
Examples/test-suite/php_pragma.i
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// Test pragma of php - pragma version.
|
||||
|
||||
%module php_pragma
|
||||
|
||||
%pragma(php) version= "1.5"
|
||||
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue