Removed a Py_None from cwrap.c.
Added SetNoneComparison in lang.cxx, which allows the language module to specify how to determine whether the empty argument was given for the 'self' pointer. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4473 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e3d8bf0d68
commit
636daff4e1
4 changed files with 24 additions and 5 deletions
|
|
@ -201,6 +201,7 @@ int Dispatcher::namespaceDeclaration(Node *n) { return defaultHandler(n); }
|
|||
Language::Language() {
|
||||
symbols = NewHash();
|
||||
classtypes = NewHash();
|
||||
none_comparison = NewString("$arg != 0");
|
||||
overloading = 0;
|
||||
multiinput = 0;
|
||||
directors = 0;
|
||||
|
|
@ -1759,7 +1760,8 @@ Language::constructorHandler(Node *n) {
|
|||
|
||||
mrename = Swig_name_construct(symname);
|
||||
if (CPlusPlus) patch_parms(parms);
|
||||
Swig_ConstructorToFunction(n,ClassType,CPlusPlus,Getattr(n,"template") ? 0 :Extend);
|
||||
Swig_ConstructorToFunction(n,ClassType,none_comparison,
|
||||
CPlusPlus,Getattr(n,"template") ? 0 :Extend);
|
||||
Setattr(n,"sym:name", mrename);
|
||||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
|
|
@ -1779,7 +1781,8 @@ Language::copyconstructorHandler(Node *n) {
|
|||
Parm *parms = Getattr(n,"parms");
|
||||
if (CPlusPlus) patch_parms(parms);
|
||||
mrename = Swig_name_copyconstructor(symname);
|
||||
Swig_ConstructorToFunction(n,ClassType, CPlusPlus, Getattr(n,"template") ? 0 : Extend);
|
||||
Swig_ConstructorToFunction(n,ClassType, none_comparison,
|
||||
CPlusPlus, Getattr(n,"template") ? 0 : Extend);
|
||||
Setattr(n,"sym:name", mrename);
|
||||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
|
|
@ -2149,3 +2152,7 @@ String * Language::getClassPrefix() const {
|
|||
String * Language::getClassType() const {
|
||||
return ClassType;
|
||||
}
|
||||
|
||||
void Language::SetNoneComparison( String *nc ) {
|
||||
none_comparison = nc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,6 +209,8 @@ public:
|
|||
/* Return true if directors are enabled */
|
||||
int directorsEnabled() const;
|
||||
|
||||
/* Set none comparison string */
|
||||
void SetNoneComparison( String *s );
|
||||
|
||||
protected:
|
||||
/* Patch C++ pass-by-value */
|
||||
|
|
@ -241,6 +243,7 @@ public:
|
|||
private:
|
||||
Hash *symbols;
|
||||
Hash *classtypes;
|
||||
String *none_comparison;
|
||||
int overloading;
|
||||
int multiinput;
|
||||
int directors;
|
||||
|
|
|
|||
|
|
@ -609,7 +609,8 @@ Swig_directormap(Node *module, String *type) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
Swig_ConstructorToFunction(Node *n, String *classname, int cplus, int flags)
|
||||
Swig_ConstructorToFunction(Node *n, String *classname,
|
||||
String *none_comparison, int cplus, int flags)
|
||||
{
|
||||
ParmList *parms;
|
||||
SwigType *type;
|
||||
|
|
@ -649,16 +650,22 @@ Swig_ConstructorToFunction(Node *n, String *classname, int cplus, int flags)
|
|||
String *name = Getattr(parent, "sym:name");
|
||||
String* directorname = NewStringf("__DIRECTOR__%s", name);
|
||||
String* action = NewString("");
|
||||
String* tmp_none_comparison = Copy(none_comparison);
|
||||
|
||||
Replaceall( tmp_none_comparison, "$arg", "arg1" );
|
||||
|
||||
/* if Python class has been subclassed, create a director instance.
|
||||
* otherwise, just create a normal instance.
|
||||
*/
|
||||
Printv(action, "if (arg1 != Py_None) { // subclassed\n",
|
||||
// arty: arg1 != Py_None => tmp_none_comparison
|
||||
Printv(action, "if (",tmp_none_comparison,") { // subclassed\n",
|
||||
Swig_cresult(type, "result", Swig_cppconstructor_director_call(directorname, parms)),
|
||||
"} else {\n",
|
||||
Swig_cresult(type, "result", Swig_cppconstructor_nodirector_call(classname, parms)),
|
||||
"}\n",
|
||||
NULL);
|
||||
Setattr(n, "wrap:action", action);
|
||||
Delete(tmp_none_comparison);
|
||||
Delete(action);
|
||||
Delete(directorname);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -436,7 +436,9 @@ extern String *Swig_cmemberget_call(String_or_char *name, SwigType *t, String
|
|||
/* --- Transformations --- */
|
||||
|
||||
extern int Swig_MethodToFunction(Node *n, String *classname, int flags);
|
||||
extern int Swig_ConstructorToFunction(Node *n, String *classname, int cplus, int flags);
|
||||
extern int Swig_ConstructorToFunction(Node *n, String *classname,
|
||||
String *none_comparison,
|
||||
int cplus, int flags);
|
||||
extern int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags);
|
||||
extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
|
||||
extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue