Run make beautify on python.cxx to fix code style to match style on szager-builtin branch

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12514 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-03-03 19:33:25 +00:00
commit 084a3c7205

View file

@ -166,11 +166,9 @@ public:
director_multiple_inheritance = 1; director_multiple_inheritance = 1;
director_language = 1; director_language = 1;
} }
/* ------------------------------------------------------------ /* ------------------------------------------------------------
* Thread Implementation * Thread Implementation
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
int threads_enable(Node *n) const { int threads_enable(Node *n) const {
return threads && !GetFlagAttr(n, "feature:nothread"); return threads && !GetFlagAttr(n, "feature:nothread");
} }
@ -435,7 +433,7 @@ public:
} }
} }
} /* for */ }
if (py3) { if (py3) {
/* force disable features that not compatible with Python 3.x */ /* force disable features that not compatible with Python 3.x */
@ -702,8 +700,7 @@ public:
Printv(f_shadow, "\nfrom sys import version_info\n", NULL); Printv(f_shadow, "\nfrom sys import version_info\n", NULL);
if(fastproxy) if (fastproxy) {
{
Printv(f_shadow, "if version_info >= (3,0,0):\n", NULL); Printv(f_shadow, "if version_info >= (3,0,0):\n", NULL);
Printf(f_shadow, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module); 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, "else:\n", NULL);
@ -788,8 +785,7 @@ public:
// "import types\n", // "import types\n",
"try:\n", "try:\n",
// " _object = types.ObjectType\n", // " _object = types.ObjectType\n",
" _object = object\n", " _object = object\n", " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n",
" _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n",
// "del types\n", // "del types\n",
"\n\n", NIL); "\n\n", NIL);
} }
@ -905,8 +901,7 @@ public:
* This wrapper is used to implement -fastproxy, * This wrapper is used to implement -fastproxy,
* as a replacement of new.instancemethod in Python 3. * as a replacement of new.instancemethod in Python 3.
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
int add_pyinstancemethod_new() int add_pyinstancemethod_new() {
{
String *name = NewString("SWIG_PyInstanceMethod_New"); String *name = NewString("SWIG_PyInstanceMethod_New");
Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, NULL},\n", name, name); Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, NULL},\n", name, name);
Delete(name); Delete(name);
@ -1269,7 +1264,6 @@ public:
pdocs = NewString("Parameters:\n"); pdocs = NewString("Parameters:\n");
Printf(pdocs, " %s\n", pdoc); Printf(pdocs, " %s\n", pdoc);
} }
// Write the function annoation // Write the function annoation
if (func_annotation) if (func_annotation)
Printf(doc, " : '%s'", type); Printf(doc, " : '%s'", type);
@ -1414,7 +1408,6 @@ public:
Printv(doc, "\n", pdocs, NULL); Printv(doc, "\n", pdocs, NULL);
} }
} }
// if it's overloaded then get the next decl and loop around again // if it's overloaded then get the next decl and loop around again
n = Getattr(n, "sym:nextSibling"); n = Getattr(n, "sym:nextSibling");
if (n) if (n)
@ -1429,8 +1422,7 @@ public:
* Check if string v can be a Python value literal, * Check if string v can be a Python value literal,
* (eg. number or string), or translate it to a Python literal. * (eg. number or string), or translate it to a Python literal.
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
String* pyvalue(String *v, SwigType *t) String *pyvalue(String *v, SwigType *t) {
{
if (v && Len(v) > 0) { if (v && Len(v) > 0) {
char fc = (Char(v))[0]; char fc = (Char(v))[0];
if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) { if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) {
@ -1455,8 +1447,7 @@ public:
* (So we can generate proper parameter list with default * (So we can generate proper parameter list with default
* values..) * values..)
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
bool is_primitive_defaultargs(Node *n) bool is_primitive_defaultargs(Node *n) {
{
ParmList *plist = CopyParmList(Getattr(n, "parms")); ParmList *plist = CopyParmList(Getattr(n, "parms"));
Parm *p; Parm *p;
Parm *pnext; Parm *pnext;
@ -1487,8 +1478,7 @@ public:
* siblings generated due to the original function have * siblings generated due to the original function have
* default arguments. * default arguments.
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
bool is_real_overloaded(Node *n) bool is_real_overloaded(Node *n) {
{
Node *h = Getattr(n, "sym:overloaded"); Node *h = Getattr(n, "sym:overloaded");
Node *i; Node *i;
if (!h) if (!h)
@ -1513,18 +1503,15 @@ public:
* Generate parameter list for Python functions or methods, * Generate parameter list for Python functions or methods,
* reuse make_autodocParmList() to do so. * reuse make_autodocParmList() to do so.
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
String* make_pyParmList(Node *n, bool in_class, bool is_calling, int kw) String *make_pyParmList(Node *n, bool in_class, bool is_calling, int kw) {
{
/* Get the original function for a defaultargs copy, /* Get the original function for a defaultargs copy,
* see default_arguments() in parser.y. */ * see default_arguments() in parser.y. */
Node *nn = Getattr(n, "defaultargs"); Node *nn = Getattr(n, "defaultargs");
if (nn) n = nn; if (nn)
n = nn;
/* For overloaded function, just use *args */ /* For overloaded function, just use *args */
if (is_real_overloaded(n) || if (is_real_overloaded(n) || GetFlag(n, "feature:compactdefaultargs") || !is_primitive_defaultargs(n)) {
GetFlag(n, "feature:compactdefaultargs") ||
!is_primitive_defaultargs(n))
{
String *parms = NewString(""); String *parms = NewString("");
if (in_class) if (in_class)
Printf(parms, "self, "); Printf(parms, "self, ");
@ -1538,8 +1525,7 @@ public:
String *params = NewString(""); String *params = NewString("");
String *_params = make_autodocParmList(n, false, is_calling, funcanno); String *_params = make_autodocParmList(n, false, is_calling, funcanno);
if (in_class) if (in_class) {
{
Printf(params, "self"); Printf(params, "self");
if (Len(_params) > 0) if (Len(_params) > 0)
Printf(params, ", "); Printf(params, ", ");
@ -1620,8 +1606,7 @@ public:
* Helper function for constructing the function annotation * Helper function for constructing the function annotation
* of the returning type, return a empty string for Python 2.x * of the returning type, return a empty string for Python 2.x
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
String* returnTypeAnnotation(Node *n) String *returnTypeAnnotation(Node *n) {
{
String *ret = 0; String *ret = 0;
Parm *p = Getattr(n, "parms"); Parm *p = Getattr(n, "parms");
String *tm; String *tm;
@ -1643,7 +1628,8 @@ public:
* the function prototype. */ * the function prototype. */
if (!ret) { if (!ret) {
ret = Getattr(n, "type"); ret = Getattr(n, "type");
if (ret) ret = SwigType_str(ret, 0); if (ret)
ret = SwigType_str(ret, 0);
} }
return (ret && py3) ? NewStringf(" -> \"%s\" ", ret) return (ret && py3) ? NewStringf(" -> \"%s\" ", ret)
: NewString(""); : NewString("");
@ -2867,7 +2853,8 @@ public:
if (!bname || ignore) { if (!bname || ignore) {
if (!bname && !ignore) { if (!bname && !ignore) {
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(n), Getline(n), Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(n), Getline(n),
"Base class '%s' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %%import directive.\n", SwigType_namestr(Getattr(b.item, "name"))); "Base class '%s' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %%import directive.\n",
SwigType_namestr(Getattr(b.item, "name")));
} }
b = Next(b); b = Next(b);
continue; continue;
@ -2980,8 +2967,7 @@ public:
} }
Printv(f_wrappers, Printv(f_wrappers,
" SWIG_TypeNewClientData(SWIGTYPE", SwigType_manglestr(ct), ", SWIG_NewClientData(obj));\n", " SWIG_TypeNewClientData(SWIGTYPE", SwigType_manglestr(ct), ", SWIG_NewClientData(obj));\n", " return SWIG_Py_Void();\n", "}\n\n", NIL);
" return SWIG_Py_Void();\n", "}\n\n", NIL);
String *cname = NewStringf("%s_swigregister", class_name); String *cname = NewStringf("%s_swigregister", class_name);
add_method(cname, cname, 0); add_method(cname, cname, 0);
Delete(smart); Delete(smart);
@ -2990,7 +2976,8 @@ public:
Delete(realct); Delete(realct);
} }
if (!have_constructor) { if (!have_constructor) {
Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"", "No constructor defined", (Getattr(n, "abstract") ? " - class is abstract" : ""), "\")\n", NIL); Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"", "No constructor defined",
(Getattr(n, "abstract") ? " - class is abstract" : ""), "\")\n", NIL);
} else if (fastinit) { } else if (fastinit) {
Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL);
@ -3032,7 +3019,8 @@ public:
List *shadow_list = Getattr(n, "shadow_methods"); List *shadow_list = Getattr(n, "shadow_methods");
for (int i = 0; i < Len(shadow_list); ++i) { for (int i = 0; i < Len(shadow_list); ++i) {
String *symname = Getitem(shadow_list, i); String *symname = Getitem(shadow_list, i);
Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s,None,%s)\n", class_name, symname, module, Swig_name_member(NSPACE_TODO, class_name, symname), class_name); Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s,None,%s)\n", class_name, symname, module, Swig_name_member(NSPACE_TODO, class_name, symname),
class_name);
} }
} }
Printf(f_shadow_file, "%s_swigregister = %s.%s_swigregister\n", class_name, module, class_name); Printf(f_shadow_file, "%s_swigregister = %s.%s_swigregister\n", class_name, module, class_name);
@ -3180,10 +3168,12 @@ public:
} else { } else {
if (!modern) { if (!modern) {
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), "\n", NIL); Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), "\n",
NIL);
} }
if (!classic) { if (!classic) {
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), ")\n", NIL); Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname),
")\n", NIL);
} }
} }
} }