Merge branch 'ptomulik-fix/nonclass-constants'
* ptomulik-fix/nonclass-constants: prevent _swigconstant boilerplate for non-class types
This commit is contained in:
commit
c1d200ba7d
1 changed files with 21 additions and 6 deletions
|
|
@ -3458,11 +3458,15 @@ public:
|
||||||
String *name = Getattr(n, "name");
|
String *name = Getattr(n, "name");
|
||||||
String *iname = Getattr(n, "sym:name");
|
String *iname = Getattr(n, "sym:name");
|
||||||
SwigType *type = Getattr(n, "type");
|
SwigType *type = Getattr(n, "type");
|
||||||
|
SwigType *basetype = SwigType_base(type);
|
||||||
String *rawval = Getattr(n, "rawval");
|
String *rawval = Getattr(n, "rawval");
|
||||||
String *value = rawval ? rawval : Getattr(n, "value");
|
String *value = rawval ? rawval : Getattr(n, "value");
|
||||||
String *tm;
|
String *tm;
|
||||||
int have_tm = 0;
|
int have_tm = 0;
|
||||||
int have_builtin_symname = 0;
|
int have_builtin_symname = 0;
|
||||||
|
int is_classobj = SwigType_isclass(basetype);
|
||||||
|
|
||||||
|
Delete(basetype);
|
||||||
|
|
||||||
if (!addSymbol(iname, n))
|
if (!addSymbol(iname, n))
|
||||||
return SWIG_ERROR;
|
return SWIG_ERROR;
|
||||||
|
|
@ -3496,8 +3500,15 @@ public:
|
||||||
Replaceall(tm, "$source", value);
|
Replaceall(tm, "$source", value);
|
||||||
Replaceall(tm, "$target", name);
|
Replaceall(tm, "$target", name);
|
||||||
Replaceall(tm, "$value", value);
|
Replaceall(tm, "$value", value);
|
||||||
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER)) && (!in_class || !Getattr(n, "feature:python:callback"))) {
|
if (is_classobj && !builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER)) && (!in_class || !Getattr(n, "feature:python:callback"))) {
|
||||||
// Generate method which registers the new constant
|
// Generate `*_swigconstant()` method which registers the new constant.
|
||||||
|
//
|
||||||
|
// *_swigconstant methods are required for constants of class type.
|
||||||
|
// Class types are registered in shadow file (see *_swigregister). The
|
||||||
|
// instances of class must be created (registered) after the type is
|
||||||
|
// registered, so we can't let SWIG_init() to register constants of
|
||||||
|
// class type (the SWIG_init() is called before shadow classes are
|
||||||
|
// defined and registered).
|
||||||
Printf(f_wrappers, "SWIGINTERN PyObject *%s_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", iname);
|
Printf(f_wrappers, "SWIGINTERN PyObject *%s_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", iname);
|
||||||
Printf(f_wrappers, tab2 "PyObject *module;\n", tm);
|
Printf(f_wrappers, tab2 "PyObject *module;\n", tm);
|
||||||
Printf(f_wrappers, tab2 "PyObject *d;\n");
|
Printf(f_wrappers, tab2 "PyObject *d;\n");
|
||||||
|
|
@ -3537,13 +3548,17 @@ public:
|
||||||
|
|
||||||
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||||
if (!in_class) {
|
if (!in_class) {
|
||||||
Printv(f_shadow, "\n",NIL);
|
if(is_classobj) {
|
||||||
Printv(f_shadow, module, ".", iname, "_swigconstant(",module,")\n", NIL);
|
Printv(f_shadow, "\n",NIL);
|
||||||
|
Printv(f_shadow, module, ".", iname, "_swigconstant(",module,")\n", NIL);
|
||||||
|
}
|
||||||
Printv(f_shadow, iname, " = ", module, ".", iname, "\n", NIL);
|
Printv(f_shadow, iname, " = ", module, ".", iname, "\n", NIL);
|
||||||
} else {
|
} else {
|
||||||
if (!(Getattr(n, "feature:python:callback"))) {
|
if (!(Getattr(n, "feature:python:callback"))) {
|
||||||
Printv(f_shadow_stubs, "\n",NIL);
|
if(is_classobj) {
|
||||||
Printv(f_shadow_stubs, module, ".", iname, "_swigconstant(", module, ")\n", NIL);
|
Printv(f_shadow_stubs, "\n",NIL);
|
||||||
|
Printv(f_shadow_stubs, module, ".", iname, "_swigconstant(", module, ")\n", NIL);
|
||||||
|
}
|
||||||
Printv(f_shadow_stubs, iname, " = ", module, ".", iname, "\n", NIL);
|
Printv(f_shadow_stubs, iname, " = ", module, ".", iname, "\n", NIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue