From 4439968f05dac6bf5699c83b003a650e8fcbf7bc Mon Sep 17 00:00:00 2001 From: Duy-Nguyen Ta Date: Wed, 30 Nov 2016 05:56:07 -0500 Subject: [PATCH] tabs to spaces --- wrap/Argument.cpp | 4 ++-- wrap/Class.cpp | 32 ++++++++++++++++---------------- wrap/Constructor.cpp | 8 ++++---- wrap/GlobalFunction.cpp | 22 +++++++++++----------- wrap/Method.cpp | 30 +++++++++++++++--------------- wrap/Module.cpp | 12 ++++++------ wrap/OverloadedFunction.h | 10 +++++----- wrap/StaticMethod.cpp | 32 ++++++++++++++++---------------- wrap/TemplateMethod.cpp | 2 +- wrap/TypedefPair.h | 2 +- 10 files changed, 77 insertions(+), 77 deletions(-) diff --git a/wrap/Argument.cpp b/wrap/Argument.cpp index 54980b6ad..bcb859e7a 100644 --- a/wrap/Argument.cpp +++ b/wrap/Argument.cpp @@ -252,12 +252,12 @@ std::string ArgumentList::pyx_paramsList() const { /* ************************************************************************* */ std::string ArgumentList::pyx_castParamsToPythonType() const { if (size() == 0) - return "\t\t\tpass\n"; + return " pass\n"; // cast params to their correct python argument type to pass in the function call later string s; for (size_t j = 0; j < size(); ++j) - s += "\t\t\t" + at(j).name + " = <" + at(j).type.pyxArgumentType() + s += " " + at(j).name + " = <" + at(j).type.pyxArgumentType() + ">(__params['" + at(j).name + "'])\n"; return s; } diff --git a/wrap/Class.cpp b/wrap/Class.cpp index e14d57ad5..11bfc9f49 100644 --- a/wrap/Class.cpp +++ b/wrap/Class.cpp @@ -732,7 +732,7 @@ void Class::python_wrapper(FileWriter& wrapperFile) const { void Class::emit_cython_pxd(FileWriter& pxdFile, const std::vector& allClasses) const { pxdFile.oss << "cdef extern from \"" << includeFile << "\" namespace \"" << qualifiedNamespaces("::") << "\":" << endl; - pxdFile.oss << "\tcdef cppclass " << pxdClassName() << " \"" << qualifiedName("::") << "\""; + pxdFile.oss << " cdef cppclass " << pxdClassName() << " \"" << qualifiedName("::") << "\""; if (templateArgs.size()>0) { pxdFile.oss << "["; for(size_t i = 0; i& allCl size_t numMethods = constructor.nrOverloads() + static_methods.size() + methods_.size() + templateMethods_.size(); if (numMethods == 0) - pxdFile.oss << "\t\tpass"; + pxdFile.oss << " pass"; } /* ************************************************************************* */ @@ -795,7 +795,7 @@ void Class::pyxDynamicCast(FileWriter& pyxFile, const Class& curLevel, parentCythonClass = curLevel.parentClass->pxd_class_in_pyx(); pyxFile.oss << "def dynamic_cast_" << me << "_" << parent << "(" << parent << " parent):\n"; - pyxFile.oss << "\treturn " << me << ".cyCreateFromShared(<" << sharedMe + pyxFile.oss << " return " << me << ".cyCreateFromShared(<" << sharedMe << ">dynamic_pointer_cast[" << pxd_class_in_pyx() << "," << parentCythonClass << "](parent." << parentObj << "))\n"; @@ -820,23 +820,23 @@ void Class::emit_cython_pyx(FileWriter& pyxFile, const std::vector& allCl pyxFile.oss << ":\n"; // shared variable of the corresponding cython object - pyxFile.oss << "\tcdef " << shared_pxd_class_in_pyx() << " " << shared_pxd_obj_in_pyx() << "\n"; + pyxFile.oss << " cdef " << shared_pxd_class_in_pyx() << " " << shared_pxd_obj_in_pyx() << "\n"; // __cinit___ - pyxFile.oss << "\tdef __cinit__(self, *args, **kwargs):\n" - "\t\tself." << shared_pxd_obj_in_pyx() << " = " + pyxFile.oss << " def __cinit__(self, *args, **kwargs):\n" + " self." << shared_pxd_obj_in_pyx() << " = " << shared_pxd_class_in_pyx() << "()\n"; for (size_t i = 0; i0) - pyxFile.oss << "\t\telse:\n\t\t\traise TypeError('" << pyxClassName() + pyxFile.oss << " else:\n raise TypeError('" << pyxClassName() << " construction failed!')\n"; - pyxInitParentObj(pyxFile, "\t\tself", "self." + shared_pxd_obj_in_pyx(), allClasses); + pyxInitParentObj(pyxFile, " self", "self." + shared_pxd_obj_in_pyx(), allClasses); pyxFile.oss << "\n"; // Constructors @@ -844,13 +844,13 @@ void Class::emit_cython_pyx(FileWriter& pyxFile, const std::vector& allCl if (constructor.nrOverloads()>0) pyxFile.oss << "\n"; // cyCreateFromShared - pyxFile.oss << "\t@staticmethod\n"; - pyxFile.oss << "\tcdef " << pyxClassName() << " cyCreateFromShared(const " + pyxFile.oss << " @staticmethod\n"; + pyxFile.oss << " cdef " << pyxClassName() << " cyCreateFromShared(const " << shared_pxd_class_in_pyx() << "& other):\n" - << "\t\tcdef " << pyxClassName() << " ret = " << pyxClassName() << "()\n" - << "\t\tret." << shared_pxd_obj_in_pyx() << " = other\n"; - pyxInitParentObj(pyxFile, "\t\tret", "other", allClasses); - pyxFile.oss << "\t\treturn ret" << "\n"; + << " cdef " << pyxClassName() << " ret = " << pyxClassName() << "()\n" + << " ret." << shared_pxd_obj_in_pyx() << " = other\n"; + pyxInitParentObj(pyxFile, " ret", "other", allClasses); + pyxFile.oss << " return ret" << "\n"; for(const StaticMethod& m: static_methods | boost::adaptors::map_values) m.emit_cython_pyx(pyxFile, *this); diff --git a/wrap/Constructor.cpp b/wrap/Constructor.cpp index b7a219458..3c6c9cebb 100644 --- a/wrap/Constructor.cpp +++ b/wrap/Constructor.cpp @@ -134,7 +134,7 @@ void Constructor::emit_cython_pxd(FileWriter& pxdFile, Str className) const { ArgumentList args = argumentList(i); // generate the constructor - pxdFile.oss << "\t\t" << className << "("; + pxdFile.oss << " " << className << "("; args.emit_cython_pxd(pxdFile, className); pxdFile.oss << ") " << "except +\n"; @@ -145,14 +145,14 @@ void Constructor::emit_cython_pxd(FileWriter& pxdFile, Str className) const { void Constructor::emit_cython_pyx(FileWriter& pyxFile, const Class& cls) const { for (size_t i = 0; i < nrOverloads(); i++) { ArgumentList args = argumentList(i); - pyxFile.oss << "\tdef " + cls.pyxClassName() + "_" + to_string(i) + + pyxFile.oss << " def " + cls.pyxClassName() + "_" + to_string(i) + "(self, *args, **kwargs):\n"; pyxFile.oss << pyx_resolveOverloadParams(args, true); - pyxFile.oss << "\t\tself." << cls.shared_pxd_obj_in_pyx() << " = " + pyxFile.oss << " self." << cls.shared_pxd_obj_in_pyx() << " = " << cls.shared_pxd_class_in_pyx() << "(new " << cls.pxd_class_in_pyx() << "(" << args.pyx_asParams() << "))\n"; - pyxFile.oss << "\t\treturn True\n\n"; + pyxFile.oss << " return True\n\n"; } } diff --git a/wrap/GlobalFunction.cpp b/wrap/GlobalFunction.cpp index cfb323aba..4a8b547e5 100644 --- a/wrap/GlobalFunction.cpp +++ b/wrap/GlobalFunction.cpp @@ -138,7 +138,7 @@ void GlobalFunction::emit_cython_pxd(FileWriter& file) const { << overloads[0].qualifiedNamespaces("::") << "\":" << endl; for (size_t i = 0; i < nrOverloads(); ++i) { - file.oss << "\t\t"; + file.oss << " "; returnVals_[i].emit_cython_pxd(file, ""); file.oss << pyRename(name_) + " \"" + overloads[0].qualifiedName("::") + "\"("; @@ -165,11 +165,11 @@ void GlobalFunction::emit_cython_pyx_no_overload(FileWriter& file) const { /// Call cython corresponding function and return string ret = pyx_functionCall("pxd", funcName, 0); if (!returnVals_[0].isVoid()) { - file.oss << "\tcdef " << returnVals_[0].pyx_returnType() + file.oss << " cdef " << returnVals_[0].pyx_returnType() << " ret = " << ret << "\n"; - file.oss << "\treturn " << returnVals_[0].pyx_casting("ret") << "\n"; + file.oss << " return " << returnVals_[0].pyx_casting("ret") << "\n"; } else { - file.oss << "\t" << ret << "\n"; + file.oss << " " << ret << "\n"; } } @@ -186,11 +186,11 @@ void GlobalFunction::emit_cython_pyx(FileWriter& file) const { // Dealing with overloads.. file.oss << "def " << funcName << "(*args, **kwargs):\n"; for (size_t i = 0; i < N; ++i) { - file.oss << "\tsuccess, results = " << funcName << "_" << i + file.oss << " success, results = " << funcName << "_" << i << "(*args, **kwargs)\n"; - file.oss << "\tif success:\n\t\t\treturn results\n"; + file.oss << " if success:\n return results\n"; } - file.oss << "\traise TypeError('Could not find the correct overload')\n"; + file.oss << " raise TypeError('Could not find the correct overload')\n"; for (size_t i = 0; i < N; ++i) { ArgumentList args = argumentList(i); @@ -201,12 +201,12 @@ void GlobalFunction::emit_cython_pyx(FileWriter& file) const { /// Call cython corresponding function string ret = pyx_functionCall("pxd", funcName, i); if (!returnVals_[i].isVoid()) { - file.oss << "\tcdef " << returnVals_[i].pyx_returnType() + file.oss << " cdef " << returnVals_[i].pyx_returnType() << " ret = " << ret << "\n"; - file.oss << "\treturn True, " << returnVals_[i].pyx_casting("ret") << "\n"; + file.oss << " return True, " << returnVals_[i].pyx_casting("ret") << "\n"; } else { - file.oss << "\t" << ret << "\n"; - file.oss << "\treturn True, None\n"; + file.oss << " " << ret << "\n"; + file.oss << " return True, None\n"; } } } diff --git a/wrap/Method.cpp b/wrap/Method.cpp index 10cb6ea5f..656abed3d 100644 --- a/wrap/Method.cpp +++ b/wrap/Method.cpp @@ -83,7 +83,7 @@ string Method::wrapper_call(FileWriter& wrapperFile, Str cppClassName, /* ************************************************************************* */ void Method::emit_cython_pxd(FileWriter& file, const Class& cls) const { for (size_t i = 0; i < nrOverloads(); ++i) { - file.oss << "\t\t"; + file.oss << " "; returnVals_[i].emit_cython_pxd(file, cls.pxdClassName()); file.oss << pyRename(name_) + " \"" + name_ + "\"" << "("; @@ -100,10 +100,10 @@ void Method::emit_cython_pyx_no_overload(FileWriter& file, string funcName = pyRename(name_); // leverage python's special treatment for print if (funcName == "print_") - file.oss << "\tdef __str__(self):\n\t\tself.print_('')\n\t\treturn ''\n"; + file.oss << " def __str__(self):\n self.print_('')\n return ''\n"; // Function definition - file.oss << "\tdef " << funcName; + file.oss << " def " << funcName; // modify name of function instantiation as python doesn't allow overloads // e.g. template funcName(...) --> funcNameA, funcNameB, funcNameC if (templateArgValue_) file.oss << templateArgValue_->pyxClassName(); @@ -117,11 +117,11 @@ void Method::emit_cython_pyx_no_overload(FileWriter& file, string caller = "self." + cls.shared_pxd_obj_in_pyx() + ".get()"; string ret = pyx_functionCall(caller, funcName, 0); if (!returnVals_[0].isVoid()) { - file.oss << "\t\tcdef " << returnVals_[0].pyx_returnType() + file.oss << " cdef " << returnVals_[0].pyx_returnType() << " ret = " << ret << "\n"; - file.oss << "\t\treturn " << returnVals_[0].pyx_casting("ret") << "\n"; + file.oss << " return " << returnVals_[0].pyx_casting("ret") << "\n"; } else { - file.oss << "\t\t" << ret << "\n"; + file.oss << " " << ret << "\n"; } } @@ -142,17 +142,17 @@ void Method::emit_cython_pyx(FileWriter& file, const Class& cls) const { } // Dealing with overloads.. - file.oss << "\tdef " << instantiatedName << "(self, *args, **kwargs):\n"; + file.oss << " def " << instantiatedName << "(self, *args, **kwargs):\n"; for (size_t i = 0; i < N; ++i) { - file.oss << "\t\tsuccess, results = self." << instantiatedName << "_" << i + file.oss << " success, results = self." << instantiatedName << "_" << i << "(*args, **kwargs)\n"; - file.oss << "\t\tif success:\n\t\t\treturn results\n"; + file.oss << " if success:\n return results\n"; } - file.oss << "\t\traise TypeError('Could not find the correct overload')\n"; + file.oss << " raise TypeError('Could not find the correct overload')\n"; for (size_t i = 0; i < N; ++i) { ArgumentList args = argumentList(i); - file.oss << "\tdef " + instantiatedName + "_" + to_string(i) + + file.oss << " def " + instantiatedName + "_" + to_string(i) + "(self, *args, **kwargs):\n"; file.oss << pyx_resolveOverloadParams(args, false); // lazy: always return None even if it's a void function @@ -161,12 +161,12 @@ void Method::emit_cython_pyx(FileWriter& file, const Class& cls) const { string ret = pyx_functionCall(caller, funcName, i); if (!returnVals_[i].isVoid()) { - file.oss << "\t\tcdef " << returnVals_[i].pyx_returnType() + file.oss << " cdef " << returnVals_[i].pyx_returnType() << " ret = " << ret << "\n"; - file.oss << "\t\treturn True, " << returnVals_[i].pyx_casting("ret") << "\n"; + file.oss << " return True, " << returnVals_[i].pyx_casting("ret") << "\n"; } else { - file.oss << "\t\t" << ret << "\n"; - file.oss << "\t\treturn True, None\n"; + file.oss << " " << ret << "\n"; + file.oss << " return True, None\n"; } } } diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 6c616bbcf..c82b10b2e 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -337,12 +337,12 @@ void Module::emit_cython_pxd(FileWriter& pxdFile) const { // boost shared_ptr pxdFile.oss << "cdef extern from \"boost/shared_ptr.hpp\" namespace \"boost\":\n" - "\tcppclass shared_ptr[T]:\n" - "\t\tshared_ptr()\n" - "\t\tshared_ptr(T*)\n" - "\t\tT* get()\n" - "\t\tT& operator*()\n\n" - "\tcdef shared_ptr[T] dynamic_pointer_cast[T,U](const shared_ptr[U]& r)\n"; + " cppclass shared_ptr[T]:\n" + " shared_ptr()\n" + " shared_ptr(T*)\n" + " T* get()\n" + " T& operator*()\n\n" + " cdef shared_ptr[T] dynamic_pointer_cast[T,U](const shared_ptr[U]& r)\n"; for(const TypedefPair& types: typedefs) types.emit_cython_pxd(pxdFile); diff --git a/wrap/OverloadedFunction.h b/wrap/OverloadedFunction.h index a9e8bd02a..71acf822b 100644 --- a/wrap/OverloadedFunction.h +++ b/wrap/OverloadedFunction.h @@ -73,16 +73,16 @@ public: std::string pyx_resolveOverloadParams(const ArgumentList& args, bool isVoid, size_t indentLevel = 2) const { std::string indent; - for (size_t i = 0; i 0) { s += indent + "__params = kwargs.copy()\n"; s += indent + "__names = [" + args.pyx_paramsList() + "]\n"; s += indent + "for i in range(len(args)):\n"; - s += indent + "\t__params[__names[i]] = args[i]\n"; + s += indent + " __params[__names[i]] = args[i]\n"; for (size_t i = 0; i0)?"_" + to_string(i):"") << " \"" << name_ << "\"" << "("; argumentList(i).emit_cython_pxd(file, cls.pxdClassName()); @@ -73,14 +73,14 @@ void StaticMethod::emit_cython_pxd(FileWriter& file, const Class& cls) const { void StaticMethod::emit_cython_pyx_no_overload(FileWriter& file, const Class& cls) const { assert(nrOverloads() == 1); - file.oss << "\t@staticmethod\n"; - file.oss << "\tdef " << name_ << "("; + file.oss << " @staticmethod\n"; + file.oss << " def " << name_ << "("; argumentList(0).emit_cython_pyx(file); file.oss << "):\n"; /// Call cython corresponding function and return string ret = pyx_functionCall(cls.pxd_class_in_pyx(), name_, 0); - file.oss << "\t\t"; + file.oss << " "; if (!returnVals_[0].isVoid()) { file.oss << "return " << returnVals_[0].pyx_casting(ret) << "\n"; } else @@ -97,35 +97,35 @@ void StaticMethod::emit_cython_pyx(FileWriter& file, const Class& cls) const { } // Dealing with overloads.. - file.oss << "\t@staticmethod\n"; - file.oss << "\tdef " << name_ << "(*args, **kwargs):\n"; + file.oss << " @staticmethod\n"; + file.oss << " def " << name_ << "(*args, **kwargs):\n"; for (size_t i = 0; i < N; ++i) { string funcName = name_ + "_" + to_string(i); - file.oss << "\t\tsuccess, results = " << cls.pyxClassName() << "." + file.oss << " success, results = " << cls.pyxClassName() << "." << funcName << "(*args, **kwargs)\n"; - file.oss << "\t\tif success:\n\t\t\treturn results\n"; + file.oss << " if success:\n return results\n"; } - file.oss << "\t\traise TypeError('Could not find the correct overload')\n"; + file.oss << " raise TypeError('Could not find the correct overload')\n"; for(size_t i = 0; i < N; ++i) { - file.oss << "\t@staticmethod\n"; + file.oss << " @staticmethod\n"; string funcName = name_ + "_" + to_string(i); string pxdFuncName = name_ + ((i>0)?"_" + to_string(i):""); ArgumentList args = argumentList(i); - file.oss << "\tdef " + funcName + "(*args, **kwargs):\n"; + file.oss << " def " + funcName + "(*args, **kwargs):\n"; file.oss << pyx_resolveOverloadParams(args, false); // lazy: always return None even if it's a void function /// Call cython corresponding function and return string ret = pyx_functionCall(cls.pxd_class_in_pyx(), pxdFuncName, i); if (!returnVals_[i].isVoid()) { - file.oss << "\t\tcdef " << returnVals_[i].pyx_returnType() + file.oss << " cdef " << returnVals_[i].pyx_returnType() << " ret = " << ret << "\n"; - file.oss << "\t\treturn True, " << returnVals_[i].pyx_casting("ret") << "\n"; + file.oss << " return True, " << returnVals_[i].pyx_casting("ret") << "\n"; } else { - file.oss << "\t\t" << ret << "\n"; - file.oss << "\t\treturn True, None\n"; + file.oss << " " << ret << "\n"; + file.oss << " return True, None\n"; } file.oss << "\n"; } diff --git a/wrap/TemplateMethod.cpp b/wrap/TemplateMethod.cpp index 39f41ad6e..20a0be020 100644 --- a/wrap/TemplateMethod.cpp +++ b/wrap/TemplateMethod.cpp @@ -23,7 +23,7 @@ using namespace wrap; /* ************************************************************************* */ void TemplateMethod::emit_cython_pxd(FileWriter& file, const Class& cls) const { for(size_t i = 0; i < nrOverloads(); ++i) { - file.oss << "\t\t"; + file.oss << " "; returnVals_[i].emit_cython_pxd(file, cls.pxdClassName()); file.oss << name_ << "[" << argName << "]" << "("; argumentList(i).emit_cython_pxd(file, cls.pxdClassName()); diff --git a/wrap/TypedefPair.h b/wrap/TypedefPair.h index df970191d..c2224eaf2 100644 --- a/wrap/TypedefPair.h +++ b/wrap/TypedefPair.h @@ -21,7 +21,7 @@ struct TypedefPair { void emit_cython_pxd(FileWriter& file) const { file.oss << "cdef extern from \"" << includeFile << "\" namespace \"" << oldType.qualifiedNamespaces("::") << "\":\n"; - file.oss << "\tctypedef " << oldType.pxdClassName() << " " + file.oss << " ctypedef " << oldType.pxdClassName() << " " << newType.pxdClassName() << "\n"; } };