Add -php5 option which will turn on PHP5-specific output (and -php4 will

generate PHP4-specific output, with -php just being an alias for one of them.
Currently the only difference is that -php5 SWIGPHP5 is defined instead of
SWIGPHP4.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9117 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2006-05-15 00:16:32 +00:00
commit b1997e54ea
2 changed files with 38 additions and 27 deletions

View file

@ -21,16 +21,16 @@ char cvsroot_php4_cxx[] = "$Header$";
static const char *usage = (char*)"\ static const char *usage = (char*)"\
PHP4 Options (available with -php4)\n\ PHP Options (available with -php4 or -php5)\n\
-cppext - cpp file extension (default to .cpp)\n\ -cppext - cpp file extension (default to .cpp)\n\
-noproxy - Don't generate proxy classes.\n\ -noproxy - Don't generate proxy classes.\n\
-dlname <name> - Set module prefix to <name>\n\ -dlname <name> - Set module prefix to <name>\n\
-make - Create simple makefile\n\ -make - Create simple makefile\n\
-phpfull - Create full make files\n\ -phpfull - Create full make files\n\
-withincs <incs>- With -phpfull writes needed incs in config.m4\n\ -withincs <incs> - With -phpfull writes needed incs in config.m4\n\
-withlibs <libs>- With -phpfull writes needed libs in config.m4\n\ -withlibs <libs> - With -phpfull writes needed libs in config.m4\n\
-withc <files> - With -phpfull makes extra C files in Makefile.in\n\ -withc <files> - With -phpfull makes extra C files in Makefile.in\n\
-withcxx <files>- With -phpfull makes extra C++ files in Makefile.in\n\ -withcxx <files> - With -phpfull makes extra C++ files in Makefile.in\n\
\n"; \n";
static int constructors=0; static int constructors=0;
@ -172,11 +172,13 @@ SwigPHP_emit_resource_registrations() {
} }
} }
class PHP4 : public Language { class PHP : public Language {
int php_version;
public: public:
PHP(int php_version_) : php_version(php_version_) { }
/* Test to see if a type corresponds to something wrapped with a shadow class. */ /* Test to see if a type corresponds to something wrapped with a shadow class. */
String *is_shadow(SwigType *t) { String *is_shadow(SwigType *t) {
String *r = 0; String *r = 0;
Node *n = classLookup(t); Node *n = classLookup(t);
@ -271,7 +273,11 @@ public:
} }
Preprocessor_define((void *) "SWIGPHP 1", 0); Preprocessor_define((void *) "SWIGPHP 1", 0);
Preprocessor_define((void *) "SWIGPHP4 1", 0); if (php_version == 4) {
Preprocessor_define((void *) "SWIGPHP4 1", 0);
} else if (php_version == 5) {
Preprocessor_define((void *) "SWIGPHP5 1", 0);
}
SWIG_typemap_lang("php4"); SWIG_typemap_lang("php4");
/* DB: Suggest using a language configuration file */ /* DB: Suggest using a language configuration file */
SWIG_config_file("php4.swg"); SWIG_config_file("php4.swg");
@ -1334,7 +1340,7 @@ public:
} }
/* /*
* PHP4::pragma() * PHP::pragma()
* *
* Pragma directive. * Pragma directive.
* *
@ -1999,17 +2005,17 @@ public:
return SWIG_OK; return SWIG_OK;
} }
}; /* class PHP4 */ }; /* class PHP */
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* swig_php() - Instantiate module * swig_php() - Instantiate module
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static PHP4 *maininstance=0; static PHP *maininstance=0;
// We use this function to be able to write out zend_register_list_destructor_ex // We use this function to be able to write out zend_register_list_destructor_ex
// lines for most things in the type table // lines for most things in the type table
// NOTE: it's a function NOT A PHP4::METHOD // NOTE: it's a function NOT A PHP::METHOD
extern "C" extern "C"
void typetrace(SwigType *ty, String *mangled, String *clientdata) { void typetrace(SwigType *ty, String *mangled, String *clientdata) {
Node *class_node; Node *class_node;
@ -2031,16 +2037,19 @@ void typetrace(SwigType *ty, String *mangled, String *clientdata) {
if (r_prevtracefunc) (*r_prevtracefunc)(ty, mangled, (String *) clientdata); if (r_prevtracefunc) (*r_prevtracefunc)(ty, mangled, (String *) clientdata);
} }
static Language * new_swig_php() { static Language * new_swig_php(int php_version) {
maininstance=new PHP4(); maininstance=new PHP(php_version);
if (! r_prevtracefunc) { if (! r_prevtracefunc) {
r_prevtracefunc=SwigType_remember_trace(typetrace); r_prevtracefunc=SwigType_remember_trace(typetrace);
} else { } else {
Printf(stderr,"php4 Typetrace vector already saved!\n"); Printf(stderr,"php Typetrace vector already saved!\n");
assert(0); assert(0);
} }
return maininstance; return maininstance;
} }
extern "C" Language * swig_php(void) { extern "C" Language * swig_php4(void) {
return new_swig_php(); return new_swig_php(4);
}
extern "C" Language * swig_php5(void) {
return new_swig_php(5);
} }

View file

@ -32,7 +32,8 @@ extern "C" {
Language *swig_modula3(void); Language *swig_modula3(void);
Language *swig_mzscheme(void); Language *swig_mzscheme(void);
Language *swig_java(void); Language *swig_java(void);
Language *swig_php(void); Language *swig_php4(void);
Language *swig_php5(void);
Language *swig_ocaml(void); Language *swig_ocaml(void);
Language *swig_pike(void); Language *swig_pike(void);
Language *swig_sexp(void); Language *swig_sexp(void);
@ -42,7 +43,7 @@ extern "C" {
Language *swig_allegrocl(void); Language *swig_allegrocl(void);
Language *swig_lua(void); Language *swig_lua(void);
Language *swig_clisp(void); Language *swig_clisp(void);
Language *swig_cffi(void); Language *swig_cffi(void);
Language *swig_uffi(void); Language *swig_uffi(void);
} }
@ -60,7 +61,7 @@ static swig_module modules[] = {
{"-allegrocl", swig_allegrocl, "ALLEGROCL"}, {"-allegrocl", swig_allegrocl, "ALLEGROCL"},
{"-chicken", swig_chicken, "CHICKEN"}, {"-chicken", swig_chicken, "CHICKEN"},
{"-clisp", swig_clisp, "CLISP"}, {"-clisp", swig_clisp, "CLISP"},
{"-cffi", swig_cffi, "CFFI"}, {"-cffi", swig_cffi, "CFFI"},
{"-csharp", swig_csharp, "C#"}, {"-csharp", swig_csharp, "C#"},
{"-guile", swig_guile, "Guile"}, {"-guile", swig_guile, "Guile"},
{"-java", swig_java, "Java"}, {"-java", swig_java, "Java"},
@ -70,8 +71,9 @@ static swig_module modules[] = {
{"-ocaml", swig_ocaml, "Ocaml"}, {"-ocaml", swig_ocaml, "Ocaml"},
{"-perl", swig_perl5, "Perl"}, {"-perl", swig_perl5, "Perl"},
{"-perl5", swig_perl5, 0}, {"-perl5", swig_perl5, 0},
{"-php", swig_php, "PHP"}, {"-php", swig_php4, 0},
{"-php4", swig_php, 0}, {"-php4", swig_php4, "PHP4"},
{"-php5", swig_php5, "PHP5"},
{"-pike", swig_pike, "Pike"}, {"-pike", swig_pike, "Pike"},
{"-python", swig_python, "Python"}, {"-python", swig_python, "Python"},
{"-ruby", swig_ruby, "Ruby"}, {"-ruby", swig_ruby, "Ruby"},