Merge branch 'master' into directorargout_and_java_typemaps
This commit is contained in:
commit
4ba9de370e
470 changed files with 15434 additions and 3110 deletions
|
|
@ -197,15 +197,17 @@ class Allocate:public Dispatcher {
|
|||
// Found a polymorphic method.
|
||||
// Mark the polymorphic method, in case the virtual keyword was not used.
|
||||
Setattr(n, "storage", "virtual");
|
||||
|
||||
if (both_have_public_access || both_have_protected_access) {
|
||||
if (!is_non_public_base(inclass, b))
|
||||
Setattr(n, "override", base); // Note C# definition of override, ie access must be the same
|
||||
} else if (!both_have_private_access) {
|
||||
// Different access
|
||||
if (this_wrapping_protected_members || base_wrapping_protected_members)
|
||||
if (!Getattr(b, "feature:interface")) { // interface implementation neither hides nor overrides
|
||||
if (both_have_public_access || both_have_protected_access) {
|
||||
if (!is_non_public_base(inclass, b))
|
||||
Setattr(n, "hides", base); // Note C# definition of hiding, ie hidden if access is different
|
||||
Setattr(n, "override", base); // Note C# definition of override, ie access must be the same
|
||||
}
|
||||
else if (!both_have_private_access) {
|
||||
// Different access
|
||||
if (this_wrapping_protected_members || base_wrapping_protected_members)
|
||||
if (!is_non_public_base(inclass, b))
|
||||
Setattr(n, "hides", base); // Note C# definition of hiding, ie hidden if access is different
|
||||
}
|
||||
}
|
||||
// Try and find the most base's covariant return type
|
||||
SwigType *most_base_covariant_type = Getattr(base, "covariant");
|
||||
|
|
|
|||
|
|
@ -1584,11 +1584,23 @@ public:
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
virtual int insertDirective(Node *n) {
|
||||
int ret = SWIG_OK;
|
||||
String *code = Getattr(n, "code");
|
||||
String *section = Getattr(n, "section");
|
||||
Replaceall(code, "$module", module_class_name);
|
||||
Replaceall(code, "$imclassname", imclass_name);
|
||||
Replaceall(code, "$dllimport", dllimport);
|
||||
return Language::insertDirective(n);
|
||||
|
||||
if (!ImportMode && (Cmp(section, "proxycode") == 0)) {
|
||||
if (proxy_class_code) {
|
||||
Swig_typemap_replace_embedded_typemap(code, n);
|
||||
int offset = Len(code) > 0 && *Char(code) == '\n' ? 1 : 0;
|
||||
Printv(proxy_class_code, Char(code) + offset, "\n", NIL);
|
||||
}
|
||||
} else {
|
||||
ret = Language::insertDirective(n);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -2044,34 +2056,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* calculateDirectBase()
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
void calculateDirectBase(Node* n) {
|
||||
Node* direct_base = 0;
|
||||
// C++ inheritance
|
||||
Node *attributes = NewHash();
|
||||
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
|
||||
const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE, attributes);
|
||||
bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false;
|
||||
bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false;
|
||||
Delete(attributes);
|
||||
if (!purebase_replace) {
|
||||
if (List *baselist = Getattr(n, "bases")) {
|
||||
Iterator base = First(baselist);
|
||||
while (base.item && (GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface")))
|
||||
base = Next(base);
|
||||
direct_base = base.item;
|
||||
}
|
||||
if (!direct_base && purebase_notderived)
|
||||
direct_base = symbolLookup(const_cast<String*>(pure_baseclass));
|
||||
} else {
|
||||
direct_base = symbolLookup(const_cast<String*>(pure_baseclass));
|
||||
}
|
||||
Setattr(n, "direct_base", direct_base);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* classHandler()
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
|
@ -2157,7 +2141,6 @@ public:
|
|||
emitInterfaceDeclaration(n, interface_name, interface_class_code);
|
||||
Delete(output_directory);
|
||||
}
|
||||
calculateDirectBase(n);
|
||||
}
|
||||
|
||||
Language::classHandler(n);
|
||||
|
|
@ -2426,21 +2409,8 @@ public:
|
|||
Printf(function_code, " %s ", methodmods);
|
||||
if (!is_smart_pointer()) {
|
||||
// Smart pointer classes do not mirror the inheritance hierarchy of the underlying pointer type, so no virtual/override/new required.
|
||||
if (Node *base_ovr = Getattr(n, "override")) {
|
||||
if (GetFlag(n, "isextendmember"))
|
||||
if (Getattr(n, "override"))
|
||||
Printf(function_code, "override ");
|
||||
else {
|
||||
Node* base = parentNode(base_ovr);
|
||||
bool ovr = false;
|
||||
for (Node* direct_base = Getattr(parentNode(n), "direct_base"); direct_base; direct_base = Getattr(direct_base, "direct_base")) {
|
||||
if (direct_base == base) { // "override" only applies if the base was not discarded (e.g. in case of multiple inheritance or via "ignore")
|
||||
ovr = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Printf(function_code, ovr ? "override " : "virtual ");
|
||||
}
|
||||
}
|
||||
else if (checkAttribute(n, "storage", "virtual"))
|
||||
Printf(function_code, "virtual ");
|
||||
if (Getattr(n, "hides"))
|
||||
|
|
@ -3917,8 +3887,12 @@ public:
|
|||
}
|
||||
|
||||
Printf(callback_def, " private %s SwigDirector%s(", tm, overloaded_name);
|
||||
if (!ignored_method)
|
||||
Printf(director_delegate_definitions, " public delegate %s", tm);
|
||||
if (!ignored_method) {
|
||||
const String *csdirectordelegatemodifiers = Getattr(n, "feature:csdirectordelegatemodifiers");
|
||||
String *modifiers = (csdirectordelegatemodifiers ? NewStringf("%s%s", csdirectordelegatemodifiers, Len(csdirectordelegatemodifiers) > 0 ? " " : "") : NewStringf("public "));
|
||||
Printf(director_delegate_definitions, " %sdelegate %s", modifiers, tm);
|
||||
Delete(modifiers);
|
||||
}
|
||||
} else {
|
||||
Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(returntype, 0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -717,9 +717,20 @@ public:
|
|||
* D::insertDirective()
|
||||
* --------------------------------------------------------------------------- */
|
||||
virtual int insertDirective(Node *n) {
|
||||
int ret = SWIG_OK;
|
||||
String *code = Getattr(n, "code");
|
||||
String *section = Getattr(n, "section");
|
||||
replaceModuleVariables(code);
|
||||
return Language::insertDirective(n);
|
||||
|
||||
if (!ImportMode && (Cmp(section, "proxycode") == 0)) {
|
||||
if (proxy_class_body_code) {
|
||||
Swig_typemap_replace_embedded_typemap(code, n);
|
||||
Printv(proxy_class_body_code, code, NIL);
|
||||
}
|
||||
} else {
|
||||
ret = Language::insertDirective(n);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1612,10 +1612,22 @@ public:
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
virtual int insertDirective(Node *n) {
|
||||
int ret = SWIG_OK;
|
||||
String *code = Getattr(n, "code");
|
||||
String *section = Getattr(n, "section");
|
||||
Replaceall(code, "$module", module_class_name);
|
||||
Replaceall(code, "$imclassname", imclass_name);
|
||||
return Language::insertDirective(n);
|
||||
|
||||
if (!ImportMode && (Cmp(section, "proxycode") == 0)) {
|
||||
if (proxy_class_code) {
|
||||
Swig_typemap_replace_embedded_typemap(code, n);
|
||||
int offset = Len(code) > 0 && *Char(code) == '\n' ? 1 : 0;
|
||||
Printv(proxy_class_code, Char(code) + offset, "\n", NIL);
|
||||
}
|
||||
} else {
|
||||
ret = Language::insertDirective(n);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -870,7 +870,7 @@ int Language::cDeclaration(Node *n) {
|
|||
} else {
|
||||
// Found an unignored templated method that has an empty template instantiation (%template())
|
||||
// Ignore it unless it has been %rename'd
|
||||
if (Strncmp(symname, "__dummy_", 8) == 0) {
|
||||
if (Strncmp(symname, "__dummy_", 8) == 0 && Cmp(storage, "typedef") != 0) {
|
||||
SetFlag(n, "feature:ignore");
|
||||
Swig_warning(WARN_LANG_TEMPLATE_METHOD_IGNORE, input_file, line_number,
|
||||
"%%template() contains no name. Template method ignored: %s\n", Swig_name_decl(n));
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ static const char *usage1 = (const char *) "\
|
|||
-copyctor - Automatically generate copy constructors wherever possible\n\
|
||||
-cpperraswarn - Treat the preprocessor #error statement as #warning (default)\n\
|
||||
-cppext <ext> - Change file extension of generated C++ files to <ext>\n\
|
||||
(default is cxx, except for PHP which uses cpp)\n\
|
||||
(default is cxx, except for PHP5 which uses cpp)\n\
|
||||
-copyright - Display copyright notices\n\
|
||||
-debug-classes - Display information about the classes found in the interface\n\
|
||||
-debug-module <n>- Display module parse tree at stages 1-4, <n> is a csv list of stages\n\
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
static const char *usage = "\
|
||||
PHP Options (available with -php)\n\
|
||||
PHP Options (available with -php7)\n\
|
||||
-noproxy - Don't generate proxy classes.\n\
|
||||
-prefix <prefix> - Prepend <prefix> to all class names in PHP wrappers\n\
|
||||
\n";
|
||||
|
|
@ -100,6 +100,11 @@ static String *s_oowrappers;
|
|||
static String *s_fakeoowrappers;
|
||||
static String *s_phpclasses;
|
||||
|
||||
/* To reduce code size (generated and compiled) we only want to emit each
|
||||
* different arginfo once, so we need to track which have been used.
|
||||
*/
|
||||
static Hash *arginfo_used;
|
||||
|
||||
/* Variables for using PHP classes */
|
||||
static Node *current_class = 0;
|
||||
|
||||
|
|
@ -129,6 +134,7 @@ extern "C" {
|
|||
|
||||
static void SwigPHP_emit_resource_registrations() {
|
||||
Iterator ki;
|
||||
bool emitted_default_dtor = false;
|
||||
|
||||
if (!zend_types)
|
||||
return;
|
||||
|
|
@ -140,9 +146,7 @@ static void SwigPHP_emit_resource_registrations() {
|
|||
DOH *key = ki.key;
|
||||
Node *class_node = ki.item;
|
||||
String *human_name = key;
|
||||
|
||||
// Write out destructor function header
|
||||
Printf(s_wrappers, "static ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key);
|
||||
String *rsrc_dtor_name = NULL;
|
||||
|
||||
// write out body
|
||||
if (class_node != NOTCLASS) {
|
||||
|
|
@ -152,51 +156,42 @@ static void SwigPHP_emit_resource_registrations() {
|
|||
human_name = Getattr(class_node, "name");
|
||||
// Do we have a known destructor for this type?
|
||||
if (destructor) {
|
||||
Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key);
|
||||
} else {
|
||||
Printf(s_wrappers, " /* No destructor for class %s */\n", human_name);
|
||||
Printf(s_wrappers, " efree(rsrc->ptr);\n");
|
||||
rsrc_dtor_name = NewStringf("_wrap_destroy%s", key);
|
||||
// Write out custom destructor function
|
||||
Printf(s_wrappers, "static ZEND_RSRC_DTOR_FUNC(%s) {\n", rsrc_dtor_name);
|
||||
Printf(s_wrappers, " %s(res, SWIGTYPE%s->name);\n", destructor, key);
|
||||
Printf(s_wrappers, "}\n");
|
||||
}
|
||||
} else {
|
||||
Printf(s_wrappers, " /* No destructor for simple type %s */\n", key);
|
||||
Printf(s_wrappers, " efree(rsrc->ptr);\n");
|
||||
}
|
||||
|
||||
// close function
|
||||
Printf(s_wrappers, "}\n");
|
||||
if (!rsrc_dtor_name) {
|
||||
rsrc_dtor_name = NewString("_swig_default_rsrc_destroy");
|
||||
if (!emitted_default_dtor) {
|
||||
// Write out custom destructor function
|
||||
Printf(s_wrappers, "static ZEND_RSRC_DTOR_FUNC(%s) {\n", rsrc_dtor_name);
|
||||
Printf(s_wrappers, " efree(res->ptr);\n");
|
||||
Printf(s_wrappers, "}\n");
|
||||
emitted_default_dtor = true;
|
||||
}
|
||||
}
|
||||
|
||||
// declare le_swig_<mangled> to store php registration
|
||||
Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name);
|
||||
|
||||
// register with php
|
||||
Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex"
|
||||
"(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key);
|
||||
"(%s, NULL, SWIGTYPE%s->name, module_number);\n", key, rsrc_dtor_name, key);
|
||||
|
||||
// store php type in class struct
|
||||
Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key);
|
||||
|
||||
Delete(rsrc_dtor_name);
|
||||
|
||||
ki = Next(ki);
|
||||
}
|
||||
}
|
||||
|
||||
class PHP : public Language {
|
||||
String *emit_action(Node *n) {
|
||||
// Adjust wrap:action to add TSRMLS_CC.
|
||||
String * action = Getattr(n, "wrap:action");
|
||||
if (action) {
|
||||
char * p = Strstr(action, "Swig::DirectorPureVirtualException::raise(\"");
|
||||
if (p) {
|
||||
p += strlen("Swig::DirectorPureVirtualException::raise(\"");
|
||||
p = strchr(p, '"');
|
||||
if (p) {
|
||||
++p;
|
||||
Insert(action, (int)(p - Char(action)), " TSRMLS_CC");
|
||||
}
|
||||
}
|
||||
}
|
||||
return ::emit_action(n);
|
||||
}
|
||||
|
||||
public:
|
||||
PHP() {
|
||||
director_language = 1;
|
||||
|
|
@ -208,7 +203,6 @@ public:
|
|||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
SWIG_library_directory("php");
|
||||
SWIG_config_cppext("cpp");
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-prefix") == 0) {
|
||||
|
|
@ -225,25 +219,11 @@ public:
|
|||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(usage, stdout);
|
||||
} else if (strcmp(argv[i], "-make") == 0 ||
|
||||
strcmp(argv[i], "-withc") == 0 ||
|
||||
strcmp(argv[i], "-withcxx") == 0) {
|
||||
Printf(stderr, "*** %s is no longer supported.\n", argv[i]);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
} else if (strcmp(argv[i], "-phpfull") == 0 ||
|
||||
strcmp(argv[i], "-withlibs") == 0 ||
|
||||
strcmp(argv[i], "-withincs") == 0) {
|
||||
Printf(stderr, "*** %s is no longer supported.\n*** We recommend building as a dynamically loadable module.\n", argv[i]);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
} else if (strcmp(argv[i], "-dlname") == 0) {
|
||||
Printf(stderr, "*** -dlname is no longer supported.\n*** If you want to change the module name, use -module instead.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
Preprocessor_define("SWIGPHP 1", 0);
|
||||
// SWIGPHP5 is deprecated, and no longer documented.
|
||||
Preprocessor_define("SWIGPHP5 1", 0);
|
||||
Preprocessor_define("SWIGPHP7 1", 0);
|
||||
SWIG_typemap_lang("php");
|
||||
SWIG_config_file("php.swg");
|
||||
allow_overloading();
|
||||
|
|
@ -267,7 +247,7 @@ public:
|
|||
}
|
||||
|
||||
/* Set comparison with null for ConstructorToFunction */
|
||||
setSubclassInstanceCheck(NewString("$arg->type != IS_NULL"));
|
||||
setSubclassInstanceCheck(NewString("Z_TYPE_P($arg) != IS_NULL"));
|
||||
|
||||
/* Initialize all of the output files */
|
||||
String *outfile = Getattr(n, "outfile");
|
||||
|
|
@ -282,14 +262,14 @@ public:
|
|||
f_runtime = NewStringEmpty();
|
||||
|
||||
/* sections of the output file */
|
||||
s_init = NewString("/* init section */\n");
|
||||
r_init = NewString("/* rinit section */\n");
|
||||
s_shutdown = NewString("/* shutdown section */\n");
|
||||
r_shutdown = NewString("/* rshutdown section */\n");
|
||||
s_init = NewStringEmpty();
|
||||
r_init = NewStringEmpty();
|
||||
s_shutdown = NewStringEmpty();
|
||||
r_shutdown = NewStringEmpty();
|
||||
s_header = NewString("/* header section */\n");
|
||||
s_wrappers = NewString("/* wrapper section */\n");
|
||||
/* subsections of the init section */
|
||||
s_vinit = NewString("/* vinit subsection */\n");
|
||||
s_vinit = NewStringEmpty();
|
||||
s_vdecl = NewString("/* vdecl subsection */\n");
|
||||
s_cinit = NewString("/* cinit subsection */\n");
|
||||
s_oinit = NewString("/* oinit subsection */\n");
|
||||
|
|
@ -382,7 +362,7 @@ public:
|
|||
|
||||
/* Initialize the rest of the module */
|
||||
|
||||
Printf(s_oinit, "ZEND_INIT_MODULE_GLOBALS(%s, %s_init_globals, %s_destroy_globals);\n", module, module, module);
|
||||
Printf(s_oinit, "ZEND_INIT_MODULE_GLOBALS(%s, %s_init_globals, NULL);\n", module, module);
|
||||
|
||||
/* start the header section */
|
||||
Printf(s_header, "ZEND_BEGIN_MODULE_GLOBALS(%s)\n", module);
|
||||
|
|
@ -390,21 +370,16 @@ public:
|
|||
Printf(s_header, "int error_code;\n");
|
||||
Printf(s_header, "ZEND_END_MODULE_GLOBALS(%s)\n", module);
|
||||
Printf(s_header, "ZEND_DECLARE_MODULE_GLOBALS(%s)\n", module);
|
||||
Printf(s_header, "#ifdef ZTS\n");
|
||||
Printf(s_header, "#define SWIG_ErrorMsg() TSRMG(%s_globals_id, zend_%s_globals *, error_msg )\n", module, module);
|
||||
Printf(s_header, "#define SWIG_ErrorCode() TSRMG(%s_globals_id, zend_%s_globals *, error_code )\n", module, module);
|
||||
Printf(s_header, "#else\n");
|
||||
Printf(s_header, "#define SWIG_ErrorMsg() (%s_globals.error_msg)\n", module);
|
||||
Printf(s_header, "#define SWIG_ErrorCode() (%s_globals.error_code)\n", module);
|
||||
Printf(s_header, "#endif\n\n");
|
||||
|
||||
/* The following can't go in Lib/php/phprun.swg as it uses SWIG_ErrorMsg(), etc
|
||||
* which has to be dynamically generated as it depends on the module name.
|
||||
*/
|
||||
Append(s_header, "#ifdef __GNUC__\n");
|
||||
Append(s_header, "static void SWIG_FAIL(TSRMLS_D) __attribute__ ((__noreturn__));\n");
|
||||
Append(s_header, "static void SWIG_FAIL(void) __attribute__ ((__noreturn__));\n");
|
||||
Append(s_header, "#endif\n\n");
|
||||
Append(s_header, "static void SWIG_FAIL(TSRMLS_D) {\n");
|
||||
Append(s_header, "static void SWIG_FAIL(void) {\n");
|
||||
Append(s_header, " zend_error(SWIG_ErrorCode(), \"%s\", SWIG_ErrorMsg());\n");
|
||||
// zend_error() should never return with the parameters we pass, but if it
|
||||
// does, we really don't want to let SWIG_FAIL() return. This also avoids
|
||||
|
|
@ -417,41 +392,36 @@ public:
|
|||
Printf(s_header, " globals->error_code = default_error_code;\n");
|
||||
Printf(s_header, "}\n");
|
||||
|
||||
Printf(s_header, "static void %s_destroy_globals(zend_%s_globals * globals) { (void)globals; }\n", module, module);
|
||||
|
||||
Printf(s_header, "\n");
|
||||
Printf(s_header, "static void SWIG_ResetError(TSRMLS_D) {\n");
|
||||
Printf(s_header, "static void SWIG_ResetError(void) {\n");
|
||||
Printf(s_header, " SWIG_ErrorMsg() = default_error_msg;\n");
|
||||
Printf(s_header, " SWIG_ErrorCode() = default_error_code;\n");
|
||||
Printf(s_header, "}\n");
|
||||
|
||||
Append(s_header, "\n");
|
||||
Printf(s_header, "ZEND_NAMED_FUNCTION(_wrap_swig_%s_alter_newobject) {\n", module);
|
||||
Append(s_header, " zval **args[2];\n");
|
||||
Append(s_header, " zval args[2];\n");
|
||||
Append(s_header, " swig_object_wrapper *value;\n");
|
||||
Append(s_header, " int type;\n");
|
||||
Append(s_header, "\n");
|
||||
Append(s_header, " SWIG_ResetError(TSRMLS_C);\n");
|
||||
Append(s_header, " SWIG_ResetError();\n");
|
||||
Append(s_header, " if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) {\n");
|
||||
Append(s_header, " WRONG_PARAM_COUNT;\n");
|
||||
Append(s_header, " }\n");
|
||||
Append(s_header, "\n");
|
||||
Append(s_header, " value = (swig_object_wrapper *) zend_list_find((*args[0])->value.lval, &type);\n");
|
||||
Append(s_header, " value->newobject = zval_is_true(*args[1]);\n");
|
||||
Append(s_header, " value = (swig_object_wrapper *) Z_RES_VAL(args[0]);\n");
|
||||
Append(s_header, " value->newobject = zval_is_true(&args[1]);\n");
|
||||
Append(s_header, "\n");
|
||||
Append(s_header, " return;\n");
|
||||
Append(s_header, "}\n");
|
||||
Printf(s_header, "ZEND_NAMED_FUNCTION(_wrap_swig_%s_get_newobject) {\n", module);
|
||||
Append(s_header, " zval **args[1];\n");
|
||||
Append(s_header, " zval args[1];\n");
|
||||
Append(s_header, " swig_object_wrapper *value;\n");
|
||||
Append(s_header, " int type;\n");
|
||||
Append(s_header, "\n");
|
||||
Append(s_header, " SWIG_ResetError(TSRMLS_C);\n");
|
||||
Append(s_header, " SWIG_ResetError();\n");
|
||||
Append(s_header, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n");
|
||||
Append(s_header, " WRONG_PARAM_COUNT;\n");
|
||||
Append(s_header, " }\n");
|
||||
Append(s_header, "\n");
|
||||
Append(s_header, " value = (swig_object_wrapper *) zend_list_find((*args[0])->value.lval, &type);\n");
|
||||
Append(s_header, " value = (swig_object_wrapper *) Z_RES_VAL(args[0]);\n");
|
||||
Append(s_header, " RETVAL_LONG(value->newobject);\n");
|
||||
Append(s_header, "\n");
|
||||
Append(s_header, " return;\n");
|
||||
|
|
@ -496,17 +466,10 @@ public:
|
|||
Printf(f_h, "#else\n");
|
||||
Printf(f_h, "# define PHP_%s_API\n", cap_module);
|
||||
Printf(f_h, "#endif\n\n");
|
||||
Printf(f_h, "#ifdef ZTS\n");
|
||||
Printf(f_h, "#include \"TSRM.h\"\n");
|
||||
Printf(f_h, "#endif\n\n");
|
||||
Printf(f_h, "PHP_MINIT_FUNCTION(%s);\n", module);
|
||||
Printf(f_h, "PHP_MSHUTDOWN_FUNCTION(%s);\n", module);
|
||||
Printf(f_h, "PHP_RINIT_FUNCTION(%s);\n", module);
|
||||
Printf(f_h, "PHP_RSHUTDOWN_FUNCTION(%s);\n", module);
|
||||
Printf(f_h, "PHP_MINFO_FUNCTION(%s);\n\n", module);
|
||||
|
||||
/* start the arginfo section */
|
||||
s_arginfo = NewString("/* arginfo subsection */\n");
|
||||
arginfo_used = NewHash();
|
||||
|
||||
/* start the function entry section */
|
||||
s_entry = NewString("/* entry subsection */\n");
|
||||
|
|
@ -518,45 +481,66 @@ 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);
|
||||
|
||||
/* start the init section */
|
||||
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");
|
||||
Append(s_init, "#endif\n");
|
||||
Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n", NIL);
|
||||
Printf(s_init, " STANDARD_MODULE_HEADER,\n");
|
||||
Printf(s_init, " (char*)\"%s\",\n", module);
|
||||
Printf(s_init, " %s_functions,\n", module);
|
||||
Printf(s_init, " PHP_MINIT(%s),\n", module);
|
||||
Printf(s_init, " PHP_MSHUTDOWN(%s),\n", module);
|
||||
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");
|
||||
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);
|
||||
/* Emit all of the code */
|
||||
Language::top(n);
|
||||
|
||||
Printf(s_init, "#ifdef __cplusplus\n");
|
||||
Printf(s_init, "extern \"C\" {\n");
|
||||
Printf(s_init, "#endif\n");
|
||||
// We want to write "SWIGEXPORT ZEND_GET_MODULE(%s)" but ZEND_GET_MODULE
|
||||
// in PHP5 has "extern "C" { ... }" around it so we can't do that.
|
||||
Printf(s_init, "SWIGEXPORT zend_module_entry *get_module(void) { return &%s_module_entry; }\n", module);
|
||||
Printf(s_init, "#ifdef __cplusplus\n");
|
||||
Printf(s_init, "}\n");
|
||||
Printf(s_init, "#endif\n\n");
|
||||
SwigPHP_emit_resource_registrations();
|
||||
|
||||
/* start the init section */
|
||||
{
|
||||
String * s_init_old = s_init;
|
||||
s_init = NewString("/* init section */\n");
|
||||
Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n", NIL);
|
||||
Printf(s_init, " STANDARD_MODULE_HEADER,\n");
|
||||
Printf(s_init, " \"%s\",\n", module);
|
||||
Printf(s_init, " %s_functions,\n", module);
|
||||
Printf(s_init, " PHP_MINIT(%s),\n", module);
|
||||
if (Len(s_shutdown) > 0) {
|
||||
Printf(s_init, " PHP_MSHUTDOWN(%s),\n", module);
|
||||
} else {
|
||||
Printf(s_init, " NULL, /* No MSHUTDOWN code */\n");
|
||||
}
|
||||
if (Len(r_init) > 0 || Len(s_vinit) > 0) {
|
||||
Printf(s_init, " PHP_RINIT(%s),\n", module);
|
||||
} else {
|
||||
Printf(s_init, " NULL, /* No RINIT code */\n");
|
||||
}
|
||||
if (Len(r_shutdown) > 0) {
|
||||
Printf(s_init, " PHP_RSHUTDOWN(%s),\n", module);
|
||||
} else {
|
||||
Printf(s_init, " NULL, /* No RSHUTDOWN code */\n");
|
||||
}
|
||||
if (Len(pragma_phpinfo) > 0) {
|
||||
Printf(s_init, " PHP_MINFO(%s),\n", module);
|
||||
} else {
|
||||
Printf(s_init, " NULL, /* No MINFO code */\n");
|
||||
}
|
||||
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);
|
||||
|
||||
Printf(s_init, "#ifdef __cplusplus\n");
|
||||
Printf(s_init, "extern \"C\" {\n");
|
||||
Printf(s_init, "#endif\n");
|
||||
// We want to write "SWIGEXPORT ZEND_GET_MODULE(%s)" but ZEND_GET_MODULE
|
||||
// in PHP5 has "extern "C" { ... }" around it so we can't do that.
|
||||
Printf(s_init, "SWIGEXPORT zend_module_entry *get_module(void) { return &%s_module_entry; }\n", module);
|
||||
Printf(s_init, "#ifdef __cplusplus\n");
|
||||
Printf(s_init, "}\n");
|
||||
Printf(s_init, "#endif\n\n");
|
||||
|
||||
Printf(s_init, "#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\n\n", module);
|
||||
|
||||
Printv(s_init, s_init_old, NIL);
|
||||
Delete(s_init_old);
|
||||
}
|
||||
|
||||
/* We have to register the constants before they are (possibly) used
|
||||
* by the pointer typemaps. This all needs re-arranging really as
|
||||
* things are being called in the wrong order
|
||||
*/
|
||||
Printf(s_init, "#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\n", module);
|
||||
|
||||
/* 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");
|
||||
|
|
@ -573,38 +557,66 @@ public:
|
|||
Printf(s_init, "}\n\n");
|
||||
|
||||
// Now do REQUEST init which holds any user specified %rinit, and also vinit
|
||||
Printf(s_init, "PHP_RINIT_FUNCTION(%s)\n{\n", module);
|
||||
Printf(s_init, "%s\n", r_init);
|
||||
if (Len(r_init) > 0 || Len(s_vinit) > 0) {
|
||||
Printf(f_h, "PHP_RINIT_FUNCTION(%s);\n", module);
|
||||
|
||||
/* finish our init section which will have been used by class wrappers */
|
||||
Printf(s_vinit, "/* end vinit subsection */\n");
|
||||
Printf(s_init, "%s\n", s_vinit);
|
||||
Clear(s_vinit);
|
||||
Delete(s_vinit);
|
||||
Printf(s_init, "PHP_RINIT_FUNCTION(%s)\n{\n", module);
|
||||
if (Len(r_init) > 0) {
|
||||
Printv(s_init,
|
||||
"/* rinit section */\n",
|
||||
r_init, "\n",
|
||||
NIL);
|
||||
}
|
||||
|
||||
Printf(s_init, " return SUCCESS;\n");
|
||||
Printf(s_init, "}\n\n");
|
||||
if (Len(s_vinit) > 0) {
|
||||
/* finish our init section which will have been used by class wrappers */
|
||||
Printv(s_init,
|
||||
"/* vinit subsection */\n",
|
||||
s_vinit, "\n"
|
||||
"/* end vinit subsection */\n",
|
||||
NIL);
|
||||
Clear(s_vinit);
|
||||
}
|
||||
Delete(s_vinit);
|
||||
|
||||
Printv(s_init, "PHP_MSHUTDOWN_FUNCTION(", module, ")\n"
|
||||
"{\n",
|
||||
s_shutdown,
|
||||
"#ifdef ZTS\n"
|
||||
" ts_free_id(", module, "_globals_id);\n"
|
||||
"#endif\n"
|
||||
" return SUCCESS;\n"
|
||||
"}\n\n", NIL);
|
||||
Printf(s_init, " return SUCCESS;\n");
|
||||
Printf(s_init, "}\n\n");
|
||||
}
|
||||
|
||||
Printf(s_init, "PHP_RSHUTDOWN_FUNCTION(%s)\n{\n", module);
|
||||
Printf(s_init, "%s\n", r_shutdown);
|
||||
Printf(s_init, " return SUCCESS;\n");
|
||||
Printf(s_init, "}\n\n");
|
||||
Printf(f_h, "PHP_MINIT_FUNCTION(%s);\n", module);
|
||||
|
||||
if (Len(s_shutdown) > 0) {
|
||||
Printf(f_h, "PHP_MSHUTDOWN_FUNCTION(%s);\n", module);
|
||||
|
||||
Printv(s_init, "PHP_MSHUTDOWN_FUNCTION(", module, ")\n"
|
||||
"/* shutdown section */\n"
|
||||
"{\n",
|
||||
s_shutdown,
|
||||
" return SUCCESS;\n"
|
||||
"}\n\n", NIL);
|
||||
}
|
||||
|
||||
if (Len(r_shutdown) > 0) {
|
||||
Printf(f_h, "PHP_RSHUTDOWN_FUNCTION(%s);\n", module);
|
||||
|
||||
Printf(s_init, "PHP_RSHUTDOWN_FUNCTION(%s)\n{\n", module);
|
||||
Printf(s_init, "/* rshutdown section */\n");
|
||||
Printf(s_init, "%s\n", r_shutdown);
|
||||
Printf(s_init, " return SUCCESS;\n");
|
||||
Printf(s_init, "}\n\n");
|
||||
}
|
||||
|
||||
if (Len(pragma_phpinfo) > 0) {
|
||||
Printf(f_h, "PHP_MINFO_FUNCTION(%s);\n", module);
|
||||
|
||||
Printf(s_init, "PHP_MINFO_FUNCTION(%s)\n{\n", module);
|
||||
Printf(s_init, "%s", pragma_phpinfo);
|
||||
Printf(s_init, "}\n");
|
||||
}
|
||||
|
||||
Printf(s_init, "PHP_MINFO_FUNCTION(%s)\n{\n", module);
|
||||
Printf(s_init, "%s", pragma_phpinfo);
|
||||
Printf(s_init, "}\n");
|
||||
Printf(s_init, "/* end init section */\n");
|
||||
|
||||
Printf(f_h, "#endif /* PHP_%s_H */\n", cap_module);
|
||||
Printf(f_h, "\n#endif /* PHP_%s_H */\n", cap_module);
|
||||
|
||||
Delete(f_h);
|
||||
|
||||
|
|
@ -648,6 +660,7 @@ public:
|
|||
Delete(s_arginfo);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
Delete(arginfo_used);
|
||||
|
||||
Printf(f_phpcode, "%s\n%s\n", pragma_incl, pragma_code);
|
||||
if (s_fakeoowrappers) {
|
||||
|
|
@ -667,22 +680,36 @@ public:
|
|||
void create_command(String *cname, String *iname, Node *n) {
|
||||
// This is for the single main zend_function_entry record
|
||||
Printf(f_h, "ZEND_NAMED_FUNCTION(%s);\n", iname);
|
||||
String * s = cs_entry;
|
||||
if (!s) s = s_entry;
|
||||
Printf(s, " SWIG_ZEND_NAMED_FE(%(lower)s,%s,swig_arginfo_%(lower)s)\n", cname, iname, cname);
|
||||
|
||||
// This is the above referenced arginfo structure.
|
||||
// We want to only emit each different arginfo once, as that reduces the
|
||||
// size of both the generated source code and the compiled extension
|
||||
// module. To do this, we name the arginfo to encode the number of
|
||||
// parameters and which (if any) are passed by reference by using a
|
||||
// sequence of 0s (for non-reference) and 1s (for by references).
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%(lower)s, 0, 0, 0)\n", cname);
|
||||
String * arginfo_code = NewStringEmpty();
|
||||
for (Parm *p = l; p; p = Getattr(p, "tmap:in:next")) {
|
||||
/* Ignored parameters */
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
continue;
|
||||
}
|
||||
int byref = GetFlag(p, "tmap:in:byref");
|
||||
Printf(s_arginfo, " ZEND_ARG_PASS_INFO(%d)\n", byref);
|
||||
Append(arginfo_code, GetFlag(p, "tmap:in:byref") ? "1" : "0");
|
||||
}
|
||||
Printf(s_arginfo, "ZEND_END_ARG_INFO()\n");
|
||||
|
||||
if (!GetFlag(arginfo_used, arginfo_code)) {
|
||||
// Not had this one before, so emit it.
|
||||
SetFlag(arginfo_used, arginfo_code);
|
||||
Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%s, 0, 0, 0)\n", arginfo_code);
|
||||
for (const char * p = Char(arginfo_code); *p; ++p) {
|
||||
Printf(s_arginfo, " ZEND_ARG_PASS_INFO(%c)\n", *p);
|
||||
}
|
||||
Printf(s_arginfo, "ZEND_END_ARG_INFO()\n");
|
||||
}
|
||||
|
||||
String * s = cs_entry;
|
||||
if (!s) s = s_entry;
|
||||
Printf(s, " SWIG_ZEND_NAMED_FE(%(lower)s,%s,swig_arginfo_%s)\n", cname, iname, arginfo_code);
|
||||
Delete(arginfo_code);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
@ -710,12 +737,12 @@ public:
|
|||
|
||||
Wrapper_add_local(f, "argc", "int argc");
|
||||
|
||||
Printf(tmp, "zval **argv[%d]", maxargs);
|
||||
Printf(tmp, "zval argv[%d]", maxargs);
|
||||
Wrapper_add_local(f, "argv", tmp);
|
||||
|
||||
Printf(f->code, "argc = ZEND_NUM_ARGS();\n");
|
||||
|
||||
Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n");
|
||||
Printf(f->code, "zend_get_parameters_array_ex(argc, argv);\n");
|
||||
|
||||
Replaceall(dispatch, "$args", "self,args");
|
||||
|
||||
|
|
@ -723,7 +750,7 @@ public:
|
|||
|
||||
Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n");
|
||||
Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
|
||||
Printv(f->code, "SWIG_FAIL(TSRMLS_C);\n", NIL);
|
||||
Printv(f->code, "SWIG_FAIL();\n", NIL);
|
||||
|
||||
Printv(f->code, "}\n", NIL);
|
||||
Wrapper_print(f, s_wrappers);
|
||||
|
|
@ -819,8 +846,8 @@ public:
|
|||
if (num_arguments > 0) {
|
||||
String *args = NewStringEmpty();
|
||||
if (wrapperType == directorconstructor)
|
||||
Wrapper_add_local(f, "arg0", "zval *arg0");
|
||||
Printf(args, "zval **args[%d]", num_arguments);
|
||||
Wrapper_add_local(f, "arg0", "zval * arg0");
|
||||
Printf(args, "zval args[%d]", num_arguments);
|
||||
Wrapper_add_local(f, "args", args);
|
||||
Delete(args);
|
||||
args = NULL;
|
||||
|
|
@ -834,7 +861,7 @@ public:
|
|||
|
||||
// NOTE: possible we ignore this_ptr as a param for native constructor
|
||||
|
||||
Printf(f->code, "SWIG_ResetError(TSRMLS_C);\n");
|
||||
Printf(f->code, "SWIG_ResetError();\n");
|
||||
|
||||
if (numopt > 0) { // membervariable wrappers do not have optional args
|
||||
Wrapper_add_local(f, "arg_count", "int arg_count");
|
||||
|
|
@ -851,7 +878,7 @@ public:
|
|||
Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n");
|
||||
}
|
||||
if (wrapperType == directorconstructor)
|
||||
Printf(f->code, "arg0 = *args[0];\n \n");
|
||||
Printf(f->code, "arg0 = &args[0];\n \n");
|
||||
|
||||
/* Now convert from PHP to C variables */
|
||||
// At this point, argcount if used is the number of deliberately passed args
|
||||
|
|
@ -891,7 +918,7 @@ public:
|
|||
}
|
||||
|
||||
if ((tm = Getattr(p, "tmap:in"))) {
|
||||
Replaceall(tm, "$source", source);
|
||||
Replaceall(tm, "$source", &source);
|
||||
Replaceall(tm, "$target", ln);
|
||||
Replaceall(tm, "$input", source);
|
||||
Setattr(p, "emit:input", source);
|
||||
|
|
@ -915,7 +942,7 @@ public:
|
|||
|
||||
if (is_member_director(n)) {
|
||||
Wrapper_add_local(f, "upcall", "bool upcall = false");
|
||||
Printf(f->code, "upcall = !Swig::Director::swig_is_overridden_method((char *)\"%s%s\", (char *)\"%s\" TSRMLS_CC);\n",
|
||||
Printf(f->code, "upcall = !Swig::Director::swig_is_overridden_method(\"%s%s\", \"%s\");\n",
|
||||
prefix, Swig_class_name(Swig_methodclass(n)), name);
|
||||
}
|
||||
|
||||
|
|
@ -1006,7 +1033,7 @@ public:
|
|||
/* Error handling code */
|
||||
Printf(f->code, "fail:\n");
|
||||
Printv(f->code, cleanup, NIL);
|
||||
Append(f->code, "SWIG_FAIL(TSRMLS_C);\n");
|
||||
Append(f->code, "SWIG_FAIL();\n");
|
||||
|
||||
Printf(f->code, "}\n");
|
||||
|
||||
|
|
@ -1056,6 +1083,7 @@ public:
|
|||
bool handle_as_overload = false;
|
||||
String **arg_names;
|
||||
String **arg_values;
|
||||
unsigned char * byref;
|
||||
// Method or static method or plain function.
|
||||
const char *methodname = 0;
|
||||
String *output = s_oowrappers;
|
||||
|
|
@ -1196,7 +1224,8 @@ public:
|
|||
}
|
||||
|
||||
arg_values = (String **) malloc(max_num_of_arguments * sizeof(String *));
|
||||
if (!arg_values) {
|
||||
byref = (unsigned char *) malloc(max_num_of_arguments);
|
||||
if (!arg_values || !byref) {
|
||||
/* FIXME: How should this be handled? The rest of SWIG just seems
|
||||
* to not bother checking for malloc failing! */
|
||||
fprintf(stderr, "Malloc failed!\n");
|
||||
|
|
@ -1204,6 +1233,7 @@ public:
|
|||
}
|
||||
for (i = 0; i < max_num_of_arguments; ++i) {
|
||||
arg_values[i] = NULL;
|
||||
byref[i] = false;
|
||||
}
|
||||
|
||||
Node *o;
|
||||
|
|
@ -1223,6 +1253,7 @@ public:
|
|||
continue;
|
||||
}
|
||||
assert(0 <= argno && argno < max_num_of_arguments);
|
||||
byref[argno] = GetFlag(p, "tmap:in:byref");
|
||||
String *&pname = arg_names[argno];
|
||||
const char *pname_cstr = GetChar(p, "name");
|
||||
// Just get rid of the C++ namespace part for now.
|
||||
|
|
@ -1471,6 +1502,7 @@ public:
|
|||
Printf(args, ",");
|
||||
if (i || wrapperType == memberfn)
|
||||
Printf(invoke, ",");
|
||||
if (byref[i]) Printf(args, "&");
|
||||
String *value = arg_values[i];
|
||||
if (value) {
|
||||
const char *v = Char(value);
|
||||
|
|
@ -1479,6 +1511,9 @@ public:
|
|||
Replaceall(value, "$", "\\$");
|
||||
}
|
||||
Printf(args, "$%s=%s", arg_names[i], value);
|
||||
} else if (constructor && i >= 1 && i < min_num_of_arguments) {
|
||||
// We need to be able to call __construct($resource).
|
||||
Printf(args, "$%s=null", arg_names[i]);
|
||||
} else {
|
||||
Printf(args, "$%s", arg_names[i]);
|
||||
}
|
||||
|
|
@ -1499,6 +1534,15 @@ public:
|
|||
Printf(invoke_args, ",");
|
||||
}
|
||||
Printf(invoke_args, "%s", args);
|
||||
if (constructor && min_num_of_arguments > 1) {
|
||||
// We need to be able to call __construct($resource).
|
||||
Clear(args);
|
||||
Printf(args, "$%s", arg_names[0]);
|
||||
for (i = 1; i < min_num_of_arguments; ++i) {
|
||||
Printf(args, ",");
|
||||
Printf(args, "$%s=null", arg_names[i]);
|
||||
}
|
||||
}
|
||||
bool had_a_case = false;
|
||||
int last_handled_i = i - 1;
|
||||
for (; i < max_num_of_arguments; ++i) {
|
||||
|
|
@ -2290,15 +2334,15 @@ done:
|
|||
Delete(director_ctor_code);
|
||||
director_ctor_code = NewStringEmpty();
|
||||
director_prot_ctor_code = NewStringEmpty();
|
||||
Printf(director_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n");
|
||||
Printf(director_prot_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n");
|
||||
Printf(director_ctor_code, "if (Z_TYPE_P(arg0) == IS_NULL) { /* not subclassed */\n");
|
||||
Printf(director_prot_ctor_code, "if (Z_TYPE_P(arg0) == IS_NULL) { /* not subclassed */\n");
|
||||
Printf(director_ctor_code, " %s = (%s *)new %s(%s);\n", Swig_cresult_name(), ctype, ctype, args);
|
||||
Printf(director_prot_ctor_code, " SWIG_PHP_Error(E_ERROR, \"accessing abstract class or protected constructor\");\n", name, name, args);
|
||||
if (i) {
|
||||
Insert(args, 0, ", ");
|
||||
}
|
||||
Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0 TSRMLS_CC%s);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0 TSRMLS_CC%s);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Delete(args);
|
||||
|
||||
wrapperType = directorconstructor;
|
||||
|
|
@ -2328,9 +2372,9 @@ done:
|
|||
Wrapper *f = NewWrapper();
|
||||
Printf(f->def, "/* This function is designed to be called by the zend list destructors */\n");
|
||||
Printf(f->def, "/* to typecast and do the actual destruction */\n");
|
||||
Printf(f->def, "static void %s(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) {\n", destructorname);
|
||||
Printf(f->def, "static void %s(zend_resource *res, const char *type_name) {\n", destructorname);
|
||||
|
||||
Wrapper_add_localv(f, "value", "swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr", NIL);
|
||||
Wrapper_add_localv(f, "value", "swig_object_wrapper *value=(swig_object_wrapper *) res->ptr", NIL);
|
||||
Wrapper_add_localv(f, "ptr", "void *ptr=value->ptr", NIL);
|
||||
Wrapper_add_localv(f, "newobject", "int newobject=value->newobject", NIL);
|
||||
|
||||
|
|
@ -2348,7 +2392,7 @@ done:
|
|||
|
||||
Printf(f->code, " efree(value);\n");
|
||||
Printf(f->code, " if (! newobject) return; /* can't delete it! */\n");
|
||||
Printf(f->code, " arg1 = (%s)SWIG_ZTS_ConvertResourceData(ptr,type_name,SWIGTYPE%s TSRMLS_CC);\n", SwigType_lstr(pt, 0), SwigType_manglestr(pt));
|
||||
Printf(f->code, " arg1 = (%s)SWIG_ConvertResourceData(ptr, type_name, SWIGTYPE%s);\n", SwigType_lstr(pt, 0), SwigType_manglestr(pt));
|
||||
Printf(f->code, " if (! arg1) zend_error(E_ERROR, \"%s resource already free'd\");\n", Char(name));
|
||||
|
||||
Setattr(n, "wrap:name", destructorname);
|
||||
|
|
@ -2360,7 +2404,7 @@ done:
|
|||
Printf(f->code, "thrown:\n");
|
||||
Append(f->code, "return;\n");
|
||||
Append(f->code, "fail:\n");
|
||||
Append(f->code, "SWIG_FAIL(TSRMLS_C);\n");
|
||||
Append(f->code, "SWIG_FAIL();\n");
|
||||
Printf(f->code, "}\n");
|
||||
|
||||
Wrapper_print(f, s_wrappers);
|
||||
|
|
@ -2420,16 +2464,9 @@ done:
|
|||
String *call;
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
|
||||
// We put TSRMLS_DC after the self parameter in order to cope with
|
||||
// any default parameters.
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||
const char * p = Char(target);
|
||||
const char * comma = strchr(p, ',');
|
||||
int ins = comma ? (int)(comma - p) : Len(target) - 1;
|
||||
Insert(target, ins, " TSRMLS_DC");
|
||||
|
||||
call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self TSRMLS_CC) {", classname, target, call);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self) {", classname, target, call);
|
||||
Append(w->def, "}");
|
||||
Delete(target);
|
||||
Wrapper_print(w, f_directors);
|
||||
|
|
@ -2439,14 +2476,7 @@ done:
|
|||
|
||||
/* constructor header */
|
||||
{
|
||||
// We put TSRMLS_DC after the self parameter in order to cope with
|
||||
// any default parameters.
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||
const char * p = Char(target);
|
||||
const char * comma = strchr(p, ',');
|
||||
int ins = comma ? (int)(comma - p) : Len(target) - 1;
|
||||
Insert(target, ins, " TSRMLS_DC");
|
||||
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
|
|
@ -2531,8 +2561,6 @@ done:
|
|||
Append(w->def, " {");
|
||||
Append(declaration, ";\n");
|
||||
|
||||
Printf(w->code, "TSRMLS_FETCH_FROM_CTX(swig_zts_ctx);\n");
|
||||
|
||||
/* declare method return value
|
||||
* if the return value is a reference or const reference, a specialized typemap must
|
||||
* handle it, including declaration of c_result ($result).
|
||||
|
|
@ -2553,7 +2581,7 @@ done:
|
|||
Printf(w->code, "%s;\n", super_call);
|
||||
Delete(super_call);
|
||||
} else {
|
||||
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\" TSRMLS_CC);\n", SwigType_namestr(c_classname),
|
||||
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname),
|
||||
SwigType_namestr(name));
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2568,7 +2596,6 @@ done:
|
|||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
||||
Parm *p;
|
||||
char source[256];
|
||||
|
||||
int outputs = 0;
|
||||
if (!is_void)
|
||||
|
|
@ -2592,16 +2619,11 @@ done:
|
|||
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
|
||||
String *parse = Getattr(p, "tmap:directorin:parse");
|
||||
if (!parse) {
|
||||
sprintf(source, "obj%d", idx++);
|
||||
String *input = NewStringf("&%s", source);
|
||||
String *input = NewStringf("&args[%d]", idx++);
|
||||
Setattr(p, "emit:directorinput", input);
|
||||
Replaceall(tm, "$input", input);
|
||||
Delete(input);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
Printv(wrap_args, "zval ", source, ";\n", NIL);
|
||||
Printf(wrap_args, "args[%d] = &%s;\n", idx - 1, source);
|
||||
Printv(wrap_args, "INIT_ZVAL(", source, ");\n", NIL);
|
||||
|
||||
Printv(wrap_args, tm, "\n", NIL);
|
||||
Putc('O', parse_args);
|
||||
} else {
|
||||
|
|
@ -2644,17 +2666,17 @@ done:
|
|||
}
|
||||
|
||||
if (!idx) {
|
||||
Printf(w->code, "zval **args = NULL;\n");
|
||||
Printf(w->code, "zval *args = NULL;\n");
|
||||
} else {
|
||||
Printf(w->code, "zval *args[%d];\n", idx);
|
||||
Printf(w->code, "zval args[%d];\n", idx);
|
||||
}
|
||||
Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name());
|
||||
Append(w->code, "if (!swig_self) {\n");
|
||||
Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");");
|
||||
Append(w->code, "}\n\n");
|
||||
Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name());
|
||||
// typemap_directorout testcase requires that 0 can be assigned to the
|
||||
// variable named after the result of Swig_cresult_name(), so that can't
|
||||
// be a zval - make it a pointer to one instead.
|
||||
Printf(w->code, "zval swig_zval_result, swig_funcname;\n", Swig_cresult_name());
|
||||
Printf(w->code, "zval * SWIGUNUSED %s = &swig_zval_result;\n", Swig_cresult_name());
|
||||
const char * funcname = GetChar(n, "sym:name");
|
||||
Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname));
|
||||
Printf(w->code, "ZVAL_STRINGL(&swig_funcname, \"%s\", %d);\n", funcname, strlen(funcname));
|
||||
|
||||
/* wrap complex arguments to zvals */
|
||||
Printv(w->code, wrap_args, NIL);
|
||||
|
|
@ -2662,8 +2684,8 @@ done:
|
|||
if (error_used_in_typemap) {
|
||||
Append(w->code, "error = ");
|
||||
}
|
||||
Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,");
|
||||
Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx);
|
||||
Append(w->code, "call_user_function(EG(function_table), &swig_self, &swig_funcname,");
|
||||
Printf(w->code, " &swig_zval_result, %d, args);\n", idx);
|
||||
|
||||
if (tm) {
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
|
|
@ -2715,8 +2737,6 @@ done:
|
|||
}
|
||||
}
|
||||
|
||||
Printf(w->code, "FREE_ZVAL(%s);\n", Swig_cresult_name());
|
||||
|
||||
Delete(parse_args);
|
||||
Delete(cleanup);
|
||||
Delete(outarg);
|
||||
|
|
@ -2738,7 +2758,7 @@ done:
|
|||
}
|
||||
|
||||
Append(w->code, "fail:\n");
|
||||
Append(w->code, "SWIG_FAIL(TSRMLS_C);\n");
|
||||
Append(w->code, "SWIG_FAIL();\n");
|
||||
Append(w->code, "}\n");
|
||||
|
||||
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
|
||||
|
|
@ -2783,7 +2803,8 @@ static PHP *maininstance = 0;
|
|||
// We use this function to be able to write out zend_register_list_destructor_ex
|
||||
// lines for most things in the type table
|
||||
// NOTE: it's a function NOT A PHP::METHOD
|
||||
extern "C" void typetrace(const SwigType *ty, String *mangled, String *clientdata) {
|
||||
extern "C" {
|
||||
static void typetrace(const SwigType *ty, String *mangled, String *clientdata) {
|
||||
Node *class_node;
|
||||
if (!zend_types) {
|
||||
zend_types = NewHash();
|
||||
|
|
@ -2803,6 +2824,7 @@ extern "C" void typetrace(const SwigType *ty, String *mangled, String *clientdat
|
|||
if (r_prevtracefunc)
|
||||
(*r_prevtracefunc) (ty, mangled, (String *) clientdata);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* new_swig_php() - Instantiate module
|
||||
|
|
@ -2819,13 +2841,6 @@ static Language *new_swig_php() {
|
|||
return maininstance;
|
||||
}
|
||||
|
||||
extern "C" Language *swig_php4(void) {
|
||||
Printf(stderr, "*** -php4 is no longer supported.\n"
|
||||
"*** Either upgrade to PHP5 or use SWIG 1.3.36 or earlier.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
return NULL; // To avoid compiler warnings.
|
||||
}
|
||||
|
||||
extern "C" Language *swig_php(void) {
|
||||
return new_swig_php();
|
||||
}
|
||||
|
|
|
|||
2858
Source/Modules/php5.cxx
Normal file
2858
Source/Modules/php5.cxx
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -261,10 +261,9 @@ public:
|
|||
rename = strip(name);
|
||||
Printf(f_classInit, "ADD_FUNCTION(\"%s\", %s, tFunc(%s), 0);\n", rename, function, description);
|
||||
break;
|
||||
case CLASS_CONST:
|
||||
assert(false); // shouldn't have gotten here for CLASS_CONST nodes
|
||||
default:
|
||||
assert(false); // what is this?
|
||||
case CLASS_CONST: // shouldn't have gotten here for CLASS_CONST nodes
|
||||
default: // what is this?
|
||||
assert(false);
|
||||
}
|
||||
Delete(rename);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ static File *f_shadow_py = 0;
|
|||
static String *f_shadow = 0;
|
||||
static String *f_shadow_begin = 0;
|
||||
static Hash *f_shadow_imports = 0;
|
||||
static String *f_shadow_builtin_imports = 0;
|
||||
static String *f_shadow_after_begin = 0;
|
||||
static String *f_shadow_stubs = 0;
|
||||
static Hash *builtin_getset = 0;
|
||||
static Hash *builtin_closures = 0;
|
||||
|
|
@ -565,6 +565,7 @@ public:
|
|||
* interface file to enable director generation.
|
||||
*/
|
||||
String *mod_docstring = NULL;
|
||||
String *moduleimport = NULL;
|
||||
{
|
||||
Node *mod = Getattr(n, "module");
|
||||
if (mod) {
|
||||
|
|
@ -605,6 +606,7 @@ public:
|
|||
}
|
||||
mod_docstring = Getattr(options, "docstring");
|
||||
package = Getattr(options, "package");
|
||||
moduleimport = Getattr(options, "moduleimport");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -779,6 +781,7 @@ public:
|
|||
}
|
||||
|
||||
/* If shadow classing is enabled, we're going to change the module name to "_module" */
|
||||
String *default_import_code = NewString("");
|
||||
if (shadow) {
|
||||
String *filen = NewStringf("%s%s.py", SWIG_output_directory(), Char(module));
|
||||
// If we don't have an interface then change the module name X to _X
|
||||
|
|
@ -796,7 +799,7 @@ public:
|
|||
f_shadow = NewString("");
|
||||
f_shadow_begin = NewString("");
|
||||
f_shadow_imports = NewHash();
|
||||
f_shadow_builtin_imports = NewString("");
|
||||
f_shadow_after_begin = NewString("");
|
||||
f_shadow_stubs = NewString("");
|
||||
|
||||
Swig_register_filebyname("shadow", f_shadow);
|
||||
|
|
@ -808,19 +811,19 @@ public:
|
|||
// follow PEP257 rules: https://www.python.org/dev/peps/pep-0257/
|
||||
// reported by pep257: https://github.com/GreenSteam/pep257
|
||||
bool multi_line_ds = Strchr(mod_docstring, '\n') != 0;
|
||||
Printv(f_shadow, triple_double, multi_line_ds ? "\n":"", mod_docstring, multi_line_ds ? "\n":"", triple_double, "\n\n", NIL);
|
||||
Printv(f_shadow_after_begin, "\n", triple_double, multi_line_ds ? "\n":"", mod_docstring, multi_line_ds ? "\n":"", triple_double, "\n", NIL);
|
||||
}
|
||||
Delete(mod_docstring);
|
||||
mod_docstring = NULL;
|
||||
}
|
||||
|
||||
Printv(f_shadow, "\nfrom sys import version_info as _swig_python_version_info\n", NULL);
|
||||
Printv(default_import_code, "\nfrom sys import version_info as _swig_python_version_info\n", NULL);
|
||||
|
||||
if (!builtin && fastproxy) {
|
||||
Printv(f_shadow, "if _swig_python_version_info >= (3, 0, 0):\n", NULL);
|
||||
Printf(f_shadow, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module);
|
||||
Printv(f_shadow, "else:\n", NULL);
|
||||
Printv(f_shadow, tab4, "from new import instancemethod as new_instancemethod\n", NULL);
|
||||
Printv(default_import_code, "if _swig_python_version_info >= (3, 0, 0):\n", NULL);
|
||||
Printf(default_import_code, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module);
|
||||
Printv(default_import_code, "else:\n", NULL);
|
||||
Printv(default_import_code, tab4, "from new import instancemethod as new_instancemethod\n", NULL);
|
||||
}
|
||||
|
||||
/* Import the C-extension module. This should be a relative import,
|
||||
|
|
@ -840,42 +843,39 @@ public:
|
|||
* ImportError then fallback and try and load just the module name from
|
||||
* the global namespace.
|
||||
*/
|
||||
Printv(f_shadow, "if _swig_python_version_info >= (2, 7, 0):\n", NULL);
|
||||
Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL);
|
||||
Printv(f_shadow, tab8, "import importlib\n", NULL);
|
||||
Printv(f_shadow, tab8, "pkg = __name__.rpartition('.')[0]\n", NULL);
|
||||
Printf(f_shadow, tab8 "mname = '.'.join((pkg, '%s')).lstrip('.')\n",
|
||||
module);
|
||||
Printv(f_shadow, tab8, "try:\n", NULL);
|
||||
Printv(f_shadow, tab8, tab4, "return importlib.import_module(mname)\n",
|
||||
NULL);
|
||||
Printv(f_shadow, tab8, "except ImportError:\n", NULL);
|
||||
Printf(f_shadow, tab8 tab4 "return importlib.import_module('%s')\n",
|
||||
module);
|
||||
Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module);
|
||||
Printv(f_shadow, tab4, "del swig_import_helper\n", NULL);
|
||||
Printv(f_shadow, "elif _swig_python_version_info >= (2, 6, 0):\n", NULL);
|
||||
Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL);
|
||||
Printv(f_shadow, tab8, "from os.path import dirname\n", NULL);
|
||||
Printv(f_shadow, tab8, "import imp\n", NULL);
|
||||
Printv(f_shadow, tab8, "fp = None\n", NULL);
|
||||
Printv(f_shadow, tab8, "try:\n", NULL);
|
||||
Printf(f_shadow, tab4 tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module);
|
||||
Printf(f_shadow, tab8 "except ImportError:\n");
|
||||
Printv(default_import_code, "if _swig_python_version_info >= (2, 7, 0):\n", NULL);
|
||||
Printv(default_import_code, tab4, "def swig_import_helper():\n", NULL);
|
||||
Printv(default_import_code, tab8, "import importlib\n", NULL);
|
||||
Printv(default_import_code, tab8, "pkg = __name__.rpartition('.')[0]\n", NULL);
|
||||
Printf(default_import_code, tab8 "mname = '.'.join((pkg, '%s')).lstrip('.')\n", module);
|
||||
Printv(default_import_code, tab8, "try:\n", NULL);
|
||||
Printv(default_import_code, tab8, tab4, "return importlib.import_module(mname)\n", NULL);
|
||||
Printv(default_import_code, tab8, "except ImportError:\n", NULL);
|
||||
Printf(default_import_code, tab8 tab4 "return importlib.import_module('%s')\n", module);
|
||||
Printf(default_import_code, tab4 "%s = swig_import_helper()\n", module);
|
||||
Printv(default_import_code, tab4, "del swig_import_helper\n", NULL);
|
||||
Printv(default_import_code, "elif _swig_python_version_info >= (2, 6, 0):\n", NULL);
|
||||
Printv(default_import_code, tab4, "def swig_import_helper():\n", NULL);
|
||||
Printv(default_import_code, tab8, "from os.path import dirname\n", NULL);
|
||||
Printv(default_import_code, tab8, "import imp\n", NULL);
|
||||
Printv(default_import_code, tab8, "fp = None\n", NULL);
|
||||
Printv(default_import_code, tab8, "try:\n", NULL);
|
||||
Printf(default_import_code, tab4 tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module);
|
||||
Printf(default_import_code, tab8 "except ImportError:\n");
|
||||
/* At here, the module may already loaded, so simply import it. */
|
||||
Printf(f_shadow, tab4 tab8 "import %s\n", module);
|
||||
Printf(f_shadow, tab4 tab8 "return %s\n", module);
|
||||
Printv(f_shadow, tab8 "try:\n", NULL);
|
||||
Printf(default_import_code, tab4 tab8 "import %s\n", module);
|
||||
Printf(default_import_code, tab4 tab8 "return %s\n", module);
|
||||
Printv(default_import_code, tab8 "try:\n", NULL);
|
||||
/* imp.load_module() handles fp being None. */
|
||||
Printf(f_shadow, tab4 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module);
|
||||
Printv(f_shadow, tab8, "finally:\n", NULL);
|
||||
Printv(f_shadow, tab4 tab8 "if fp is not None:\n", NULL);
|
||||
Printv(f_shadow, tab8 tab8, "fp.close()\n", NULL);
|
||||
Printv(f_shadow, tab8, "return _mod\n", NULL);
|
||||
Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module);
|
||||
Printv(f_shadow, tab4, "del swig_import_helper\n", NULL);
|
||||
Printv(f_shadow, "else:\n", NULL);
|
||||
Printf(f_shadow, tab4 "import %s\n", module);
|
||||
Printf(default_import_code, tab4 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module);
|
||||
Printv(default_import_code, tab8, "finally:\n", NULL);
|
||||
Printv(default_import_code, tab4 tab8 "if fp is not None:\n", NULL);
|
||||
Printv(default_import_code, tab8 tab8, "fp.close()\n", NULL);
|
||||
Printv(default_import_code, tab8, "return _mod\n", NULL);
|
||||
Printf(default_import_code, tab4 "%s = swig_import_helper()\n", module);
|
||||
Printv(default_import_code, tab4, "del swig_import_helper\n", NULL);
|
||||
Printv(default_import_code, "else:\n", NULL);
|
||||
Printf(default_import_code, tab4 "import %s\n", module);
|
||||
|
||||
if (builtin) {
|
||||
/*
|
||||
|
|
@ -890,22 +890,22 @@ public:
|
|||
* globals()[attr] = getattr(_foo, attr)
|
||||
*
|
||||
*/
|
||||
Printf(f_shadow, "# pull in all the attributes from %s\n", module);
|
||||
Printv(f_shadow, "if __name__.rpartition('.')[0] != '':\n", NULL);
|
||||
Printv(f_shadow, tab4, "if _swig_python_version_info >= (2, 7, 0):\n", NULL);
|
||||
Printv(f_shadow, tab8, "try:\n", NULL);
|
||||
Printf(f_shadow, tab8 tab4 "from .%s import *\n", module);
|
||||
Printv(f_shadow, tab8 "except ImportError:\n", NULL);
|
||||
Printf(f_shadow, tab8 tab4 "from %s import *\n", module);
|
||||
Printv(f_shadow, tab4, "else:\n", NULL);
|
||||
Printf(f_shadow, tab8 "from %s import *\n", module);
|
||||
Printv(f_shadow, "else:\n", NULL);
|
||||
Printf(f_shadow, tab4 "from %s import *\n", module);
|
||||
Printf(default_import_code, "# pull in all the attributes from %s\n", module);
|
||||
Printv(default_import_code, "if __name__.rpartition('.')[0] != '':\n", NULL);
|
||||
Printv(default_import_code, tab4, "if _swig_python_version_info >= (2, 7, 0):\n", NULL);
|
||||
Printv(default_import_code, tab8, "try:\n", NULL);
|
||||
Printf(default_import_code, tab8 tab4 "from .%s import *\n", module);
|
||||
Printv(default_import_code, tab8 "except ImportError:\n", NULL);
|
||||
Printf(default_import_code, tab8 tab4 "from %s import *\n", module);
|
||||
Printv(default_import_code, tab4, "else:\n", NULL);
|
||||
Printf(default_import_code, tab8 "from %s import *\n", module);
|
||||
Printv(default_import_code, "else:\n", NULL);
|
||||
Printf(default_import_code, tab4 "from %s import *\n", module);
|
||||
}
|
||||
|
||||
/* Delete the _swig_python_version_info symbol since we don't use it elsewhere in the
|
||||
* module. */
|
||||
Printv(f_shadow, "del _swig_python_version_info\n", NULL);
|
||||
Printv(default_import_code, "del _swig_python_version_info\n\n", NULL);
|
||||
|
||||
if (modern || !classic) {
|
||||
Printv(f_shadow, "try:\n", tab4, "_swig_property = property\n", "except NameError:\n", tab4, "pass # Python < 2.2 doesn't have 'property'.\n\n", NULL);
|
||||
|
|
@ -1052,8 +1052,16 @@ public:
|
|||
if (!modern && !classic) {
|
||||
Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL);
|
||||
}
|
||||
Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL);
|
||||
Printv(f_shadow_py, "\n", f_shadow_builtin_imports, "\n", NIL);
|
||||
if (Len(f_shadow_begin) > 0)
|
||||
Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL);
|
||||
if (Len(f_shadow_after_begin) > 0)
|
||||
Printv(f_shadow_py, f_shadow_after_begin, "\n", NIL);
|
||||
if (moduleimport) {
|
||||
Replaceall(moduleimport, "$module", module);
|
||||
Printv(f_shadow_py, "\n", moduleimport, "\n", NIL);
|
||||
} else {
|
||||
Printv(f_shadow_py, default_import_code, NIL);
|
||||
}
|
||||
Printv(f_shadow_py, f_shadow, "\n", NIL);
|
||||
Printv(f_shadow_py, f_shadow_stubs, "\n", NIL);
|
||||
Delete(f_shadow_py);
|
||||
|
|
@ -1077,6 +1085,11 @@ public:
|
|||
Printf(f_begin, "static PyTypeObject *builtin_bases[%d];\n\n", max_bases + 2);
|
||||
Wrapper_pretty_print(f_init, f_begin);
|
||||
|
||||
Delete(default_import_code);
|
||||
Delete(f_shadow_after_begin);
|
||||
Delete(f_shadow_imports);
|
||||
Delete(f_shadow_begin);
|
||||
Delete(f_shadow);
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_builtins);
|
||||
|
|
@ -1385,7 +1398,7 @@ public:
|
|||
String *_import = import_directive_string(package, pkg, modname, "_");
|
||||
if (!GetFlagAttr(f_shadow_imports, _import)) {
|
||||
String *import = import_directive_string(package, pkg, modname);
|
||||
Printf(builtin ? f_shadow_builtin_imports : f_shadow, "%s", import);
|
||||
Printf(builtin ? f_shadow_after_begin : f_shadow, "%s", import);
|
||||
Delete(import);
|
||||
SetFlag(f_shadow_imports, _import);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -974,7 +974,9 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
|
|||
String *key;
|
||||
int i, n = Len(keys);
|
||||
/* Loop over all the <Class>_set and <Class>_get entries in the table. */
|
||||
|
||||
/* This function checks for names ending in _set - perhaps it should */
|
||||
/* use attributes of some other form, as it potentially clashes with */
|
||||
/* methods ending in _set */
|
||||
if(n && outputNamespaceInfo) {
|
||||
Printf(s_namespace, "exportClasses(");
|
||||
}
|
||||
|
|
@ -984,9 +986,13 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
|
|||
|
||||
String *className = Getitem(el, 0);
|
||||
char *ptr = Char(key);
|
||||
ptr = &ptr[Len(key) - 3];
|
||||
int isSet = strcmp(ptr, "set") == 0;
|
||||
|
||||
int klen = Len(key);
|
||||
int isSet = 0;
|
||||
if (klen > 4) {
|
||||
ptr = &ptr[klen - 4];
|
||||
isSet = strcmp(ptr, "_set") == 0;
|
||||
}
|
||||
|
||||
// OutputArrayMethod(className, el, out);
|
||||
OutputMemberReferenceMethod(className, isSet, el, out);
|
||||
|
||||
|
|
@ -1064,7 +1070,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
|
|||
|
||||
if (!isSet && varaccessor > 0) {
|
||||
Printf(f->code, "%svaccessors = c(", tab8);
|
||||
int vcount = 0;
|
||||
int first = 1;
|
||||
for(j = 0; j < numMems; j+=3) {
|
||||
String *item = Getitem(el, j);
|
||||
String *dup = Getitem(el, j + 1);
|
||||
|
|
@ -1072,8 +1078,8 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
|
|||
ptr = &ptr[Len(dup) - 3];
|
||||
|
||||
if (!strcmp(ptr, "get")) {
|
||||
vcount++;
|
||||
Printf(f->code, "'%s'%s", item, vcount < varaccessor ? ", " : "");
|
||||
Printf(f->code, "%s'%s'", first ? "" : ", ", item);
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
Printf(f->code, ");\n");
|
||||
|
|
@ -1273,7 +1279,9 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
|
|||
if(isSet < 0) {
|
||||
int n = Len(name);
|
||||
char *ptr = Char(name);
|
||||
isSet = Strcmp(NewString(&ptr[n-3]), "set") == 0;
|
||||
if (n>4) {
|
||||
isSet = Strcmp(NewString(&ptr[n-4]), "_set") == 0;
|
||||
}
|
||||
}
|
||||
|
||||
List *l = isSet ? class_member_set_functions : class_member_functions;
|
||||
|
|
@ -1753,7 +1761,8 @@ int R::functionWrapper(Node *n) {
|
|||
|
||||
int n = Len(iname);
|
||||
char *ptr = Char(iname);
|
||||
bool isSet(Strcmp(NewString(&ptr[n-3]), "set") == 0);
|
||||
bool isSet(0);
|
||||
if (n > 4) isSet = Strcmp(NewString(&ptr[n-4]), "_set") == 0;
|
||||
|
||||
|
||||
String *tmp = NewString("");
|
||||
|
|
|
|||
|
|
@ -1419,9 +1419,8 @@ public:
|
|||
case DESTRUCTOR:
|
||||
case CLASS_CONST:
|
||||
case STATIC_VAR:
|
||||
assert(false); // Should not have gotten here for these types
|
||||
default:
|
||||
assert(false);
|
||||
assert(false); // Should not have gotten here for these types
|
||||
}
|
||||
|
||||
defineAliases(n, iname);
|
||||
|
|
@ -3288,7 +3287,7 @@ public:
|
|||
}
|
||||
|
||||
/* declare Ruby return value */
|
||||
String *value_result = NewStringf("VALUE %s", Swig_cresult_name());
|
||||
String *value_result = NewStringf("VALUE SWIGUNUSED %s", Swig_cresult_name());
|
||||
Wrapper_add_local(w, Swig_cresult_name(), value_result);
|
||||
Delete(value_result);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ extern "C" {
|
|||
Language *swig_java(void);
|
||||
Language *swig_php(void);
|
||||
Language *swig_php4(void);
|
||||
Language *swig_php5(void);
|
||||
Language *swig_ocaml(void);
|
||||
Language *swig_octave(void);
|
||||
Language *swig_pike(void);
|
||||
|
|
@ -83,9 +84,10 @@ static swig_module modules[] = {
|
|||
{"-octave", swig_octave, "Octave"},
|
||||
{"-perl", swig_perl5, "Perl"},
|
||||
{"-perl5", swig_perl5, 0},
|
||||
{"-php", swig_php, "PHP"},
|
||||
{"-php", swig_php5, 0},
|
||||
{"-php4", swig_php4, 0},
|
||||
{"-php5", swig_php, 0},
|
||||
{"-php5", swig_php5, "PHP5"},
|
||||
{"-php7", swig_php, "PHP7"},
|
||||
{"-pike", swig_pike, "Pike"},
|
||||
{"-python", swig_python, "Python"},
|
||||
{"-r", swig_r, "R (aka GNU S)"},
|
||||
|
|
|
|||
|
|
@ -566,6 +566,10 @@ class TypePass:private Dispatcher {
|
|||
SwigType_typedef_class(rname);
|
||||
Delete(rname);
|
||||
/* SwigType_typedef_class(name); */
|
||||
} else if (Strcmp(ttype, "cdecl") == 0) {
|
||||
String *rname = SwigType_typedef_resolve_all(name);
|
||||
SwigType_typedef_class(rname);
|
||||
Delete(rname);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue